[PATCH v2 0/9] Fixes for SPI boot on SanCloud BBE Lite

These changes fix SPI boot on the SanCloud BBE Lite and other AM335x boards.
They also put us in a good place to enable SPL_OF_CONTROL for eMMC/SD card boot on AM335x boards. Note that if SPL_OF_CONTROL is enabled, some SPL features need to be dropped due to the limited amount of sram available. In my testing I dropped NAND, NET & USB support.
This series has been build tested for all targets using buildman and no errors were observed. It has been boot tested on the SanCloud BBE Lite with the following configurations:
1) SD card boot using am335x_evm_defconfig with no config changes.
2) SD card boot using am335x_evm_defconfig with the following config changes:
CONFIG_SPL_OF_CONTROL=y CONFIG_SPL_OF_TRANSLATE=y CONFIG_SPL_MUSB_NEW=n CONFIG_SPL_NAND_DRIVERS=n CONFIG_SPL_NAND_ECC=n CONFIG_SPL_NAND_BASE=n CONFIG_SPL_NET=n CONFIG_SPL_USB_GADGET=n
3) SPI boot using am335x_evm_spiboot_defconfig with the following config changes:
CONFIG_DEFAULT_DEVICE_TREE="am335x-sancloud-bbe-lite" CONFIG_OF_LIST="am335x-sancloud-bbe-lite"
As discussed in my previous message [1], I can't see how to construct a test case to accompany the first patch which fixes an SPL crash during the pre-relocation lists_bind_drivers() call due to exhaustion of the available memory. We can discuss this further though if anyone has any ideas on how to write an appropriate test case.
[1]: https://lore.kernel.org/u-boot/d8182df9-1a09-81b9-dfbe-ebca4bad432f@sancloud...
Paul Barker (9): dm: core: Fix iteration over driver_info records bus: TI sysc driver requires DM bus: Optionally include TI sysc driver in SPL/TPL am335x-evm: Enable required dtb nodes in SPL am335x-evm: Fix spiboot configuration am335x-evm: Support STMicro/Micron SPI flash am335x-sancloud-bbe-lite: SPI flash is JEDEC compatible am335x-sancloud-bbe: Add -u-boot.dtsi files MAINTAINERS: Adopt SanCloud boards
MAINTAINERS | 6 +++ arch/arm/dts/am335x-evm-u-boot.dtsi | 30 ++++++++++++- .../dts/am335x-sancloud-bbe-lite-u-boot.dtsi | 44 +++++++++++++++++++ arch/arm/dts/am335x-sancloud-bbe-lite.dts | 2 +- arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi | 6 +++ configs/am335x_evm_defconfig | 1 + configs/am335x_evm_spiboot_defconfig | 5 +++ drivers/Makefile | 2 +- drivers/bus/Kconfig | 9 +++- drivers/bus/Makefile | 5 ++- drivers/core/lists.c | 6 +-- 11 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 arch/arm/dts/am335x-sancloud-bbe-lite-u-boot.dtsi create mode 100644 arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi
base-commit: 0cbeed4f6648e0e4966475e3544280a69ecb59d3

We should only perform additional iteration steps when needed to initialize the parent of a device. Other binding errors (such as a missing driver) should not lead to additional iteration steps.
Unnecessary iteration steps can cause issues when memory is tightly constrained (such as in the TPL/SPL) since device_bind_by_name() unconditionally allocates memory for a struct udevice. On the SanCloud BBE this led to boot failure caused by memory exhaustion in the SPL when booting from SPI flash.
Signed-off-by: Paul Barker paul.barker@sancloud.com --- drivers/core/lists.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/core/lists.c b/drivers/core/lists.c index 3878957c9ef4..8034a8f48d99 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -120,10 +120,10 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only) int ret;
ret = bind_drivers_pass(parent, pre_reloc_only); - if (!ret) - break; - if (ret != -EAGAIN && !result) + if (!result || result == -EAGAIN) result = ret; + if (ret != -EAGAIN) + break; }
return result;

