On rk3588, OP-TEE uses the device tree to detect the available SDRAM that should be used for dynamic shared memory. Since the amount of SDRAM is detected during boot, the rk3588 device tree doesn't contain memory nodes. Therefore, barebox has to detect the memory and add memory nodes the device tree in the PBL before passing the device tree to the TF-A, which passes it on to OP-TEE.
Adding nodes to the fdt increases the size of the fdt. As OP-TEE also modifies and extends the passed device tree, the fdt grows even further in OP-TEE. Therefore, there must be some extra reserved space in the fdt. OP-TEE has CFG_DTB_MAX_SIZE as limit, which is the minimum amount of space that must be reserved by barebox. The PBL_FDT_MIN_SIZE option allows to configure this size as minimum. I thought about adding disabled memory nodes to the dts and enabling/fixing the existing nodes instead of adding new nodes. Finding and fixing the correct existing node turned out to be more complex than adding a new node. As we have to reserve some space in the fdt for OP-TEE anyway, adding new nodes looks like the better solution. The downstream TF-A may crash if barebox passes a device tree to it. barebox cannot detect, if the loaded TF-A is downstream or upstream. Therefore, add a config item to enable passing the device tree. Patches 1 and 2 are some cleanup as preparation for actual changes. Patches 3 to 6 extend the libfdt integration with helpers to modify and add memory dt nodes. Patches 7 to 9 add the rockchip specific code to read the memory size from the DRAM controller, add memory dt nodes to the fdt, and pass the fdt to the TF-A and OP-TEE. Signed-off-by: Michael Tretter <m.tret...@pengutronix.de> --- Michael Tretter (9): ARM: rockchip: fix formatting ARM: rockchip: dmc: use RK3588_INT_REG_START for rk3588 lib: fdt: add fdt_addresses PBL: fdt: refactor helper for reading nr of cells PBL: fdt: make minimum fdt size configurable PBL: fdt: add fdt_fixup_mem to fixup memory nodes ARM: rockchip: dmc: add rk3588_ram_sizes to get full ram size ARM: rockchip: pass device tree to TF-A ARM: rockchip: fixup memory in device tree for TF-A arch/arm/mach-rockchip/Kconfig | 13 +++++++ arch/arm/mach-rockchip/atf.c | 62 ++++++++++++++++++------------ arch/arm/mach-rockchip/dmc.c | 37 ++++++++++++++++-- include/mach/rockchip/dmc.h | 2 + include/pbl.h | 1 + lib/Makefile | 2 +- lib/fdt_addresses.c | 4 ++ pbl/Kconfig | 12 ++++++ pbl/fdt.c | 86 +++++++++++++++++++++++++++++++++++++----- scripts/Makefile.lib | 2 + 10 files changed, 184 insertions(+), 37 deletions(-) --- base-commit: fb35d7a2fe800260ca1ce2e189731e48ccefcf7b change-id: 20250515-rk3588-optee-08cc33320963 Best regards, -- Michael Tretter <m.tret...@pengutronix.de>