Cubieboard2:SUN7I:Add LED BOOT support
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/1 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"
---
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(+)
board/sunxi/board.c +49 -0
@@ -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
Signature · 1 line
2.25.1
Hi,
you should add maintainer email for your patch
$ scripts/get_maintainer.pl board/sunxi/board.c Jagan Teki <[email protected]> (maintainer:ARM SUNXI) Andre Przywara <[email protected]> (maintainer:ARM SUNXI) [email protected] (open list)
regards Frank
Quoted 86 lines
Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr
Von: "Javad Rahimi" <[email protected]>
An: [email protected]
Cc: "Javad Rahimi" <[email protected]>
Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT supportThis 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 <[email protected]>---
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 fixedboard/sunxi/board.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)board/sunxi/board.c +49
-1@@ -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
On Wed, 8 Dec 2021 15:25:54 +0100
Frank Wunderlich <[email protected]> wrote:
Hi,
Quoted 6 lines
you should add maintainer email for your patch
$ scripts/get_maintainer.pl board/sunxi/board.c Jagan Teki <[email protected]> (maintainer:ARM SUNXI) Andre Przywara <[email protected]> (maintainer:ARM SUNXI) [email protected] (open list)
Thanks Frank!
Quoted 10 lines
Quoted 10 lines
Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr
Von: "Javad Rahimi" <[email protected]>
An: [email protected]
Cc: "Javad Rahimi" <[email protected]>
Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT supportThis 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
Quoted 76 lines
Quoted 76 lines
Signed-off-by Javad Rahimi <[email protected]>---
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 fixedboard/sunxi/board.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)board/sunxi/board.c +49
-1@@ -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
Quoted 6 lines · Andre Przywara
On Wed, 8 Dec 2021 15:25:54 +0100
Frank Wunderlich <[email protected]> wrote:Hi,
Quoted 9 lines
Quoted 6 lines
you should add maintainer email for your patch
$ scripts/get_maintainer.pl board/sunxi/board.c Jagan Teki <[email protected]> (maintainer:ARM SUNXI) Andre Przywara <[email protected]> (maintainer:ARM SUNXI) [email protected] (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
Quoted 95 lines
Quoted 10 lines
Quoted 10 lines
Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr
Von: "Javad Rahimi" <[email protected]>
An: [email protected]
Cc: "Javad Rahimi" <[email protected]>
Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT supportThis 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/0534153fd1Cheers,
AndreQuoted 76 lines
Quoted 76 lines
Signed-off-by Javad Rahimi <[email protected]>---
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 fixedboard/sunxi/board.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)board/sunxi/board.c +49
-1@@ -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
A message that is not in the archive (sent off-list or not yet received): CAL245av-S3yyrxwZ8A3W2wdkYWC3bwOvPWh1BoaU25JEZ8uOvQ@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 45 lines · Andre Przywara
Quoted 34 lines · On Wed, 8 Dec 2021 19:14:22 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 26 lines · Andre Przywara
On Wed, 8 Dec 2021 15:25:54 +0100
Frank Wunderlich <[email protected]> wrote:Hi,
Quoted 6 lines
you should add maintainer email for your patch
$ scripts/get_maintainer.pl board/sunxi/board.c Jagan Teki <[email protected]> (maintainer:ARM SUNXI) Andre Przywara <[email protected]> (maintainer:ARM SUNXI) [email protected] (open list)Thanks Frank!
Quoted 10 lines
Quoted 10 lines
Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr
Von: "Javad Rahimi" <[email protected]>
An: [email protected]
Cc: "Javad Rahimi" <[email protected]>
Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT supportThis 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"
Quoted 7 lines
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/0534153fd1Cheers,
AndreQuoted 6 lines
Hi Andre,
Thanks for your comments. I studied thepinephone_defconfig. By default, when activating the same options onCubieboard2_defconfigit shows linker error for__led_initand__led_set.
In other words, they are not defined. So, in this patch, I added the
implementation for these functions for this board.
Quoted 9 lines
Did you add the:
CONFIG_SPL_DRIVERS_MISC=y
line as well? And re-ran makeCubieboard2_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=400000 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
Quoted 78 lines
Quoted 77 lines
Quoted 77 lines
Quoted 76 lines
Quoted 76 lines
Signed-off-by Javad Rahimi <[email protected]>---
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 fixedboard/sunxi/board.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)board/sunxi/board.c +49
-1@@ -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
Quoted 82 lines · On Wed, 8 Dec 2021 20:48:54 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 45 lines · Andre Przywara
Quoted 34 lines · On Wed, 8 Dec 2021 19:14:22 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 26 lines · Andre Przywara
On Wed, 8 Dec 2021 15:25:54 +0100
Frank Wunderlich <[email protected]> wrote:Hi,
Quoted 6 lines
you should add maintainer email for your patch
$ scripts/get_maintainer.pl board/sunxi/board.c Jagan Teki <[email protected]> (maintainer:ARM SUNXI) Andre Przywara <[email protected]> (maintainer:ARM SUNXI) [email protected] (open list)Thanks Frank!
Quoted 10 lines
Quoted 10 lines
Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr
Von: "Javad Rahimi" <[email protected]>
An: [email protected]
Cc: "Javad Rahimi" <[email protected]>
Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT supportThis 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"
Quoted 7 lines
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/0534153fd1Cheers,
AndreQuoted 6 lines
Hi Andre,
Thanks for your comments. I studied thepinephone_defconfig. By default, when activating the same options onCubieboard2_defconfigit shows linker error for__led_initand__led_set.
In other words, they are not defined. So, in this patch, I added the
implementation for these functions for this board.Quoted 9 lines
Did you add the:
CONFIG_SPL_DRIVERS_MISC=y
line as well? And re-ran makeCubieboard2_defconfig? Because that seemed to work for me.Cheers,
AndreWhen 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=yCONFIG_ARCH_SUNXI=yCONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cubieboard2"CONFIG_SPL_DRIVERS_MISC=yCONFIG_SPL=yCONFIG_MACH_SUN7I=yCONFIG_DRAM_CLK=480CONFIG_MMC0_CD_PIN="PH1"CONFIG_SATAPWR="PB8"CONFIG_AHCI=y
#CONFIG_SYS_MALLOC_CLEAR_ON_INITis not setCONFIG_SPL_I2C=yCONFIG_SCSI_AHCI=yCONFIG_SYS_I2C_MVTWSI=yCONFIG_SYS_I2C_SLAVE=0x7fCONFIG_SYS_I2C_SPEED=400000CONFIG_PHY_REALTEK=yCONFIG_ETH_DESIGNWARE=yCONFIG_MII=y
Quoted 8 lines
CONFIG_SUN7I_GMAC=yCONFIG_SCSI=yCONFIG_USB_EHCI_HCD=yCONFIG_USB_OHCI_HCD=yCONFIG_LED_STATUS=yCONFIG_LED_STATUS_GPIO=yCONFIG_LED_STATUS0=yCONFIG_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
Quoted 82 lines
CONFIG_LED_STATUS_STATE=2
```
Best Regards,
JavadQuoted 78 lines
Quoted 77 lines
Quoted 77 lines
Quoted 76 lines
Quoted 76 lines
Signed-off-by Javad Rahimi <[email protected]>---
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 fixedboard/sunxi/board.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)board/sunxi/board.c +49
-1@@ -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
Quoted 95 lines · Andre Przywara
Quoted 82 lines · On Wed, 8 Dec 2021 20:48:54 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 45 lines · Andre Przywara
Quoted 34 lines · On Wed, 8 Dec 2021 19:14:22 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 26 lines · Andre Przywara
On Wed, 8 Dec 2021 15:25:54 +0100
Frank Wunderlich <[email protected]> wrote:Hi,
Quoted 6 lines
you should add maintainer email for your patch
$ scripts/get_maintainer.pl board/sunxi/board.c Jagan Teki <[email protected]> (maintainer:ARM SUNXI) Andre Przywara <[email protected]> (maintainer:ARM SUNXI) [email protected] (open list)Thanks Frank!
Quoted 10 lines
Quoted 10 lines
Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr
Von: "Javad Rahimi" <[email protected]>
An: [email protected]
Cc: "Javad Rahimi" <[email protected]>
Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT supportThis 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"
Quoted 7 lines
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/0534153fd1Cheers,
AndreQuoted 6 lines
Hi Andre,
Thanks for your comments. I studied thepinephone_defconfig. By default, when activating the same options onCubieboard2_defconfigit shows linker error for__led_initand__led_set.
In other words, they are not defined. So, in this patch, I added the
implementation for these functions for this board.Quoted 9 lines
Did you add the:
CONFIG_SPL_DRIVERS_MISC=y
line as well? And re-ran makeCubieboard2_defconfig? Because that seemed to work for me.Cheers,
AndreWhen 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=yCONFIG_ARCH_SUNXI=yCONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cubieboard2"CONFIG_SPL_DRIVERS_MISC=yCONFIG_SPL=yCONFIG_MACH_SUN7I=yCONFIG_DRAM_CLK=480CONFIG_MMC0_CD_PIN="PH1"CONFIG_SATAPWR="PB8"CONFIG_AHCI=y
#CONFIG_SYS_MALLOC_CLEAR_ON_INITis not setCONFIG_SPL_I2C=yCONFIG_SCSI_AHCI=yCONFIG_SYS_I2C_MVTWSI=yCONFIG_SYS_I2C_SLAVE=0x7fCONFIG_SYS_I2C_SPEED=400000CONFIG_PHY_REALTEK=yCONFIG_ETH_DESIGNWARE=yCONFIG_MII=yQuoted 8 lines
CONFIG_SUN7I_GMAC=yCONFIG_SCSI=yCONFIG_USB_EHCI_HCD=yCONFIG_USB_OHCI_HCD=yCONFIG_LED_STATUS=yCONFIG_LED_STATUS_GPIO=yCONFIG_LED_STATUS0=yCONFIG_LED_STATUS_BIT=114
Quoted 7 lines
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 + 20Cheers,
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
Quoted 83 lines
Quoted 82 lines
CONFIG_LED_STATUS_STATE=2
```
Best Regards,
JavadQuoted 78 lines
Quoted 77 lines
Quoted 77 lines
Quoted 76 lines
Quoted 76 lines
Signed-off-by Javad Rahimi <[email protected]>---
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 fixedboard/sunxi/board.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)board/sunxi/board.c +49
-1@@ -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
`
Quoted 104 lines · Javad Rahimi
Quoted 95 lines · Andre Przywara
Quoted 82 lines · On Wed, 8 Dec 2021 20:48:54 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 45 lines · Andre Przywara
Quoted 34 lines · On Wed, 8 Dec 2021 19:14:22 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 26 lines · Andre Przywara
On Wed, 8 Dec 2021 15:25:54 +0100
Frank Wunderlich <[email protected]> wrote:Hi,
Quoted 6 lines
you should add maintainer email for your patch
$ scripts/get_maintainer.pl board/sunxi/board.c Jagan Teki <[email protected]> (maintainer:ARM SUNXI) Andre Przywara <[email protected]> (maintainer:ARM SUNXI) [email protected] (open list)Thanks Frank!
Quoted 10 lines
Quoted 10 lines
Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr
Von: "Javad Rahimi" <[email protected]>
An: [email protected]
Cc: "Javad Rahimi" <[email protected]>
Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT supportThis 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"
Quoted 7 lines
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/0534153fd1Cheers,
AndreQuoted 6 lines
Hi Andre,
Thanks for your comments. I studied thepinephone_defconfig. By default, when activating the same options onCubieboard2_defconfigit shows linker error for__led_initand__led_set.
In other words, they are not defined. So, in this patch, I added the
implementation for these functions for this board.Quoted 9 lines
Did you add the:
CONFIG_SPL_DRIVERS_MISC=y
line as well? And re-ran makeCubieboard2_defconfig? Because that seemed to work for me.Cheers,
AndreWhen 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=yCONFIG_ARCH_SUNXI=yCONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cubieboard2"CONFIG_SPL_DRIVERS_MISC=yCONFIG_SPL=yCONFIG_MACH_SUN7I=yCONFIG_DRAM_CLK=480CONFIG_MMC0_CD_PIN="PH1"CONFIG_SATAPWR="PB8"CONFIG_AHCI=y
#CONFIG_SYS_MALLOC_CLEAR_ON_INITis not setCONFIG_SPL_I2C=yCONFIG_SCSI_AHCI=yCONFIG_SYS_I2C_MVTWSI=yCONFIG_SYS_I2C_SLAVE=0x7fCONFIG_SYS_I2C_SPEED=400000CONFIG_PHY_REALTEK=yCONFIG_ETH_DESIGNWARE=yCONFIG_MII=yQuoted 8 lines
CONFIG_SUN7I_GMAC=yCONFIG_SCSI=yCONFIG_USB_EHCI_HCD=yCONFIG_USB_OHCI_HCD=yCONFIG_LED_STATUS=yCONFIG_LED_STATUS_GPIO=yCONFIG_LED_STATUS0=yCONFIG_LED_STATUS_BIT=114Quoted 7 lines
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 + 20Cheers,
Andre
Quoted 7 lines
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
Hi Andre,
The freeze problem solved when I placed status_led_init function aftergd->ram_size = sunxi_dram_init();
When it is called before sunxi_dram_init(), the bootloader freezes.
Best Regards,
Javad
Quoted 83 lines
Quoted 83 lines
Quoted 82 lines
CONFIG_LED_STATUS_STATE=2
```
Best Regards,
JavadQuoted 78 lines
Quoted 77 lines
Quoted 77 lines
Quoted 76 lines
Quoted 76 lines
Signed-off-by Javad Rahimi <[email protected]>---
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 fixedboard/sunxi/board.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)board/sunxi/board.c +49
-1@@ -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
On Thu, 9 Dec 2021 14:38:08 +0330
Javad Rahimi <[email protected]> wrote:
Hi Javad,
Quoted 112 lines · Javad Rahimi
Quoted 104 lines · Andre Przywara
Quoted 95 lines
Quoted 82 lines · On Wed, 8 Dec 2021 20:48:54 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 45 lines · Andre Przywara
Quoted 34 lines · On Wed, 8 Dec 2021 19:14:22 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 26 lines · Andre Przywara
On Wed, 8 Dec 2021 15:25:54 +0100
Frank Wunderlich <[email protected]> wrote:Hi,
Quoted 6 lines
you should add maintainer email for your patch
$ scripts/get_maintainer.pl board/sunxi/board.c Jagan Teki <[email protected]> (maintainer:ARM SUNXI) Andre Przywara <[email protected]> (maintainer:ARM SUNXI) [email protected] (open list)Thanks Frank!
Quoted 10 lines
Quoted 10 lines
Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr
Von: "Javad Rahimi" <[email protected]>
An: [email protected]
Cc: "Javad Rahimi" <[email protected]>
Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT supportThis 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"
Quoted 7 lines
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/0534153fd1Cheers,
AndreQuoted 6 lines
Hi Andre,
Thanks for your comments. I studied thepinephone_defconfig. By default, when activating the same options onCubieboard2_defconfigit shows linker error for__led_initand__led_set.
In other words, they are not defined. So, in this patch, I added the
implementation for these functions for this board.Quoted 9 lines
Did you add the:
CONFIG_SPL_DRIVERS_MISC=y
line as well? And re-ran makeCubieboard2_defconfig? Because that seemed to work for me.Cheers,
AndreWhen 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=yCONFIG_ARCH_SUNXI=yCONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cubieboard2"CONFIG_SPL_DRIVERS_MISC=yCONFIG_SPL=yCONFIG_MACH_SUN7I=yCONFIG_DRAM_CLK=480CONFIG_MMC0_CD_PIN="PH1"CONFIG_SATAPWR="PB8"CONFIG_AHCI=y
#CONFIG_SYS_MALLOC_CLEAR_ON_INITis not setCONFIG_SPL_I2C=yCONFIG_SCSI_AHCI=yCONFIG_SYS_I2C_MVTWSI=yCONFIG_SYS_I2C_SLAVE=0x7fCONFIG_SYS_I2C_SPEED=400000CONFIG_PHY_REALTEK=yCONFIG_ETH_DESIGNWARE=yCONFIG_MII=yQuoted 8 lines
CONFIG_SUN7I_GMAC=yCONFIG_SCSI=yCONFIG_USB_EHCI_HCD=yCONFIG_USB_OHCI_HCD=yCONFIG_LED_STATUS=yCONFIG_LED_STATUS_GPIO=yCONFIG_LED_STATUS0=yCONFIG_LED_STATUS_BIT=114Quoted 7 lines
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 + 20Cheers,
AndreQuoted 7 lines
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
Quoted 5 lines
Hi Andre,
The freeze problem solved when I placedstatus_led_initfunction aftergd->ram_size=sunxi_dram_init();
When it is called beforesunxi_dram_init(), the bootloader freezes.
That's probably our old friend .bss in SPL again: To save precious SRAM space, we place the BSS section in DRAM, so it's only available after the DRAM init happened. So far the code that runs before DRAM init is not using variables placed in BSS, so everything works. Possible solutions are:
1) see if we can get rid of BSS variables in the LED code (my bet is on "static int status_led_init_done = 0;" as the culprit)
2) move the LED init after the DRAM init. That's probably a bit late, though, depends a bit on what people expect from the boot LED.
3) I guess the A20 can afford BSS in SRAM, but that would not help with other (64-bit) boards. I actually wonder how it works there, though?
I'd prefer 1), but 2) is surely easier.
Cheers,
Andre
Quoted 86 lines
Best Regards,
JavadQuoted 83 lines
Quoted 83 lines
Quoted 82 lines
CONFIG_LED_STATUS_STATE=2
```
Best Regards,
JavadQuoted 78 lines
Quoted 77 lines
Quoted 77 lines
Quoted 76 lines
Quoted 76 lines
Signed-off-by Javad Rahimi <[email protected]>---
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 fixedboard/sunxi/board.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)board/sunxi/board.c +49
-1@@ -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
On Thu, Dec 9, 2021 at 2:54 PM Andre Przywara <[email protected]> wrote:
Hi Andre,
Quoted 135 lines
On Thu, 9 Dec 2021 14:38:08 +0330
Javad Rahimi <[email protected]> wrote:Hi Javad,
Quoted 112 lines · Javad Rahimi
Quoted 104 lines · Andre Przywara
Quoted 95 lines
Quoted 82 lines · On Wed, 8 Dec 2021 20:48:54 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 45 lines · Andre Przywara
Quoted 34 lines · On Wed, 8 Dec 2021 19:14:22 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 26 lines · Andre Przywara
On Wed, 8 Dec 2021 15:25:54 +0100
Frank Wunderlich <[email protected]> wrote:Hi,
Quoted 6 lines
you should add maintainer email for your patch
$ scripts/get_maintainer.pl board/sunxi/board.c Jagan Teki <[email protected]> (maintainer:ARM SUNXI) Andre Przywara <[email protected]> (maintainer:ARM SUNXI) [email protected] (open list)Thanks Frank!
Quoted 10 lines
Quoted 10 lines
Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr
Von: "Javad Rahimi" <[email protected]>
An: [email protected]
Cc: "Javad Rahimi" <[email protected]>
Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT supportThis 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"
Quoted 7 lines
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/0534153fd1Cheers,
AndreQuoted 6 lines
Hi Andre,
Thanks for your comments. I studied thepinephone_defconfig. By default, when activating the same options onCubieboard2_defconfigit shows linker error for__led_initand__led_set.
In other words, they are not defined. So, in this patch, I added the
implementation for these functions for this board.Quoted 9 lines
Did you add the:
CONFIG_SPL_DRIVERS_MISC=y
line as well? And re-ran makeCubieboard2_defconfig? Because that seemed to work for me.Cheers,
AndreWhen 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=yCONFIG_ARCH_SUNXI=yCONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cubieboard2"CONFIG_SPL_DRIVERS_MISC=yCONFIG_SPL=yCONFIG_MACH_SUN7I=yCONFIG_DRAM_CLK=480CONFIG_MMC0_CD_PIN="PH1"CONFIG_SATAPWR="PB8"CONFIG_AHCI=y
#CONFIG_SYS_MALLOC_CLEAR_ON_INITis not setCONFIG_SPL_I2C=yCONFIG_SCSI_AHCI=yCONFIG_SYS_I2C_MVTWSI=yCONFIG_SYS_I2C_SLAVE=0x7fCONFIG_SYS_I2C_SPEED=400000CONFIG_PHY_REALTEK=yCONFIG_ETH_DESIGNWARE=yCONFIG_MII=yQuoted 8 lines
CONFIG_SUN7I_GMAC=yCONFIG_SCSI=yCONFIG_USB_EHCI_HCD=yCONFIG_USB_OHCI_HCD=yCONFIG_LED_STATUS=yCONFIG_LED_STATUS_GPIO=yCONFIG_LED_STATUS0=yCONFIG_LED_STATUS_BIT=114Quoted 7 lines
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 + 20Cheers,
AndreQuoted 7 lines
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,
JavadQuoted 5 lines
Hi Andre,
The freeze problem solved when I placedstatus_led_initfunction aftergd->ram_size=sunxi_dram_init();
When it is called beforesunxi_dram_init(), the bootloader freezes.That's probably our old friend .bss in SPL again: To save precious SRAM space, we place the BSS section in DRAM, so it's only available after the DRAM init happened. So far the code that runs before DRAM init is not using variables placed in BSS, so everything works. Possible solutions are:
1) see if we can get rid of BSS variables in the LED code (my bet is on "static intstatus_led_init_done= 0;" as the culprit)
2) move the LED init after the DRAM init. That's probably a bit late, though, depends a bit on what people expect from the boot LED.
3) I guess the A20 can afford BSS in SRAM, but that would not help with other (64-bit) boards. I actually wonder how it works there, though?
Quoted 5 lines
I'd prefer 1), but 2) is surely easier.
Cheers,
Andre
Your guess was true. The status_led_init_done was the culprit. I removed this variable and added a one-bit variable named "initialized" to the led_dev_t . In this case, when __led_init is called, we can set it for every single LED. In this case, we can check ld->initilized for each led rather than blindly checking the status_led_init_done global variable.
Best Regards,
Javad
Quoted 87 lines
Quoted 86 lines
Best Regards,
JavadQuoted 83 lines
Quoted 83 lines
Quoted 82 lines
CONFIG_LED_STATUS_STATE=2
```
Best Regards,
JavadQuoted 78 lines
Quoted 77 lines
Quoted 77 lines
Quoted 76 lines
Quoted 76 lines
Signed-off-by Javad Rahimi <[email protected]>---
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 fixedboard/sunxi/board.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)board/sunxi/board.c +49
-1@@ -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
On Thu, 9 Dec 2021 15:51:50 +0330
Javad Rahimi <[email protected]> wrote:
Hi,
Quoted 142 lines · Andre Przywara
Hi Andre,
Quoted 135 lines
On Thu, 9 Dec 2021 14:38:08 +0330
Javad Rahimi <[email protected]> wrote:Hi Javad,
Quoted 112 lines · Javad Rahimi
Quoted 104 lines · Andre Przywara
Quoted 95 lines
Quoted 82 lines · On Wed, 8 Dec 2021 20:48:54 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 45 lines · Andre Przywara
Quoted 34 lines · On Wed, 8 Dec 2021 19:14:22 +0330 Javad Rahimi <[email protected]> wrote:
Quoted 26 lines · Andre Przywara
On Wed, 8 Dec 2021 15:25:54 +0100
Frank Wunderlich <[email protected]> wrote:Hi,
Quoted 6 lines
you should add maintainer email for your patch
$ scripts/get_maintainer.pl board/sunxi/board.c Jagan Teki <[email protected]> (maintainer:ARM SUNXI) Andre Przywara <[email protected]> (maintainer:ARM SUNXI) [email protected] (open list)Thanks Frank!
Quoted 10 lines
Quoted 10 lines
Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr
Von: "Javad Rahimi" <[email protected]>
An: [email protected]
Cc: "Javad Rahimi" <[email protected]>
Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT supportThis 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"
Quoted 7 lines
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/0534153fd1Cheers,
AndreQuoted 6 lines
Hi Andre,
Thanks for your comments. I studied thepinephone_defconfig. By default, when activating the same options onCubieboard2_defconfigit shows linker error for__led_initand__led_set.
In other words, they are not defined. So, in this patch, I added the
implementation for these functions for this board.Quoted 9 lines
Did you add the:
CONFIG_SPL_DRIVERS_MISC=y
line as well? And re-ran makeCubieboard2_defconfig? Because that seemed to work for me.Cheers,
AndreWhen 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=yCONFIG_ARCH_SUNXI=yCONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cubieboard2"CONFIG_SPL_DRIVERS_MISC=yCONFIG_SPL=yCONFIG_MACH_SUN7I=yCONFIG_DRAM_CLK=480CONFIG_MMC0_CD_PIN="PH1"CONFIG_SATAPWR="PB8"CONFIG_AHCI=y
#CONFIG_SYS_MALLOC_CLEAR_ON_INITis not setCONFIG_SPL_I2C=yCONFIG_SCSI_AHCI=yCONFIG_SYS_I2C_MVTWSI=yCONFIG_SYS_I2C_SLAVE=0x7fCONFIG_SYS_I2C_SPEED=400000CONFIG_PHY_REALTEK=yCONFIG_ETH_DESIGNWARE=yCONFIG_MII=yQuoted 8 lines
CONFIG_SUN7I_GMAC=yCONFIG_SCSI=yCONFIG_USB_EHCI_HCD=yCONFIG_USB_OHCI_HCD=yCONFIG_LED_STATUS=yCONFIG_LED_STATUS_GPIO=yCONFIG_LED_STATUS0=yCONFIG_LED_STATUS_BIT=114Quoted 7 lines
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 + 20Cheers,
AndreQuoted 7 lines
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,
JavadQuoted 5 lines
Hi Andre,
The freeze problem solved when I placedstatus_led_initfunction aftergd->ram_size=sunxi_dram_init();
When it is called beforesunxi_dram_init(), the bootloader freezes.That's probably our old friend .bss in SPL again: To save precious SRAM space, we place the BSS section in DRAM, so it's only available after the DRAM init happened. So far the code that runs before DRAM init is not using variables placed in BSS, so everything works. Possible solutions are:
1) see if we can get rid of BSS variables in the LED code (my bet is on "static intstatus_led_init_done= 0;" as the culprit)
2) move the LED init after the DRAM init. That's probably a bit late, though, depends a bit on what people expect from the boot LED.
3) I guess the A20 can afford BSS in SRAM, but that would not help with other (64-bit) boards. I actually wonder how it works there, though?Quoted 5 lines
I'd prefer 1), but 2) is surely easier.
Cheers,
Andre
Quoted 6 lines
Your guess was true. The
status_led_init_donewas the culprit. I removed this variable and added a one-bit variable named "initialized" to theled_dev_t. In this case, when__led_initis called, we can set it for every single LED. In this case, we can checkld->initilizedfor each led rather than blindly checking thestatus_led_init_doneglobal variable.
Interesting idea, though I don't know too much about this code, and why we had the global variable in the first place.
Can you prepare a patch and send it to the mailing list, so that people can have a look and discuss this?
Cheers,
Andre
Quoted 89 lines
Best Regards,
JavadQuoted 87 lines
Quoted 86 lines
Best Regards,
JavadQuoted 83 lines
Quoted 83 lines
Quoted 82 lines
CONFIG_LED_STATUS_STATE=2
```
Best Regards,
JavadQuoted 78 lines
Quoted 77 lines
Quoted 77 lines
Quoted 76 lines
Quoted 76 lines
Signed-off-by Javad Rahimi <[email protected]>---
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 fixedboard/sunxi/board.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)board/sunxi/board.c +49
-1@@ -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