Message ID | 1589012108-11064-2-git-send-email-amittomer25@gmail.com |
---|---|
State | Accepted |
Commit | 3ca564e96e90a4714147262c9d201e077ef54a26 |
Headers | show |
Series | Calculate SDRAM size for Actions OWL SoCs | expand |
On Sat, May 09, 2020 at 01:45:07PM +0530, Amit Singh Tomar wrote: > Calculate the SDRAM size from DDR capacity register registers instead > of using hard-coded value. This is quite useful to get correct size > on differnt boards based on Actions OWL family of SoCs (S700 and S900). > > There is no documentation available that talks about DDR registers, and > this is very much taken from vendor source. > > This commit lets Linux boot on Cubieboard7-lite(based on S700). > > Signed-off-by: Amit Singh Tomar <amittomer25 at gmail.com> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam at linaro.org> Thanks, Mani > --- > Changes since v3: > * Fixed S900 support as suggested by Mani. > * Changes the function name to owl_get_ddrcap. > Changes since v2: > * Fixed the variable name so that it can compile > for S900. > Changes since v1: > * added support for S900 > * updated the commit message to reflect common OWL > support. > --- > arch/arm/mach-owl/soc.c | 22 +++++++++++++++++++++- > 1 file changed, 21 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/mach-owl/soc.c b/arch/arm/mach-owl/soc.c > index 409cbd319f20..fcf61d39b63a 100644 > --- a/arch/arm/mach-owl/soc.c > +++ b/arch/arm/mach-owl/soc.c > @@ -13,14 +13,34 @@ > #include <asm/mach-types.h> > #include <asm/psci.h> > > +#define DMM_INTERLEAVE_PER_CH_CFG 0xe0290028 > + > DECLARE_GLOBAL_DATA_PTR; > > +unsigned int owl_get_ddrcap(void) > +{ > + unsigned int val, cap; > + > + /* ddr capacity register initialized by ddr driver > + * in early bootloader > + */ > +#if defined(CONFIG_MACH_S700) > + val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0x7; > + cap = (val + 1) * 256; > +#elif defined(CONFIG_MACH_S900) > + val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0xf; > + cap = 64 * (1 << val); > +#endif > + > + return cap; > +} > + > /* > * dram_init - sets uboots idea of sdram size > */ > int dram_init(void) > { > - gd->ram_size = CONFIG_SYS_SDRAM_SIZE; > + gd->ram_size = owl_get_ddrcap() * 1024 * 1024; > return 0; > } > > -- > 2.7.4 >
diff --git a/arch/arm/mach-owl/soc.c b/arch/arm/mach-owl/soc.c index 409cbd319f20..fcf61d39b63a 100644 --- a/arch/arm/mach-owl/soc.c +++ b/arch/arm/mach-owl/soc.c @@ -13,14 +13,34 @@ #include <asm/mach-types.h> #include <asm/psci.h> +#define DMM_INTERLEAVE_PER_CH_CFG 0xe0290028 + DECLARE_GLOBAL_DATA_PTR; +unsigned int owl_get_ddrcap(void) +{ + unsigned int val, cap; + + /* ddr capacity register initialized by ddr driver + * in early bootloader + */ +#if defined(CONFIG_MACH_S700) + val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0x7; + cap = (val + 1) * 256; +#elif defined(CONFIG_MACH_S900) + val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0xf; + cap = 64 * (1 << val); +#endif + + return cap; +} + /* * dram_init - sets uboots idea of sdram size */ int dram_init(void) { - gd->ram_size = CONFIG_SYS_SDRAM_SIZE; + gd->ram_size = owl_get_ddrcap() * 1024 * 1024; return 0; }
Calculate the SDRAM size from DDR capacity register registers instead of using hard-coded value. This is quite useful to get correct size on differnt boards based on Actions OWL family of SoCs (S700 and S900). There is no documentation available that talks about DDR registers, and this is very much taken from vendor source. This commit lets Linux boot on Cubieboard7-lite(based on S700). Signed-off-by: Amit Singh Tomar <amittomer25 at gmail.com> --- Changes since v3: * Fixed S900 support as suggested by Mani. * Changes the function name to owl_get_ddrcap. Changes since v2: * Fixed the variable name so that it can compile for S900. Changes since v1: * added support for S900 * updated the commit message to reflect common OWL support. --- arch/arm/mach-owl/soc.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)