[PATCH 2/9] ram: rockchip: rk3588: Simplify get_info() ops

Jonas Karlman <[email protected]> Tue, 4 Aug 2026 10:57:11 +0000
Newsgroups gmane.comp.boot-loaders.u-boot
Message-ID <[email protected]>
The PMU1GRF base address is fixed and known at compile time. However,
the base address is read from DT at runtime in this driver, delaying
reading the four HW regs to determine RAM size by several ms.

Change to use a constant for the PMU1GRF base address to speed up
reading RAM size and simplify the driver by removing use of probe and
private data. The driver list entry name is also renamed to match the
compatible, for possible use with OF_PLATDATA.

Signed-off-by: Jonas Karlman <[email protected]>
---
 drivers/ram/rockchip/sdram_rk3588.c | 31 ++++++-----------------------
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/drivers/ram/rockchip/sdram_rk3588.c b/drivers/ram/rockchip/sdram_rk3588.c
index a144b432d76f..c572f602630a 100644
--- a/drivers/ram/rockchip/sdram_rk3588.c
+++ b/drivers/ram/rockchip/sdram_rk3588.c
@@ -3,37 +3,20 @@
  * (C) Copyright 2021 Rockchip Electronics Co., Ltd.
  */
 
-#include <config.h>
 #include <dm.h>
 #include <ram.h>
-#include <syscon.h>
-#include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/grf_rk3588.h>
 #include <asm/arch-rockchip/sdram.h>
 
-struct dram_info {
-	struct ram_info info;
-	struct rk3588_pmu1grf *pmugrf;
-};
-
-static int rk3588_dmc_probe(struct udevice *dev)
-{
-	struct dram_info *priv = dev_get_priv(dev);
-
-	priv->pmugrf = syscon_get_first_range(ROCKCHIP_SYSCON_PMUGRF);
-	priv->info.base = CFG_SYS_SDRAM_BASE;
-	priv->info.size =
-		rockchip_sdram_size((phys_addr_t)&priv->pmugrf->os_reg[2]) +
-		rockchip_sdram_size((phys_addr_t)&priv->pmugrf->os_reg[4]);
-
-	return 0;
-}
+#define PMU1GRF_BASE			0xfd58a000
 
 static int rk3588_dmc_get_info(struct udevice *dev, struct ram_info *info)
 {
-	struct dram_info *priv = dev_get_priv(dev);
+	static struct rk3588_pmu1grf * const pmugrf = (void *)PMU1GRF_BASE;
 
-	*info = priv->info;
+	info->base = CFG_SYS_SDRAM_BASE;
+	info->size = rockchip_sdram_size((phys_addr_t)&pmugrf->os_reg[2]) +
+		     rockchip_sdram_size((phys_addr_t)&pmugrf->os_reg[4]);
 
 	return 0;
 }
@@ -47,11 +30,9 @@ static const struct udevice_id rk3588_dmc_ids[] = {
 	{ }
 };
 
-U_BOOT_DRIVER(dmc_rk3588) = {
+U_BOOT_DRIVER(rockchip_rk3588_dmc) = {
 	.name = "rockchip_rk3588_dmc",
 	.id = UCLASS_RAM,
 	.of_match = rk3588_dmc_ids,
 	.ops = &rk3588_dmc_ops,
-	.probe = rk3588_dmc_probe,
-	.priv_auto = sizeof(struct dram_info),
 };
-- 
2.54.0