OMAP3: add boot status GPIO LED for IGEP boards
PATCH 1/1 OMAP3: add boot status GPIO LED for IGEP boards
This patch adds an GPIO LED boot status for IGEP boards.
The GPIO LED used is the red LED0 while the Linux kernel uses the green LED0 as the boot status.
By using different GPIO LEDs, the user can know in which step of the boot process the board currently is.
--- board/isee/igep0020/Makefile | 4 ++- board/isee/igep0020/igep0020.c | 9 +++++ board/isee/igep0030/Makefile | 4 ++- board/isee/igep0030/igep0030.c | 9 +++++ board/isee/led.c | 74 ++++++++++++++++++++++++++++++++++++++++ include/configs/igep00x0.h | 11 ++++++ 6 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 board/isee/led.c
board/isee/igep0020/Makefile +3 -1
@@ -25,8 +25,10 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).o -COBJS := igep0020.o +COBJS-y := igep0020.o +COBJS-$(CONFIG_STATUS_LED) += ../led.o +COBJS := $(sort $(COBJS-y)) SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))
board/isee/igep0020/igep0020.c +9 -0
@@ -21,6 +21,9 @@* MA 02111-1307 USA */ #include <common.h> +#ifdef CONFIG_STATUS_LED +#include <status_led.h> +#endif #include <netdev.h> #include <twl4030.h> #include <asm/io.h>
@@ -52,9 +55,15 @@ static const u32 gpmc_lan_config[] = {int board_init (void ) {gpmc_init ();/* in SRAM or SDRAM, finish GPMC */ +/* machine type for kernel */ + gd->bd->bi_arch_number =MACH_TYPE_IGEP0020 ;/* 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 ); +#endif +return 0 ; }
board/isee/igep0030/Makefile +3 -1
@@ -25,8 +25,10 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).o -COBJS := igep0030.o +COBJS-y := igep0030.o +COBJS-$(CONFIG_STATUS_LED) += ../led.o +COBJS := $(sort $(COBJS-y)) SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))
board/isee/igep0030/igep0030.c +9 -0
@@ -21,6 +21,9 @@* MA 02111-1307 USA */ #include <common.h> +#ifdef CONFIG_STATUS_LED +#include <status_led.h> +#endif #include <twl4030.h> #include <asm/io.h> #include <asm/arch/mem.h>
@@ -39,9 +42,15 @@ DECLARE_GLOBAL_DATA_PTR;int board_init (void ) {gpmc_init ();/* in SRAM or SDRAM, finish GPMC */ +/* machine type for kernel */ + gd->bd->bi_arch_number =MACH_TYPE_IGEP0030 ;/* 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 ); +#endif +return 0 ; }
board/isee/led.c new file +74 -0
74 lines not on this page · raw message
include/configs/igep00x0.h +11 -0
@@ -82,6 +82,17 @@#define CONFIG_OMAP_HSMMC 1#define CONFIG_DOS_PARTITION 1 +/* Status LED */ +#define CONFIG_STATUS_LED 1 +#define CONFIG_BOARD_SPECIFIC_LED 1 +#define STATUS_LED_BIT 0x01 +#define STATUS_LED_STATE STATUS_LED_ON +#define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2) +#define STATUS_LED_BIT1 0x02 +#define STATUS_LED_STATE1 STATUS_LED_ON +#define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ / 2) +#define STATUS_LED_BOOT STATUS_LED_BIT +/* USB */ #define CONFIG_MUSB_UDC 1#define CONFIG_USB_OMAP3 1
Signature · 1 line
1.7.7.6
PATCH 1/1 OMAP3: add boot status GPIO LED for IGEP boards
Quoted 18 lines · Javier Martinez Canillas
This patch adds an GPIO LED boot status for IGEP boards.
The GPIO LED used is the red LED0 while the Linux kernel uses the green LED0 as the boot status.
By using different GPIO LEDs, the user can know in which step of the boot process the board currently is.
Signed-off-by Javier Martinez Canillas <[email protected]>--- board/isee/igep0020/Makefile | 4 ++- board/isee/igep0020/igep0020.c | 9 +++++ board/isee/igep0030/Makefile | 4 ++- board/isee/igep0030/igep0030.c | 9 +++++ board/isee/led.c | 74 ++++++++++++++++++++++++++++++++++++++++ include/configs/igep00x0.h | 11 ++++++ 6 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 board/isee/led.c
[...]
Quoted 4 lines
board/isee/igep0020/igep0020.c +0
-0
[...]
board/isee/igep0020/igep0020.c static const u32 gpmc_lan_config[] = { · line 59
Quoted 6 lines
board/isee/igep0020/igep0020.c +2
-0@@ -52,9 +55,15 @@ static const u32 gpmc_lan_config[] = {int board_init (void ) {gpmc_init ();/* in SRAM or SDRAM, finish GPMC */ +/* machine type for kernel */ + gd->bd->bi_arch_number =MACH_TYPE_IGEP0020 ;
Please, use CONFIG_MACH_TYPE instead.
[...]
Quoted 4 lines
board/isee/igep0030/igep0030.c +0
-0
[...]
board/isee/igep0030/igep0030.c DECLARE_GLOBAL_DATA_PTR; · line 46
Quoted 6 lines
board/isee/igep0030/igep0030.c +2
-0@@ -39,9 +42,15 @@ DECLARE_GLOBAL_DATA_PTR;int board_init (void ) {gpmc_init ();/* in SRAM or SDRAM, finish GPMC */ +/* machine type for kernel */ + gd->bd->bi_arch_number =MACH_TYPE_IGEP0030 ;
same here
[...]
Quoted 5 lines
board/isee/led.c new file +0
-0
[...]
Quoted 4 lines
board/isee/led.c new file +4
-0+ +/* GPIO pins for the LED */ +#define IGEP0020_GPIO_LED 27 +#define IGEP0030_GPIO_LED 16
board/isee/led.c line 46
Quoted 10 lines
board/isee/led.c new file +10
-0+ +DECLARE_GLOBAL_DATA_PTR ; + +static int __get_gpio () +{ +if (gd->bd->bi_arch_number ==MACH_TYPE_IGEP0020 ) +return IGEP0020_GPIO_LED ; +else +return IGEP0030_GPIO_LED ; +}
Once you define the CONFIG_MACH_TYPE in your board config file, you can then just do something like:
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
#define IGEP_GPIO_LED 27
#else /* MACH_TYPE_IGEP0030 */
#define IGEP_GPIO_LED 16
#endif
remove the above function completely and just use IGEP_GPIO_LED define. This will also probably simplify the below code.
What do you think?
Quoted 50 lines
board/isee/led.c new file +28
-0+ +void __led_init (led_id_t mask,int state) +{ +__led_set (mask, state); +} + +void __led_toggle (led_id_t mask) +{ +int state, toggle_gpio =0 ; + + toggle_gpio =__get_gpio (); + +if (!gpio_request (toggle_gpio,"" )) { +gpio_direction_output (toggle_gpio,0 ); + state =gpio_get_value (toggle_gpio); +gpio_set_value (toggle_gpio, !state); + } +} + +void __led_set (led_id_t mask,int state) +{ +int gpio =__get_gpio (); + +if (!gpio_request (gpio,"" )) { +gpio_direction_output (gpio,0 ); +gpio_set_value (gpio, state); + } +}include/configs/igep00x0.h +11
-0@@ -82,6 +82,17 @@#define CONFIG_OMAP_HSMMC 1#define CONFIG_DOS_PARTITION 1 +/* Status LED */ +#define CONFIG_STATUS_LED 1 +#define CONFIG_BOARD_SPECIFIC_LED 1 +#define STATUS_LED_BIT 0x01 +#define STATUS_LED_STATE STATUS_LED_ON +#define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2) +#define STATUS_LED_BIT1 0x02 +#define STATUS_LED_STATE1 STATUS_LED_ON +#define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ / 2) +#define STATUS_LED_BOOT STATUS_LED_BIT +/* USB */ #define CONFIG_MUSB_UDC 1#define CONFIG_USB_OMAP3 1
Signature · 2 lines
Regards, Igor.
PATCH 1/1 OMAP3: add boot status GPIO LED for IGEP boards
Quoted 3 lines · Igor Grinberg
Quoted 2 lines · Javier Martinez Canillas
This patch adds an GPIO LED boot status for IGEP boards.
Hi Igor, thanks a lot for your comments
Quoted 11 lines
board/isee/igep0020/igep0020.c static const u32 gpmc_lan_config[] = { · line 59
Quoted 6 lines
board/isee/igep0020/igep0020.c +2
-0@@ -52,9 +55,15 @@ static const u32 gpmc_lan_config[] = {int board_init (void ) {gpmc_init ();/* in SRAM or SDRAM, finish GPMC */ +/* machine type for kernel */ + gd->bd->bi_arch_number =MACH_TYPE_IGEP0020 ;Please, use
CONFIG_MACH_TYPEinstead.[...]
Yes, I was just setting this to have some state that could be used latter on board/isee/led.c but now I realized that bi_arch_number is set in arch/arm/lib/board.c
gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
So, I'm just going to remove this assignment
Quoted 7 lines
Quoted 4 lines
board/isee/igep0030/igep0030.c +0
-0[...]
Quoted 9 lines
board/isee/igep0030/igep0030.c DECLARE_GLOBAL_DATA_PTR; · line 46
Quoted 6 lines
board/isee/igep0030/igep0030.c +2
-0@@ -39,9 +42,15 @@ DECLARE_GLOBAL_DATA_PTR;int board_init (void ) {gpmc_init ();/* in SRAM or SDRAM, finish GPMC */ +/* machine type for kernel */ + gd->bd->bi_arch_number =MACH_TYPE_IGEP0030 ;same here
ditto
Quoted 34 lines
[...]
Quoted 5 lines
board/isee/led.c new file +0
-0[...]
Quoted 4 lines
board/isee/led.c new file +4
-0+ +/* GPIO pins for the LED */ +#define IGEP0020_GPIO_LED 27 +#define IGEP0030_GPIO_LED 16board/isee/led.c line 46
Quoted 10 lines
board/isee/led.c new file +10
-0+ +DECLARE_GLOBAL_DATA_PTR ; + +static int __get_gpio () +{ +if (gd->bd->bi_arch_number ==MACH_TYPE_IGEP0020 ) +return IGEP0020_GPIO_LED ; +else +return IGEP0030_GPIO_LED ; +}Once you define the
CONFIG_MACH_TYPEin your board config file, you can then just do something like:#if (
CONFIG_MACH_TYPE==MACH_TYPE_IGEP0020)
#defineIGEP_GPIO_LED27
#else /*MACH_TYPE_IGEP0030*/
#defineIGEP_GPIO_LED16
#endif
Quoted 4 lines
remove the above function completely and just use
IGEP_GPIO_LEDdefine. This will also probably simplify the below code.
What do you think?
Agreed, your approach is much better and simpler.
Will send a v2 with your suggestions,
Thanks a lot and best regards,
Javier