Patchwork [U-Boot,v3,1/1] OMAP3: add boot status GPIO LED for IGEP boards

login
register
mail settings
Submitter Javier Martinez Canillas
Date Dec. 24, 2012, 11:51 a.m.
Message ID <1356349896-11693-1-git-send-email-javier.martinez@collabora.co.uk>
Download mbox | patch
Permalink /patch/208052/
State Superseded
Delegated to: Tom Rini
Headers show

Comments

Javier Martinez Canillas - Dec. 24, 2012, 11:51 a.m.
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 <javier.martinez@collabora.co.uk>
---

Changes since v2:
    - Use show_boot_progress() instead implementing yet another boot status
      signalling as suggested by Wolfgang Denk.

Changes since v1:
    - Don't set gd->bd->bi_arch_number since is done in arch/arm/lib/board.c
    - Use CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020 instead of check bi_arch_number
      as suggested by Igor Grinberg.

 board/isee/igep0020/igep0020.c |   15 +++++++++++++++
 board/isee/igep0020/igep0020.h |    2 ++
 board/isee/igep0030/igep0030.c |   15 +++++++++++++++
 board/isee/igep0030/igep0030.h |    2 ++
 include/configs/igep00x0.h     |    3 +++
 5 files changed, 37 insertions(+), 0 deletions(-)
Wolfgang Denk - Dec. 25, 2012, 7:57 p.m.
Dear Javier Martinez Canillas,

In message <1356349896-11693-1-git-send-email-javier.martinez@collabora.co.uk> you wrote:
> 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 <javier.martinez@collabora.co.uk>
...
> --- a/board/isee/igep0020/igep0020.c
> +++ b/board/isee/igep0020/igep0020.c
...
> +#if defined(CONFIG_SHOW_BOOT_PROGRESS) && !defined(CONFIG_SPL_BUILD)
> +void show_boot_progress(int val)
> +{
> +	if (val < 0) {
> +		/* something went wrong */
> +		return;
> +	}
> +
> +	if (!gpio_request(IGEP0020_GPIO_LED, "")) {
> +		gpio_direction_output(IGEP0020_GPIO_LED, 0);
> +		gpio_set_value(IGEP0020_GPIO_LED, 1);
> +	}
> +}
> +#endif
...
> --- a/board/isee/igep0030/igep0030.c
> +++ b/board/isee/igep0030/igep0030.c
...
> +#if defined(CONFIG_SHOW_BOOT_PROGRESS) && !defined(CONFIG_SPL_BUILD)
> +void show_boot_progress(int val)
> +{
> +	if (val < 0) {
> +		/* something went wrong */
> +		return;
> +	}
> +
> +	if (!gpio_request(IGEP0030_GPIO_LED, "")) {
> +		gpio_direction_output(IGEP0030_GPIO_LED, 0);
> +		gpio_set_value(IGEP0030_GPIO_LED, 1);
> +	}
> +}
> +#endif

Can we not avoid duplicating this code?   If you change
IGEP0020_GPIO_LED and IGEP0030_GPIO_LED into some common name like
IGEP00XX_GPIO_LED, you can use common code for all such boards.

Thanks.

Best regards,

Wolfgang Denk
Javier Martinez Canillas - Dec. 26, 2012, 3:20 a.m.
On Tue, Dec 25, 2012 at 8:57 PM, Wolfgang Denk <wd@denx.de> wrote:
> Dear Javier Martinez Canillas,
>

Hello Wolfang,

Thanks a lot for your suggestions.

> In message <1356349896-11693-1-git-send-email-javier.martinez@collabora.co.uk> you wrote:
>> 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 <javier.martinez@collabora.co.uk>
> ...
>> --- a/board/isee/igep0020/igep0020.c
>> +++ b/board/isee/igep0020/igep0020.c
> ...
>> +#if defined(CONFIG_SHOW_BOOT_PROGRESS) && !defined(CONFIG_SPL_BUILD)
>> +void show_boot_progress(int val)
>> +{
>> +     if (val < 0) {
>> +             /* something went wrong */
>> +             return;
>> +     }
>> +
>> +     if (!gpio_request(IGEP0020_GPIO_LED, "")) {
>> +             gpio_direction_output(IGEP0020_GPIO_LED, 0);
>> +             gpio_set_value(IGEP0020_GPIO_LED, 1);
>> +     }
>> +}
>> +#endif
> ...
>> --- a/board/isee/igep0030/igep0030.c
>> +++ b/board/isee/igep0030/igep0030.c
> ...
>> +#if defined(CONFIG_SHOW_BOOT_PROGRESS) && !defined(CONFIG_SPL_BUILD)
>> +void show_boot_progress(int val)
>> +{
>> +     if (val < 0) {
>> +             /* something went wrong */
>> +             return;
>> +     }
>> +
>> +     if (!gpio_request(IGEP0030_GPIO_LED, "")) {
>> +             gpio_direction_output(IGEP0030_GPIO_LED, 0);
>> +             gpio_set_value(IGEP0030_GPIO_LED, 1);
>> +     }
>> +}
>> +#endif
>
> Can we not avoid duplicating this code?   If you change
> IGEP0020_GPIO_LED and IGEP0030_GPIO_LED into some common name like
> IGEP00XX_GPIO_LED, you can use common code for all such boards.
>

