Commit 4a829111 by acarrizosa

IGEP0046: Add led and HWtest support

parent 2502b2aa
......@@ -9,59 +9,110 @@
#include <asm/io.h>
#include <asm/arch/sys_proto.h>
#include <asm/gpio.h>
#include "led.h"
/* Return gpio number from Name */
int gpio_name_to_num(char* name)
{
int i = 0;
while(ldef[i].led_name[0] != 0){
if(!strcmp(name, ldef[i].led_name)){
return ldef[i].gpio_num;
}
i++;
}
return 0;
}
/* GPIO pins for the LEDs */
/* GPIO Leds */
#define IGEP0146_LED_RED 8
#define IGEP0146_LED_GREEN 9
#define IGEP0146_LED_RED_USER0 8
#define IGEP0146_LED_GREEN_USER1 9
#ifdef CONFIG_LED_STATUS_GREEN
void green_led_off(void)
{
__led_set(IGEP0146_LED_GREEN, 0);
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0146)
__led_set(IGEP0146_LED_GREEN_USER1, CONFIG_LED_STATUS_OFF);
#elif (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0046)
__led_set(gpio_name_to_num("green"), CONFIG_LED_STATUS_OFF);
#endif
}
void green_led_on(void)
{
__led_set(IGEP0146_LED_GREEN, 1);
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0146)
__led_set(IGEP0146_LED_GREEN_USER1, CONFIG_LED_STATUS_ON);
#elif (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0046)
__led_set(gpio_name_to_num("green"), CONFIG_LED_STATUS_ON);
#endif
}
#endif
#ifdef CONFIG_LED_STATUS_BLUE
void blue_led_off(void)
#ifdef CONFIG_LED_STATUS_RED
void red_led_off(void)
{
__led_set(IGEP0146_LED_RED, 0);
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0146)
__led_set(IGEP0146_LED_RED_USER0, CONFIG_LED_STATUS_OFF);
#elif (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0046)
__led_set(gpio_name_to_num("red"), CONFIG_LED_STATUS_OFF);
#endif
}
void blue_led_on(void)
void red_led_on(void)
{
__led_set(IGEP0146_LED_RED, 1);
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0146)
__led_set(IGEP0146_LED_RED_USER0, CONFIG_LED_STATUS_ON);
#elif (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0046)
__led_set(gpio_name_to_num("red"), CONFIG_LED_STATUS_ON);
#endif
}
#endif
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0146)
static int get_led_gpio(led_id_t mask)
{
#ifdef CONFIG_LED_STATUS0
if (CONFIG_LED_STATUS_BIT == mask){
return IGEP0146_LED_RED;
if (CONFIG_LED_STATUS_BIT == mask)
{
return IGEP0146_LED_RED_USER0;
}
#endif
#ifdef CONFIG_LED_STATUS1
if (CONFIG_LED_STATUS_BIT1 == mask){
return IGEP0146_LED_GREEN;
if (CONFIG_LED_STATUS_BIT1 == mask)
{
return IGEP0146_LED_GREEN_USER1;
}
#endif
return 0;
}
#elif (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0046)
/* Convert Status from gpio mask */
static int get_led_gpio(led_id_t mask)
{
int i = 0;
while(ldef[i].led_name[0] != 0){
if(mask == ldef[i].led_st)
{
return ldef[i].gpio_num;
}
i++;
}
return 0;
}
#endif
void __led_init (led_id_t mask, int state)
{
int toggle_gpio;
toggle_gpio = get_led_gpio(mask);
if(toggle_gpio){
if(toggle_gpio)
{
if (!gpio_request(toggle_gpio, "led"))
__led_set(mask, state);
}
......@@ -72,7 +123,8 @@ void __led_toggle (led_id_t mask)
int state, toggle_gpio;
toggle_gpio = get_led_gpio(mask);
if(toggle_gpio){
if(toggle_gpio)
{
state = gpio_get_value(toggle_gpio);
gpio_direction_output(toggle_gpio, !state);
}
......@@ -83,7 +135,8 @@ void __led_set (led_id_t mask, int state)
int toggle_gpio;
toggle_gpio = get_led_gpio(mask);
if(toggle_gpio){
if(toggle_gpio)
{
gpio_direction_output(toggle_gpio, state);
}
}
/*
* Copyright (c) 2018 ISEE 2007 SL
* Aitor Carrizosa <acarrizosa@iatec.biz>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __CONFIG_IGEP_LED_H
#define __CONFIG_IGEP_LED_H
typedef struct led_definition_t
{
char led_name[25]; /* led name id */
int gpio_num; /* gpio number */
int led_st; /* led status */
} led_definition ;
/* Extern definition */
extern led_definition *ldef;
#endif
\ No newline at end of file
......@@ -9,3 +9,7 @@
obj-y += igep0046_eeprom.o
obj-$(CONFIG_POWER_PFUZE100) += pfuze.o
obj-y += igep0046.o
ifdef CONFIG_LED_STATUS
obj-y += ../common/led.o
endif
\ No newline at end of file
......@@ -37,6 +37,7 @@
#include "../common/igep_common.h"
#include <usb.h>
#include <mmc.h>
#include "../common/led.h"
DECLARE_GLOBAL_DATA_PTR;
......@@ -457,13 +458,31 @@ int board_early_init_f(void)
/* configure LEDS */
gpio_direction_output(IMX_GPIO_NR(4, 18), 0);
gpio_direction_output(IMX_GPIO_NR(4, 19), 1);
gpio_direction_output(IMX_GPIO_NR(4, 19), 0);
gpio_direction_output(IMX_GPIO_NR(4, 20), 0);
gpio_direction_output(IMX_GPIO_NR(4, 17), 1);
gpio_direction_output(IMX_GPIO_NR(4, 17), 0);
return 0;
}
/* GPIO pins for the LEDs */
/* GPIO Leds */
#define IGEP0046_LED_RED_USER0 114 /* led_red_gpio4_18 */
#define IGEP0046_LED_GREEN_USER1 115 /* led_green_gpio4_19 */
#define IGEP0046_LED_RED_USER2 116 /* led_red2_gpio4_20 */
#define IGEP0046_LED_GREEN_USER3 113 /* led_green2_gpio4_17 */
led_definition myldef[] = {
{"red", IGEP0046_LED_RED_USER0, CONFIG_LED_STATUS_BIT},
{"green", IGEP0046_LED_GREEN_USER1, CONFIG_LED_STATUS_BIT1},
{"red1", IGEP0046_LED_RED_USER2, CONFIG_LED_STATUS_BIT2},
{"green1", IGEP0046_LED_GREEN_USER3, CONFIG_LED_STATUS_BIT3},
{ 0, 0, -1 }
};
led_definition *ldef = (led_definition*) &myldef;
int board_init(void)
{
......
......@@ -16,3 +16,45 @@ CONFIG_BASE0040=y
CONFIG_HUSH_PARSER=y
CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
#
# LED Support
#
CONFIG_LED=y
CONFIG_CMD_LED=y
# CONFIG_LED_GPIO is not set
CONFIG_LED_STATUS=y
CONFIG_LED_STATUS_OFF=0
CONFIG_LED_STATUS_BLINKING=1
CONFIG_LED_STATUS_ON=1
# CONFIG_LED_STATUS_GPIO=n
CONFIG_LED_STATUS_BOARD_SPECIFIC=y
#
# LEDs parameters
#
CONFIG_LED_STATUS0=y
CONFIG_LED_STATUS_BIT=26
CONFIG_LED_STATUS_STATE=0
CONFIG_LED_STATUS_FREQ=500
CONFIG_LED_STATUS1=y
CONFIG_LED_STATUS_BIT1=27
CONFIG_LED_STATUS_STATE1=0
CONFIG_LED_STATUS_FREQ1=500
CONFIG_LED_STATUS2=y
CONFIG_LED_STATUS_BIT2=28
CONFIG_LED_STATUS_STATE2=0
CONFIG_LED_STATUS_FREQ2=500
CONFIG_LED_STATUS3=y
CONFIG_LED_STATUS_BIT3=400
CONFIG_LED_STATUS_STATE3=0
CONFIG_LED_STATUS_FREQ3=500
# CONFIG_LED_STATUS4 is not set
# CONFIG_LED_STATUS5 is not set
# CONFIG_LED_STATUS_BOOT_ENABLE is not set
# CONFIG_LED_STATUS_YELLOW_ENABLE is not set
# CONFIG_LED_STATUS_BLUE_ENABLE is not set
CONFIG_LED_STATUS_GREEN_ENABLE=y
CONFIG_LED_STATUS_GREEN=0
CONFIG_LED_STATUS_RED_ENABLE=y
CONFIG_LED_STATUS_RED=0
CONFIG_LED_STATUS_CMD=y
\ No newline at end of file
......@@ -17,3 +17,45 @@ CONFIG_HUSH_PARSER=y
CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_HWTEST=y
#
# LED Support
#
CONFIG_LED=y
CONFIG_CMD_LED=y
# CONFIG_LED_GPIO is not set
CONFIG_LED_STATUS=y
CONFIG_LED_STATUS_OFF=0
CONFIG_LED_STATUS_BLINKING=1
CONFIG_LED_STATUS_ON=1
# CONFIG_LED_STATUS_GPIO=n
CONFIG_LED_STATUS_BOARD_SPECIFIC=y
#
# LEDs parameters
#
CONFIG_LED_STATUS0=y
CONFIG_LED_STATUS_BIT=26
CONFIG_LED_STATUS_STATE=0
CONFIG_LED_STATUS_FREQ=500
CONFIG_LED_STATUS1=y
CONFIG_LED_STATUS_BIT1=27
CONFIG_LED_STATUS_STATE1=0
CONFIG_LED_STATUS_FREQ1=500
CONFIG_LED_STATUS2=y
CONFIG_LED_STATUS_BIT2=28
CONFIG_LED_STATUS_STATE2=0
CONFIG_LED_STATUS_FREQ2=500
CONFIG_LED_STATUS3=y
CONFIG_LED_STATUS_BIT3=400
CONFIG_LED_STATUS_STATE3=0
CONFIG_LED_STATUS_FREQ3=500
# CONFIG_LED_STATUS4 is not set
# CONFIG_LED_STATUS5 is not set
# CONFIG_LED_STATUS_BOOT_ENABLE is not set
# CONFIG_LED_STATUS_YELLOW_ENABLE is not set
# CONFIG_LED_STATUS_RED_ENABLE is not set
CONFIG_LED_STATUS_GREEN_ENABLE=y
CONFIG_LED_STATUS_GREEN=1
CONFIG_LED_STATUS_BLUE_ENABLE=y
CONFIG_LED_STATUS_BLUE=1
CONFIG_LED_STATUS_CMD=y
\ No newline at end of file
......@@ -15,3 +15,44 @@ CONFIG_BASE0040=y
CONFIG_HUSH_PARSER=y
CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
#
# LED Support
#
CONFIG_LED=y
# CONFIG_LED_GPIO is not set
CONFIG_LED_STATUS=y
CONFIG_LED_STATUS_OFF=0
CONFIG_LED_STATUS_BLINKING=1
CONFIG_LED_STATUS_ON=2
# CONFIG_LED_STATUS_GPIO is not set
CONFIG_LED_STATUS_BOARD_SPECIFIC=y
#
# LEDs parameters
#
CONFIG_LED_STATUS0=y
CONFIG_LED_STATUS_BIT=26
CONFIG_LED_STATUS_STATE=0
CONFIG_LED_STATUS_FREQ=2
CONFIG_LED_STATUS1=y
CONFIG_LED_STATUS_BIT1=27
CONFIG_LED_STATUS_STATE1=0
CONFIG_LED_STATUS_FREQ1=2
CONFIG_LED_STATUS2=y
CONFIG_LED_STATUS_BIT2=28
CONFIG_LED_STATUS_STATE2=0
CONFIG_LED_STATUS_FREQ2=2
CONFIG_LED_STATUS3=y
CONFIG_LED_STATUS_BIT3=400
CONFIG_LED_STATUS_STATE3=0
CONFIG_LED_STATUS_FREQ3=2
# CONFIG_LED_STATUS4 is not set
# CONFIG_LED_STATUS5 is not set
# CONFIG_LED_STATUS_BOOT_ENABLE is not set
# CONFIG_LED_STATUS_RED_ENABLE is not set
# CONFIG_LED_STATUS_YELLOW_ENABLE is not set
CONFIG_LED_STATUS_BLUE_ENABLE=y
CONFIG_LED_STATUS_BLUE=1
CONFIG_LED_STATUS_GREEN_ENABLE=y
CONFIG_LED_STATUS_GREEN=1
CONFIG_LED_STATUS_CMD=y
\ No newline at end of file
......@@ -16,3 +16,45 @@ CONFIG_HUSH_PARSER=y
CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_HWTEST=y
#
# LED Support
#
CONFIG_LED=y
CONFIG_CMD_LED=y
# CONFIG_LED_GPIO is not set
CONFIG_LED_STATUS=y
CONFIG_LED_STATUS_OFF=0
CONFIG_LED_STATUS_BLINKING=1
CONFIG_LED_STATUS_ON=1
# CONFIG_LED_STATUS_GPIO=n
CONFIG_LED_STATUS_BOARD_SPECIFIC=y
#
# LEDs parameters
#
CONFIG_LED_STATUS0=y
CONFIG_LED_STATUS_BIT=26
CONFIG_LED_STATUS_STATE=0
CONFIG_LED_STATUS_FREQ=500
CONFIG_LED_STATUS1=y
CONFIG_LED_STATUS_BIT1=27
CONFIG_LED_STATUS_STATE1=0
CONFIG_LED_STATUS_FREQ1=500
CONFIG_LED_STATUS2=y
CONFIG_LED_STATUS_BIT2=28
CONFIG_LED_STATUS_STATE2=0
CONFIG_LED_STATUS_FREQ2=500
CONFIG_LED_STATUS3=y
CONFIG_LED_STATUS_BIT3=400
CONFIG_LED_STATUS_STATE3=0
CONFIG_LED_STATUS_FREQ3=500
# CONFIG_LED_STATUS4 is not set
# CONFIG_LED_STATUS5 is not set
# CONFIG_LED_STATUS_BOOT_ENABLE is not set
# CONFIG_LED_STATUS_YELLOW_ENABLE is not set
# CONFIG_LED_STATUS_BLUE_ENABLE is not set
CONFIG_LED_STATUS_GREEN_ENABLE=y
CONFIG_LED_STATUS_GREEN=0
CONFIG_LED_STATUS_RED_ENABLE=y
CONFIG_LED_STATUS_RED=0
CONFIG_LED_STATUS_CMD=y
\ No newline at end of file
......@@ -77,6 +77,10 @@
#define CONFIG_CMDLINE_EDITING
#define CONFIG_STACKSIZE (128 * 1024)
/* Mach type */
#define MACH_TYPE_IGEP0046 4521 /* Until the next sync */
#define CONFIG_MACH_TYPE MACH_TYPE_IGEP0046
/* I2C Configs */
#define CONFIG_CMD_I2C
#define CONFIG_SYS_I2C
......@@ -192,7 +196,6 @@
#define EMMC_ENV ""
#endif
#define VIDEO_ARGS "${video_args}"
#define VIDEO_ARGS_SCRIPT "run video_args_script; "
......@@ -565,8 +568,8 @@ else
"run netload \0"
#define ENV_ERRORSTATE \
"errorstate=led 0 off; " \
"led 1 on; " \
"errorstate=led 1 off; " \
"led 0 on; " \
"sleep 60; " \
"reset \0"
......@@ -578,11 +581,11 @@ else
"echo Loaded ${bootenv} file in RAM...; " \
"run importbootenv; " \
"else " \
"echo Not found ${bootenv} file in USB...; " \
"echo Not found ${bootenv} file in SD...; " \
"run errorstate; " \
"fi; " \
"else " \
"echo No USB device found; " \
"echo No SD device found; " \
"run errorstate; " \
"fi\0 "
......@@ -616,13 +619,11 @@ else
ENV_SET_MODELANDVARIANT
#define CONFIG_BOOTCOMMAND \
"led 0 on;" \
"led 1 on;" \
"run sduenvboot;" \
"run setmodelandvariant;" \
VIDEO_ARGS_SCRIPT \
"run netboot"
#endif /*CONFIG_HWTEST*/
#endif /* __IGEP0046_CONFIG_H */
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment