Skip to contentSkip to conversation

configs: socfpga: Add QSPI support for Cyclone 5

PATCH In review Boon Khai Ng 2 participants 2 messages Mar 18 – Apr 17

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configs: socfpga: Add QSPI support for Cyclone 5

Add QSPI boot support to boot target devices list. Platform can provide their own boot settings through OCFPGA_BOOT_SETTINGS macro if needed.

Add SOCFPGA_BOOT_SETTINGS for Cyclone 5.

---
 include/configs/socfpga_common.h         | 18 ++++++++++++++++++
 include/configs/socfpga_cyclone5_socdk.h | 18 ++++++++++++++++++
 2 files changed, 36 insertions(+)
include/configs/socfpga_common.h +18 -0
index 36d6bfb3d03..5d98d662ea7 100644
@@ -137,11 +137,28 @@
 #define BOOT_TARGET_DEVICES_MMC(func)
 #endif
 
+#ifdef CONFIG_CMD_SF
+#define BOOT_TARGET_DEVICES_QSPI(func) func(QSPI, qspi, na)
+#else
+#define BOOT_TARGET_DEVICES_QSPI(func)
+#endif
+
+#define BOOTENV_DEV_QSPI(devtypeu, devtypel, instance) \
+	"bootcmd_qspi=run qspiload; run qspiboot\0"
+
+#define BOOTENV_DEV_NAME_QSPI(devtypeu, devtypel, instance) \
+	"qspi "
+
 #define BOOT_TARGET_DEVICES(func) \
 	BOOT_TARGET_DEVICES_MMC(func) \
+	BOOT_TARGET_DEVICES_QSPI(func) \
 	BOOT_TARGET_DEVICES_PXE(func) \
 	BOOT_TARGET_DEVICES_DHCP(func)
 
+#ifndef SOCFPGA_BOOT_SETTINGS
+#define SOCFPGA_BOOT_SETTINGS
+#endif
+
 #include <config_distro_bootcmd.h>
 
 #ifndef CFG_EXTRA_ENV_SETTINGS
@@ -154,6 +171,7 @@
 	"pxefile_addr_r=0x02200000\0" \
 	"ramdisk_addr_r=0x02300000\0" \
 	"socfpga_legacy_reset_compat=1\0" \
+	SOCFPGA_BOOT_SETTINGS \
 	BOOTENV
 
 #endif
include/configs/socfpga_cyclone5_socdk.h +18 -0
index c23ba2325b8..3ebb7b18020 100644
@@ -10,6 +10,24 @@
 /* Memory configurations */
 #define PHYS_SDRAM_1_SIZE		0x40000000	/* 1GiB on SoCDK */
 
+/* QSPI boot */
+#define FDT_SIZE		__stringify(0x00010000)
+#define KERNEL_SIZE		__stringify(0x005d0000)
+#define QSPI_FDT_ADDR		__stringify(0x00220000)
+#define QSPI_KERNEL_ADDR	__stringify(0x00230000)
+
+#define SOCFPGA_BOOT_SETTINGS \
+	"fdt_size=" FDT_SIZE "\0" \
+	"kernel_size=" KERNEL_SIZE "\0" \
+	"qspi_fdt_addr=" QSPI_FDT_ADDR "\0" \
+	"qspi_kernel_addr=" QSPI_KERNEL_ADDR "\0" \
+	"qspiboot=setenv bootargs earlycon " \
+		"root=/dev/mtdblock1 rw rootfstype=jffs2; " \
+		"bootz ${kernel_addr_r} - ${fdt_addr_r}\0" \
+	"qspiload=sf probe; " \
+		"sf read ${kernel_addr_r} ${qspi_kernel_addr} ${kernel_size}; " \
+		"sf read ${fdt_addr_r} ${qspi_fdt_addr} ${fdt_size}\0"
+
 /* The rest of the configuration is shared */
 #include <configs/socfpga_common.h>
 
