[Cubieboard2 PATCH v1] Enable early LED support
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 --- Changes in v1: - "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 | 26 +++--- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/misc/status_led.c b/drivers/misc/status_led.c index a6e9c03a02..23d932ec6e 100644 --- a/drivers/misc/status_led.c +++ b/drivers/misc/status_led.c @@ -69,17 +69,22 @@ led_dev_t led_dev[] = { }; #define MAX_LED_DEV(sizeof(led_dev)/sizeof(led_dev_t)) +#define LED_INITIALIZED_BIT0x8 +#define LED_STATE_MASK 0x3 -static int status_led_init_done = 0; +#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) { led_dev_t *ld; int i; - for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) + for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) { __led_init (ld->mask, ld->state); - status_led_init_done = 1; + LED_INITIALIZE(ld->state); + } } void status_led_tick(ulong timestamp) @@ -87,11 +92,11 @@ void status_led_tick(ulong timestamp) led_dev_t *ld; int i; - if (!status_led_init_done) - status_led_init(); - for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) { + if (!LED_IS_INITIALIZED(ld->state)) + status_led_init(); + if (ld->state != CONFIG_LED_STATUS_BLINKING) continue; @@ -99,7 +104,6 @@ void status_led_tick(ulong timestamp) __led_toggle (ld->mask); ld->cnt -= ld->period; } - } } @@ -110,12 +114,12 @@ void status_led_set(int led, int state) if (led < 0 || led >= MAX_LED_DEV) return; - if (!status_led_init_done) - status_led_init(); - ld = &led_dev[led]; - ld->state = state; + if (!LED_IS_INITIALIZED(ld->state)) + status_led_init(); + + 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_ */ -- 2.25.1
[RFC PATCH v2] Cubieboard2:Enable early LED support
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 --- 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_BIT0x8 +#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_ */ -- 2.25.1
Re: [PATCH v1] Cubieboard2:Fix Cubieboard2 freeze, when LED boot enabled
On Thu, Dec 9, 2021 at 7:18 PM Andre Przywara wrote: Hi Andre, > > On Thu, 9 Dec 2021 18:50:06 +0330 > Javad Rahimi wrote: > > Hi Javad, > > thanks for the patch! > > > When enabling the LED support for Cubieboard2 (SUN7I) > > the uboot freezes in status_led_init() function. > > It uses a static global variable, while the .BSS is defined in DRAM area > > while that function is called before DRAM > > So I'd say that the commit message and the subject is misleading, it's not > a real fix, because nothing was really broken before. That fact that sunxi > puts the BSS into DRAM, even when this is not available at the very > beginning, is more a nasty workaround than a feature. > > So can you please reword the commit message, to focus on what this patch > actually does, and mention that this allow to get rid of a global > variable. And then just briefly mention that it helps sunxi to enable LEDs > early, as a motivation. > > Some things below > Sure, I will change the patch title and will present what exactly this patch is doing and why it should be done. > > Signed-off-by: Javad Rahimi > > --- > > > > drivers/misc/status_led.c | 28 +++- > > 1 file changed, 19 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/misc/status_led.c b/drivers/misc/status_led.c > > index a6e9c03a02..7d30355423 100644 > > --- a/drivers/misc/status_led.c > > +++ b/drivers/misc/status_led.c > > @@ -23,6 +23,7 @@ typedef struct { > > int state; > > int period; > > int cnt; > > + int initialized:1; > > This bitfield doesn't really help here, since the compiler will pad it > with 31 more bits. So just make it a "bool", and let the compiler figure > out what's best here. > Or can you check whether you can fold this bit into the "state" variable? > By introducing something like an "uninitialised" state? Or is there is > another way to detect initialisation (period != 0)? > Exactly, I will try to fold it into the "state" variable. Because only one bit of this variable is used. Other bit fields are free to be used. > > } led_dev_t; > > > > led_dev_t led_dev[] = { > > @@ -30,12 +31,14 @@ 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) > > @@ -43,6 +46,7 @@ led_dev_t led_dev[] = { > > CONFIG_LED_STATUS_STATE2, > > LED_STATUS_PERIOD2, > > 0, > > + 0, > > }, > > #endif > > #if defined(CONFIG_LED_STATUS3) > > @@ -50,6 +54,7 @@ led_dev_t led_dev[] = { > > CONFIG_LED_STATUS_STATE3, > > LED_STATUS_PERIOD3, > > 0, > > + 0, > > }, > > #endif > > #if defined(CONFIG_LED_STATUS4) > > @@ -57,6 +62,7 @@ led_dev_t led_dev[] = { > > CONFIG_LED_STATUS_STATE4, > > LED_STATUS_PERIOD4, > > 0, > > + 0, > > }, > > #endif > > #if defined(CONFIG_LED_STATUS5) > > @@ -64,22 +70,26 @@ 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)) > > > > -static int status_led_init_done = 0; > > > > void status_led_init(void) > > { > > led_dev_t *ld; > > int i; > > > > - for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) > > + for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) { > > __led_init (ld->mask, ld->state); > > - status_led_init_done = 1; > > + ld->initialized = 1; > > + } > > + > > + return 0; > > + > > } > > > > void status_led_tick(ulong timestamp) > > @@ -87,11 +97,11 @@ void status_led_tick(ulong timestamp) > > led_dev_t *ld; > > int i; > > > > - if (!status_led_init_done) > > - status_led_init(); > > - > >
[PATCH v1] Cubieboard2:Fix Cubieboard2 freeze, when LED boot enabled
When enabling the LED support for Cubieboard2 (SUN7I) the uboot freezes in status_led_init() function. It uses a static global variable, while the .BSS is defined in DRAM area while that function is called before DRAM Signed-off-by: Javad Rahimi --- drivers/misc/status_led.c | 28 +++- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/misc/status_led.c b/drivers/misc/status_led.c index a6e9c03a02..7d30355423 100644 --- a/drivers/misc/status_led.c +++ b/drivers/misc/status_led.c @@ -23,6 +23,7 @@ typedef struct { int state; int period; int cnt; + int initialized:1; } led_dev_t; led_dev_t led_dev[] = { @@ -30,12 +31,14 @@ 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) @@ -43,6 +46,7 @@ led_dev_t led_dev[] = { CONFIG_LED_STATUS_STATE2, LED_STATUS_PERIOD2, 0, + 0, }, #endif #if defined(CONFIG_LED_STATUS3) @@ -50,6 +54,7 @@ led_dev_t led_dev[] = { CONFIG_LED_STATUS_STATE3, LED_STATUS_PERIOD3, 0, + 0, }, #endif #if defined(CONFIG_LED_STATUS4) @@ -57,6 +62,7 @@ led_dev_t led_dev[] = { CONFIG_LED_STATUS_STATE4, LED_STATUS_PERIOD4, 0, + 0, }, #endif #if defined(CONFIG_LED_STATUS5) @@ -64,22 +70,26 @@ 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)) -static int status_led_init_done = 0; void status_led_init(void) { led_dev_t *ld; int i; - for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) + for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) { __led_init (ld->mask, ld->state); - status_led_init_done = 1; + ld->initialized = 1; + } + + return 0; + } void status_led_tick(ulong timestamp) @@ -87,11 +97,11 @@ void status_led_tick(ulong timestamp) led_dev_t *ld; int i; - if (!status_led_init_done) - status_led_init(); - for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) { + if (!ld->initialized) + continue; + if (ld->state != CONFIG_LED_STATUS_BLINKING) continue; @@ -110,11 +120,11 @@ void status_led_set(int led, int state) if (led < 0 || led >= MAX_LED_DEV) return; - if (!status_led_init_done) - status_led_init(); - ld = &led_dev[led]; + if (!ld->initialized) + return; + ld->state = state; if (state == CONFIG_LED_STATUS_BLINKING) { ld->cnt = 0;/* always start with full period*/ -- 2.25.1
Re: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support
On Thu, Dec 9, 2021 at 2:54 PM Andre Przywara wrote: Hi Andre, > > On Thu, 9 Dec 2021 14:38:08 +0330 > Javad Rahimi wrote: > > Hi Javad, > > > On Thu, Dec 9, 2021 at 6:24 AM Javad Rahimi wrote: > > > > > > On Wed, Dec 8, 2021 at 9:13 PM Andre Przywara > > > wrote: > > > > > > > > On Wed, 8 Dec 2021 20:48:54 +0330 > > > > Javad Rahimi wrote: > > > > > > > > > On Wed, Dec 8, 2021 at 8:33 PM Andre Przywara > > > > > wrote: > > > > > > > > > > > > On Wed, 8 Dec 2021 19:14:22 +0330 > > > > > > Javad Rahimi wrote: > > > > > > > > > > > > > On Wed, Dec 8, 2021 at 6:05 PM Andre Przywara > > > > > > > wrote: > > > > > > > > > > > > > > > > On Wed, 8 Dec 2021 15:25:54 +0100 > > > > > > > > Frank Wunderlich wrote: > > > > > > > > > > > > > > > > Hi, > > > > > > > > > > > > > > > > > you should add maintainer email for your patch > > > > > > > > > > > > > > > > > > $ scripts/get_maintainer.pl board/sunxi/board.c > > > > > > > > > Jagan Teki (maintainer:ARM SUNXI) > > > > > > > > > Andre Przywara (maintainer:ARM SUNXI) > > > > > > > > > u-boot@lists.denx.de (open list) > > > > > > > > > > > > > > > > Thanks Frank! > > > > > > > > > > > > > > > > > > Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr > > > > > > > > > > Von: "Javad Rahimi" > > > > > > > > > > An: u-boot@lists.denx.de > > > > > > > > > > Cc: "Javad Rahimi" > > > > > > > > > > Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support > > > > > > > > > > > > > > > > > > > > This feature makes it possible to assign one of > > > > > > > > > > LED1(PH20) and LED2(PH21) to BOOT process LED. > > > > > > > > > > User should activates the "Enable status LED API" in > > > > > > > > > > "Device Drivers -> LED Support" > > > > > > > > > > > > > > > > Please have a look at the current pinephone_defconfig, because > > > > > > > > that uses > > > > > > > > the boot LED already in a much easier fashion: > > > > > > > > https://source.denx.de/u-boot/u-boot/-/commit/0534153fd1 > > > > > > > > > > > > > > > > Cheers, > > > > > > > > Andre > > > > > > > > > > > > > > > Hi Andre, > > > > > > > Thanks for your comments. I studied the pinephone_defconfig. > > > > > > > By default, when activating the same options on > > > > > > > Cubieboard2_defconfig > > > > > > > it shows linker error for `__led_init` and `__led_set`. > > > > > > > In other words, they are not defined. So, in this patch, I added > > > > > > > the > > > > > > > implementation for these functions for this board. > > > > > > > > > > > > Did you add the: > > > > > > CONFIG_SPL_DRIVERS_MISC=y > > > > > > line as well? And re-ran make Cubieboard2_defconfig? > > > > > > Because that seemed to work for me. > > > > > > > > > > > > Cheers, > > > > > > Andre > > > > > > > > > > > > > > > > > When I add CONFIG_SPL_DRIVERS_MISC=y > > > > > By flashing SD card and turning on the board, It freezes in this step: > > > > > ``` > > > > > U-Boot SPL 2022.01-rc3-00025-gf570594bc9-dirty (Dec 08 2021 - > > > > > 20:36:51 +0330) > > > > > ``` > > > > > - > > > > > The customized defconfig file for Cubieboard: > > > > > ``` > > > > > CONFIG_ARM=y > > > > > CONFIG_ARCH_SUNXI=y > > > > > CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cubieboard2" > > > > > CONFIG_SPL_DRIVERS_MISC=y
Re: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support
` On Thu, Dec 9, 2021 at 6:24 AM Javad Rahimi wrote: > > On Wed, Dec 8, 2021 at 9:13 PM Andre Przywara wrote: > > > > On Wed, 8 Dec 2021 20:48:54 +0330 > > Javad Rahimi wrote: > > > > > On Wed, Dec 8, 2021 at 8:33 PM Andre Przywara > > > wrote: > > > > > > > > On Wed, 8 Dec 2021 19:14:22 +0330 > > > > Javad Rahimi wrote: > > > > > > > > > On Wed, Dec 8, 2021 at 6:05 PM Andre Przywara > > > > > wrote: > > > > > > > > > > > > On Wed, 8 Dec 2021 15:25:54 +0100 > > > > > > Frank Wunderlich wrote: > > > > > > > > > > > > Hi, > > > > > > > > > > > > > you should add maintainer email for your patch > > > > > > > > > > > > > > $ scripts/get_maintainer.pl board/sunxi/board.c > > > > > > > Jagan Teki (maintainer:ARM SUNXI) > > > > > > > Andre Przywara (maintainer:ARM SUNXI) > > > > > > > u-boot@lists.denx.de (open list) > > > > > > > > > > > > Thanks Frank! > > > > > > > > > > > > > > Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr > > > > > > > > Von: "Javad Rahimi" > > > > > > > > An: u-boot@lists.denx.de > > > > > > > > Cc: "Javad Rahimi" > > > > > > > > Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support > > > > > > > > > > > > > > > > This feature makes it possible to assign one of > > > > > > > > LED1(PH20) and LED2(PH21) to BOOT process LED. > > > > > > > > User should activates the "Enable status LED API" in > > > > > > > > "Device Drivers -> LED Support" > > > > > > > > > > > > Please have a look at the current pinephone_defconfig, because that > > > > > > uses > > > > > > the boot LED already in a much easier fashion: > > > > > > https://source.denx.de/u-boot/u-boot/-/commit/0534153fd1 > > > > > > > > > > > > Cheers, > > > > > > Andre > > > > > > > > > > > Hi Andre, > > > > > Thanks for your comments. I studied the pinephone_defconfig. > > > > > By default, when activating the same options on Cubieboard2_defconfig > > > > > it shows linker error for `__led_init` and `__led_set`. > > > > > In other words, they are not defined. So, in this patch, I added the > > > > > implementation for these functions for this board. > > > > > > > > Did you add the: > > > > CONFIG_SPL_DRIVERS_MISC=y > > > > line as well? And re-ran make Cubieboard2_defconfig? > > > > Because that seemed to work for me. > > > > > > > > Cheers, > > > > Andre > > > > > > > > > > > When I add CONFIG_SPL_DRIVERS_MISC=y > > > By flashing SD card and turning on the board, It freezes in this step: > > > ``` > > > U-Boot SPL 2022.01-rc3-00025-gf570594bc9-dirty (Dec 08 2021 - 20:36:51 > > > +0330) > > > ``` > > > - > > > The customized defconfig file for Cubieboard: > > > ``` > > > CONFIG_ARM=y > > > CONFIG_ARCH_SUNXI=y > > > CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cubieboard2" > > > CONFIG_SPL_DRIVERS_MISC=y > > > CONFIG_SPL=y > > > CONFIG_MACH_SUN7I=y > > > CONFIG_DRAM_CLK=480 > > > CONFIG_MMC0_CD_PIN="PH1" > > > CONFIG_SATAPWR="PB8" > > > CONFIG_AHCI=y > > > # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set > > > CONFIG_SPL_I2C=y > > > CONFIG_SCSI_AHCI=y > > > CONFIG_SYS_I2C_MVTWSI=y > > > CONFIG_SYS_I2C_SLAVE=0x7f > > > CONFIG_SYS_I2C_SPEED=40 > > > CONFIG_PHY_REALTEK=y > > > CONFIG_ETH_DESIGNWARE=y > > > CONFIG_MII=y > > > CONFIG_SUN7I_GMAC=y > > > CONFIG_SCSI=y > > > CONFIG_USB_EHCI_HCD=y > > > CONFIG_USB_OHCI_HCD=y > > > CONFIG_LED_STATUS=y > > > CONFIG_LED_STATUS_GPIO=y > > > CONFIG_LED_STATUS0=y > > > CONFIG_LED_STATUS_BIT=114 > > > > This is the GPIO number, you need to adjust this to point to the pin your > > LED is connected to. PH20 would be 244, for in
Re: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support
On Wed, Dec 8, 2021 at 9:13 PM Andre Przywara wrote: > > On Wed, 8 Dec 2021 20:48:54 +0330 > Javad Rahimi wrote: > > > On Wed, Dec 8, 2021 at 8:33 PM Andre Przywara > > wrote: > > > > > > On Wed, 8 Dec 2021 19:14:22 +0330 > > > Javad Rahimi wrote: > > > > > > > On Wed, Dec 8, 2021 at 6:05 PM Andre Przywara > > > > wrote: > > > > > > > > > > On Wed, 8 Dec 2021 15:25:54 +0100 > > > > > Frank Wunderlich wrote: > > > > > > > > > > Hi, > > > > > > > > > > > you should add maintainer email for your patch > > > > > > > > > > > > $ scripts/get_maintainer.pl board/sunxi/board.c > > > > > > Jagan Teki (maintainer:ARM SUNXI) > > > > > > Andre Przywara (maintainer:ARM SUNXI) > > > > > > u-boot@lists.denx.de (open list) > > > > > > > > > > Thanks Frank! > > > > > > > > > > > > Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr > > > > > > > Von: "Javad Rahimi" > > > > > > > An: u-boot@lists.denx.de > > > > > > > Cc: "Javad Rahimi" > > > > > > > Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support > > > > > > > > > > > > > > This feature makes it possible to assign one of > > > > > > > LED1(PH20) and LED2(PH21) to BOOT process LED. > > > > > > > User should activates the "Enable status LED API" in > > > > > > > "Device Drivers -> LED Support" > > > > > > > > > > Please have a look at the current pinephone_defconfig, because that > > > > > uses > > > > > the boot LED already in a much easier fashion: > > > > > https://source.denx.de/u-boot/u-boot/-/commit/0534153fd1 > > > > > > > > > > Cheers, > > > > > Andre > > > > > > > > > Hi Andre, > > > > Thanks for your comments. I studied the pinephone_defconfig. > > > > By default, when activating the same options on Cubieboard2_defconfig > > > > it shows linker error for `__led_init` and `__led_set`. > > > > In other words, they are not defined. So, in this patch, I added the > > > > implementation for these functions for this board. > > > > > > Did you add the: > > > CONFIG_SPL_DRIVERS_MISC=y > > > line as well? And re-ran make Cubieboard2_defconfig? > > > Because that seemed to work for me. > > > > > > Cheers, > > > Andre > > > > > > > > When I add CONFIG_SPL_DRIVERS_MISC=y > > By flashing SD card and turning on the board, It freezes in this step: > > ``` > > U-Boot SPL 2022.01-rc3-00025-gf570594bc9-dirty (Dec 08 2021 - 20:36:51 > > +0330) > > ``` > > - > > The customized defconfig file for Cubieboard: > > ``` > > CONFIG_ARM=y > > CONFIG_ARCH_SUNXI=y > > CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cubieboard2" > > CONFIG_SPL_DRIVERS_MISC=y > > CONFIG_SPL=y > > CONFIG_MACH_SUN7I=y > > CONFIG_DRAM_CLK=480 > > CONFIG_MMC0_CD_PIN="PH1" > > CONFIG_SATAPWR="PB8" > > CONFIG_AHCI=y > > # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set > > CONFIG_SPL_I2C=y > > CONFIG_SCSI_AHCI=y > > CONFIG_SYS_I2C_MVTWSI=y > > CONFIG_SYS_I2C_SLAVE=0x7f > > CONFIG_SYS_I2C_SPEED=40 > > CONFIG_PHY_REALTEK=y > > CONFIG_ETH_DESIGNWARE=y > > CONFIG_MII=y > > CONFIG_SUN7I_GMAC=y > > CONFIG_SCSI=y > > CONFIG_USB_EHCI_HCD=y > > CONFIG_USB_OHCI_HCD=y > > CONFIG_LED_STATUS=y > > CONFIG_LED_STATUS_GPIO=y > > CONFIG_LED_STATUS0=y > > CONFIG_LED_STATUS_BIT=114 > > This is the GPIO number, you need to adjust this to point to the pin your > LED is connected to. PH20 would be 244, for instance: > ('H' - 'A') * 32 + 20 > > Cheers, > Andre > Thanks, Now the LED is ON, but the loader still freezes in (SPL, I think) ``` U-Boot SPL 2022.01-rc3-00025-gf570594bc9-dirty (Dec 09 2021 - 06:19:40 +0330) ``` Best Regards, Javad > > CONFIG_LED_STATUS_STATE=2 > > ``` > > Best Regards, > > Javad > > > > > > > > > > > > > > Signed-off-by: Javad Rahimi > > > > > > > --- > > > > > > > This is my first contributation in
Re: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support
On Wed, Dec 8, 2021 at 8:33 PM Andre Przywara wrote: > > On Wed, 8 Dec 2021 19:14:22 +0330 > Javad Rahimi wrote: > > > On Wed, Dec 8, 2021 at 6:05 PM Andre Przywara > > wrote: > > > > > > On Wed, 8 Dec 2021 15:25:54 +0100 > > > Frank Wunderlich wrote: > > > > > > Hi, > > > > > > > you should add maintainer email for your patch > > > > > > > > $ scripts/get_maintainer.pl board/sunxi/board.c > > > > Jagan Teki (maintainer:ARM SUNXI) > > > > Andre Przywara (maintainer:ARM SUNXI) > > > > u-boot@lists.denx.de (open list) > > > > > > Thanks Frank! > > > > > > > > Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr > > > > > Von: "Javad Rahimi" > > > > > An: u-boot@lists.denx.de > > > > > Cc: "Javad Rahimi" > > > > > Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support > > > > > > > > > > This feature makes it possible to assign one of > > > > > LED1(PH20) and LED2(PH21) to BOOT process LED. > > > > > User should activates the "Enable status LED API" in > > > > > "Device Drivers -> LED Support" > > > > > > Please have a look at the current pinephone_defconfig, because that uses > > > the boot LED already in a much easier fashion: > > > https://source.denx.de/u-boot/u-boot/-/commit/0534153fd1 > > > > > > Cheers, > > > Andre > > > > > Hi Andre, > > Thanks for your comments. I studied the pinephone_defconfig. > > By default, when activating the same options on Cubieboard2_defconfig > > it shows linker error for `__led_init` and `__led_set`. > > In other words, they are not defined. So, in this patch, I added the > > implementation for these functions for this board. > > Did you add the: > CONFIG_SPL_DRIVERS_MISC=y > line as well? And re-ran make Cubieboard2_defconfig? > Because that seemed to work for me. > > Cheers, > Andre > > When I add CONFIG_SPL_DRIVERS_MISC=y By flashing SD card and turning on the board, It freezes in this step: ``` U-Boot SPL 2022.01-rc3-00025-gf570594bc9-dirty (Dec 08 2021 - 20:36:51 +0330) ``` - The customized defconfig file for Cubieboard: ``` CONFIG_ARM=y CONFIG_ARCH_SUNXI=y CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cubieboard2" CONFIG_SPL_DRIVERS_MISC=y CONFIG_SPL=y CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=480 CONFIG_MMC0_CD_PIN="PH1" CONFIG_SATAPWR="PB8" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set CONFIG_SPL_I2C=y CONFIG_SCSI_AHCI=y CONFIG_SYS_I2C_MVTWSI=y CONFIG_SYS_I2C_SLAVE=0x7f CONFIG_SYS_I2C_SPEED=40 CONFIG_PHY_REALTEK=y CONFIG_ETH_DESIGNWARE=y CONFIG_MII=y CONFIG_SUN7I_GMAC=y CONFIG_SCSI=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_OHCI_HCD=y CONFIG_LED_STATUS=y CONFIG_LED_STATUS_GPIO=y CONFIG_LED_STATUS0=y CONFIG_LED_STATUS_BIT=114 CONFIG_LED_STATUS_STATE=2 ``` Best Regards, Javad > > > > > > > > > > Signed-off-by: Javad Rahimi > > > > > --- > > > > > This is my first contributation in open source world. > > > > > I'm sorry if I have mistakes in my commits and versioning. > > > > > I do my best to learn fast. > > > > > > > > > > Changes in v2: > > > > > - Missed braces added > > > > > - Unnecessary debug removed > > > > > - Some typo fixed > > > > > > > > > > board/sunxi/board.c | 49 > > > > > + > > > > > 1 file changed, 49 insertions(+) > > > > > > > > > > diff --git a/board/sunxi/board.c b/board/sunxi/board.c > > > > > index 4f5747c34a..5e2f6ae902 100644 > > > > > --- a/board/sunxi/board.c > > > > > +++ b/board/sunxi/board.c > > > > > @@ -1002,3 +1002,52 @@ int board_fit_config_name_match(const char > > > > > *name) > > > > > return ret; > > > > > } > > > > > #endif > > > > > + > > > > > +#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT) && > > > > > defined(CONFIG_LED_STATUS_BOARD_SPECIFIC) > > > > > + > > > > > +#define CUBIE2_LED_BOOT_GPIO "PH20" > > > > > +static int gpio_boot_led; > > > > > + > > > > > +void __led_init(led_id_t mask, int state) > > > > > +{ > > > > >
Re: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support
On Wed, Dec 8, 2021 at 6:05 PM Andre Przywara wrote: > > On Wed, 8 Dec 2021 15:25:54 +0100 > Frank Wunderlich wrote: > > Hi, > > > you should add maintainer email for your patch > > > > $ scripts/get_maintainer.pl board/sunxi/board.c > > Jagan Teki (maintainer:ARM SUNXI) > > Andre Przywara (maintainer:ARM SUNXI) > > u-boot@lists.denx.de (open list) > > Thanks Frank! > Hi Andre, Thanks for your comments. I studied the pinephone_defconfig. By default, when activating the same options on Cubieboard2_defconfig it shows linker error for `__led_init` and `__led_set`. In other words, they are not defined. So, in this patch, I added the implementation for these functions for this board. Regards, Javad > > > Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr > > > Von: "Javad Rahimi" > > > An: u-boot@lists.denx.de > > > Cc: "Javad Rahimi" > > > Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support > > > > > > This feature makes it possible to assign one of > > > LED1(PH20) and LED2(PH21) to BOOT process LED. > > > User should activates the "Enable status LED API" in > > > "Device Drivers -> LED Support" > > Please have a look at the current pinephone_defconfig, because that uses > the boot LED already in a much easier fashion: > https://source.denx.de/u-boot/u-boot/-/commit/0534153fd1 > > Cheers, > Andre > > > > > > > Signed-off-by: Javad Rahimi > > > --- > > > This is my first contributation in open source world. > > > I'm sorry if I have mistakes in my commits and versioning. > > > I do my best to learn fast. > > > > > > Changes in v2: > > > - Missed braces added > > > - Unnecessary debug removed > > > - Some typo fixed > > > > > > board/sunxi/board.c | 49 + > > > 1 file changed, 49 insertions(+) > > > > > > diff --git a/board/sunxi/board.c b/board/sunxi/board.c > > > index 4f5747c34a..5e2f6ae902 100644 > > > --- a/board/sunxi/board.c > > > +++ b/board/sunxi/board.c > > > @@ -1002,3 +1002,52 @@ int board_fit_config_name_match(const char *name) > > > return ret; > > > } > > > #endif > > > + > > > +#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT) && > > > defined(CONFIG_LED_STATUS_BOARD_SPECIFIC) > > > + > > > +#define CUBIE2_LED_BOOT_GPIO "PH20" > > > +static int gpio_boot_led; > > > + > > > +void __led_init(led_id_t mask, int state) > > > +{ > > > + int ret; > > > + > > > + if (mask != CONFIG_LED_STATUS_BOOT) > > > + return; > > > + > > > + ret = gpio_lookup_name(CUBIE2_LED_BOOT_GPIO, NULL, NULL, > > > &gpio_boot_led); > > > + > > > + if (ret) > > > + return; > > > + > > > + ret = gpio_request(gpio_boot_led, "boot_led"); > > > + if (ret == -1) { > > > + debug("[gpio_request] Error:%d\n", ret); > > > + return; > > > + } > > > + > > > + ret = gpio_direction_output(gpio_boot_led, 1); > > > + if (ret == -1) { > > > + debug("[gpio_direction_output] Error:%d\n", ret); > > > + return; > > > + } > > > + __led_set(mask, state); > > > +} > > > + > > > +void __led_set(led_id_t mask, int state) > > > +{ > > > + if (mask != CONFIG_LED_STATUS_BOOT) > > > + return; > > > + > > > + gpio_set_value(gpio_boot_led, state); > > > +} > > > + > > > +void __led_toggle(led_id_t mask) > > > +{ > > > + if (mask != CONFIG_LED_STATUS_BOOT) > > > + return; > > > + > > > + gpio_set_value(gpio_boot_led, !gpio_get_value(gpio_boot_led)); > > > +} > > > + > > > +#endif > > > -- > > > 2.25.1 > > > > > > >
[PATCH v3] Cubieboard2:SUN7I:Add LED BOOT support
This feature makes it possible to assign one of LED1(PH20) and LED2(PH21) to BOOT process LED. User should activates the "Enable status LED API" in "Device Drivers -> LED Support" Signed-off-by: Javad Rahimi --- This is my first contributation in open source world. I'm sorry if I have mistakes in my commits and versioning. I do my best to learn fast. Changes in v3: - Maintainers email added Changes in v2: - Missed braces added - Unnecessary debug removed - Some typo fixed board/sunxi/board.c | 49 + 1 file changed, 49 insertions(+) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 4f5747c34a..5e2f6ae902 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -1002,3 +1002,52 @@ int board_fit_config_name_match(const char *name) return ret; } #endif + +#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT) && defined(CONFIG_LED_STATUS_BOARD_SPECIFIC) + +#define CUBIE2_LED_BOOT_GPIO "PH20" +static int gpio_boot_led; + +void __led_init(led_id_t mask, int state) +{ + int ret; + + if (mask != CONFIG_LED_STATUS_BOOT) + return; + + ret = gpio_lookup_name(CUBIE2_LED_BOOT_GPIO, NULL, NULL, &gpio_boot_led); + + if (ret) + return; + + ret = gpio_request(gpio_boot_led, "boot_led"); + if (ret == -1) { + debug("[gpio_request] Error:%d\n", ret); + return; + } + + ret = gpio_direction_output(gpio_boot_led, 1); + if (ret == -1) { + debug("[gpio_direction_output] Error:%d\n", ret); + return; + } + __led_set(mask, state); +} + +void __led_set(led_id_t mask, int state) +{ + if (mask != CONFIG_LED_STATUS_BOOT) + return; + + gpio_set_value(gpio_boot_led, state); +} + +void __led_toggle(led_id_t mask) +{ + if (mask != CONFIG_LED_STATUS_BOOT) + return; + + gpio_set_value(gpio_boot_led, !gpio_get_value(gpio_boot_led)); +} + +#endif -- 2.25.1
[PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support
This feature makes it possible to assign one of LED1(PH20) and LED2(PH21) to BOOT process LED. User should activates the "Enable status LED API" in "Device Drivers -> LED Support" Signed-off-by: Javad Rahimi --- This is my first contributation in open source world. I'm sorry if I have mistakes in my commits and versioning. I do my best to learn fast. Changes in v2: - Missed braces added - Unnecessary debug removed - Some typo fixed board/sunxi/board.c | 49 + 1 file changed, 49 insertions(+) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 4f5747c34a..5e2f6ae902 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -1002,3 +1002,52 @@ int board_fit_config_name_match(const char *name) return ret; } #endif + +#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT) && defined(CONFIG_LED_STATUS_BOARD_SPECIFIC) + +#define CUBIE2_LED_BOOT_GPIO "PH20" +static int gpio_boot_led; + +void __led_init(led_id_t mask, int state) +{ + int ret; + + if (mask != CONFIG_LED_STATUS_BOOT) + return; + + ret = gpio_lookup_name(CUBIE2_LED_BOOT_GPIO, NULL, NULL, &gpio_boot_led); + + if (ret) + return; + + ret = gpio_request(gpio_boot_led, "boot_led"); + if (ret == -1) { + debug("[gpio_request] Error:%d\n", ret); + return; + } + + ret = gpio_direction_output(gpio_boot_led, 1); + if (ret == -1) { + debug("[gpio_direction_output] Error:%d\n", ret); + return; + } + __led_set(mask, state); +} + +void __led_set(led_id_t mask, int state) +{ + if (mask != CONFIG_LED_STATUS_BOOT) + return; + + gpio_set_value(gpio_boot_led, state); +} + +void __led_toggle(led_id_t mask) +{ + if (mask != CONFIG_LED_STATUS_BOOT) + return; + + gpio_set_value(gpio_boot_led, !gpio_get_value(gpio_boot_led)); +} + +#endif -- 2.25.1
[PATCH] Braces added to the if
Signed-off-by: Javad Rahimi --- board/sunxi/board.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index ff80283702..62d32b6329 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -1017,9 +1017,10 @@ void __led_init (led_id_t mask, int state) ret = gpio_lookup_name(CUBIE2_LED_BOOT_GPIO, NULL, NULL, &gpio_boot_led); - if (ret) + if (ret) { debug("[gpio_lookup_name]LED Err: %d", ret); return; + } gpio_request(gpio_boot_led, "boot_led"); gpio_direction_output(gpio_boot_led, 1); -- 2.25.1
[PATCH] LED BOOT support added for Cubieboard2.
PH20 and PH21 are two LED on the board which users can select to be turn on at boot time. Signed-off-by: Javad Rahimi --- board/sunxi/board.c | 42 ++ 1 file changed, 42 insertions(+) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 4f5747c34a..ff80283702 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -1002,3 +1002,45 @@ int board_fit_config_name_match(const char *name) return ret; } #endif + +#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT) && defined(CONFIG_LED_STATUS_BOARD_SPECIFIC) + +#define CUBIE2_LED_BOOT_GPIO "PH20" +static int gpio_boot_led; + +void __led_init (led_id_t mask, int state) +{ + int ret; + + if (CONFIG_LED_STATUS_BOOT != mask) + return; + + ret = gpio_lookup_name(CUBIE2_LED_BOOT_GPIO, NULL, NULL, &gpio_boot_led); + + if (ret) + debug("[gpio_lookup_name]LED Err: %d", ret); + return; + + gpio_request(gpio_boot_led, "boot_led"); + gpio_direction_output(gpio_boot_led, 1); + __led_set(mask, state); +} + +void __led_set(led_id_t mask, int state) +{ + if (CONFIG_LED_STATUS_BOOT != mask) + return; + + debug("[__led_set]LED Mask:%ld, STATE:%d\n", mask, state); + gpio_set_value(gpio_boot_led, state); +} + +void __led_toggle(led_id_t mask) +{ + if (CONFIG_LED_STATUS_BOOT != mask) + return; + + gpio_set_value(gpio_boot_led, ~gpio_get_value(gpio_boot_led)); +} + +#endif -- 2.25.1
Add BOOT LED support for Cubieboard2
I'm still waiting for my email approval, Is something wrong with my message? Hello, I added LED boot support for my SUN7I based Cubieboard2. I want to send a patch for the changes. It is my first contribution and as It has been mentioned in the `Patches` pages, I'm asking you before for confirmation sending the patch. Best regards Javad
Add BOOT LED support for Cubieboard2
Hello, I added LED boot support for my SUN7I based Cubieboard2. I want to send a patch for the changes. It is my first contribution and as It has been mentioned in the `Patches` pages, I'm asking you before for confirmation sending the patch. Best regards Javad