Yes, in fact I'm going to send a patch that removes the code
duplication between igep0020 and igep0030 by using a single board file
for both devices and a following patch that adds a single GPIO LED
support function for both boards.

> Thanks.
>
> Best regards,
>
> Wolfgang Denk
>

Thanks a lot and best regards,
Javier

Patch

diff --git a/board/isee/igep0020/igep0020.c b/board/isee/igep0020/igep0020.c
index a8257a3..5b6afa9 100644
--- a/board/isee/igep0020/igep0020.c
+++ b/board/isee/igep0020/igep0020.c
@@ -58,6 +58,21 @@  int board_init(void)
 	return 0;
 }
 
+#if defined(CONFIG_SHOW_BOOT_PROGRESS) && !defined(CONFIG_SPL_BUILD)
+void show_boot_progress(int val)
+{
+	if (val < 0) {
+		/* something went wrong */
+		return;
+	}
+
+	if (!gpio_request(IGEP0020_GPIO_LED, "")) {
+		gpio_direction_output(IGEP0020_GPIO_LED, 0);
+		gpio_set_value(IGEP0020_GPIO_LED, 1);
+	}
+}
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 /*
  * Routine: omap_rev_string
diff --git a/board/isee/igep0020/igep0020.h b/board/isee/igep0020/igep0020.h
index 3335ecc..1958bdd 100644
--- a/board/isee/igep0020/igep0020.h
+++ b/board/isee/igep0020/igep0020.h
@@ -23,6 +23,8 @@ 
 #ifndef _IGEP0020_H_
 #define _IGEP0020_H_
 
+#define IGEP0020_GPIO_LED   27
+
 const omap3_sysinfo sysinfo = {
 	DDR_STACKED,
 	"IGEP v2 board",
diff --git a/board/isee/igep0030/igep0030.c b/board/isee/igep0030/igep0030.c
index 107cb7f..91aff8c 100644
--- a/board/isee/igep0030/igep0030.c
+++ b/board/isee/igep0030/igep0030.c
@@ -45,6 +45,21 @@  int board_init(void)
 	return 0;
 }
 
+#if defined(CONFIG_SHOW_BOOT_PROGRESS) && !defined(CONFIG_SPL_BUILD)
+void show_boot_progress(int val)
+{
+	if (val < 0) {
+		/* something went wrong */
+		return;
+	}
+
+	if (!gpio_request(IGEP0030_GPIO_LED, "")) {
+		gpio_direction_output(IGEP0030_GPIO_LED, 0);
+		gpio_set_value(IGEP0030_GPIO_LED, 1);
+	}
+}
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 /*
  * Routine: omap_rev_string
diff --git a/board/isee/igep0030/igep0030.h b/board/isee/igep0030/igep0030.h
index a93339d..42c2d9c 100644
--- a/board/isee/igep0030/igep0030.h
+++ b/board/isee/igep0030/igep0030.h
@@ -23,6 +23,8 @@ 
 #ifndef _IGEP0030_H_
 #define _IGEP0030_H_
 
+#define IGEP0030_GPIO_LED 16
+
 const omap3_sysinfo sysinfo = {
 	DDR_STACKED,
 	"OMAP3 IGEP module",
diff --git a/include/configs/igep00x0.h b/include/configs/igep00x0.h
index be7937d..07b1d3a 100644
--- a/include/configs/igep00x0.h
+++ b/include/configs/igep00x0.h
@@ -82,6 +82,9 @@ 
 #define CONFIG_OMAP_HSMMC		1
 #define CONFIG_DOS_PARTITION		1
 
+/* define to enable boot progress via leds */
+#define CONFIG_SHOW_BOOT_PROGRESS
+
 /* USB */
 #define CONFIG_MUSB_UDC			1
 #define CONFIG_USB_OMAP3		1