Message ID | 20200720141407.30241-8-ovidiu.panait@windriver.com |
---|---|
State | Superseded |
Delegated to: | Tom Rini |
Headers | show |
Series | [v3,01/17] Kconfig: Introduce CONFIG_SYS_HAS_SRAM | expand |
Hi Ovidiu, [snip] > diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c > index 27b5832a0c..ccb7e1b265 100644 > --- a/arch/arc/lib/cpu.c > +++ b/arch/arc/lib/cpu.c > @@ -27,8 +27,6 @@ int arch_cpu_init(void) > > int arch_early_init_r(void) > { > - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; > - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; > return 0; Do we still need an empty arch_early_init_r()? I.e. get rid of it and: --------------------------------->8------------------------------- diff --git a/arch/Kconfig b/arch/Kconfig index 91e049b322..2cc656b641 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -10,7 +10,6 @@ choice config ARC bool "ARC architecture" - select ARCH_EARLY_INIT_R select ARC_TIMER select CLK select HAVE_PRIVATE_LIBGCC --------------------------------->8------------------------------- -Alexey
Hi Ovidiu, On Mon, 20 Jul 2020 at 08:20, Ovidiu Panait <ovidiu.panait@windriver.com> wrote: > > In most cases (arc, ppc, mips, sh, m68k) gd->bd->bi_memsize and > gd->bd->bi_memstart are populated in a similar fashion: > > bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; > bd->bi_memsize = gd->ram_size; > > However, there is a special case in board/cadence/xtfpga/xtfpga.c that > populates those fields in a board specific manner: > > gd->bd->bi_memstart = PHYSADDR(CONFIG_SYS_SDRAM_BASE); > gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; > > Due to this fact, a weak board-specific routine is introduced to take care > of this scenario. Also, move all assignments to bi_mem* fields to > setup_bdinfo initcall. > > Use gd->ram_base to populate bi_memstart to avoid an ifdef. > > Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> > --- > > arch/arc/lib/cpu.c | 2 -- > board/cadence/xtfpga/xtfpga.c | 7 ++++++- > common/board_f.c | 21 +++++++++++++++------ > include/init.h | 12 ++++++++++++ > 4 files changed, 33 insertions(+), 9 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org> This is unfortunate and I would much rather that some board-specific code fix it up earlier or later. But I can't see an obvious place to do this. Regards, Simon
On 21.07.2020 10:05, Alexey Brodkin wrote: > Hi Ovidiu, > > [snip] > >> diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c >> index 27b5832a0c..ccb7e1b265 100644 >> --- a/arch/arc/lib/cpu.c >> +++ b/arch/arc/lib/cpu.c >> @@ -27,8 +27,6 @@ int arch_cpu_init(void) >> >> int arch_early_init_r(void) >> { >> - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; >> - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; >> return 0; > Do we still need an empty arch_early_init_r()? > I.e. get rid of it and: > --------------------------------->8------------------------------- > diff --git a/arch/Kconfig b/arch/Kconfig > index 91e049b322..2cc656b641 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -10,7 +10,6 @@ choice > > config ARC > bool "ARC architecture" > - select ARCH_EARLY_INIT_R > select ARC_TIMER > select CLK > select HAVE_PRIVATE_LIBGCC > --------------------------------->8------------------------------- Hi Alexey, Thanks for your input. I'll include these changes in v4. Ovidiu > -Alexey
diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c index 27b5832a0c..ccb7e1b265 100644 --- a/arch/arc/lib/cpu.c +++ b/arch/arc/lib/cpu.c @@ -27,8 +27,6 @@ int arch_cpu_init(void) int arch_early_init_r(void) { - gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; - gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; return 0; } diff --git a/board/cadence/xtfpga/xtfpga.c b/board/cadence/xtfpga/xtfpga.c index 2869e5cf68..6f168f3f9f 100644 --- a/board/cadence/xtfpga/xtfpga.c +++ b/board/cadence/xtfpga/xtfpga.c @@ -49,7 +49,7 @@ int checkboard(void) return 0; } -int dram_init_banksize(void) +int board_setup_bdinfo_mem(void) { gd->bd->bi_memstart = PHYSADDR(CONFIG_SYS_SDRAM_BASE); gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; @@ -57,6 +57,11 @@ int dram_init_banksize(void) return 0; } +int dram_init_banksize(void) +{ + return 0; +} + int board_postclk_init(void) { /* diff --git a/common/board_f.c b/common/board_f.c index 4356431488..ac72096e3a 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -598,6 +598,19 @@ static int display_new_sp(void) return 0; } +__weak int board_setup_bdinfo_mem(void) +{ + struct bd_info *bd = gd->bd; + + /* + * Save local variables to board info struct + */ + bd->bi_memstart = gd->ram_base; /* start of memory */ + bd->bi_memsize = gd->ram_size; /* size in bytes */ + + return 0; +} + __weak int arch_setup_bdinfo(void) { return 0; @@ -605,6 +618,8 @@ __weak int arch_setup_bdinfo(void) int setup_bdinfo(void) { + board_setup_bdinfo_mem(); + return arch_setup_bdinfo(); } @@ -614,12 +629,6 @@ static int setup_board_part1(void) { struct bd_info *bd = gd->bd; - /* - * Save local variables to board info struct - */ - bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of memory */ - bd->bi_memsize = gd->ram_size; /* size in bytes */ - #ifdef CONFIG_SYS_SRAM_BASE bd->bi_sramstart = CONFIG_SYS_SRAM_BASE; /* start of SRAM */ bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */ diff --git a/include/init.h b/include/init.h index e9354e8fca..85c8f49095 100644 --- a/include/init.h +++ b/include/init.h @@ -141,6 +141,18 @@ int arch_reserve_stacks(void); */ int arch_reserve_mmu(void); +/** + * board_setup_bdinfo_mem() - Populate gd->bd->bi_mem* fields + * + * Board-specific routine for populating gd->bd->bi_mem* fields. + * It is called during the generic board init sequence in setup_bdinfo. + * + * If an implementation is not provided, the generic one will be used. + * + * Return: 0 if OK + */ +int board_setup_bdinfo_mem(void); + /** * arch_setup_bdinfo() - Architecture dependent boardinfo setup *
In most cases (arc, ppc, mips, sh, m68k) gd->bd->bi_memsize and gd->bd->bi_memstart are populated in a similar fashion: bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; bd->bi_memsize = gd->ram_size; However, there is a special case in board/cadence/xtfpga/xtfpga.c that populates those fields in a board specific manner: gd->bd->bi_memstart = PHYSADDR(CONFIG_SYS_SDRAM_BASE); gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; Due to this fact, a weak board-specific routine is introduced to take care of this scenario. Also, move all assignments to bi_mem* fields to setup_bdinfo initcall. Use gd->ram_base to populate bi_memstart to avoid an ifdef. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> --- arch/arc/lib/cpu.c | 2 -- board/cadence/xtfpga/xtfpga.c | 7 ++++++- common/board_f.c | 21 +++++++++++++++------ include/init.h | 12 ++++++++++++ 4 files changed, 33 insertions(+), 9 deletions(-)