summaryrefslogtreecommitdiff
path: root/arch/arm/mach-owl
diff options
context:
space:
mode:
authorAmit Singh Tomar <amittomer25@gmail.com>2020-05-09 11:15:07 +0300
committerTom Rini <trini@konsulko.com>2020-07-07 23:09:22 +0300
commit3ca564e96e90a4714147262c9d201e077ef54a26 (patch)
tree5999e0b77f86cf6128cd5ab5ed0aaae4401f268a /arch/arm/mach-owl
parent26073f9ed3ab0aaf3c2a2b433fecb30a95a067d6 (diff)
downloadu-boot-3ca564e96e90a4714147262c9d201e077ef54a26.tar.xz
Actions: OWL: Calculate SDRAM size
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@gmail.com> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Diffstat (limited to 'arch/arm/mach-owl')
-rw-r--r--arch/arm/mach-owl/soc.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/arch/arm/mach-owl/soc.c b/arch/arm/mach-owl/soc.c
index 7d3f6f6285..fd6ee7c1c0 100644
--- a/arch/arm/mach-owl/soc.c
+++ b/arch/arm/mach-owl/soc.c
@@ -15,14 +15,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;
}