Signature · 1 line
2.43.7
#1 lore raw

Hi Boon Khai,

Quoted 3 lines · Boon Khai Ng

Add QSPI boot support to boot target devices list. Platform can provide their own boot settings through OCFPGA_BOOT_SETTINGS macro if needed.

Commit message typo:  “OCFPGA_BOOT_SETTINGS” — should be SOCFPGA_BOOT_SETTINGS.

Quoted 14 lines

Add SOCFPGA_BOOT_SETTINGS for Cyclone 5.

---
  include/configs/socfpga_common.h         | 18 ++++++++++++++++++
  include/configs/socfpga_cyclone5_socdk.h | 18 ++++++++++++++++++
  2 files changed, 36 insertions(+)
include/configs/socfpga_common.h +0 -0
index 36d6bfb3d03..5d98d662ea7 100644

include/configs/socfpga_common.h line 141

Quoted 5 lines
include/configs/socfpga_common.h +2 -0
@@ -137,11 +137,28 @@
  #define BOOT_TARGET_DEVICES_MMC(func)
  #endif
 
+#ifdef CONFIG_CMD_SF
+#define BOOT_TARGET_DEVICES_QSPI(func) func(QSPI, qspi, na)

Any defconfig that sets CONFIG_CMD_SF=y and includes this header

will get qspi in boot_targets and a generic bootcmd_qspi=run qspiload; run qspiboot.

Those commands only exist in the default env if the board defines SOCFPGA_BOOT_SETTINGS (this patch only defines it for Cyclone V SOCdk).

Other SoCFPGA targets (Arria V, DE10, Sockit, …) might enable CMD_SF for a small SPI flash or a different layout without defining qspiload / qspiboot.

After this change, distro autoboot can eventually run bootcmd_qspi and fail once MMC/PXE/DHCP paths do not boot a kernel.

QSPI boot-target integration should be restricted to Cyclone V with new Kconfig-guarded macro.

Example:
config SOCFPGA_DISTRO_BOOT_QSPI
    bool "Append QSPI to distro boot targets (boot_targets)" depends on CMD_SF
    default y if TARGET_SOCFPGA_CYCLONE5_SOCDK
    help
      When enabled, socfpga_common.h adds QSPI to the distro boot device list and defines bootcmd_qspi (run qspiload; run qspiboot). The board header must supply qspiload and qspiboot in default environment (for example via SOCFPGA_BOARD_ENV_APPEND). Disable on boards that enable CMD_SF for a small SPI flash or a layout incompatible with that flow.

Any other board stays n unless it sets CONFIG_SOCFPGA_DISTRO_BOOT_QSPI=y in its defconfig (and defines qspiload / qspiboot in env).

#if IS_ENABLED(CONFIG_CMD_SF) && IS_ENABLED(CONFIG_SOCFPGA_DISTRO_BOOT_QSPI) #define BOOT_TARGET_DEVICES_QSPI(func) func(QSPI, qspi, na)

[...]

Quoted 5 lines
include/configs/socfpga_common.h +5 -0
+#else
+#define BOOT_TARGET_DEVICES_QSPI(func)
+#endif
+
+#define BOOTENV_DEV_QSPI(devtypeu, devtypel, instance) \

include/configs/socfpga_common.h line 156

Quoted 10 lines
include/configs/socfpga_common.h +6 -0
+	"bootcmd_qspi=run qspiload; run qspiboot\0"
+
+#define BOOTENV_DEV_NAME_QSPI(devtypeu, devtypel, instance) \
+	"qspi "
+
  #define BOOT_TARGET_DEVICES(func) \
  	BOOT_TARGET_DEVICES_MMC(func) \
+	BOOT_TARGET_DEVICES_QSPI(func) \
  	BOOT_TARGET_DEVICES_PXE(func) \
  	BOOT_TARGET_DEVICES_DHCP(func)

Best regards,

Tien Fong