From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Tue, 20 Nov 2018 13:04:08 +0100 Subject: [U-Boot] [PATCH u-boot-marvell v3 09/10] board: turris_mox: Support 1 GB version of Turris Mox In-Reply-To: <20181120120409.12822-1-marek.behun@nic.cz> References: <20181120120409.12822-1-marek.behun@nic.cz> Message-ID: <20181120120409.12822-9-marek.behun@nic.cz> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Depending on the data in the OTP memory, differentiate between the 512 MiB and 1 GiB versions of Turris Mox and report these RAM sizes in dram_init and dram_init_banksize. Signed-off-by: Marek Beh=C3=BAn --- arch/arm/mach-mvebu/arm64-common.c | 7 ++++++- board/CZ.NIC/turris_mox/turris_mox.c | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-mvebu/arm64-common.c b/arch/arm/mach-mvebu/arm64= -common.c index f47273fde9..5e6ac9fc4a 100644 --- a/arch/arm/mach-mvebu/arm64-common.c +++ b/arch/arm/mach-mvebu/arm64-common.c @@ -43,8 +43,12 @@ const struct mbus_dram_target_info *mvebu_mbus_dram_info= (void) return NULL; } =20 -/* DRAM init code ... */ +/* + * DRAM init code ... + * Turris Mox defines this itself, depending on data in burned eFuses + */ =20 +#ifndef CONFIG_TARGET_TURRIS_MOX int dram_init_banksize(void) { fdtdec_setup_memory_banksize(); @@ -59,6 +63,7 @@ int dram_init(void) =20 return 0; } +#endif /* !CONFIG_TARGET_TURRIS_MOX */ =20 int arch_cpu_init(void) { diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox= /turris_mox.c index 89b3cd2ce0..9aa2fc004d 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -14,6 +14,7 @@ #include #include #include +#include =20 #ifdef CONFIG_WDT_ARMADA_37XX #include @@ -40,6 +41,32 @@ =20 DECLARE_GLOBAL_DATA_PTR; =20 +int dram_init(void) +{ + int ret, ram_size; + + gd->ram_base =3D 0; + gd->ram_size =3D (phys_size_t)0x20000000; + + ret =3D mbox_sp_get_board_info(NULL, NULL, NULL, NULL, &ram_size); + if (ret < 0) { + puts("Cannot read RAM size from OTP, defaulting to 512 MiB"); + } else { + if (ram_size =3D=3D 1024) + gd->ram_size =3D (phys_size_t)0x40000000; + } + + return 0; +} + +int dram_init_banksize(void) +{ + gd->bd->bi_dram[0].start =3D (phys_addr_t)0; + gd->bd->bi_dram[0].size =3D gd->ram_size; + + return 0; +} + #if defined(CONFIG_OF_BOARD_FIXUP) int board_fix_fdt(void *blob) { --=20 2.18.1