arm: mvebu: clearfog: defconfig and eMMC updates
cover arm: mvebu: clearfog: defconfig and eMMC updates
Minor defconfig and eMMC updates for SolidRun's A388 Clearfog devices.
Changes since initial discussion:
https://lists.denx.de/pipermail/u-boot/2023-February/510492.html
- CONFIG_SPL_SPI selected for SPI defconfig
- Runtime patching of kernel FDT added for eMMC detection
Note that this patch depends on this patch series (has been merged to u-boot-marvell/next):
https://lists.denx.de/pipermail/u-boot/2023-March/511038.html
Martin Rowe (4):
arm: mvebu: clearfog: Fix MMC detection
arm: mvebu: clearfog: Align defconfigs
arm: mvebu: clearfog: Add defconfig for SPI booting
arm: mvebu: clearfog: Detect MMC vs SDHC and fixup fdt
board/solidrun/clearfog/clearfog.c | 42 +++++++++++++++++++
configs/clearfog_defconfig | 5 ++-
configs/clearfog_sata_defconfig | 12 ++++--
...arfog_defconfig => clearfog_spi_defconfig} | 10 ++++-
4 files changed, 61 insertions(+), 8 deletions(-)
copy configs/{clearfog_defconfig => clearfog_spi_defconfig} (91%)Signature · 1 line
2.39.2
PATCH 1/4 arm: mvebu: clearfog: Fix MMC detection
A388 Clearfog MMC is either SD Card or eMMC with different behaviour for both. Setting MMC_BROKEN_CD allows both to correctly detect MMC.
--- configs/clearfog_defconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
configs/clearfog_defconfig +1 -2
@@ -46,7 +46,6 @@ CONFIG_CMD_USB=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y -CONFIG_CMD_MVEBU_BUBT=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_MIN_ENTRIES=128 CONFIG_ARP_TIMEOUT=200
@@ -59,7 +58,7 @@ CONFIG_DM_I2C=y CONFIG_SYS_I2C_MVTWSI=y CONFIG_I2C_EEPROM=y CONFIG_SPL_I2C_EEPROM=y -CONFIG_SUPPORT_EMMC_BOOT=y +CONFIG_MMC_BROKEN_CD=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_SDMA=y CONFIG_MMC_SDHCI_MV=y
Signature · 1 line
2.39.2
Re: [PATCH 1/4] arm: mvebu: clearfog: Fix MMC detection
Quoted 2 lines · On Sunday 05 March 2023 21:30:57 Martin Rowe wrote:
A388 Clearfog MMC is either SD Card or eMMC with different behaviour for both. Setting
MMC_BROKEN_CDallows both to correctly detect MMC.
When you are sending defconfig changes, please do not put there unrelated canonicalization changes. Canonicalization of defconfigs are done semi-automatically when Tom regenerates them. So avoid CONFIG_SUPPORT_EMMC_BOOT and CONFIG_CMD_MVEBU_BUBT changes for eMMC related change.
Anyway, I have looked at how MMC_BROKEN_CD is working in u-boot. The relevant part is sdhci_get_cd() function in drivers/mmc/sdhci.c file and in mmc_of_parse() function in drivers/mmc/mmc-uclass.c file.
So instead of MMC_BROKEN_CD would not it be better the following u-boot specific patch? cd-gpios is completely ignored by u-boot when non-removable is set.
arch/arm/dts/armada-388-clearfog-u-boot.dtsi +1 -0
@@ -10,6 +10,7 @@ &sdhci { u-boot,dm-spl; + non-removable; /* assume that the card is always present, required for eMMC variant */ }; &gpio0 {
Quoted 29 lines
Signed-off-by Martin Rowe <[email protected]>--- configs/clearfog_defconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)configs/clearfog_defconfig +1
-2@@ -46,7 +46,6 @@ CONFIG_CMD_USB=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y -CONFIG_CMD_MVEBU_BUBT=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_MIN_ENTRIES=128 CONFIG_ARP_TIMEOUT=200@@ -59,7 +58,7 @@ CONFIG_DM_I2C=y CONFIG_SYS_I2C_MVTWSI=y CONFIG_I2C_EEPROM=y CONFIG_SPL_I2C_EEPROM=y -CONFIG_SUPPORT_EMMC_BOOT=y +CONFIG_MMC_BROKEN_CD=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_SDMA=y CONFIG_MMC_SDHCI_MV=ySignature · 1 line
2.39.2
Re: [PATCH 1/4] arm: mvebu: clearfog: Fix MMC detection
Quoted 10 lines · Pali Rohár
Quoted 2 lines · On Sunday 05 March 2023 21:30:57 Martin Rowe wrote:
A388 Clearfog MMC is either SD Card or eMMC with different behaviour for both. Setting
MMC_BROKEN_CDallows both to correctly detect MMC.When you are sending defconfig changes, please do not put there unrelated canonicalization changes. Canonicalization of defconfigs are done semi-automatically when Tom regenerates them. So avoid
CONFIG_SUPPORT_EMMC_BOOTandCONFIG_CMD_MVEBU_BUBTchanges for eMMC related change.
Noted. I'll fix it up.
Anyway, I have looked at how MMC_BROKEN_CD is working in u-boot. The
Quoted 7 lines
relevant part is
sdhci_get_cd()function indrivers/mmc/sdhci.cfile and inmmc_of_parse()function indrivers/mmc/mmc-uclass.cfile.So instead of
MMC_BROKEN_CDwould not it be better the following u-boot specific patch? cd-gpios is completely ignored by u-boot when non-removable is set.
Both are fine with me. I initially went with MMC_BROKEN_CD since it seemed like the established way. I've tested the patch below and the only issue is in the corner case of non-MMC boot while expecting something from MMC, but the error message is helpful enough ("Card did not respond to voltage select! : -110"). I'll resubmit with your patch instead.
Quoted 46 lines
arch/arm/dts/armada-388-clearfog-u-boot.dtsi +1
-0@@ -10,6 +10,7 @@ &sdhci { u-boot,dm-spl; + non-removable; /* assume that the card is always present, requiredfor eMMC variant */
};&gpio0 {
Quoted 29 lines
Signed-off-by Martin Rowe <[email protected]>--- configs/clearfog_defconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)configs/clearfog_defconfig +1
-3@@ -46,7 +46,6 @@ CONFIG_CMD_USB=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y -CONFIG_CMD_MVEBU_BUBT=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_MIN_ENTRIES=128 CONFIG_ARP_TIMEOUT=200@@ -59,7 +58,7 @@ CONFIG_DM_I2C=y CONFIG_SYS_I2C_MVTWSI=y CONFIG_I2C_EEPROM=y CONFIG_SPL_I2C_EEPROM=y -CONFIG_SUPPORT_EMMC_BOOT=y +CONFIG_MMC_BROKEN_CD=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_SDMA=y CONFIG_MMC_SDHCI_MV=y --2.39.2
PATCH 2/4 arm: mvebu: clearfog: Align defconfigs
In reply to Martin RoweEnsure that functionality of generated configs is identical between SATA and MMC defconfigs for Clearfog boards. The only expected difference is the boot mode and environment location.
--- configs/clearfog_defconfig | 1 + configs/clearfog_sata_defconfig | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-)
configs/clearfog_defconfig +1 -0
@@ -46,6 +46,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y +CONFIG_MVEBU_SATA_BOOT=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_MIN_ENTRIES=128 CONFIG_ARP_TIMEOUT=200
configs/clearfog_sata_defconfig +7 -4
@@ -3,14 +3,19 @@ CONFIG_ARCH_CPU_INIT=y CONFIG_SYS_THUMB_BUILD=y CONFIG_ARCH_MVEBU=y CONFIG_TEXT_BASE=0x00800000 +CONFIG_SPL_GPIO=y CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_NR_DRAM_BANKS=2 +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xff0000 CONFIG_TARGET_CLEARFOG=y CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA=y CONFIG_DEFAULT_DEVICE_TREE="armada-388-clearfog" CONFIG_SPL_TEXT_BASE=0x40000030 +CONFIG_SPL_MMC=y CONFIG_SPL_SERIAL=y +CONFIG_SPL_STACK=0x4002c000 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xf1012000 CONFIG_DEBUG_UART_CLOCK=250000000
@@ -18,8 +23,6 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y -CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y -CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xff0000 CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y
@@ -31,7 +34,6 @@ CONFIG_SPL_BSS_START_ADDR=0x40023000 CONFIG_SPL_BSS_MAX_SIZE=0x4000 CONFIG_SPL_SYS_MALLOC_SIMPLE=y # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set -CONFIG_SPL_STACK=0x4002c000 CONFIG_SPL_I2C=y CONFIG_SYS_MAXARGS=32 CONFIG_CMD_TLV_EEPROM=y
@@ -46,7 +48,6 @@ CONFIG_CMD_USB=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y -CONFIG_CMD_MVEBU_BUBT=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_MIN_ENTRIES=128 CONFIG_ARP_TIMEOUT=200
@@ -59,6 +60,8 @@ CONFIG_DM_I2C=y CONFIG_SYS_I2C_MVTWSI=y CONFIG_I2C_EEPROM=y CONFIG_SPL_I2C_EEPROM=y +CONFIG_MMC_BROKEN_CD=y +CONFIG_SPL_DM_MMC=y CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_SDMA=y
Signature · 1 line
2.39.2
Re: [PATCH 2/4] arm: mvebu: clearfog: Align defconfigs
Quoted 15 lines · On Sunday 05 March 2023 21:30:58 Martin Rowe wrote:
Ensure that functionality of generated configs is identical between SATA and MMC defconfigs for Clearfog boards. The only expected difference is the boot mode and environment location.
Signed-off-by Martin Rowe <[email protected]>--- configs/clearfog_defconfig | 1 + configs/clearfog_sata_defconfig | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-)configs/clearfog_defconfig +0
-0
configs/clearfog_defconfig CONFIG_CMD_USB=y · line 49
Quoted 4 lines
configs/clearfog_defconfig +1
-0@@ -46,6 +46,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y +CONFIG_MVEBU_SATA_BOOT=y
MVEBU_*_BOOT is the default target for the bubt command. I guess that you do not want to set default one to SATA for eMMC/SD boot.
Anyway, when you are doing cleanup of clearfog defconfig files, what about renaming clearfog_defconfig to clearfog_mmc_defconfig?
Quoted 12 lines
configs/clearfog_defconfig +0
-0CONFIG_ENV_OVERWRITE=y CONFIG_ENV_MIN_ENTRIES=128 CONFIG_ARP_TIMEOUT=200configs/clearfog_sata_defconfig +1
-0@@ -3,14 +3,19 @@ CONFIG_ARCH_CPU_INIT=y CONFIG_SYS_THUMB_BUILD=y CONFIG_ARCH_MVEBU=y CONFIG_TEXT_BASE=0x00800000 +CONFIG_SPL_GPIO=y
configs/clearfog_sata_defconfig CONFIG_ARCH_CPU_INIT=y · line 16
Quoted 10 lines
configs/clearfog_sata_defconfig +3
-0CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_NR_DRAM_BANKS=2 +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xff0000 CONFIG_TARGET_CLEARFOG=y CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA=y CONFIG_DEFAULT_DEVICE_TREE="armada-388-clearfog" CONFIG_SPL_TEXT_BASE=0x40000030 +CONFIG_SPL_MMC=y
SPL contains code just for loading main u-boot. So I think you do not need MMC support in SPL code (symbols prefixed by CONFIG_SPL) which loads u-boot from SATA.
Quoted 42 lines
configs/clearfog_sata_defconfig +3
-4CONFIG_SPL_SERIAL=y +CONFIG_SPL_STACK=0x4002c000 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xf1012000 CONFIG_DEBUG_UART_CLOCK=250000000@@ -18,8 +23,6 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y -CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y -CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xff0000 CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y@@ -31,7 +34,6 @@ CONFIG_SPL_BSS_START_ADDR=0x40023000 CONFIG_SPL_BSS_MAX_SIZE=0x4000 CONFIG_SPL_SYS_MALLOC_SIMPLE=y # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set -CONFIG_SPL_STACK=0x4002c000 CONFIG_SPL_I2C=y CONFIG_SYS_MAXARGS=32 CONFIG_CMD_TLV_EEPROM=y@@ -46,7 +48,6 @@ CONFIG_CMD_USB=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y -CONFIG_CMD_MVEBU_BUBT=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_MIN_ENTRIES=128 CONFIG_ARP_TIMEOUT=200@@ -59,6 +60,8 @@ CONFIG_DM_I2C=y CONFIG_SYS_I2C_MVTWSI=y CONFIG_I2C_EEPROM=y CONFIG_SPL_I2C_EEPROM=y +CONFIG_MMC_BROKEN_CD=y +CONFIG_SPL_DM_MMC=y CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_SDMA=ySignature · 1 line
2.39.2
Re: [PATCH 2/4] arm: mvebu: clearfog: Align defconfigs
Quoted 11 lines · Pali Rohár
Quoted 10 lines · On Sunday 05 March 2023 21:30:58 Martin Rowe wrote:
Ensure that functionality of generated configs is identical between SATA and MMC defconfigs for Clearfog boards. The only expected difference is the boot mode and environment location.
Signed-off-by Martin Rowe <[email protected]>--- configs/clearfog_defconfig | 1 + configs/clearfog_sata_defconfig | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-)
Quoted 13 lines
configs/clearfog_defconfig CONFIG_CMD_USB=y · line 49
Quoted 9 lines
configs/clearfog_defconfig +1
-0@@ -46,6 +46,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y +CONFIG_MVEBU_SATA_BOOT=yMVEBU_*_BOOT is the default target for the bubt command. I guess that you do not want to set default one to SATA for eMMC/SD boot.
Correct, I'll remove it.
Anyway, when you are doing cleanup of clearfog defconfig files, what
Quoted 2 lines
about renaming
clearfog_defconfigtoclearfog_mmc_defconfig?
I considered this but left it as is since we have several years worth of support with that original name. It will make bisects easier if we keep it the same, but I don't feel strongly either way. Happy to rename it if you'd prefer.
Quoted 19 lines
Review
Quoted 4 lines
configs/clearfog_defconfig +0
-0CONFIG_ENV_OVERWRITE=y CONFIG_ENV_MIN_ENTRIES=128 CONFIG_ARP_TIMEOUT=200(quoted diff) +0
-0b/configs/clearfog_sata_defconfig
Quoted 14 lines
index
e9b36150ea..b11d8746b0100644configs/clearfog_sata_defconfig +3
-0@@ -3,14 +3,19 @@ CONFIG_ARCH_CPU_INIT=y CONFIG_SYS_THUMB_BUILD=y CONFIG_ARCH_MVEBU=y CONFIG_TEXT_BASE=0x00800000 +CONFIG_SPL_GPIO=y CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_NR_DRAM_BANKS=2 +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xff0000 CONFIG_TARGET_CLEARFOG=y
Quoted 9 lines
configs/clearfog_sata_defconfig CONFIG_ARCH_CPU_INIT=y · line 16
Quoted 4 lines
configs/clearfog_sata_defconfig +1
-0CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA=y CONFIG_DEFAULT_DEVICE_TREE="armada-388-clearfog" CONFIG_SPL_TEXT_BASE=0x40000030 +CONFIG_SPL_MMC=ySPL contains code just for loading main u-boot. So I think you do not need MMC support in SPL code (symbols prefixed by
CONFIG_SPL) which loads u-boot from SATA.
Correct, I'll remove it.
That's actually all of the changes removed (the rest are canonicalization or the resolved MMC issue), so I'll drop this patch completely in v2.
Quoted 43 lines
CONFIG_SPL_SERIAL=yQuoted 41 lines
configs/clearfog_sata_defconfig +3
-5+CONFIG_SPL_STACK=0x4002c000 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xf1012000 CONFIG_DEBUG_UART_CLOCK=250000000@@ -18,8 +23,6 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y -CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y -CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xff0000 CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y@@ -31,7 +34,6 @@ CONFIG_SPL_BSS_START_ADDR=0x40023000 CONFIG_SPL_BSS_MAX_SIZE=0x4000 CONFIG_SPL_SYS_MALLOC_SIMPLE=y # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set -CONFIG_SPL_STACK=0x4002c000 CONFIG_SPL_I2C=y CONFIG_SYS_MAXARGS=32 CONFIG_CMD_TLV_EEPROM=y@@ -46,7 +48,6 @@ CONFIG_CMD_USB=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y -CONFIG_CMD_MVEBU_BUBT=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_MIN_ENTRIES=128 CONFIG_ARP_TIMEOUT=200@@ -59,6 +60,8 @@ CONFIG_DM_I2C=y CONFIG_SYS_I2C_MVTWSI=y CONFIG_I2C_EEPROM=y CONFIG_SPL_I2C_EEPROM=y +CONFIG_MMC_BROKEN_CD=y +CONFIG_SPL_DM_MMC=y CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_SDMA=y --2.39.2
PATCH 3/4 arm: mvebu: clearfog: Add defconfig for SPI booting
In reply to Martin RoweThis new clearfog_spi_defconfig file is a copy of existing clearfog_defconfig file modified to instruct build system to generate final kwbimage for SPI booting and to store the environment in SPI.
---
configs/{clearfog_sata_defconfig => clearfog_spi_defconfig} | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
copy configs/{clearfog_sata_defconfig => clearfog_spi_defconfig} (96%)configs/clearfog_spi_defconfig renamed from configs/clearfog_sata_defconfig +3 -1
@@ -10,7 +10,7 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xff0000 CONFIG_TARGET_CLEARFOG=y -CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA=y +CONFIG_ENV_SECT_SIZE=0x10000 CONFIG_DEFAULT_DEVICE_TREE="armada-388-clearfog" CONFIG_SPL_TEXT_BASE=0x40000030 CONFIG_SPL_MMC=y
@@ -19,6 +19,7 @@ CONFIG_SPL_STACK=0x4002c000 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xf1012000 CONFIG_DEBUG_UART_CLOCK=250000000 +CONFIG_SPL_LIBDISK_SUPPORT=y CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y
@@ -48,6 +49,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y +CONFIG_MVEBU_SATA_BOOT=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_MIN_ENTRIES=128 CONFIG_ARP_TIMEOUT=200
Signature · 1 line
2.39.2
Re: [PATCH 3/4] arm: mvebu: clearfog: Add defconfig for SPI booting
Quoted 27 lines · On Sunday 05 March 2023 21:30:59 Martin Rowe wrote:
This new
clearfog_spi_defconfigfile is a copy of existingclearfog_defconfigfile modified to instruct build system to generate final kwbimage for SPI booting and to store the environment in SPI.Signed-off-by Martin Rowe <[email protected]>--- configs/{clearfog_sata_defconfig => clearfog_spi_defconfig} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) copy configs/{clearfog_sata_defconfig => clearfog_spi_defconfig} (96%)configs/clearfog_spi_defconfig renamed from configs/clearfog_sata_defconfig +1
-1@@ -10,7 +10,7 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xff0000 CONFIG_TARGET_CLEARFOG=y -CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA=y +CONFIG_ENV_SECT_SIZE=0x10000 CONFIG_DEFAULT_DEVICE_TREE="armada-388-clearfog" CONFIG_SPL_TEXT_BASE=0x40000030 CONFIG_SPL_MMC=y
configs/clearfog_spi_defconfig CONFIG_SPL_STACK=0x4002c000 · line 22
Quoted 4 lines
configs/clearfog_spi_defconfig renamed from configs/clearfog_sata_defconfig +1
-0@@ -19,6 +19,7 @@ CONFIG_SPL_STACK=0x4002c000 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xf1012000 CONFIG_DEBUG_UART_CLOCK=250000000 +CONFIG_SPL_LIBDISK_SUPPORT=y
I think you do not need libdisk support in SPL which loads main u-boot from SPI.
configs/clearfog_spi_defconfig CONFIG_CMD_USB=y · line 52
Quoted 8 lines
configs/clearfog_spi_defconfig renamed from configs/clearfog_sata_defconfig +1
-0CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y@@ -48,6 +49,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y +CONFIG_MVEBU_SATA_BOOT=y
Should not be default bubt location SPI for SPI booting?
Quoted 6 lines
configs/clearfog_spi_defconfig renamed from configs/clearfog_sata_defconfig +0
-0CONFIG_ENV_OVERWRITE=y CONFIG_ENV_MIN_ENTRIES=128 CONFIG_ARP_TIMEOUT=200Signature · 1 line
2.39.2
Re: [PATCH 3/4] arm: mvebu: clearfog: Add defconfig for SPI booting
Quoted 28 lines · Pali Rohár
Review
Quoted 11 lines · On Sunday 05 March 2023 21:30:59 Martin Rowe wrote:
This new
clearfog_spi_defconfigfile is a copy of existingclearfog_defconfigfile modified to instruct build system to generate final kwbimage for SPI booting and to store the environment in SPI.Signed-off-by Martin Rowe <[email protected]>--- configs/{clearfog_sata_defconfig => clearfog_spi_defconfig} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) copy configs/{clearfog_sata_defconfig => clearfog_spi_defconfig} (96%)(quoted diff) +0
-0b/configs/clearfog_spi_defconfig
Quoted 15 lines
similarity index 96%
copy from configs/clearfog_sata_defconfig
copy to configs/clearfog_spi_defconfig
indexb11d8746b0..d6695f31e6100644configs/clearfog_spi_defconfig renamed from configs/clearfog_sata_defconfig +1
-1@@ -10,7 +10,7 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xff0000 CONFIG_TARGET_CLEARFOG=y -CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA=y +CONFIG_ENV_SECT_SIZE=0x10000 CONFIG_DEFAULT_DEVICE_TREE="armada-388-clearfog" CONFIG_SPL_TEXT_BASE=0x40000030 CONFIG_SPL_MMC=y
Quoted 9 lines
configs/clearfog_spi_defconfig CONFIG_SPL_STACK=0x4002c000 · line 22
Quoted 5 lines
configs/clearfog_spi_defconfig renamed from configs/clearfog_sata_defconfig +1
-0@@ -19,6 +19,7 @@ CONFIG_SPL_STACK=0x4002c000 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xf1012000 CONFIG_DEBUG_UART_CLOCK=250000000 +CONFIG_SPL_LIBDISK_SUPPORT=yI think you do not need libdisk support in SPL which loads main u-boot from SPI.
Makes sense, I'll remove
Quoted 11 lines
configs/clearfog_spi_defconfig CONFIG_CMD_USB=y · line 52
Quoted 8 lines
configs/clearfog_spi_defconfig renamed from configs/clearfog_sata_defconfig +1
-0CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y@@ -48,6 +49,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y +CONFIG_MVEBU_SATA_BOOT=yShould not be default bubt location SPI for SPI booting?
Yes, I'll fix
Quoted 7 lines
CONFIG_ENV_OVERWRITE=yQuoted 5 lines
configs/clearfog_spi_defconfig renamed from configs/clearfog_sata_defconfig +0
-1CONFIG_ENV_MIN_ENTRIES=128 CONFIG_ARP_TIMEOUT=200 --2.39.2
PATCH 4/4 arm: mvebu: clearfog: Detect MMC vs SDHC and fixup fdt
In reply to Martin Rowe[upstream of vendor commit 19a96f7c40a8fc1d0a6546ac2418d966e5840a99]
The Clearfog devices have only one SDHC device. This is either eMMC if it is populated on the SOM or SDHC if not. The Linux device tree assumes the SDHC case. Detect if the device is an eMMC and fixup the device-tree so it will be detected by Linux.
Ported from vendor repo at https://github.com/SolidRun/u-boot
--- board/solidrun/clearfog/clearfog.c | 42 ++++++++++++++++++++++++++++++ configs/clearfog_defconfig | 1 + configs/clearfog_sata_defconfig | 1 + configs/clearfog_spi_defconfig | 1 + 4 files changed, 45 insertions(+)
board/solidrun/clearfog/clearfog.c +42 -0
@@ -10,6 +10,7 @@#include <miiphy.h> #include <net.h> #include <netdev.h> +#include <mmc.h> #include <asm/global_data.h> #include <asm/io.h> #include <asm/arch/cpu.h>
@@ -261,3 +262,44 @@ int board_late_init(void)return 0 ; } + +static bool has_emmc (void ) +{ +struct mmc *mmc; + mmc =find_mmc_device (0 ); +if (!mmc) +return 0 ; +return (!mmc_init (mmc) &&IS_MMC (mmc)) ? true : false; +} + +/* +* The Clearfog devices have only one SDHC device. This is either eMMC +* if it is populated on the SOM or SDHC if not. The Linux device tree +* assumes the SDHC case. Detect if the device is an eMMC and fixup the +* device-tree so it will be detected by Linux. +*/ +int ft_board_setup (void *blob,struct bd_info *bd) +{ +__maybe_unused int offset, rc; + +if (has_emmc ()) { +puts ("Patching FDT so that eMMC is detected by kernel\n" ); + offset =fdt_path_offset (blob,"/soc/internal-regs/sdhci@d8000" ); +if (offset >=0 ) { + rc =fdt_delprop (blob, offset,"cd-gpios" ); +if (rc == -FDT_ERR_NOTFOUND ) +return 0 ;/* Assume that the device tree is already customized for eMMC */ +if (rc) { +printf ("Unable to remove cd-gpios for eMMC, err=%s\n" ,fdt_strerror (rc)); +return rc; + } + rc =fdt_setprop_empty (blob, offset,"non-removable" ); +if (rc) { +printf ("Unable to add non-removable for eMMC, err=%s\n" ,fdt_strerror (rc)); +return rc; + } + } + } + +return 0 ; +}
configs/clearfog_defconfig +1 -0
@@ -21,6 +21,7 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y
configs/clearfog_sata_defconfig +1 -0
@@ -23,6 +23,7 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y
configs/clearfog_spi_defconfig +1 -0
@@ -24,6 +24,7 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y
Signature · 1 line
2.39.2
Re: [PATCH 4/4] arm: mvebu: clearfog: Detect MMC vs SDHC and fixup fdt
Quoted 46 lines · On Sunday 05 March 2023 21:31:00 Martin Rowe wrote:
[upstream of vendor commit
19a96f7c40a8fc1d0a6546ac2418d966e5840a99]The Clearfog devices have only one SDHC device. This is either eMMC if it is populated on the SOM or SDHC if not. The Linux device tree assumes the SDHC case. Detect if the device is an eMMC and fixup the device-tree so it will be detected by Linux.
Ported from vendor repo at https://github.com/SolidRun/u-boot
Signed-off-by Martin Rowe <[email protected]>--- board/solidrun/clearfog/clearfog.c | 42 ++++++++++++++++++++++++++++++ configs/clearfog_defconfig | 1 + configs/clearfog_sata_defconfig | 1 + configs/clearfog_spi_defconfig | 1 + 4 files changed, 45 insertions(+)board/solidrun/clearfog/clearfog.c +14
-0@@ -10,6 +10,7 @@#include <miiphy.h> #include <net.h> #include <netdev.h> +#include <mmc.h> #include <asm/global_data.h> #include <asm/io.h> #include <asm/arch/cpu.h> @@ -261,3 +262,44 @@ int board_late_init(void)return 0 ; } + +static bool has_emmc (void ) +{ +struct mmc *mmc; + mmc =find_mmc_device (0 ); +if (!mmc) +return 0 ; +return (!mmc_init (mmc) &&IS_MMC (mmc)) ? true : false; +} + +/* +* The Clearfog devices have only one SDHC device. This is either eMMC +* if it is populated on the SOM or SDHC if not. The Linux device tree
board/solidrun/clearfog/clearfog.c int board_late_init(void) · line 287
Quoted 10 lines
board/solidrun/clearfog/clearfog.c +10
-0+* assumes the SDHC case. Detect if the device is an eMMC and fixup the +* device-tree so it will be detected by Linux. +*/ +int ft_board_setup (void *blob,struct bd_info *bd) +{ +__maybe_unused int offset, rc; + +if (has_emmc ()) { +puts ("Patching FDT so that eMMC is detected by kernel\n" ); + offset =fdt_path_offset (blob,"/soc/internal-regs/sdhci@d8000" );
Do not use fixed DT paths when parsing Linux kernel DT files. Linux developers often changes DT node names in their DTS files which cause changing of DT paths and hence this code in bootloader stops working.
I would suggest to find node offset by compatible string ("marvell,armada-380-sdhci"). Look for inspiration what I done in past:
https://source.denx.de/u-boot/u-boot/-/commit/7cd67018dd7f754c66cf08a76397bbee254b32aa
board/solidrun/clearfog/clearfog.c int board_late_init(void) · line 291
Quoted 4 lines
board/solidrun/clearfog/clearfog.c +4
-0+if (offset >=0 ) { + rc =fdt_delprop (blob, offset,"cd-gpios" ); +if (rc == -FDT_ERR_NOTFOUND ) +return 0 ;/* Assume that the device tree is already customized for eMMC */
I would suggest to always add "non-removable" property when it does not exist.
board/solidrun/clearfog/clearfog.c int board_late_init(void) · line 294
Quoted 3 lines
board/solidrun/clearfog/clearfog.c +3
-0+if (rc) { +printf ("Unable to remove cd-gpios for eMMC, err=%s\n" ,fdt_strerror (rc)); +return rc;
Normally it is not a good idea to return non-zero value from ft_board_setup() function because it "crashes" u-boot and stops booting kernel.
Quoted 16 lines
board/solidrun/clearfog/clearfog.c +11
-0+ } + rc =fdt_setprop_empty (blob, offset,"non-removable" ); +if (rc) { +printf ("Unable to add non-removable for eMMC, err=%s\n" ,fdt_strerror (rc)); +return rc; + } + } + } + +return 0 ; +}configs/clearfog_defconfig +0
-0
configs/clearfog_defconfig CONFIG_SYS_LOAD_ADDR=0x800000 · line 24
Quoted 4 lines
configs/clearfog_defconfig +1
-0@@ -21,6 +21,7 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y
Hint: To avoid having CONFIG_OF_BOARD_SETUP=y in every defconfig file, you can add "select OF_BOARD_SETUP" into "config TARGET_CLEARFOG" section in arch/arm/mach-mvebu/Kconfig file.
Quoted 30 lines
configs/clearfog_defconfig +0
-0CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=yconfigs/clearfog_sata_defconfig +1
-0@@ -23,6 +23,7 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=yconfigs/clearfog_spi_defconfig +1
-0@@ -24,6 +24,7 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=ySignature · 1 line
2.39.2
Re: [PATCH 4/4] arm: mvebu: clearfog: Detect MMC vs SDHC and fixup fdt
Quoted 60 lines · Pali Rohár
Quoted 10 lines · On Sunday 05 March 2023 21:31:00 Martin Rowe wrote:
[upstream of vendor commit
19a96f7c40a8fc1d0a6546ac2418d966e5840a99]The Clearfog devices have only one SDHC device. This is either eMMC if it is populated on the SOM or SDHC if not. The Linux device tree assumes the SDHC case. Detect if the device is an eMMC and fixup the device-tree so it will be detected by Linux.
Ported from vendor repo at https://github.com/SolidRun/u-boot
Signed-off-by Martin Rowe <[email protected]>Review
Quoted 8 lines
--- board/solidrun/clearfog/clearfog.c | 42 ++++++++++++++++++++++++++++++ configs/clearfog_defconfig | 1 + configs/clearfog_sata_defconfig | 1 + configs/clearfog_spi_defconfig | 1 + 4 files changed, 45 insertions(+)(quoted diff) +0
-0
b/board/solidrun/clearfog/clearfog.cQuoted 28 lines
index
03adb591d8..cafead3a1a100644board/solidrun/clearfog/clearfog.c +14
-0@@ -10,6 +10,7 @@#include <miiphy.h> #include <net.h> #include <netdev.h> +#include <mmc.h> #include <asm/global_data.h> #include <asm/io.h> #include <asm/arch/cpu.h> @@ -261,3 +262,44 @@ int board_late_init(void)return 0 ; } + +static bool has_emmc (void ) +{ +struct mmc *mmc; + mmc =find_mmc_device (0 ); +if (!mmc) +return 0 ; +return (!mmc_init (mmc) &&IS_MMC (mmc)) ? true : false; +} + +/* +* The Clearfog devices have only one SDHC device. This is either eMMC +* if it is populated on the SOM or SDHC if not. The Linux device tree board/solidrun/clearfog/clearfog.c int board_late_init(void) · line 287
Quoted 10 lines
board/solidrun/clearfog/clearfog.c +10
-0+* assumes the SDHC case. Detect if the device is an eMMC and fixup the +* device-tree so it will be detected by Linux. +*/ +int ft_board_setup (void *blob,struct bd_info *bd) +{ +__maybe_unused int offset, rc; + +if (has_emmc ()) { +puts ("Patching FDT so that eMMC is detected by kernel\n" ); + offset = fdt_path_offset(blob,"/soc/internal-regs/sdhci@d8000");
Quoted 9 lines
Do not use fixed DT paths when parsing Linux kernel DT files. Linux developers often changes DT node names in their DTS files which cause changing of DT paths and hence this code in bootloader stops working.
I would suggest to find node offset by compatible string ("marvell,armada-380-sdhci"). Look for inspiration what I done in past:
https://source.denx.de/u-boot/u-boot/-/commit/7cd67018dd7f754c66cf08a76397bbee254b32aa
Makes sense, I'll rework the patch.
Quoted 9 lines
board/solidrun/clearfog/clearfog.c int board_late_init(void)
Quoted 4 lines
board/solidrun/clearfog/clearfog.c +4
-0+if (offset >=0 ) { + rc =fdt_delprop (blob, offset,"cd-gpios" ); +if (rc == -FDT_ERR_NOTFOUND ) +return 0 ;/* Assume that the device tree is already customized for eMMC */
I would suggest to always add "non-removable" property when it does not exist.
OK, that makes sense, too. I'll test that out.
Quoted 9 lines
+ if (rc) {
board/solidrun/clearfog/clearfog.c int board_late_init(void) · line 292
Quoted 1 line
board/solidrun/clearfog/clearfog.c +1
-0+ printf("Unable to remove cd-gpios foreMMC, err=%s\n",
fdt_strerror(rc));board/solidrun/clearfog/clearfog.c int board_late_init(void) · line 293
Quoted 1 line
board/solidrun/clearfog/clearfog.c +1
-0+return rc;Normally it is not a good idea to return non-zero value from
ft_board_setup()function because it "crashes" u-boot and stops booting kernel.
I think this might be an exception. If the board has eMMC there's a reasonable chance that it's used for the root device. By the time Linux tries and fails to mount the root device there are already reams of printks on the serial console that make it hard to see the root cause all the way back in u-boot. Failing early with an appropriate error message would be more beneficial while troubleshooting this problem.
There's a corner case where you have an eMMC board and never use the eMMC device (like my use case), so you wouldn't want to have it fail for something that you don't use. I think we'll cause more issues for people that can't mount their root device than for people that get an error for a device they don't use.
Given I'm going to rework the logic here anyway it's likely this first 'return rc' will be removed, but I think it is worth retaining the one below.
Quoted 18 lines
+ }
board/solidrun/clearfog/clearfog.c int board_late_init(void) · line 294
Quoted 1 line
board/solidrun/clearfog/clearfog.c +1
-0+ rc = fdt_setprop_empty(blob, offset,"non-removable");
board/solidrun/clearfog/clearfog.c int board_late_init(void) · line 296
Quoted 2 lines
board/solidrun/clearfog/clearfog.c +2
-0+if (rc) { + printf("Unable to add non-removable foreMMC, err=%s\n",
fdt_strerror(rc));Quoted 12 lines
board/solidrun/clearfog/clearfog.c +7
-0+return rc; + } + } + } + +return 0 ; +}configs/clearfog_defconfig +0
-0@@ -21,6 +21,7 @@ CONFIG_SYS_LOAD_ADDR=0x800000
Quoted 9 lines
configs/clearfog_defconfig CONFIG_SYS_LOAD_ADDR=0x800000 · line 24
Quoted 4 lines
configs/clearfog_defconfig +1
-0CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=yHint: To avoid having
CONFIG_OF_BOARD_SETUP=yin every defconfig file, you can add "selectOF_BOARD_SETUP" into "configTARGET_CLEARFOG" section inarch/arm/mach-mvebu/Kconfigfile.
I'll fix that up.
Quoted 33 lines
Review
Quoted 4 lines
configs/clearfog_defconfig +0
-0CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y(quoted diff) +0
-0b/configs/clearfog_sata_defconfig
Review
Quoted 12 lines
index
b11d8746b0..081ebd7e7a100644configs/clearfog_sata_defconfig +1
-0@@ -23,6 +23,7 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y(quoted diff) +0
-0b/configs/clearfog_spi_defconfig
Quoted 14 lines
index
d6695f31e6..6b9e817f68100644configs/clearfog_spi_defconfig +1
-1@@ -24,6 +24,7 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y --2.39.2