Commit 4a829111 by acarrizosa

IGEP0046: Add led and HWtest support

parent 2502b2aa
...@@ -9,61 +9,112 @@ ...@@ -9,61 +9,112 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/arch/sys_proto.h> #include <asm/arch/sys_proto.h>
#include <asm/gpio.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 pins for the LEDs */
/* GPIO Leds */ /* GPIO Leds */
#define IGEP0146_LED_RED 8 #define IGEP0146_LED_RED_USER0 8
#define IGEP0146_LED_GREEN 9 #define IGEP0146_LED_GREEN_USER1 9
#ifdef CONFIG_LED_STATUS_GREEN #ifdef CONFIG_LED_STATUS_GREEN
void green_led_off(void) 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) 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 #endif
#ifdef CONFIG_LED_STATUS_BLUE #ifdef CONFIG_LED_STATUS_RED
void blue_led_off(void) 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 #endif
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0146)
static int get_led_gpio(led_id_t mask) static int get_led_gpio(led_id_t mask)
{ {
#ifdef CONFIG_LED_STATUS0 #ifdef CONFIG_LED_STATUS0
if (CONFIG_LED_STATUS_BIT == mask){ if (CONFIG_LED_STATUS_BIT == mask)
return IGEP0146_LED_RED; {
return IGEP0146_LED_RED_USER0;
} }
#endif #endif
#ifdef CONFIG_LED_STATUS1 #ifdef CONFIG_LED_STATUS1
if (CONFIG_LED_STATUS_BIT1 == mask){ if (CONFIG_LED_STATUS_BIT1 == mask)
return IGEP0146_LED_GREEN; {
return IGEP0146_LED_GREEN_USER1;
} }
#endif #endif
return 0; 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) void __led_init (led_id_t mask, int state)
{ {
int toggle_gpio; int toggle_gpio;
toggle_gpio = get_led_gpio(mask); toggle_gpio = get_led_gpio(mask);
if(toggle_gpio){ if(toggle_gpio)
{
if (!gpio_request(toggle_gpio, "led")) if (!gpio_request(toggle_gpio, "led"))
__led_set(mask, state); __led_set(mask, state);
} }
} }
...@@ -72,9 +123,10 @@ void __led_toggle (led_id_t mask) ...@@ -72,9 +123,10 @@ void __led_toggle (led_id_t mask)
int state, toggle_gpio; int state, toggle_gpio;
toggle_gpio = get_led_gpio(mask); toggle_gpio = get_led_gpio(mask);
if(toggle_gpio){ if(toggle_gpio)
{
state = gpio_get_value(toggle_gpio); state = gpio_get_value(toggle_gpio);
gpio_direction_output(toggle_gpio, !state); gpio_direction_output(toggle_gpio, !state);
} }
} }
...@@ -83,7 +135,8 @@ void __led_set (led_id_t mask, int state) ...@@ -83,7 +135,8 @@ void __led_set (led_id_t mask, int state)
int toggle_gpio; int toggle_gpio;
toggle_gpio = get_led_gpio(mask); toggle_gpio = get_led_gpio(mask);
if(toggle_gpio){ if(toggle_gpio)
{
gpio_direction_output(toggle_gpio, state); 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 @@ ...@@ -9,3 +9,7 @@
obj-y += igep0046_eeprom.o obj-y += igep0046_eeprom.o
obj-$(CONFIG_POWER_PFUZE100) += pfuze.o obj-$(CONFIG_POWER_PFUZE100) += pfuze.o
obj-y += igep0046.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 @@ ...@@ -37,6 +37,7 @@
#include "../common/igep_common.h" #include "../common/igep_common.h"
#include <usb.h> #include <usb.h>
#include <mmc.h> #include <mmc.h>
#include "../common/led.h"
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -457,13 +458,31 @@ int board_early_init_f(void) ...@@ -457,13 +458,31 @@ int board_early_init_f(void)
/* configure LEDS */ /* configure LEDS */
gpio_direction_output(IMX_GPIO_NR(4, 18), 0); 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, 20), 0);
gpio_direction_output(IMX_GPIO_NR(4, 17), 1); gpio_direction_output(IMX_GPIO_NR(4, 17), 0);
return 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) int board_init(void)
{ {
......
...@@ -15,4 +15,46 @@ CONFIG_DEFAULT_FDT_FILE="imx6dl-igep-base0040rd102.dtb" ...@@ -15,4 +15,46 @@ CONFIG_DEFAULT_FDT_FILE="imx6dl-igep-base0040rd102.dtb"
CONFIG_BASE0040=y CONFIG_BASE0040=y
CONFIG_HUSH_PARSER=y CONFIG_HUSH_PARSER=y
CONFIG_LOCALVERSION="" CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set # CONFIG_LOCALVERSION_AUTO is not set
\ No newline at end of file #
# 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
...@@ -16,4 +16,46 @@ CONFIG_BASE0040=y ...@@ -16,4 +16,46 @@ CONFIG_BASE0040=y
CONFIG_HUSH_PARSER=y CONFIG_HUSH_PARSER=y
CONFIG_LOCALVERSION="" CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set # CONFIG_LOCALVERSION_AUTO is not set
CONFIG_HWTEST=y CONFIG_HWTEST=y
\ No newline at end of file #
# 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
...@@ -14,4 +14,45 @@ CONFIG_DEFAULT_FDT_FILE="imx6q-igep-base0040rd102.dtb" ...@@ -14,4 +14,45 @@ CONFIG_DEFAULT_FDT_FILE="imx6q-igep-base0040rd102.dtb"
CONFIG_BASE0040=y CONFIG_BASE0040=y
CONFIG_HUSH_PARSER=y CONFIG_HUSH_PARSER=y
CONFIG_LOCALVERSION="" CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set # CONFIG_LOCALVERSION_AUTO is not set
\ No newline at end of file #
# 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
...@@ -15,4 +15,46 @@ CONFIG_BASE0040=y ...@@ -15,4 +15,46 @@ CONFIG_BASE0040=y
CONFIG_HUSH_PARSER=y CONFIG_HUSH_PARSER=y
CONFIG_LOCALVERSION="" CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set # CONFIG_LOCALVERSION_AUTO is not set
CONFIG_HWTEST=y CONFIG_HWTEST=y
\ No newline at end of file #
# 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 @@ ...@@ -77,6 +77,10 @@
#define CONFIG_CMDLINE_EDITING #define CONFIG_CMDLINE_EDITING
#define CONFIG_STACKSIZE (128 * 1024) #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 */ /* I2C Configs */
#define CONFIG_CMD_I2C #define CONFIG_CMD_I2C
#define CONFIG_SYS_I2C #define CONFIG_SYS_I2C
...@@ -192,7 +196,6 @@ ...@@ -192,7 +196,6 @@
#define EMMC_ENV "" #define EMMC_ENV ""
#endif #endif
#define VIDEO_ARGS "${video_args}" #define VIDEO_ARGS "${video_args}"
#define VIDEO_ARGS_SCRIPT "run video_args_script; " #define VIDEO_ARGS_SCRIPT "run video_args_script; "
...@@ -565,8 +568,8 @@ else ...@@ -565,8 +568,8 @@ else
"run netload \0" "run netload \0"
#define ENV_ERRORSTATE \ #define ENV_ERRORSTATE \
"errorstate=led 0 off; " \ "errorstate=led 1 off; " \
"led 1 on; " \ "led 0 on; " \
"sleep 60; " \ "sleep 60; " \
"reset \0" "reset \0"
...@@ -578,11 +581,11 @@ else ...@@ -578,11 +581,11 @@ else
"echo Loaded ${bootenv} file in RAM...; " \ "echo Loaded ${bootenv} file in RAM...; " \
"run importbootenv; " \ "run importbootenv; " \
"else " \ "else " \
"echo Not found ${bootenv} file in USB...; " \ "echo Not found ${bootenv} file in SD...; " \
"run errorstate; " \ "run errorstate; " \
"fi; " \ "fi; " \
"else " \ "else " \
"echo No USB device found; " \ "echo No SD device found; " \
"run errorstate; " \ "run errorstate; " \
"fi\0 " "fi\0 "
...@@ -616,13 +619,11 @@ else ...@@ -616,13 +619,11 @@ else
ENV_SET_MODELANDVARIANT ENV_SET_MODELANDVARIANT
#define CONFIG_BOOTCOMMAND \ #define CONFIG_BOOTCOMMAND \
"led 0 on;" \ "led 1 on;" \
"run sduenvboot;" \ "run sduenvboot;" \
"run setmodelandvariant;" \ "run setmodelandvariant;" \
VIDEO_ARGS_SCRIPT \ VIDEO_ARGS_SCRIPT \
"run netboot" "run netboot"
#endif /*CONFIG_HWTEST*/ #endif /*CONFIG_HWTEST*/
#endif /* __IGEP0046_CONFIG_H */
#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