Skip to contentSkip to conversation

riscv: Call spl_board_init_f() in the generic SPL board_init_f()

PATCH New Bin Meng 4 participants 21 messages Aug 3, 2020 – Aug 6, 2020 6 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Bin Meng

author
#0 lore raw

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

From: Bin Meng <[email protected]>

The generic SPL version of board_init_f() should give a call to board specific codes to initialize board in the SPL phase.

---

 arch/riscv/include/asm/spl.h | 7 +++++++
 arch/riscv/lib/spl.c         | 9 +++++++++
 2 files changed, 16 insertions(+)
arch/riscv/include/asm/spl.h +7 -0
index 45c03fb..1487f2d 100644
@@ -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
arch/riscv/lib/spl.c +9 -0
index c47dcd4..e24ec5a 100644
@@ -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)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/6 riscv: sifive/fu540: spl: Drop our own version of board_init_f()

From: Bin Meng <[email protected]>

Use the generic board_init_f() provided by the RISC-V library codes.

---

 board/sifive/fu540/spl.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
board/sifive/fu540/spl.c +1 -18
index 55325cf..31d315d 100644
@@ -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);
-}
Signature · 1 line
2.7.4

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

PATCH 2/6 riscv: sifive/fu540: spl: Drop our own version of board_init_f()

Quoted 6 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Monday, August 03, 2020 2:09 PM
To: Rick Jian-Zhi Chen(???); Pragnesh Patel; U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/6] riscv: sifive/fu540: spl: Drop our own version of board_init_f()

Quoted 6 lines

From: Bin Meng <[email protected]>

Use the generic board_init_f() provided by the RISC-V library codes.

---

Quoted 39 lines
 board/sifive/fu540/spl.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
board/sifive/fu540/spl.c +1 -19
@@ -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);
-}
--

2.7.4

#4 lore raw

PATCH 2/6 riscv: sifive/fu540: spl: Drop our own version of board_init_f()

In reply to Bin Meng
Quoted 14 lines

-----Original Message-----
From: Bin Meng <[email protected]>
Sent: 03 August 2020 11:39
To: Rick Chen <[email protected]>; Pragnesh Patel <[email protected]>; U-Boot Mailing List <[email protected]>
Cc: Bin Meng <[email protected]>
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 <[email protected]>

Quoted 8 lines

Use the generic board_init_f() provided by the RISC-V library codes.

---

board/sifive/fu540/spl.c | 19 +------------------

1 file changed, 1 insertion(+), 18 deletions(-)
author
#5 lore raw

PATCH 3/6 riscv: sifive/fu540: spl: Rename soc_spl_init()

In reply to Bin Meng

From: Bin Meng <[email protected]>

spl_soc_init() seems to be a better name, as all SPL functions names start from the spl_ prefix.

---

 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(-)
arch/riscv/cpu/fu540/spl.c +1 -1
index a2034e9..45657b7 100644
@@ -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;
arch/riscv/include/asm/arch-fu540/spl.h +1 -1
index 0c188be..4697279 100644
@@ -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 */
board/sifive/fu540/spl.c +1 -1
index 31d315d..135e118 100644
@@ -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;
Signature · 1 line
2.7.4

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

PATCH 3/6 riscv: sifive/fu540: spl: Rename soc_spl_init()

Quoted 10 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Monday, August 03, 2020 2:09 PM
To: Rick Jian-Zhi Chen(???); Pragnesh Patel; U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 3/6] riscv: sifive/fu540: spl: Rename soc_spl_init()

From: Bin Meng <[email protected]>

spl_soc_init() seems to be a better name, as all SPL functions names start from the spl_ prefix.

Quoted 7 lines

---

 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(-)
#8 lore raw

PATCH 3/6 riscv: sifive/fu540: spl: Rename soc_spl_init()

In reply to Bin Meng
Quoted 16 lines

-----Original Message-----
From: Bin Meng <[email protected]>
Sent: 03 August 2020 11:39
To: Rick Chen <[email protected]>; Pragnesh Patel <[email protected]>; U-Boot Mailing List <[email protected]>
Cc: Bin Meng <[email protected]>
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 <[email protected]>

spl_soc_init() seems to be a better name, as all SPL functions names start from the spl_ prefix.

Quoted 8 lines

---

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(-)
author
#9 lore raw

PATCH 4/6 riscv: sifive/fu540: kconfig: Move FU540 driver related options to the SoC level

In reply to Bin Meng

From: Bin Meng <[email protected]>

All FU540 driver related options should be in the SoC level Kconfig.

---

 arch/riscv/cpu/fu540/Kconfig | 22 ++++++++++++++++++++++
 board/sifive/fu540/Kconfig   | 22 ----------------------
 2 files changed, 22 insertions(+), 22 deletions(-)
arch/riscv/cpu/fu540/Kconfig +22 -0
index 2dcad8e..53e1963 100644
@@ -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
 
board/sifive/fu540/Kconfig +0 -22
index f3217f6..fc28120 100644
@@ -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
 
Signature · 1 line
2.7.4

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw

PATCH 4/6 riscv: sifive/fu540: kconfig: Move FU540 driver related options to the SoC level

Quoted 8 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Monday, August 03, 2020 2:09 PM
To: Rick Jian-Zhi Chen(???); Pragnesh Patel; U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 4/6] riscv: sifive/fu540: kconfig: Move FU540 driver related options to the SoC level

From: Bin Meng <[email protected]>

Quoted 8 lines

All FU540 driver related options should be in the SoC level Kconfig.

---

 arch/riscv/cpu/fu540/Kconfig | 22 ++++++++++++++++++++++
 board/sifive/fu540/Kconfig   | 22 ----------------------
 2 files changed, 22 insertions(+), 22 deletions(-)
#12 lore raw

PATCH 4/6 riscv: sifive/fu540: kconfig: Move FU540 driver related options to the SoC level

In reply to Bin Meng
Quoted 14 lines

-----Original Message-----
From: Bin Meng <[email protected]>
Sent: 03 August 2020 11:39
To: Rick Chen <[email protected]>; Pragnesh Patel <[email protected]>; U-Boot Mailing List <[email protected]>
Cc: Bin Meng <[email protected]>
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 <[email protected]>

Quoted 9 lines

All FU540 driver related options should be in the SoC level Kconfig.

---

arch/riscv/cpu/fu540/Kconfig | 22 ++++++++++++++++++++++
board/sifive/fu540/Kconfig | 22 ----------------------

2 files changed, 22 insertions(+), 22 deletions(-)
author
#13 lore raw

PATCH 5/6 riscv: sifive/fu540: Drop NET_RANDOM_ETHADDR

In reply to Bin Meng

From: Bin Meng <[email protected]>

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.

---

 board/sifive/fu540/Kconfig | 1 -
 1 file changed, 1 deletion(-)
board/sifive/fu540/Kconfig +0 -1
index fc28120..e70d1e5 100644
@@ -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
Signature · 1 line
2.7.4
#14 lore raw

PATCH 5/6 riscv: sifive/fu540: Drop NET_RANDOM_ETHADDR

Quoted 27 lines · Bin Meng

From: Bin Meng <[email protected]>

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.

---

 board/sifive/fu540/Kconfig | 1 -
 1 file changed, 1 deletion(-)
board/sifive/fu540/Kconfig +0 -1
index fc28120..e70d1e5 100644
@@ -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
Signature · 1 line
2.7.4

A message that is not in the archive (sent off-list or not yet received): [email protected]

#16 lore raw

PATCH 5/6 riscv: sifive/fu540: Drop NET_RANDOM_ETHADDR

Quoted 8 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Monday, August 03, 2020 2:09 PM
To: Rick Jian-Zhi Chen(???); Pragnesh Patel; U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 5/6] riscv: sifive/fu540: Drop NET_RANDOM_ETHADDR

From: Bin Meng <[email protected]>

Quoted 7 lines

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.

---

 board/sifive/fu540/Kconfig | 1 -
 1 file changed, 1 deletion(-)
#17 lore raw

PATCH 5/6 riscv: sifive/fu540: Drop NET_RANDOM_ETHADDR

In reply to Bin Meng
Quoted 17 lines

-----Original Message-----
From: Bin Meng <[email protected]>
Sent: 03 August 2020 11:39
To: Rick Chen <[email protected]>; Pragnesh Patel <[email protected]>; U-Boot Mailing List <[email protected]>
Cc: Bin Meng <[email protected]>
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 <[email protected]>

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.

Quoted 6 lines

---

board/sifive/fu540/Kconfig | 1 -

1 file changed, 1 deletion(-)
author
#18 lore raw

PATCH 6/6 riscv: sifive/fu540: Move SPL related functions to spl.c

In reply to Bin Meng

From: Bin Meng <[email protected]>

It's better to keep all SPL related functions in the same spl.c.

---

 board/sifive/fu540/fu540.c | 33 ---------------------------------
 board/sifive/fu540/spl.c   | 33 ++++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 34 deletions(-)
board/sifive/fu540/fu540.c +0 -33
index 57753ba..54e5a4c 100644
@@ -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
board/sifive/fu540/spl.c +32 -1
index 135e118..fe27316 100644
@@ -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
Signature · 1 line
2.7.4
#19 lore raw

PATCH 6/6 riscv: sifive/fu540: Move SPL related functions to spl.c

Quoted 114 lines · Bin Meng

From: Bin Meng <[email protected]>

It's better to keep all SPL related functions in the same spl.c.

---

 board/sifive/fu540/fu540.c | 33 ---------------------------------
 board/sifive/fu540/spl.c   | 33 ++++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 34 deletions(-)
