diff mbox series

[U-Boot,04/10] arm: socfpga: Update dram_init_banksize() for Stratix10

Message ID 1552379474-12867-5-git-send-email-ley.foon.tan@intel.com
State Superseded
Delegated to: Marek Vasut
Headers show
Series Update Stratix 10 SDRAM driver | expand

Commit Message

Ley Foon Tan March 12, 2019, 8:31 a.m. UTC
Setup bi_dram struct based on returned from setup_memory_banks().

Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
---
 arch/arm/mach-socfpga/board.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Comments

Marek Vasut March 12, 2019, 10:45 a.m. UTC | #1
On 3/12/19 9:31 AM, Ley Foon Tan wrote:
> Setup bi_dram struct based on returned from setup_memory_banks().
> 
> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> ---
>  arch/arm/mach-socfpga/board.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-socfpga/board.c b/arch/arm/mach-socfpga/board.c
> index 7c8c05cc31..a0e9917e47 100644
> --- a/arch/arm/mach-socfpga/board.c
> +++ b/arch/arm/mach-socfpga/board.c
> @@ -12,6 +12,7 @@
>  #include <asm/arch/clock_manager.h>
>  #include <asm/arch/misc.h>
>  #include <asm/io.h>
> +#include <asm/arch/sdram.h>
>  
>  #include <usb.h>
>  #include <usb/dwc2_udc.h>
> @@ -48,8 +49,21 @@ int board_init(void)
>  
>  int dram_init_banksize(void)
>  {
> -	fdtdec_setup_memory_banksize();
> +#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10) && defined(CONFIG_ALTERA_SDRAM)
> +	phys_addr_t bank_start[CONFIG_NR_DRAM_BANKS];
> +	phys_size_t bank_size[CONFIG_NR_DRAM_BANKS];
> +	int bank;
> +
> +	gd->ram_size = sdram_calculate_size();
> +	setup_memory_banks(bank_start, bank_size);
>  
> +	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
> +		gd->bd->bi_dram[bank].start = bank_start[bank];
> +		gd->bd->bi_dram[bank].size = bank_size[bank];
> +	}
> +#else
> +	fdtdec_setup_memory_banksize();
> +#endif
>  	return 0;
>  }

Split this out into separate file if this really needs to be different,
but can't you somehow use fdtdec_setup_memory_size() on S10 and then
apply sanity checking instead ?
Westergreen, Dalon March 12, 2019, 2:25 p.m. UTC | #2
On Tue, 2019-03-12 at 11:45 +0100, Marek Vasut wrote:
> On 3/12/19 9:31 AM, Ley Foon Tan wrote:
> > Setup bi_dram struct based on returned from setup_memory_banks().
> > 
> > Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> > ---
> >  arch/arm/mach-socfpga/board.c | 16 +++++++++++++++-
> >  1 file changed, 15 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm/mach-socfpga/board.c b/arch/arm/mach-socfpga/board.c
> > index 7c8c05cc31..a0e9917e47 100644
> > --- a/arch/arm/mach-socfpga/board.c
> > +++ b/arch/arm/mach-socfpga/board.c
> > @@ -12,6 +12,7 @@
> >  #include <asm/arch/clock_manager.h>
> >  #include <asm/arch/misc.h>
> >  #include <asm/io.h>
> > +#include <asm/arch/sdram.h>
> >  
> >  #include <usb.h>
> >  #include <usb/dwc2_udc.h>
> > @@ -48,8 +49,21 @@ int board_init(void)
> >  
> >  int dram_init_banksize(void)
> >  {
> > -	fdtdec_setup_memory_banksize();
> > +#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10) &&
> > defined(CONFIG_ALTERA_SDRAM)
> > +	phys_addr_t bank_start[CONFIG_NR_DRAM_BANKS];
> > +	phys_size_t bank_size[CONFIG_NR_DRAM_BANKS];
> > +	int bank;
> > +
> > +	gd->ram_size = sdram_calculate_size();
> > +	setup_memory_banks(bank_start, bank_size);
> >  
> > +	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
> > +		gd->bd->bi_dram[bank].start = bank_start[bank];
> > +		gd->bd->bi_dram[bank].size = bank_size[bank];
> > +	}
> > +#else
> > +	fdtdec_setup_memory_banksize();
> > +#endif
> >  	return 0;
> >  }
> 
> Split this out into separate file if this really needs to be different,
> but can't you somehow use fdtdec_setup_memory_size() on S10 and then
> apply sanity checking instead ?
> 
yes, this can be done with fdtdec_setup_memory_size.

--dalon
diff mbox series

Patch

diff --git a/arch/arm/mach-socfpga/board.c b/arch/arm/mach-socfpga/board.c
index 7c8c05cc31..a0e9917e47 100644
--- a/arch/arm/mach-socfpga/board.c
+++ b/arch/arm/mach-socfpga/board.c
@@ -12,6 +12,7 @@ 
 #include <asm/arch/clock_manager.h>
 #include <asm/arch/misc.h>
 #include <asm/io.h>
+#include <asm/arch/sdram.h>
 
 #include <usb.h>
 #include <usb/dwc2_udc.h>
@@ -48,8 +49,21 @@  int board_init(void)
 
 int dram_init_banksize(void)
 {
-	fdtdec_setup_memory_banksize();
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10) && defined(CONFIG_ALTERA_SDRAM)
+	phys_addr_t bank_start[CONFIG_NR_DRAM_BANKS];
+	phys_size_t bank_size[CONFIG_NR_DRAM_BANKS];
+	int bank;
+
+	gd->ram_size = sdram_calculate_size();
+	setup_memory_banks(bank_start, bank_size);
 
+	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
+		gd->bd->bi_dram[bank].start = bank_start[bank];
+		gd->bd->bi_dram[bank].size = bank_size[bank];
+	}
+#else
+	fdtdec_setup_memory_banksize();
+#endif
 	return 0;
 }