From: Michal Simek Date: Tue, 22 Nov 2016 12:00:23 +0100 Subject: [U-Boot] [PATCH] board: topic: Detect RAM size at boot In-Reply-To: <1479717007-20170-1-git-send-email-mike.looijmans@topic.nl> References: <1479717007-20170-1-git-send-email-mike.looijmans@topic.nl> Message-ID: <58e539bf-35a4-5a5d-330b-7ff0f2da17f2@monstr.eu> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 21.11.2016 09:30, Mike Looijmans wrote: > Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent requiring > separate bootloaders for each variant, just detect the RAM size at boot time > instead of relying on the devicetree information. > > Signed-off-by: Mike Looijmans > --- > board/topic/zynq/board.c | 39 +++++++++++++++++++++++++++++++++++++++ > configs/topic_miami_defconfig | 1 + > configs/topic_miamiplus_defconfig | 1 + > 3 files changed, 41 insertions(+) > > diff --git a/board/topic/zynq/board.c b/board/topic/zynq/board.c > index a95c9d1..8a5765e 100644 > --- a/board/topic/zynq/board.c > +++ b/board/topic/zynq/board.c > @@ -1 +1,40 @@ > +/* > + * (C) Copyright 2016 Topic Embedded Products > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +/* > + * Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent needing > + * separate bootloaders for each variant, just detect the RAM size at boot time > + * instead of relying on the devicetree information. > + */ > +#define CONFIG_SYS_SDRAM_BASE 0 > +#define CONFIG_SYS_SDRAM_SIZE topic_get_sdram_size() I am not happy with this but I see where you go. > +#define CONFIG_SYS_SDRAM_SIZE_MAX 0x40000000u > + > +static unsigned int topic_get_sdram_size(void); > + > #include "../../xilinx/zynq/board.c" > + > +#include > + > +int ft_board_setup(void *blob, bd_t *bd) > +{ > + fdt_fixup_memory(blob, (u64)CONFIG_SYS_SDRAM_BASE, (u64)gd->ram_size); > + > + return 0; > +} This action is taken at arch_fixup_fdt(). Can you please confirm that this is really needed? And it is not done there? That you don't duplicate stuff here. > + > +void dram_init_banksize(void) > +{ > + gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; > + gd->bd->bi_dram[0].size = gd->ram_size; > +} This should be fine. > + > +unsigned int topic_get_sdram_size(void) > +{ > + /* Detect and fix ram size */ > + return get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, > + CONFIG_SYS_SDRAM_SIZE_MAX); In the first look I didn't know that get_ram_size is u-boot function for memsize detection. Thanks, Michal -- Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature URL: