[PATCH v4] ARM: rpi: parse memory from vc fdt
Johannes Schneider
johannes.schneider at leica-geosystems.com
Wed Jan 11 03:36:29 PST 2023
From: Marcin Niestroj <m.niestroj at emb.dev>
Currently for RaspberryPi platform there is only one memory bank
created, based on information fetched over mailbox. This is fine for
booting Barebox, but unfortunately all the other memory banks are not
propagated to Linux during boot, thus cannot be utilized. In fact, even
when using /vc.dtb as device-tree for Linux, all memory nodes in FDT are
deleted and new ones are created by Barebox by memory fixup mechanism,
using exising RAM information. As a result RaspberryPi 4 boots Linux
with 1GB RAM available, instead of 2GB (2 banks, each 1GB).
At the end of VideoCore FDT parsing, do the same as of_probe_memory() in
mem_initcall does, but for VideoCore provided devicetree/memory
information. During Linux boot this information is used for memory fixup
mechanism and in case of RaspberryPi 4 this results in 2 memory banks
being propagated:
# ls /proc/device-tree/memory*
/proc/device-tree/memory at 0:
device_type name reg
/proc/device-tree/memory at 40000000:
device_type name reg
Signed-off-by: Marcin Niestroj <m.niestroj at emb.dev>
Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
Link: https://lore.barebox.org/20230110193251.2821638-1-m.niestroj@grinn-global.com
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
arch/arm/boards/raspberry-pi/rpi-common.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index 77935e5c88..c6c7fd52bd 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -258,7 +258,7 @@ static u32 rpi_boot_mode, rpi_boot_part;
static void rpi_vc_fdt_parse(void *fdt)
{
int ret;
- struct device_node *root, *chosen, *bootloader;
+ struct device_node *root, *chosen, *bootloader, *memory;
char *str;
root = of_unflatten_dtb(fdt, INT_MAX);
@@ -324,6 +324,16 @@ static void rpi_vc_fdt_parse(void *fdt)
if (IS_ENABLED(CONFIG_RESET_SOURCE))
reset_source_set(rpi_decode_pm_rsts(chosen, bootloader));
+ /* Parse all available nodes with "memory" device_type */
+ memory = root;
+ while (1) {
+ memory = of_find_node_by_type(memory, "memory");
+ if (!memory)
+ break;
+
+ of_add_memory(memory, false);
+ }
+
out:
if (root)
of_delete_node(root);
--
2.25.1
More information about the barebox
mailing list