status_led: Kconfig migration
Move all of the status LED feature to drivers/led/Kconfig.
The LED status definitions were moved from the board configuration
files to the defconfig files.
TBD: Move all of the definitions in the include/status_led.h to the
relevant board's defconfig files.
Tested boards: CL-SOM-AM57x, CM-T335
Signed-off-by: Uri Mashiach <uri.mashiach@compulab.co.il>
diff --git a/board/BuS/eb_cpu5282/eb_cpu5282.c b/board/BuS/eb_cpu5282/eb_cpu5282.c
index 2164b52..b1740ee 100644
--- a/board/BuS/eb_cpu5282/eb_cpu5282.c
+++ b/board/BuS/eb_cpu5282/eb_cpu5282.c
@@ -174,7 +174,7 @@
void __led_set(led_id_t mask, int state)
{
- if (state == STATUS_LED_ON)
+ if (state == CONFIG_LED_STATUS_ON)
MCFGPTA_GPTPORT |= (1 << 3);
else
MCFGPTA_GPTPORT &= ~(1 << 3);
diff --git a/board/bf533-stamp/bf533-stamp.c b/board/bf533-stamp/bf533-stamp.c
index eb000a6..185a651 100644
--- a/board/bf533-stamp/bf533-stamp.c
+++ b/board/bf533-stamp/bf533-stamp.c
@@ -50,8 +50,8 @@
#ifdef CONFIG_SHOW_BOOT_PROGRESS
-#define STATUS_LED_OFF 0
-#define STATUS_LED_ON 1
+#define CONFIG_LED_STATUS_OFF 0
+#define CONFIG_LED_STATUS_ON 1
static int gpio_setup;
@@ -76,24 +76,30 @@
{
switch (status) {
case BOOTSTAGE_ID_CHECK_MAGIC:
- stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
+ stamp_led_set(CONFIG_LED_STATUS_OFF, CONFIG_LED_STATUS_OFF,
+ CONFIG_LED_STATUS_ON);
break;
case BOOTSTAGE_ID_CHECK_HEADER:
- stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
+ stamp_led_set(CONFIG_LED_STATUS_OFF, CONFIG_LED_STATUS_ON,
+ CONFIG_LED_STATUS_OFF);
break;
case BOOTSTAGE_ID_CHECK_CHECKSUM:
- stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
+ stamp_led_set(CONFIG_LED_STATUS_OFF, CONFIG_LED_STATUS_ON,
+ CONFIG_LED_STATUS_ON);
break;
case BOOTSTAGE_ID_CHECK_ARCH:
- stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
+ stamp_led_set(CONFIG_LED_STATUS_ON, CONFIG_LED_STATUS_OFF,
+ CONFIG_LED_STATUS_OFF);
break;
case BOOTSTAGE_ID_CHECK_IMAGETYPE:
case BOOTSTAGE_ID_DECOMP_IMAGE:
- stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
+ stamp_led_set(CONFIG_LED_STATUS_ON, CONFIG_LED_STATUS_OFF,
+ CONFIG_LED_STATUS_ON);
break;
case BOOTSTAGE_ID_KERNEL_LOADED:
case BOOTSTAGE_ID_CHECK_BOOT_OS:
- stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
+ stamp_led_set(CONFIG_LED_STATUS_ON, CONFIG_LED_STATUS_ON,
+ CONFIG_LED_STATUS_OFF);
break;
case BOOTSTAGE_ID_BOOT_OS_RETURNED:
case BOOTSTAGE_ID_RD_MAGIC:
@@ -102,10 +108,12 @@
case BOOTSTAGE_ID_RAMDISK:
case BOOTSTAGE_ID_NO_RAMDISK:
case BOOTSTAGE_ID_RUN_OS:
- stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF);
+ stamp_led_set(CONFIG_LED_STATUS_OFF, CONFIG_LED_STATUS_OFF,
+ CONFIG_LED_STATUS_OFF);
break;
default:
- stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);
+ stamp_led_set(CONFIG_LED_STATUS_ON, CONFIG_LED_STATUS_ON,
+ CONFIG_LED_STATUS_ON);
break;
}
}
diff --git a/board/compulab/cm_t335/cm_t335.c b/board/compulab/cm_t335/cm_t335.c
index 428aee6..c4506b9 100644
--- a/board/compulab/cm_t335/cm_t335.c
+++ b/board/compulab/cm_t335/cm_t335.c
@@ -31,8 +31,8 @@
gpmc_init();
-#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
- status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
+#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
+ status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_OFF);
#endif
return 0;
}
diff --git a/board/compulab/cm_t35/cm_t35.c b/board/compulab/cm_t35/cm_t35.c
index 484651b..ec21955 100644
--- a/board/compulab/cm_t35/cm_t35.c
+++ b/board/compulab/cm_t35/cm_t35.c
@@ -92,8 +92,8 @@
/* boot param addr */
gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
-#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
- status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
+#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
+ status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
#endif
return 0;
diff --git a/board/compulab/cm_t3517/cm_t3517.c b/board/compulab/cm_t3517/cm_t3517.c
index 8aae248..50312b1 100644
--- a/board/compulab/cm_t3517/cm_t3517.c
+++ b/board/compulab/cm_t3517/cm_t3517.c
@@ -89,8 +89,8 @@
/* boot param addr */
gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
-#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
- status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
+#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
+ status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
#endif
cm_t3517_musb_init();
diff --git a/board/corscience/tricorder/led.c b/board/corscience/tricorder/led.c
index 30f2f50..00ffc00 100644
--- a/board/corscience/tricorder/led.c
+++ b/board/corscience/tricorder/led.c
@@ -23,16 +23,16 @@
void __led_toggle(led_id_t mask)
{
int toggle_gpio = 0;
-#ifdef STATUS_LED_BIT
- if (!toggle_gpio && STATUS_LED_BIT & mask)
+#ifdef CONFIG_LED_STATUS0
+ if (!toggle_gpio && CONFIG_LED_STATUS_BIT & mask)
toggle_gpio = TRICORDER_STATUS_LED_GREEN;
#endif
-#ifdef STATUS_LED_BIT1
- if (!toggle_gpio && STATUS_LED_BIT1 & mask)
+#ifdef CONFIG_LED_STATUS1
+ if (!toggle_gpio && CONFIG_LED_STATUS_BIT1 & mask)
toggle_gpio = TRICORDER_STATUS_LED_YELLOW;
#endif
-#ifdef STATUS_LED_BIT2
- if (!toggle_gpio && STATUS_LED_BIT2 & mask) {
+#ifdef CONFIG_LED_STATUS2
+ if (!toggle_gpio && CONFIG_LED_STATUS_BIT2 & mask) {
uint8_t val;
twl4030_i2c_read_u8(TWL4030_CHIP_LED, TWL4030_LED_LEDEN,
&val);
@@ -51,23 +51,23 @@
void __led_set(led_id_t mask, int state)
{
-#ifdef STATUS_LED_BIT
- if (STATUS_LED_BIT & mask) {
+#ifdef CONFIG_LED_STATUS0
+ if (CONFIG_LED_STATUS_BIT & mask) {
gpio_request(TRICORDER_STATUS_LED_GREEN, "");
gpio_direction_output(TRICORDER_STATUS_LED_GREEN, 0);
gpio_set_value(TRICORDER_STATUS_LED_GREEN, state);
}
#endif
-#ifdef STATUS_LED_BIT1
- if (STATUS_LED_BIT1 & mask) {
+#ifdef CONFIG_LED_STATUS1
+ if (CONFIG_LED_STATUS_BIT1 & mask) {
gpio_request(TRICORDER_STATUS_LED_YELLOW, "");
gpio_direction_output(TRICORDER_STATUS_LED_YELLOW, 0);
gpio_set_value(TRICORDER_STATUS_LED_YELLOW, state);
}
#endif
-#ifdef STATUS_LED_BIT2
- if (STATUS_LED_BIT2 & mask) {
- if (STATUS_LED_OFF == state)
+#ifdef CONFIG_LED_STATUS2
+ if (CONFIG_LED_STATUS_BIT2 & mask) {
+ if (CONFIG_LED_STATUS_OFF == state)
twl4030_i2c_write_u8(TWL4030_CHIP_LED,
TWL4030_LED_LEDEN, 0);
else
diff --git a/board/corscience/tricorder/tricorder.c b/board/corscience/tricorder/tricorder.c
index 0009452..e8260c6 100644
--- a/board/corscience/tricorder/tricorder.c
+++ b/board/corscience/tricorder/tricorder.c
@@ -120,9 +120,9 @@
print_hwversion(&eeprom);
twl4030_power_init();
- status_led_set(0, STATUS_LED_ON);
- status_led_set(1, STATUS_LED_ON);
- status_led_set(2, STATUS_LED_ON);
+ status_led_set(0, CONFIG_LED_STATUS_ON);
+ status_led_set(1, CONFIG_LED_STATUS_ON);
+ status_led_set(2, CONFIG_LED_STATUS_ON);
omap_die_id_display();
diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 5a3498f..65cc7df 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -69,8 +69,8 @@
/* boot param addr */
gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
-#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
- status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
+#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
+ status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
#endif
return 0;
diff --git a/board/motionpro/motionpro.c b/board/motionpro/motionpro.c
index dc237c1..7fa81b8 100644
--- a/board/motionpro/motionpro.c
+++ b/board/motionpro/motionpro.c
@@ -15,9 +15,9 @@
#include <miiphy.h>
#include <libfdt.h>
-#if defined(CONFIG_STATUS_LED)
+#if defined(CONFIG_LED_STATUS)
#include <status_led.h>
-#endif /* CONFIG_STATUS_LED */
+#endif /* CONFIG_LED_STATUS */
/* Kollmorgen DPR initialization data */
struct init_elem {
@@ -194,27 +194,46 @@
#endif /* CONFIG_OF_BOARD_SETUP */
-#if defined(CONFIG_STATUS_LED)
-void __led_init(led_id_t regaddr, int state)
+#if defined(CONFIG_LED_STATUS)
+vu_long *regcode_to_regaddr(led_id_t regcode)
{
- *((vu_long *) regaddr) |= ENABLE_GPIO_OUT;
+ /* GPT Enable and Mode Select Register address */
+ vu_long *reg_translate[] = {
+ (vu_long *)MPC5XXX_GPT6_ENABLE,
+ (vu_long *)MPC5XXX_GPT7_ENABLE,
+ };
- if (state == STATUS_LED_ON)
+ if (ARRAY_SIZE(reg_translate) <= regcode)
+ return NULL;
+ return reg_translate[regcode];
+}
+
+void __led_init(led_id_t regcode, int state)
+{
+ vu_long *regaddr = regcode_to_regaddr(regcode);
+
+ *regaddr |= ENABLE_GPIO_OUT;
+
+ if (state == CONFIG_LED_STATUS_ON)
*((vu_long *) regaddr) |= LED_ON;
else
*((vu_long *) regaddr) &= ~LED_ON;
}
-void __led_set(led_id_t regaddr, int state)
+void __led_set(led_id_t regcode, int state)
{
- if (state == STATUS_LED_ON)
- *((vu_long *) regaddr) |= LED_ON;
+ vu_long *regaddr = regcode_to_regaddr(regcode);
+
+ if (state == CONFIG_LED_STATUS_ON)
+ *regaddr |= LED_ON;
else
- *((vu_long *) regaddr) &= ~LED_ON;
+ *regaddr &= ~LED_ON;
}
-void __led_toggle(led_id_t regaddr)
+void __led_toggle(led_id_t regcode)
{
- *((vu_long *) regaddr) ^= LED_ON;
+ vu_long *regaddr = regcode_to_regaddr(regcode);
+
+ *regaddr ^= LED_ON;
}
-#endif /* CONFIG_STATUS_LED */
+#endif /* CONFIG_LED_STATUS */
diff --git a/board/olimex/mx23_olinuxino/mx23_olinuxino.c b/board/olimex/mx23_olinuxino/mx23_olinuxino.c
index 65cbbf1..f05fd0a 100644
--- a/board/olimex/mx23_olinuxino/mx23_olinuxino.c
+++ b/board/olimex/mx23_olinuxino/mx23_olinuxino.c
@@ -13,7 +13,7 @@
#include <asm/arch/imx-regs.h>
#include <asm/arch/clock.h>
#include <asm/arch/sys_proto.h>
-#ifdef CONFIG_STATUS_LED
+#ifdef CONFIG_LED_STATUS
#include <status_led.h>
#endif
@@ -72,8 +72,8 @@
/* Adress of boot parameters */
gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
-#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
- status_led_set(STATUS_LED_BOOT, STATUS_LED_STATE);
+#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
+ status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_STATE);
#endif
return 0;
diff --git a/board/samtec/vining_fpga/socfpga.c b/board/samtec/vining_fpga/socfpga.c
index f3a92b5..f888ecb 100644
--- a/board/samtec/vining_fpga/socfpga.c
+++ b/board/samtec/vining_fpga/socfpga.c
@@ -21,8 +21,8 @@
const unsigned int usb_nrst_gpio = 35;
int ret;
- status_led_set(1, STATUS_LED_ON);
- status_led_set(2, STATUS_LED_ON);
+ status_led_set(1, CONFIG_LED_STATUS_ON);
+ status_led_set(2, CONFIG_LED_STATUS_ON);
/* Address of boot parameters for ATAG (if ATAG is used) */
gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
diff --git a/board/ti/beagle/Makefile b/board/ti/beagle/Makefile
index 7a858be..41b552a 100644
--- a/board/ti/beagle/Makefile
+++ b/board/ti/beagle/Makefile
@@ -6,4 +6,4 @@
#
obj-y := beagle.o
-obj-$(CONFIG_STATUS_LED) += led.o
+obj-$(CONFIG_LED_STATUS) += led.o
diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index 23c7933..a6908d4 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -16,7 +16,7 @@
#include <common.h>
#include <dm.h>
#include <ns16550.h>
-#ifdef CONFIG_STATUS_LED
+#ifdef CONFIG_LED_STATUS
#include <status_led.h>
#endif
#include <twl4030.h>
@@ -96,8 +96,8 @@
/* boot param addr */
gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
-#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
- status_led_set (STATUS_LED_BOOT, STATUS_LED_ON);
+#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
+ status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
#endif
return 0;
diff --git a/board/ti/beagle/led.c b/board/ti/beagle/led.c
index a913a4c..30b8b93 100644
--- a/board/ti/beagle/led.c
+++ b/board/ti/beagle/led.c
@@ -15,26 +15,26 @@
#define BEAGLE_LED_USR0 150
#define BEAGLE_LED_USR1 149
-#ifdef STATUS_LED_GREEN
+#ifdef CONFIG_LED_STATUS_GREEN
void green_led_off(void)
{
- __led_set (STATUS_LED_GREEN, 0);
+ __led_set(CONFIG_LED_STATUS_GREEN, 0);
}
void green_led_on(void)
{
- __led_set (STATUS_LED_GREEN, 1);
+ __led_set(CONFIG_LED_STATUS_GREEN, 1);
}
#endif
static int get_led_gpio(led_id_t mask)
{
-#ifdef STATUS_LED_BIT
- if (STATUS_LED_BIT & mask)
+#ifdef CONFIG_LED_STATUS0
+ if (CONFIG_LED_STATUS_BIT & mask)
return BEAGLE_LED_USR0;
#endif
-#ifdef STATUS_LED_BIT1
- if (STATUS_LED_BIT1 & mask)
+#ifdef CONFIG_LED_STATUS1
+ if (CONFIG_LED_STATUS_BIT1 & mask)
return BEAGLE_LED_USR1;
#endif