From patchwork Sat May 9 07:03:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Tomer X-Patchwork-Id: 245327 List-Id: U-Boot discussion From: amittomer25 at gmail.com (Amit Singh Tomar) Date: Sat, 9 May 2020 12:33:37 +0530 Subject: [PATCH v3 1/2] Actions: OWL: Calculate SDRAM size In-Reply-To: <1589007818-16383-1-git-send-email-amittomer25@gmail.com> References: <1589007818-16383-1-git-send-email-amittomer25@gmail.com> Message-ID: <1589007818-16383-2-git-send-email-amittomer25@gmail.com> 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 --- 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 | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-owl/soc.c b/arch/arm/mach-owl/soc.c index 409cbd319f20..2b2b0226cdb2 100644 --- a/arch/arm/mach-owl/soc.c +++ b/arch/arm/mach-owl/soc.c @@ -13,15 +13,40 @@ #include #include +#define DMM_INTERLEAVE_BASE (0xe0290020) +#define DMM_INTERLEAVE_PER_CH_CFG (DMM_INTERLEAVE_BASE + 0x08) +#define DMM_MASTER_READ_TO (DMM_INTERLEAVE_BASE + 0x48) + DECLARE_GLOBAL_DATA_PTR; +unsigned int get_owl_ram_size(void) +{ + __maybe_unused unsigned int val, cap, channel, channel_num; + + /* 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) + channel_num = (readl(DMM_INTERLEAVE_BASE) >> 24) & 0xf; + channel = (channel_num >= 3) ? 1 : 0; + val = (readl(DMM_MASTER_READ_TO)) & 0xf; + cap = ((val + 1) << channel) * 256; +#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 = get_owl_ram_size() * 1024 * 1024; return 0; + } /* This is called after dram_init() so use get_ram_size result */ From patchwork Sat May 9 07:03:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Tomer X-Patchwork-Id: 245328 List-Id: U-Boot discussion From: amittomer25 at gmail.com (Amit Singh Tomar) Date: Sat, 9 May 2020 12:33:38 +0530 Subject: [PATCH v3 2/2] arm: actions: remove "CONFIG_SYS_SDRAM_SIZE" for Actions Owl Semi SoCs In-Reply-To: <1589007818-16383-1-git-send-email-amittomer25@gmail.com> References: <1589007818-16383-1-git-send-email-amittomer25@gmail.com> Message-ID: <1589007818-16383-3-git-send-email-amittomer25@gmail.com> Now that, we calculate SDRAM size by reading DDR registers, "CONFIG_SYS_SDRAM_SIZE" is no more needed. This commit removes "CONFIG_SYS_SDRAM_SIZE" from common configuration file. Signed-off-by: Amit Singh Tomar --- * No change from previous versions. --- include/configs/owl-common.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/configs/owl-common.h b/include/configs/owl-common.h index f77a5fa4c114..7634578f856d 100644 --- a/include/configs/owl-common.h +++ b/include/configs/owl-common.h @@ -12,7 +12,6 @@ /* SDRAM Definitions */ #define CONFIG_SYS_SDRAM_BASE 0x0 -#define CONFIG_SYS_SDRAM_SIZE 0x80000000 /* Generic Timer Definitions */ #define COUNTER_FREQUENCY (24000000) /* 24MHz */