board/sifive/fu540/fu540.c +0 -33
index 57753ba..54e5a4c 100644
@@ -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
board/sifive/fu540/spl.c +32 -1
index 135e118..fe27316 100644
@@ -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
Signature · 1 line
2.7.4

A message that is not in the archive (sent off-list or not yet received): [email protected]

#21 lore raw

PATCH 6/6 riscv: sifive/fu540: Move SPL related functions to spl.c

Quoted 104 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Monday, August 03, 2020 2:09 PM
To: Rick Jian-Zhi Chen(???); Pragnesh Patel; U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 6/6] riscv: sifive/fu540: Move SPL related functions to spl.c

From: Bin Meng <[email protected]>

It's better to keep all SPL related functions in the same spl.c.

---

 board/sifive/fu540/fu540.c | 33 ---------------------------------
 board/sifive/fu540/spl.c   | 33 ++++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 34 deletions(-)
board/sifive/fu540/fu540.c +0 -32
@@ -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
board/sifive/fu540/spl.c +22 -1
@@ -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;

board/sifive/fu540/spl.c int spl_board_init_f(void)

Quoted 10 lines
board/sifive/fu540/spl.c +9 -1
+       }
+}
+
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name) {
+       /* boot using first FIT config */
+       return 0;
+}
+#endif
--

WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
#216: FILE: board/sifive/fu540/spl.c:82:
+#ifdef CONFIG_SPL_LOAD_FIT

LGTM.
Other than that,

author
#22 lore raw

PATCH 6/6 riscv: sifive/fu540: Move SPL related functions to spl.c

Hi Rick,

Quoted 112 lines · Rick Chen
Quoted 112 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Monday, August 03, 2020 2:09 PM
To: Rick Jian-Zhi Chen(???); Pragnesh Patel; U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 6/6] riscv: sifive/fu540: Move SPL related functions to spl.c

From: Bin Meng <[email protected]>

It's better to keep all SPL related functions in the same spl.c.

---

 board/sifive/fu540/fu540.c | 33 ---------------------------------
 board/sifive/fu540/spl.c   | 33 ++++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 34 deletions(-)
board/sifive/fu540/fu540.c +0 -32
@@ -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
board/sifive/fu540/spl.c +29 -1
@@ -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;
Quoted 9 lines

board/sifive/fu540/spl.c int spl_board_init_f(void)

Quoted 3 lines
board/sifive/fu540/spl.c +2 -1
+}
+#endif
--

WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
#216: FILE: board/sifive/fu540/spl.c:82:
+#ifdef CONFIG_SPL_LOAD_FIT

This file is only built for SPL so the warning can be ignored safely.

Quoted 4 lines

LGTM.
Other than that,

Regards,
Bin

#23 lore raw

PATCH 6/6 riscv: sifive/fu540: Move SPL related functions to spl.c

In reply to Bin Meng
Quoted 13 lines

-----Original Message-----
From: Bin Meng <[email protected]>
Sent: 03 August 2020 11:39
To: Rick Chen <[email protected]>; Pragnesh Patel <[email protected]>; U-Boot Mailing List <[email protected]>
Cc: Bin Meng <[email protected]>
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 <[email protected]>

Quoted 9 lines

It's better to keep all SPL related functions in the same spl.c.

---

board/sifive/fu540/fu540.c | 33 ---------------------------------
board/sifive/fu540/spl.c | 33 ++++++++++++++++++++++++++++++++-

2 files changed, 32 insertions(+), 34 deletions(-)

A message that is not in the archive (sent off-list or not yet received): [email protected]

#25 lore raw

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

Quoted 6 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Monday, August 03, 2020 2:09 PM
To: Rick Jian-Zhi Chen(???); Pragnesh Patel; U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 1/6] riscv: Call spl_board_init_f() in the generic SPL board_init_f()

Quoted 6 lines

From: Bin Meng <[email protected]>

The generic SPL version of board_init_f() should give a call to board specific codes to initialize board in the SPL phase.

---

Quoted 47 lines
 arch/riscv/include/asm/spl.h | 7 +++++++
 arch/riscv/lib/spl.c         | 9 +++++++++
 2 files changed, 16 insertions(+)
arch/riscv/include/asm/spl.h +5 -0
@@ -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
arch/riscv/lib/spl.c +9 -1
@@ -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)
--

2.7.4

#26 lore raw

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

In reply to Bin Meng
Quoted 17 lines

-----Original Message-----
From: Bin Meng <[email protected]>
Sent: 03 August 2020 11:39
To: Rick Chen <[email protected]>; Pragnesh Patel <[email protected]>; U-Boot Mailing List <[email protected]>
Cc: Bin Meng <[email protected]>
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 <[email protected]>

The generic SPL version of board_init_f() should give a call to board specific codes to initialize board in the SPL phase.

Quoted 6 lines

---

arch/riscv/include/asm/spl.h | 7 +++++++
arch/riscv/lib/spl.c | 9 +++++++++

2 files changed, 16 insertions(+)