[RFC PATCH v2] Cubieboard2:Enable early LED support
Andre Przywara
andre.przywara at arm.com
Wed Dec 15 00:49:50 CET 2021
On Sun, 12 Dec 2021 10:52:13 +0330
Javad Rahimi <javad321javad at gmail.com> wrote:
Hi,
> This patch removes the "status_led_init_done" global variable.
> By removing that variable, it is possible
> to use LEDs early in SPL, in architectures
> where .BSS is placed in DRAM area. (For example A20 series)
>
> Signed-off-by: Javad Rahimi <javad321javad at gmail.com>
This patch is on top of the other patch you sent, but which was
dismissed. Please squash the two patches into one (for instance with
"git rebase -i"), and resend.
Cheers,
Andre
> ---
>
> Changes in v2:
> - "initialized" variable removed from "led_dev_t"
> - "state" variable is used as initialization flag
> - Helper macros defined for initialization
> - Initialization is checked at begining of LED operations
>
> drivers/misc/status_led.c | 28 +++++++++++-----------------
> 1 file changed, 11 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/misc/status_led.c b/drivers/misc/status_led.c
> index 7d30355423..23d932ec6e 100644
> --- a/drivers/misc/status_led.c
> +++ b/drivers/misc/status_led.c
> @@ -23,7 +23,6 @@ typedef struct {
> int state;
> int period;
> int cnt;
> - int initialized:1;
> } led_dev_t;
>
> led_dev_t led_dev[] = {
> @@ -31,14 +30,12 @@ led_dev_t led_dev[] = {
> CONFIG_LED_STATUS_STATE,
> LED_STATUS_PERIOD,
> 0,
> - 0,
> },
> #if defined(CONFIG_LED_STATUS1)
> { CONFIG_LED_STATUS_BIT1,
> CONFIG_LED_STATUS_STATE1,
> LED_STATUS_PERIOD1,
> 0,
> - 0,
> },
> #endif
> #if defined(CONFIG_LED_STATUS2)
> @@ -46,7 +43,6 @@ led_dev_t led_dev[] = {
> CONFIG_LED_STATUS_STATE2,
> LED_STATUS_PERIOD2,
> 0,
> - 0,
> },
> #endif
> #if defined(CONFIG_LED_STATUS3)
> @@ -54,7 +50,6 @@ led_dev_t led_dev[] = {
> CONFIG_LED_STATUS_STATE3,
> LED_STATUS_PERIOD3,
> 0,
> - 0,
> },
> #endif
> #if defined(CONFIG_LED_STATUS4)
> @@ -62,7 +57,6 @@ led_dev_t led_dev[] = {
> CONFIG_LED_STATUS_STATE4,
> LED_STATUS_PERIOD4,
> 0,
> - 0,
> },
> #endif
> #if defined(CONFIG_LED_STATUS5)
> @@ -70,13 +64,17 @@ led_dev_t led_dev[] = {
> CONFIG_LED_STATUS_STATE5,
> LED_STATUS_PERIOD5,
> 0,
> - 0,
> },
> #endif
> };
>
> #define MAX_LED_DEV (sizeof(led_dev)/sizeof(led_dev_t))
> +#define LED_INITIALIZED_BIT 0x8
> +#define LED_STATE_MASK 0x3
>
> +#define LED_IS_INITIALIZED(x) (!!((x) & LED_INITIALIZED_BIT))
> +#define LED_INITIALIZE(x) ((x) |= (LED_INITIALIZED_BIT))
> +#define LED_GET_STATE(x) ((x) & LED_STATE_MASK)
>
> void status_led_init(void)
> {
> @@ -85,11 +83,8 @@ void status_led_init(void)
>
> for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) {
> __led_init (ld->mask, ld->state);
> - ld->initialized = 1;
> + LED_INITIALIZE(ld->state);
> }
> -
> - return 0;
> -
> }
>
> void status_led_tick(ulong timestamp)
> @@ -99,8 +94,8 @@ void status_led_tick(ulong timestamp)
>
> for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) {
>
> - if (!ld->initialized)
> - continue;
> + if (!LED_IS_INITIALIZED(ld->state))
> + status_led_init();
>
> if (ld->state != CONFIG_LED_STATUS_BLINKING)
> continue;
> @@ -109,7 +104,6 @@ void status_led_tick(ulong timestamp)
> __led_toggle (ld->mask);
> ld->cnt -= ld->period;
> }
> -
> }
> }
>
> @@ -122,10 +116,10 @@ void status_led_set(int led, int state)
>
> ld = &led_dev[led];
>
> - if (!ld->initialized)
> - return;
> + if (!LED_IS_INITIALIZED(ld->state))
> + status_led_init();
>
> - ld->state = state;
> + ld->state = LED_GET_STATE(ld->state);
> if (state == CONFIG_LED_STATUS_BLINKING) {
> ld->cnt = 0; /* always start with full period */
> state = CONFIG_LED_STATUS_ON; /* always start with LED _ON_ */
More information about the U-Boot
mailing list