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 7/9] ARM: rockchip: dmc: add rk3588_ram_sizes to get full ram size
Date: Wed, 28 May 2025 16:11:25 +0200 [thread overview]
Message-ID: <20250528-rk3588-optee-v2-7-63070238dd13@pengutronix.de> (raw)
In-Reply-To: <20250528-rk3588-optee-v2-0-63070238dd13@pengutronix.de>
The PBL has to pass a full description of the SDRAM to OP-TEE to allow
OP-TEE to handle dynamic shared memory in the entire SDRAM. Thus, the
PBL needs to read the full memory configuration.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
Changes in v2:
- none
---
arch/arm/mach-rockchip/dmc.c | 37 ++++++++++++++++++++++++++++++++++---
include/mach/rockchip/dmc.h | 2 ++
2 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-rockchip/dmc.c b/arch/arm/mach-rockchip/dmc.c
index 62a7ef8f1e38e989e84f08f6f4a6586be3e85532..260b8be9c7da9e8f83323822eab92a439ef4e2ef 100644
--- a/arch/arm/mach-rockchip/dmc.c
+++ b/arch/arm/mach-rockchip/dmc.c
@@ -171,11 +171,12 @@ resource_size_t rk3568_ram0_size(void)
#define RK3588_PMUGRF_OS_REG4 0x210
#define RK3588_PMUGRF_OS_REG5 0x214
-resource_size_t rk3588_ram0_size(void)
+size_t rk3588_ram_sizes(phys_addr_t *base, resource_size_t *size, size_t n)
{
void __iomem *pmugrf = IOMEM(RK3588_PMUGRF_BASE);
u32 sys_reg2, sys_reg3, sys_reg4, sys_reg5;
- resource_size_t size, size1, size2;
+ resource_size_t memsize, size1, size2;
+ size_t i = 0;
sys_reg2 = readl(pmugrf + RK3588_PMUGRF_OS_REG2);
sys_reg3 = readl(pmugrf + RK3588_PMUGRF_OS_REG3);
@@ -187,7 +188,37 @@ resource_size_t rk3588_ram0_size(void)
pr_info("%s() size1 = 0x%08llx, size2 = 0x%08llx\n", __func__, (u64)size1, (u64)size2);
- size = min_t(resource_size_t, RK3588_INT_REG_START, size1 + size2);
+ memsize = size1 + size2;
+
+ base[i] = 0xa00000;
+ size[i] = min_t(resource_size_t, RK3588_INT_REG_START, memsize) - 0xa00000;
+ i++;
+
+ if (i < n && memsize > SZ_4G) {
+ base[i] = SZ_4G;
+ size[i] = min_t(unsigned long, DRAM_GAP1_START, memsize) - SZ_4G;
+ i++;
+ }
+ if (i < n && memsize > DRAM_GAP1_END) {
+ base[i] = DRAM_GAP1_END;
+ size[i] = min_t(unsigned long, DRAM_GAP2_START, memsize) - DRAM_GAP1_END;
+ i++;
+ }
+ if (i < n && memsize > DRAM_GAP2_END) {
+ base[i] = DRAM_GAP2_END;
+ size[i] = memsize - DRAM_GAP2_END;
+ i++;
+ }
+
+ return i;
+}
+
+resource_size_t rk3588_ram0_size(void)
+{
+ phys_addr_t base;
+ resource_size_t size;
+
+ rk3588_ram_sizes(&base, &size, 1);
return size;
}
diff --git a/include/mach/rockchip/dmc.h b/include/mach/rockchip/dmc.h
index 3df9aa5e9c87857e9ac3994e0e40c60d8c91b0a4..bb5a5afd02417920446c729b96eeb90f1fa0ead0 100644
--- a/include/mach/rockchip/dmc.h
+++ b/include/mach/rockchip/dmc.h
@@ -87,4 +87,6 @@ resource_size_t rk3399_ram0_size(void);
resource_size_t rk3568_ram0_size(void);
resource_size_t rk3588_ram0_size(void);
+size_t rk3588_ram_sizes(phys_addr_t *base, resource_size_t *size, size_t n);
+
#endif
--
2.39.5
next prev parent 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 [PATCH v2 0/9] ARM: rockchip: fix dynamic shared memory in OP-TEE Michael Tretter
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 ` Michael Tretter [this message]
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-7-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