Hi I compile the master branch u-boot for LicheePi Zero, it's not working.I'm trying to fix the the issue, it's working but ugly now.
I didn't figure out why the sunxi_spi_probe function in drivers/spi/sunxi_spi.c was not called automatically. Finally, I add code to probe all spi device manually. My patch is shown below, what's the correct way to fix it? diff --git a/arch/arm/dts/sun8i-v3s-licheepi-zero.dts b/arch/arm/dts/sun8i-v3s-licheepi-zero.dts index 2e4587d26c..3a1abaa53a 100644 --- a/arch/arm/dts/sun8i-v3s-licheepi-zero.dts +++ b/arch/arm/dts/sun8i-v3s-licheepi-zero.dts @@ -99,3 +99,7 @@ usb0_id_det-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; status = "okay"; }; + +&spi0 { + status = "okay"; +}; diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 49ef217f08..7f89e5da44 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -993,7 +993,7 @@ config SPL_STACK_R_ADDR config SPL_SPI_SUNXI bool "Support for SPI Flash on Allwinner SoCs in SPL" - depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUNXI_H3_H5 || MACH_SUN50I || MACH_SUN8I_R40 || MACH_SUN50I_H6 + depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUNXI_H3_H5 || MACH_SUN50I || MACH_SUN8I_R40 || MACH_SUN50I_H6 || MACH_SUN8I_V3S help Enable support for SPI Flash. This option allows SPL to read from sunxi SPI Flash. It uses the same method as the boot ROM, so does diff --git a/cmd/sf.c b/cmd/sf.c index c0d6a8f8a0..b98a4ac0bf 100644 --- a/cmd/sf.c +++ b/cmd/sf.c @@ -83,6 +83,20 @@ static ulong bytes_per_second(unsigned int len, ulong start_ms) return 1024 * len / max(get_timer(start_ms), 1UL); } +static void spi_probe(void) +{ + struct uclass *uc; + struct udevice *dev; + + int ret = uclass_get(UCLASS_SPI, &uc); + if (ret) + return; + + uclass_foreach_dev(dev, uc) { + device_probe(dev); + } +} + static int do_spi_flash_probe(int argc, char *const argv[]) { unsigned int bus = CONFIG_SF_DEFAULT_BUS; @@ -124,6 +138,8 @@ static int do_spi_flash_probe(int argc, char *const argv[]) return -1; } + spi_probe(); + #if CONFIG_IS_ENABLED(DM_SPI_FLASH) /* Remove the old device, otherwise probe will just be a nop */ ret = spi_find_bus_and_cs(bus, cs, &bus_dev, &new); diff --git a/configs/LicheePi_Zero_defconfig b/configs/LicheePi_Zero_defconfig index 04d7b64504..42cdb25899 100644 --- a/configs/LicheePi_Zero_defconfig +++ b/configs/LicheePi_Zero_defconfig @@ -3,5 +3,9 @@ CONFIG_ARCH_SUNXI=y CONFIG_SPL=y CONFIG_MACH_SUN8I_V3S=y CONFIG_DRAM_CLK=360 +CONFIG_SPL_SPI_SUNXI=y CONFIG_DEFAULT_DEVICE_TREE="sun8i-v3s-licheepi-zero" -# CONFIG_NETDEVICES is not set +CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH_WINBOND=y +CONFIG_SPI=y +CONFIG_DM_SPI=y