summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoracarrizosa <acarrizosa@iatec.biz>2020-07-07 13:48:26 +0200
committeracarrizosa <acarrizosa@iatec.biz>2020-07-07 13:59:50 +0200
commit4a829111722e5d5e435fcbedb85b33f19cf083cc (patch)
treee8f63452f9060732051d548ce0087a9dfa5a5000
parent2502b2aaa8a75b1229c95cfefb0b584aec3fbb29 (diff)
downloadu-boot-imx-4a829111722e5d5e435fcbedb85b33f19cf083cc.zip
u-boot-imx-4a829111722e5d5e435fcbedb85b33f19cf083cc.tar.gz
u-boot-imx-4a829111722e5d5e435fcbedb85b33f19cf083cc.tar.bz2
IGEP0046: Add led and HWtest support
-rw-r--r--board/isee/common/led.c91
-rw-r--r--board/isee/common/led.h22
-rw-r--r--board/isee/igep0046/Makefile4
-rw-r--r--board/isee/igep0046/igep0046.c23
-rw-r--r--configs/igep0046_imx6dl_2G_defconfig44
-rw-r--r--configs/igep0046_imx6dl_2G_test_defconfig44
-rw-r--r--configs/igep0046_imx6q_2G_defconfig43
-rw-r--r--configs/igep0046_imx6q_2G_test_defconfig44
-rw-r--r--include/configs/igep0046.h19
9 files changed, 300 insertions, 34 deletions
diff --git a/board/isee/common/led.c b/board/isee/common/led.c
index c9503ee..fdc5f7c 100644
--- a/board/isee/common/led.c
+++ b/board/isee/common/led.c
@@ -9,61 +9,112 @@
#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);
+ __led_set(mask, state);
}
}
@@ -72,9 +123,10 @@ 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);
+ 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);
}
}
diff --git a/board/isee/common/led.h b/board/isee/common/led.h
new file mode 100644
index 0000000..ebefac5
--- /dev/null
+++ b/board/isee/common/led.h
@@ -0,0 +1,22 @@
+/*
+ * 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
diff --git a/board/isee/igep0046/Makefile b/board/isee/igep0046/Makefile
index 6e521c9..332a641 100644
--- a/board/isee/igep0046/Makefile
+++ b/board/isee/igep0046/Makefile
@@ -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
diff --git a/board/isee/igep0046/igep0046.c b/board/isee/igep0046/igep0046.c
index d1997ed..0abed86 100644
--- a/board/isee/igep0046/igep0046.c
+++ b/board/isee/igep0046/igep0046.c
@@ -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)
{
diff --git a/configs/igep0046_imx6dl_2G_defconfig b/configs/igep0046_imx6dl_2G_defconfig
index ec4c38a..5588ec1 100644
--- a/configs/igep0046_imx6dl_2G_defconfig
+++ b/configs/igep0046_imx6dl_2G_defconfig
@@ -15,4 +15,46 @@ CONFIG_DEFAULT_FDT_FILE="imx6dl-igep-base0040rd102.dtb"
CONFIG_BASE0040=y
CONFIG_HUSH_PARSER=y
CONFIG_LOCALVERSION=""
-# CONFIG_LOCALVERSION_AUTO is not set \ No newline at end of file
+# 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
diff --git a/configs/igep0046_imx6dl_2G_test_defconfig b/configs/igep0046_imx6dl_2G_test_defconfig
index 9791e23..9899c88 100644
--- a/configs/igep0046_imx6dl_2G_test_defconfig
+++ b/configs/igep0046_imx6dl_2G_test_defconfig
@@ -16,4 +16,46 @@ CONFIG_BASE0040=y
CONFIG_HUSH_PARSER=y
CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
-CONFIG_HWTEST=y \ No newline at end of file
+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
diff --git a/configs/igep0046_imx6q_2G_defconfig b/configs/igep0046_imx6q_2G_defconfig
index de50cc4..ae62be4 100644
--- a/configs/igep0046_imx6q_2G_defconfig
+++ b/configs/igep0046_imx6q_2G_defconfig
@@ -14,4 +14,45 @@ CONFIG_DEFAULT_FDT_FILE="imx6q-igep-base0040rd102.dtb"
CONFIG_BASE0040=y
CONFIG_HUSH_PARSER=y
CONFIG_LOCALVERSION=""
-# CONFIG_LOCALVERSION_AUTO is not set \ No newline at end of file
+# 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
diff --git a/configs/igep0046_imx6q_2G_test_defconfig b/configs/igep0046_imx6q_2G_test_defconfig
index 3d4ba52..e58e950 100644
--- a/configs/igep0046_imx6q_2G_test_defconfig
+++ b/configs/igep0046_imx6q_2G_test_defconfig
@@ -15,4 +15,46 @@ CONFIG_BASE0040=y
CONFIG_HUSH_PARSER=y
CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
-CONFIG_HWTEST=y \ No newline at end of file
+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
diff --git a/include/configs/igep0046.h b/include/configs/igep0046.h
index 101b90e..2b28e4d 100644
--- a/include/configs/igep0046.h
+++ b/include/configs/igep0046.h
@@ -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 */
-
+#endif /* __IGEP0046_CONFIG_H */ \ No newline at end of file