From: Michael Tretter <m.tretter@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Marco Felsch <m.felsch@pengutronix.de>
Cc: Michael Tretter <m.tretter@pengutronix.de>
Subject: [PATCH v2 0/9] ARM: rockchip: fix dynamic shared memory in OP-TEE
Date: Wed, 28 May 2025 16:11:18 +0200 [thread overview]
Message-ID: <20250528-rk3588-optee-v2-0-63070238dd13@pengutronix.de> (raw)
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, barebox must add some extra space for fdt
modification. OP-TEE has CFG_DTB_MAX_SIZE as limit, which is the minimum
amount of space that must be reserved by barebox. The
ARCH_ROCKCHIP_ATF_FDT_SIZE option allows to configure this size as
minimum Rockchip machines.
If the device tree fixup function finds memory nodes with the detected
addresses, it ensures that the nodes have the correct size and are
enabled. If a matching memory node is missing from the device tree, it
adds a new node.
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 5 extend the libfdt integration with helpers to modify and
add memory dt nodes.
Patch 6 introduces CONFIG_SCRATCH_SIZE to configure the size of the
arm_mem_scratch area.
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.tretter@pengutronix.de>
---
Changes in v2:
- pass a copy of fdt in scratch space instead of original fdt to TF-A
- drop config option to reserve space in dtb
- change fdt_fixup_mem to possibly update existing memory nodes
- Link to v1: https://lore.kernel.org/r/20250526-rk3588-optee-v1-0-5004995cbd03@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: add fdt_fixup_mem to fixup memory nodes
ARM: add CONFIG_SCRATCH_SIZE
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
Documentation/boards/rockchip.rst | 4 ++
arch/arm/include/asm/barebox-arm.h | 4 +-
arch/arm/mach-rockchip/Kconfig | 23 +++++++++
arch/arm/mach-rockchip/atf.c | 69 +++++++++++++++++----------
arch/arm/mach-rockchip/dmc.c | 37 +++++++++++++--
common/Kconfig | 5 ++
include/asm-generic/memory_layout.h | 1 +
include/mach/rockchip/bootrom.h | 3 ++
include/mach/rockchip/dmc.h | 2 +
include/pbl.h | 1 +
lib/Makefile | 2 +-
lib/fdt_addresses.c | 4 ++
pbl/fdt.c | 93 +++++++++++++++++++++++++++++++++----
13 files changed, 209 insertions(+), 39 deletions(-)
---
base-commit: fb35d7a2fe800260ca1ce2e189731e48ccefcf7b
change-id: 20250515-rk3588-optee-08cc33320963
Best regards,
--
Michael Tretter <m.tretter@pengutronix.de>
next reply other threads:[~2025-05-28 14:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-28 14:11 Michael Tretter [this message]
2025-05-28 14:11 ` [PATCH v2 1/9] ARM: rockchip: fix formatting Michael Tretter
2025-05-28 14:11 ` [PATCH v2 2/9] ARM: rockchip: dmc: use RK3588_INT_REG_START for rk3588 Michael Tretter
2025-05-28 14:11 ` [PATCH v2 3/9] lib: fdt: add fdt_addresses Michael Tretter
2025-05-28 14:11 ` [PATCH v2 4/9] PBL: fdt: refactor helper for reading nr of cells Michael Tretter
2025-05-28 14:11 ` [PATCH v2 5/9] PBL: fdt: add fdt_fixup_mem to fixup memory nodes Michael Tretter
2025-05-28 14:11 ` [PATCH v2 6/9] ARM: add CONFIG_SCRATCH_SIZE Michael Tretter
2025-05-28 15:34 ` Marco Felsch
2025-05-28 14:11 ` [PATCH v2 7/9] ARM: rockchip: dmc: add rk3588_ram_sizes to get full ram size Michael Tretter
2025-05-28 14:11 ` [PATCH v2 8/9] ARM: rockchip: pass device tree to TF-A Michael Tretter
2025-05-28 15:39 ` Marco Felsch
2025-05-28 14:11 ` [PATCH v2 9/9] ARM: rockchip: fixup memory in device tree for TF-A Michael Tretter
2025-05-28 15:40 ` Marco Felsch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250528-rk3588-optee-v2-0-63070238dd13@pengutronix.de \
--to=m.tretter@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=m.felsch@pengutronix.de \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox