Message ID | 1596434946-12630-6-git-send-email-bmeng.cn@gmail.com |
---|---|
State | Accepted |
Commit | 3581811dc26fdf9eef05a7de9f654dc6a7a2596a |
Delegated to: | Andes |
Headers | show |
Series | [1/6] riscv: Call spl_board_init_f() in the generic SPL board_init_f() | expand |
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>
> From: Bin Meng [mailto:bmeng.cn@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 <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 > -- 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, Reviewed-by: Rick Chen <rick@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>
Hi Rick, On Thu, Aug 6, 2020 at 3:00 PM Rick Chen <rickchen36@gmail.com> wrote: > > > From: Bin Meng [mailto:bmeng.cn@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 <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 > > -- > > 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. > LGTM. > Other than that, > > Reviewed-by: Rick Chen <rick@andestech.com> Regards, Bin
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