On Mon, Nov 14, 2022 at 12:42:35PM +0000, Paul Barker wrote:
We should only perform additional iteration steps when needed to initialize the parent of a device. Other binding errors (such as a missing driver) should not lead to additional iteration steps.
Unnecessary iteration steps can cause issues when memory is tightly constrained (such as in the TPL/SPL) since device_bind_by_name() unconditionally allocates memory for a struct udevice. On the SanCloud BBE this led to boot failure caused by memory exhaustion in the SPL when booting from SPI flash.
Signed-off-by: Paul Barker paul.barker@sancloud.com
For the series, applied to u-boot/master, thanks!

This driver does not build if CONFIG_DM is disabled as it uses the function `dev_get_priv`.
Signed-off-by: Paul Barker paul.barker@sancloud.com --- drivers/bus/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig index d742ed333b16..c607d24ecf60 100644 --- a/drivers/bus/Kconfig +++ b/drivers/bus/Kconfig @@ -13,7 +13,7 @@ config TI_PWMSS
config TI_SYSC bool "TI sysc interconnect target module driver" - depends on ARCH_OMAP2PLUS + depends on DM && ARCH_OMAP2PLUS help Generic driver for Texas Instruments interconnect target module found on many TI SoCs.

The TI sysc bus driver is required to allow access to the SPI bus on am335x platforms. To support SPI boot this driver needs to be enabled in the SPL/TPL as appropriate.
Signed-off-by: Paul Barker paul.barker@sancloud.com --- drivers/Makefile | 2 +- drivers/bus/Kconfig | 7 +++++++ drivers/bus/Makefile | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/Makefile b/drivers/Makefile index ac2d83af4e3f..6f1de58e0030 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_$(SPL_)SYSINFO) += sysinfo/ obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/ obj-$(CONFIG_XEN) += xen/ obj-$(CONFIG_$(SPL_)FPGA) += fpga/ +obj-y += bus/
ifndef CONFIG_TPL_BUILD ifndef CONFIG_VPL_BUILD @@ -77,7 +78,6 @@ ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
obj-y += adc/ obj-y += ata/ -obj-y += bus/ obj-$(CONFIG_DM_DEMO) += demo/ obj-$(CONFIG_BIOSEMU) += bios_emulator/ obj-y += block/ diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig index c607d24ecf60..e60aa722b97f 100644 --- a/drivers/bus/Kconfig +++ b/drivers/bus/Kconfig @@ -18,6 +18,13 @@ config TI_SYSC Generic driver for Texas Instruments interconnect target module found on many TI SoCs.
+config SPL_TI_SYSC + bool "Support TI sysc interconnect in SPL" + depends on SPL_DM && TI_SYSC + help + Generic driver for Texas Instruments interconnect target module + found on many TI SoCs. + config UNIPHIER_SYSTEM_BUS bool "UniPhier System Bus driver" depends on ARCH_UNIPHIER diff --git a/drivers/bus/Makefile b/drivers/bus/Makefile index a2e71c7b3b52..0802b9666bfc 100644 --- a/drivers/bus/Makefile +++ b/drivers/bus/Makefile @@ -3,6 +3,9 @@ # Makefile for the bus drivers. #
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),) obj-$(CONFIG_TI_PWMSS) += ti-pwmss.o -obj-$(CONFIG_TI_SYSC) += ti-sysc.o obj-$(CONFIG_UNIPHIER_SYSTEM_BUS) += uniphier-system-bus.o +endif + +obj-$(CONFIG_$(SPL_)TI_SYSC) += ti-sysc.o

For successful boot when CONFIG_SPL_OF_CONTROL=y, we need to ensure that the board EEPROM on i2c0, the uart0 serial port and the relevant boot device (mmc1 or mmc2) can be accessed in the SPL. We also need to preserve the parent nodes for each required dtb node.
Signed-off-by: Paul Barker paul.barker@sancloud.com --- arch/arm/dts/am335x-evm-u-boot.dtsi | 30 +++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/arch/arm/dts/am335x-evm-u-boot.dtsi b/arch/arm/dts/am335x-evm-u-boot.dtsi index 4cf5f9928d58..8fc65df2ef9b 100644 --- a/arch/arm/dts/am335x-evm-u-boot.dtsi +++ b/arch/arm/dts/am335x-evm-u-boot.dtsi @@ -6,9 +6,9 @@ #include "am33xx-u-boot.dtsi"
&l4_per { - + u-boot,dm-pre-reloc; segment@300000 { - + u-boot,dm-pre-reloc; target-module@e000 { u-boot,dm-pre-reloc;
@@ -26,3 +26,29 @@ &usb0 { dr_mode = "peripheral"; }; + +&i2c0 { + u-boot,dm-pre-reloc; +}; + +&l4_wkup { + u-boot,dm-pre-reloc; + segment@200000 { + u-boot,dm-pre-reloc; + target-module@9000 { + u-boot,dm-pre-reloc; + }; + }; +}; + +&uart0 { + u-boot,dm-pre-reloc; +}; + +&mmc1 { + u-boot,dm-pre-reloc; +}; + +&mmc2 { + u-boot,dm-pre-reloc; +};

The advanced address translation provided by CONFIG_SPL_OF_TRANSLATE is needed to determine the base address of the uart0 peripheral on am335x platforms when CONFIG_SPL_OF_CONTROL is enabled.
If CONFIG_SPL_OF_CONTROL is enabled in the base (non-spiboot) am335x_evm_defconfig, then CONFIG_SPL_OF_TRANSLATE will also need to be enabled there. Unfortunately this cannot be done pre-emptively due to the kconfig dependencies.
The TI clk-ctrl & TI sysc drivers are also required to bring up the SPI bus on am335x platforms.
Signed-off-by: Paul Barker paul.barker@sancloud.com --- configs/am335x_evm_spiboot_defconfig | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/configs/am335x_evm_spiboot_defconfig b/configs/am335x_evm_spiboot_defconfig index 3d04e6fa934a..2bc911cfd022 100644 --- a/configs/am335x_evm_spiboot_defconfig +++ b/configs/am335x_evm_spiboot_defconfig @@ -53,10 +53,14 @@ CONFIG_SPL_ENV_IS_NOWHERE=y CONFIG_VERSION_VARIABLE=y CONFIG_NET_RETRY_COUNT=10 CONFIG_BOOTP_SEND_HOSTNAME=y +CONFIG_SPL_OF_TRANSLATE=y +CONFIG_SPL_TI_SYSC=y CONFIG_BOOTCOUNT_LIMIT=y CONFIG_SYS_BOOTCOUNT_BE=y CONFIG_CLK=y +CONFIG_SPL_CLK=y CONFIG_CLK_CDCE9XX=y +CONFIG_CLK_TI_CTRL=y CONFIG_DFU_TFTP=y CONFIG_DFU_MMC=y CONFIG_DFU_NAND=y

This change enables access to the SPI flash on the SanCloud BBE Lite board.
Signed-off-by: Paul Barker paul.barker@sancloud.com --- configs/am335x_evm_defconfig | 1 + configs/am335x_evm_spiboot_defconfig | 1 + 2 files changed, 2 insertions(+)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index f0fbe475b394..f73123e0b71d 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -92,6 +92,7 @@ CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y CONFIG_SYS_NAND_U_BOOT_OFFS=0xc0000 CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=24000000 +CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_PHY_ATHEROS=y CONFIG_PHY_SMSC=y diff --git a/configs/am335x_evm_spiboot_defconfig b/configs/am335x_evm_spiboot_defconfig index 2bc911cfd022..7f422010c1c7 100644 --- a/configs/am335x_evm_spiboot_defconfig +++ b/configs/am335x_evm_spiboot_defconfig @@ -84,6 +84,7 @@ CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y CONFIG_SYS_NAND_U_BOOT_OFFS=0xc0000 CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=24000000 +CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_PHY_ATHEROS=y CONFIG_PHY_SMSC=y

Signed-off-by: Paul Barker paul.barker@sancloud.com --- arch/arm/dts/am335x-sancloud-bbe-lite.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/dts/am335x-sancloud-bbe-lite.dts b/arch/arm/dts/am335x-sancloud-bbe-lite.dts index d6ef19311a91..8ffbc72dc57e 100644 --- a/arch/arm/dts/am335x-sancloud-bbe-lite.dts +++ b/arch/arm/dts/am335x-sancloud-bbe-lite.dts @@ -41,7 +41,7 @@ #address-cells = <1>; #size-cells = <0>;
- compatible = "micron,spi-authenta"; + compatible = "micron,spi-authenta", "jedec,spi-nor";
reg = <0>; spi-max-frequency = <16000000>;

Hi Paul,
On 14/11/22 18:12, Paul Barker wrote:
Signed-off-by: Paul Barker paul.barker@sancloud.com
It is my humble opinion that you add some commit message here and not leave the body blank with just a sign off.
arch/arm/dts/am335x-sancloud-bbe-lite.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/dts/am335x-sancloud-bbe-lite.dts b/arch/arm/dts/am335x-sancloud-bbe-lite.dts index d6ef19311a91..8ffbc72dc57e 100644 --- a/arch/arm/dts/am335x-sancloud-bbe-lite.dts +++ b/arch/arm/dts/am335x-sancloud-bbe-lite.dts @@ -41,7 +41,7 @@ #address-cells = <1>; #size-cells = <0>;
compatible = "micron,spi-authenta";
compatible = "micron,spi-authenta", "jedec,spi-nor";
reg = <0>; spi-max-frequency = <16000000>;

The SanCloud BBE requires the same dtb nodes to be present in the SPL as the AM335x EVM.
The SanCloud BBE Lite also requires the SPI flash node and all dependencies to be present in the SPL to support SPI boot.
Signed-off-by: Paul Barker paul.barker@sancloud.com --- .../dts/am335x-sancloud-bbe-lite-u-boot.dtsi | 44 +++++++++++++++++++ arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi | 6 +++ 2 files changed, 50 insertions(+) create mode 100644 arch/arm/dts/am335x-sancloud-bbe-lite-u-boot.dtsi create mode 100644 arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi
diff --git a/arch/arm/dts/am335x-sancloud-bbe-lite-u-boot.dtsi b/arch/arm/dts/am335x-sancloud-bbe-lite-u-boot.dtsi new file mode 100644 index 000000000000..01c105ebb383 --- /dev/null +++ b/arch/arm/dts/am335x-sancloud-bbe-lite-u-boot.dtsi @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2021 SanCloud Ltd + */ + +#include "am335x-sancloud-bbe-u-boot.dtsi" + +&l4_wkup { + segment@200000 { + target-module@0 { + u-boot,dm-pre-reloc; + }; + }; +}; + +&prcm { + u-boot,dm-pre-reloc; +}; + +&per_cm { + u-boot,dm-pre-reloc; +}; + +&l4ls_clkctrl { + u-boot,dm-pre-reloc; +}; + +&l4_per { + u-boot,dm-pre-reloc; + segment@0 { + u-boot,dm-pre-reloc; + target-module@30000 { + u-boot,dm-pre-reloc; + }; + }; +}; + +&spi0 { + u-boot,dm-pre-reloc; + channel@0 { + u-boot,dm-pre-reloc; + }; +}; diff --git a/arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi b/arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi new file mode 100644 index 000000000000..06e7554a63c8 --- /dev/null +++ b/arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2022 SanCloud Ltd + */ + +#include "am335x-evm-u-boot.dtsi"

Signed-off-by: Paul Barker paul.barker@sancloud.com Cc: Marc Murphy marc.murphy@sancloud.com --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS index 8d3d528650a7..3ab1dca33a4a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -485,6 +485,12 @@ F: arch/arm/mach-exynos/ F: arch/arm/mach-s5pc1xx/ F: arch/arm/cpu/armv7/s5p-common/
+ARM SANCLOUD +M: Paul Barker paul.barker@sancloud.com +R: Marc Murphy marc.murphy@sancloud.com +S: Supported +F: arch/arm/dts/am335x-sancloud* + ARM SNAPDRAGON M: Ramon Fried rfried.dev@gmail.com S: Maintained

On 14/11/2022 12:42, Paul Barker wrote:
These changes fix SPI boot on the SanCloud BBE Lite and other AM335x boards.
They also put us in a good place to enable SPL_OF_CONTROL for eMMC/SD card boot on AM335x boards. Note that if SPL_OF_CONTROL is enabled, some SPL features need to be dropped due to the limited amount of sram available. In my testing I dropped NAND, NET & USB support.
This series has been build tested for all targets using buildman and no errors were observed. It has been boot tested on the SanCloud BBE Lite with the following configurations:
1) SD card boot using am335x_evm_defconfig with no config changes. 2) SD card boot using am335x_evm_defconfig with the following config changes: CONFIG_SPL_OF_CONTROL=y CONFIG_SPL_OF_TRANSLATE=y CONFIG_SPL_MUSB_NEW=n CONFIG_SPL_NAND_DRIVERS=n CONFIG_SPL_NAND_ECC=n CONFIG_SPL_NAND_BASE=n CONFIG_SPL_NET=n CONFIG_SPL_USB_GADGET=n 3) SPI boot using am335x_evm_spiboot_defconfig with the following config changes: CONFIG_DEFAULT_DEVICE_TREE="am335x-sancloud-bbe-lite" CONFIG_OF_LIST="am335x-sancloud-bbe-lite"
As discussed in my previous message [1], I can't see how to construct a test case to accompany the first patch which fixes an SPL crash during the pre-relocation lists_bind_drivers() call due to exhaustion of the available memory. We can discuss this further though if anyone has any ideas on how to write an appropriate test case.
Paul Barker (9): dm: core: Fix iteration over driver_info records bus: TI sysc driver requires DM bus: Optionally include TI sysc driver in SPL/TPL am335x-evm: Enable required dtb nodes in SPL am335x-evm: Fix spiboot configuration am335x-evm: Support STMicro/Micron SPI flash am335x-sancloud-bbe-lite: SPI flash is JEDEC compatible am335x-sancloud-bbe: Add -u-boot.dtsi files MAINTAINERS: Adopt SanCloud boards
MAINTAINERS | 6 +++ arch/arm/dts/am335x-evm-u-boot.dtsi | 30 ++++++++++++- .../dts/am335x-sancloud-bbe-lite-u-boot.dtsi | 44 +++++++++++++++++++ arch/arm/dts/am335x-sancloud-bbe-lite.dts | 2 +- arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi | 6 +++ configs/am335x_evm_defconfig | 1 + configs/am335x_evm_spiboot_defconfig | 5 +++ drivers/Makefile | 2 +- drivers/bus/Kconfig | 9 +++- drivers/bus/Makefile | 5 ++- drivers/core/lists.c | 6 +-- 11 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 arch/arm/dts/am335x-sancloud-bbe-lite-u-boot.dtsi create mode 100644 arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi
base-commit: 0cbeed4f6648e0e4966475e3544280a69ecb59d3
A gentle ping on this patch series.
participants (3)
-
Dhruva Gole
-
Paul Barker
-
Tom Rini