[PATCH 1/6] riscv: Call spl_board_init_f() in the generic SPL board_init_f()

From: Bin Meng bin.meng@windriver.com
The generic SPL version of board_init_f() should give a call to board specific codes to initialize board in the SPL phase.
Signed-off-by: Bin Meng bin.meng@windriver.com ---
arch/riscv/include/asm/spl.h | 7 +++++++ arch/riscv/lib/spl.c | 9 +++++++++ 2 files changed, 16 insertions(+)
diff --git a/arch/riscv/include/asm/spl.h b/arch/riscv/include/asm/spl.h index 45c03fb..1487f2d 100644 --- a/arch/riscv/include/asm/spl.h +++ b/arch/riscv/include/asm/spl.h @@ -28,4 +28,11 @@ enum { BOOT_DEVICE_NONE };
+/** + * spl_board_init_f() - initialize board in the SPL phase + * + * @return 0 if succeeded, -ve on error + */ +int spl_board_init_f(void); + #endif diff --git a/arch/riscv/lib/spl.c b/arch/riscv/lib/spl.c index c47dcd4..e24ec5a 100644 --- a/arch/riscv/lib/spl.c +++ b/arch/riscv/lib/spl.c @@ -13,6 +13,11 @@
DECLARE_GLOBAL_DATA_PTR;
+__weak int spl_board_init_f(void) +{ + return 0; +} + __weak void board_init_f(ulong dummy) { int ret; @@ -24,6 +29,10 @@ __weak void board_init_f(ulong dummy) arch_cpu_init_dm();
preloader_console_init(); + + ret = spl_board_init_f(); + if (ret) + panic("spl_board_init_f() failed: %d\n", ret); }
void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)

From: Bin Meng bin.meng@windriver.com
Use the generic board_init_f() provided by the RISC-V library codes.
Signed-off-by: Bin Meng bin.meng@windriver.com ---
board/sifive/fu540/spl.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/board/sifive/fu540/spl.c b/board/sifive/fu540/spl.c index 55325cf..31d315d 100644 --- a/board/sifive/fu540/spl.c +++ b/board/sifive/fu540/spl.c @@ -17,7 +17,7 @@
#define GEM_PHY_RESET SIFIVE_GENERIC_GPIO_NR(0, 12)
-int init_clk_and_ddr(void) +int spl_board_init_f(void) { int ret;
@@ -55,20 +55,3 @@ int init_clk_and_ddr(void)
return 0; } - -void board_init_f(ulong dummy) -{ - int ret; - - ret = spl_early_init(); - if (ret) - panic("spl_early_init() failed: %d\n", ret); - - arch_cpu_init_dm(); - - preloader_console_init(); - - ret = init_clk_and_ddr(); - if (ret) - panic("init_clk_and_ddr() failed: %d\n", ret); -}

-----Original Message----- From: Bin Meng bmeng.cn@gmail.com Sent: 03 August 2020 11:39 To: Rick Chen rick@andestech.com; Pragnesh Patel pragnesh.patel@sifive.com; U-Boot Mailing List u-boot@lists.denx.de Cc: Bin Meng bin.meng@windriver.com Subject: [PATCH 2/6] riscv: sifive/fu540: spl: Drop our own version of board_init_f()
[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe
From: Bin Meng bin.meng@windriver.com
Use the generic board_init_f() provided by the RISC-V library codes.
Signed-off-by: Bin Meng bin.meng@windriver.com
board/sifive/fu540/spl.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
Reviewed-by: Pragnesh Patel pragnesh.patel@sifive.com Tested-by: Pragnesh Patel pragnesh.patel@sifive.com

From: Bin Meng bin.meng@windriver.com
spl_soc_init() seems to be a better name, as all SPL functions names start from the spl_ prefix.
Signed-off-by: Bin Meng bin.meng@windriver.com ---
arch/riscv/cpu/fu540/spl.c | 2 +- arch/riscv/include/asm/arch-fu540/spl.h | 2 +- board/sifive/fu540/spl.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/cpu/fu540/spl.c b/arch/riscv/cpu/fu540/spl.c index a2034e9..45657b7 100644 --- a/arch/riscv/cpu/fu540/spl.c +++ b/arch/riscv/cpu/fu540/spl.c @@ -7,7 +7,7 @@ #include <dm.h> #include <log.h>
-int soc_spl_init(void) +int spl_soc_init(void) { int ret; struct udevice *dev; diff --git a/arch/riscv/include/asm/arch-fu540/spl.h b/arch/riscv/include/asm/arch-fu540/spl.h index 0c188be..4697279 100644 --- a/arch/riscv/include/asm/arch-fu540/spl.h +++ b/arch/riscv/include/asm/arch-fu540/spl.h @@ -9,6 +9,6 @@ #ifndef _SPL_SIFIVE_H #define _SPL_SIFIVE_H
-int soc_spl_init(void); +int spl_soc_init(void);
#endif /* _SPL_SIFIVE_H */ diff --git a/board/sifive/fu540/spl.c b/board/sifive/fu540/spl.c index 31d315d..135e118 100644 --- a/board/sifive/fu540/spl.c +++ b/board/sifive/fu540/spl.c @@ -21,7 +21,7 @@ int spl_board_init_f(void) { int ret;
- ret = soc_spl_init(); + ret = spl_soc_init(); if (ret) { debug("FU540 SPL init failed: %d\n", ret); return ret;

-----Original Message----- From: Bin Meng bmeng.cn@gmail.com Sent: 03 August 2020 11:39 To: Rick Chen rick@andestech.com; Pragnesh Patel pragnesh.patel@sifive.com; U-Boot Mailing List u-boot@lists.denx.de Cc: Bin Meng bin.meng@windriver.com Subject: [PATCH 3/6] riscv: sifive/fu540: spl: Rename soc_spl_init()
[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe
From: Bin Meng bin.meng@windriver.com
spl_soc_init() seems to be a better name, as all SPL functions names start from the spl_ prefix.
Signed-off-by: Bin Meng bin.meng@windriver.com
arch/riscv/cpu/fu540/spl.c | 2 +- arch/riscv/include/asm/arch-fu540/spl.h | 2 +- board/sifive/fu540/spl.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Pragnesh Patel pragnesh.patel@sifive.com Tested-by: Pragnesh Patel pragnesh.patel@sifive.com

From: Bin Meng bin.meng@windriver.com
All FU540 driver related options should be in the SoC level Kconfig.
Signed-off-by: Bin Meng bin.meng@windriver.com ---
arch/riscv/cpu/fu540/Kconfig | 22 ++++++++++++++++++++++ board/sifive/fu540/Kconfig | 22 ---------------------- 2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/arch/riscv/cpu/fu540/Kconfig b/arch/riscv/cpu/fu540/Kconfig index 2dcad8e..53e1963 100644 --- a/arch/riscv/cpu/fu540/Kconfig +++ b/arch/riscv/cpu/fu540/Kconfig @@ -5,6 +5,9 @@ config SIFIVE_FU540 bool select ARCH_EARLY_INIT_R + select SUPPORT_SPL + select RAM + select SPL_RAM if SPL imply CPU imply CPU_RISCV imply RISCV_TIMER @@ -13,6 +16,25 @@ config SIFIVE_FU540 imply SPL_CPU_SUPPORT imply SPL_OPENSBI imply SPL_LOAD_FIT + imply SMP + imply CLK_SIFIVE + imply CLK_SIFIVE_FU540_PRCI + imply SIFIVE_SERIAL + imply MACB + imply MII + imply SPI + imply SPI_SIFIVE + imply MMC + imply MMC_SPI + imply MMC_BROKEN_CD + imply CMD_MMC + imply DM_GPIO + imply SIFIVE_GPIO + imply CMD_GPIO + imply MISC + imply SIFIVE_OTP + imply DM_PWM + imply PWM_SIFIVE
if ENV_IS_IN_SPI_FLASH
diff --git a/board/sifive/fu540/Kconfig b/board/sifive/fu540/Kconfig index f3217f6..fc28120 100644 --- a/board/sifive/fu540/Kconfig +++ b/board/sifive/fu540/Kconfig @@ -26,10 +26,7 @@ config SPL_OPENSBI_LOAD_ADDR config BOARD_SPECIFIC_OPTIONS # dummy def_bool y select SIFIVE_FU540 - select SUPPORT_SPL select ENV_IS_IN_SPI_FLASH - select RAM - select SPL_RAM if SPL imply CMD_DHCP imply CMD_EXT2 imply CMD_EXT4 @@ -40,34 +37,15 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply CMD_NET imply CMD_PING imply CMD_SF - imply CLK_SIFIVE - imply CLK_SIFIVE_FU540_PRCI imply DOS_PARTITION imply EFI_PARTITION imply IP_DYN imply ISO_PARTITION - imply MACB - imply MII imply NET_RANDOM_ETHADDR imply PHY_LIB imply PHY_MSCC - imply SIFIVE_SERIAL - imply SPI - imply SPI_SIFIVE imply SPI_FLASH imply SPI_FLASH_ISSI - imply MMC - imply MMC_SPI - imply MMC_BROKEN_CD - imply CMD_MMC - imply DM_GPIO - imply SIFIVE_GPIO - imply CMD_GPIO - imply SMP - imply MISC - imply SIFIVE_OTP - imply DM_PWM - imply PWM_SIFIVE imply SYSRESET imply SYSRESET_GPIO

-----Original Message----- From: Bin Meng bmeng.cn@gmail.com Sent: 03 August 2020 11:39 To: Rick Chen rick@andestech.com; Pragnesh Patel pragnesh.patel@sifive.com; U-Boot Mailing List u-boot@lists.denx.de Cc: Bin Meng bin.meng@windriver.com Subject: [PATCH 4/6] riscv: sifive/fu540: kconfig: Move FU540 driver related options to the SoC level
[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe
From: Bin Meng bin.meng@windriver.com
All FU540 driver related options should be in the SoC level Kconfig.
Signed-off-by: Bin Meng bin.meng@windriver.com
arch/riscv/cpu/fu540/Kconfig | 22 ++++++++++++++++++++++ board/sifive/fu540/Kconfig | 22 ---------------------- 2 files changed, 22 insertions(+), 22 deletions(-)
Reviewed-by: Pragnesh Patel pragnesh.patel@sifive.com Tested-by: Pragnesh Patel pragnesh.patel@sifive.com

From: Bin Meng bin.meng@windriver.com
This option was enabled during the earlier U-Boot porting time. Now we already have the OTP driver in place and the unique MAC address is read from the OTP, there is no need to turn on this option.
Signed-off-by: Bin Meng bin.meng@windriver.com ---
board/sifive/fu540/Kconfig | 1 - 1 file changed, 1 deletion(-)
diff --git a/board/sifive/fu540/Kconfig b/board/sifive/fu540/Kconfig index fc28120..e70d1e5 100644 --- a/board/sifive/fu540/Kconfig +++ b/board/sifive/fu540/Kconfig @@ -41,7 +41,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply EFI_PARTITION imply IP_DYN imply ISO_PARTITION - imply NET_RANDOM_ETHADDR imply PHY_LIB imply PHY_MSCC imply SPI_FLASH

On Sun, Aug 02, 2020 at 11:09:05PM -0700, Bin Meng wrote:
From: Bin Meng bin.meng@windriver.com
This option was enabled during the earlier U-Boot porting time. Now we already have the OTP driver in place and the unique MAC address is read from the OTP, there is no need to turn on this option.
Signed-off-by: Bin Meng bin.meng@windriver.com
board/sifive/fu540/Kconfig | 1 - 1 file changed, 1 deletion(-)
diff --git a/board/sifive/fu540/Kconfig b/board/sifive/fu540/Kconfig index fc28120..e70d1e5 100644 --- a/board/sifive/fu540/Kconfig +++ b/board/sifive/fu540/Kconfig @@ -41,7 +41,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply EFI_PARTITION imply IP_DYN imply ISO_PARTITION
- imply NET_RANDOM_ETHADDR imply PHY_LIB imply PHY_MSCC imply SPI_FLASH
-- 2.7.4
Reviewed-by: Leo Liang ycliang@andestech.com

-----Original Message----- From: Bin Meng bmeng.cn@gmail.com Sent: 03 August 2020 11:39 To: Rick Chen rick@andestech.com; Pragnesh Patel pragnesh.patel@sifive.com; U-Boot Mailing List u-boot@lists.denx.de Cc: Bin Meng bin.meng@windriver.com Subject: [PATCH 5/6] riscv: sifive/fu540: Drop NET_RANDOM_ETHADDR
[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe
From: Bin Meng bin.meng@windriver.com
This option was enabled during the earlier U-Boot porting time. Now we already have the OTP driver in place and the unique MAC address is read from the OTP, there is no need to turn on this option.
Signed-off-by: Bin Meng bin.meng@windriver.com
board/sifive/fu540/Kconfig | 1 - 1 file changed, 1 deletion(-)
Reviewed-by: Pragnesh Patel pragnesh.patel@sifive.com Tested-by: Pragnesh Patel pragnesh.patel@sifive.com

From: Bin Meng bin.meng@windriver.com
It's better to keep all SPL related functions in the same spl.c.
Signed-off-by: Bin Meng bin.meng@windriver.com ---
board/sifive/fu540/fu540.c | 33 --------------------------------- board/sifive/fu540/spl.c | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 34 deletions(-)
diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c index 57753ba..54e5a4c 100644 --- a/board/sifive/fu540/fu540.c +++ b/board/sifive/fu540/fu540.c @@ -13,7 +13,6 @@ #include <linux/bitops.h> #include <linux/bug.h> #include <linux/delay.h> -#include <linux/io.h> #include <misc.h> #include <spl.h> #include <asm/arch/cache.h> @@ -127,35 +126,3 @@ int board_init(void)
return 0; } - -#ifdef CONFIG_SPL -#define MODE_SELECT_REG 0x1000 -#define MODE_SELECT_QSPI 0x6 -#define MODE_SELECT_SD 0xb -#define MODE_SELECT_MASK GENMASK(3, 0) - -u32 spl_boot_device(void) -{ - u32 mode_select = readl((void *)MODE_SELECT_REG); - u32 boot_device = mode_select & MODE_SELECT_MASK; - - switch (boot_device) { - case MODE_SELECT_QSPI: - return BOOT_DEVICE_SPI; - case MODE_SELECT_SD: - return BOOT_DEVICE_MMC1; - default: - debug("Unsupported boot device 0x%x but trying MMC1\n", - boot_device); - return BOOT_DEVICE_MMC1; - } -} -#endif - -#ifdef CONFIG_SPL_LOAD_FIT -int board_fit_config_name_match(const char *name) -{ - /* boot using first FIT config */ - return 0; -} -#endif diff --git a/board/sifive/fu540/spl.c b/board/sifive/fu540/spl.c index 135e118..fe27316 100644 --- a/board/sifive/fu540/spl.c +++ b/board/sifive/fu540/spl.c @@ -11,11 +11,17 @@ #include <misc.h> #include <log.h> #include <linux/delay.h> +#include <linux/io.h> #include <asm/gpio.h> #include <asm/arch/gpio.h> #include <asm/arch/spl.h>
-#define GEM_PHY_RESET SIFIVE_GENERIC_GPIO_NR(0, 12) +#define GEM_PHY_RESET SIFIVE_GENERIC_GPIO_NR(0, 12) + +#define MODE_SELECT_REG 0x1000 +#define MODE_SELECT_QSPI 0x6 +#define MODE_SELECT_SD 0xb +#define MODE_SELECT_MASK GENMASK(3, 0)
int spl_board_init_f(void) { @@ -55,3 +61,28 @@ int spl_board_init_f(void)
return 0; } + +u32 spl_boot_device(void) +{ + u32 mode_select = readl((void *)MODE_SELECT_REG); + u32 boot_device = mode_select & MODE_SELECT_MASK; + + switch (boot_device) { + case MODE_SELECT_QSPI: + return BOOT_DEVICE_SPI; + case MODE_SELECT_SD: + return BOOT_DEVICE_MMC1; + default: + debug("Unsupported boot device 0x%x but trying MMC1\n", + boot_device); + return BOOT_DEVICE_MMC1; + } +} + +#ifdef CONFIG_SPL_LOAD_FIT +int board_fit_config_name_match(const char *name) +{ + /* boot using first FIT config */ + return 0; +} +#endif

On Sun, Aug 02, 2020 at 11:09:06PM -0700, Bin Meng wrote:
From: Bin Meng bin.meng@windriver.com
It's better to keep all SPL related functions in the same spl.c.
Signed-off-by: Bin Meng bin.meng@windriver.com
board/sifive/fu540/fu540.c | 33 --------------------------------- board/sifive/fu540/spl.c | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 34 deletions(-)
diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c index 57753ba..54e5a4c 100644 --- a/board/sifive/fu540/fu540.c +++ b/board/sifive/fu540/fu540.c @@ -13,7 +13,6 @@ #include <linux/bitops.h> #include <linux/bug.h> #include <linux/delay.h> -#include <linux/io.h> #include <misc.h> #include <spl.h> #include <asm/arch/cache.h> @@ -127,35 +126,3 @@ int board_init(void)
return 0; }
-#ifdef CONFIG_SPL -#define MODE_SELECT_REG 0x1000 -#define MODE_SELECT_QSPI 0x6 -#define MODE_SELECT_SD 0xb -#define MODE_SELECT_MASK GENMASK(3, 0)
-u32 spl_boot_device(void) -{
- u32 mode_select = readl((void *)MODE_SELECT_REG);
- u32 boot_device = mode_select & MODE_SELECT_MASK;
- switch (boot_device) {
- case MODE_SELECT_QSPI:
return BOOT_DEVICE_SPI;
- case MODE_SELECT_SD:
return BOOT_DEVICE_MMC1;
- default:
debug("Unsupported boot device 0x%x but trying MMC1\n",
boot_device);
return BOOT_DEVICE_MMC1;
- }
-} -#endif
-#ifdef CONFIG_SPL_LOAD_FIT -int board_fit_config_name_match(const char *name) -{
- /* boot using first FIT config */
- return 0;
-} -#endif diff --git a/board/sifive/fu540/spl.c b/board/sifive/fu540/spl.c index 135e118..fe27316 100644 --- a/board/sifive/fu540/spl.c +++ b/board/sifive/fu540/spl.c @@ -11,11 +11,17 @@ #include <misc.h> #include <log.h> #include <linux/delay.h> +#include <linux/io.h> #include <asm/gpio.h> #include <asm/arch/gpio.h> #include <asm/arch/spl.h>
-#define GEM_PHY_RESET SIFIVE_GENERIC_GPIO_NR(0, 12) +#define GEM_PHY_RESET SIFIVE_GENERIC_GPIO_NR(0, 12)
+#define MODE_SELECT_REG 0x1000 +#define MODE_SELECT_QSPI 0x6 +#define MODE_SELECT_SD 0xb +#define MODE_SELECT_MASK GENMASK(3, 0)
int spl_board_init_f(void) { @@ -55,3 +61,28 @@ int spl_board_init_f(void)
return 0; }
+u32 spl_boot_device(void) +{
- u32 mode_select = readl((void *)MODE_SELECT_REG);
- u32 boot_device = mode_select & MODE_SELECT_MASK;
- switch (boot_device) {
- case MODE_SELECT_QSPI:
return BOOT_DEVICE_SPI;
- case MODE_SELECT_SD:
return BOOT_DEVICE_MMC1;
- default:
debug("Unsupported boot device 0x%x but trying MMC1\n",
boot_device);
return BOOT_DEVICE_MMC1;
- }
+}
+#ifdef CONFIG_SPL_LOAD_FIT +int board_fit_config_name_match(const char *name) +{
- /* boot using first FIT config */
- return 0;
+}
+#endif
2.7.4
Reviewed-by: Leo Liang ycliang@andestech.com

-----Original Message----- From: Bin Meng bmeng.cn@gmail.com Sent: 03 August 2020 11:39 To: Rick Chen rick@andestech.com; Pragnesh Patel pragnesh.patel@sifive.com; U-Boot Mailing List u-boot@lists.denx.de Cc: Bin Meng bin.meng@windriver.com Subject: [PATCH 6/6] riscv: sifive/fu540: Move SPL related functions to spl.c
[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe
From: Bin Meng bin.meng@windriver.com
It's better to keep all SPL related functions in the same spl.c.
Signed-off-by: Bin Meng bin.meng@windriver.com
board/sifive/fu540/fu540.c | 33 --------------------------------- board/sifive/fu540/spl.c | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 34 deletions(-)
Reviewed-by: Pragnesh Patel pragnesh.patel@sifive.com Tested-by: Pragnesh Patel pragnesh.patel@sifive.com

-----Original Message----- From: Bin Meng bmeng.cn@gmail.com Sent: 03 August 2020 11:39 To: Rick Chen rick@andestech.com; Pragnesh Patel pragnesh.patel@sifive.com; U-Boot Mailing List u-boot@lists.denx.de Cc: Bin Meng bin.meng@windriver.com Subject: [PATCH 1/6] riscv: Call spl_board_init_f() in the generic SPL board_init_f()
[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe
From: Bin Meng bin.meng@windriver.com
The generic SPL version of board_init_f() should give a call to board specific codes to initialize board in the SPL phase.
Signed-off-by: Bin Meng bin.meng@windriver.com
arch/riscv/include/asm/spl.h | 7 +++++++ arch/riscv/lib/spl.c | 9 +++++++++ 2 files changed, 16 insertions(+)
Reviewed-by: Pragnesh Patel pragnesh.patel@sifive.com Tested-by: Pragnesh Patel pragnesh.patel@sifive.com
participants (3)
-
Bin Meng
-
Leo Liang
-
Pragnesh Patel