[PATCH v2 07/11] driver: always ensure probe of RAM registered with mem_platform_driver

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Jan 9 05:08:18 PST 2023


Normally, SDRAM controllers are already set up by the time barebox
proper runs. The function of SDRAM controller drivers is thus limited
to reading out configured SDRAM size and registering the result as a
barebox memory bank.

This needs to happen before MMU setup, so the whole of RAM can be
initially mapped cacheable. Therefore, probe order is enforced either
via initcall level or via of_devices_ensure_probed_by_dev_id on
deep-probe-enabled systems. We have this opencoded at two places
and instead of adding a third, just rewrite mem_platform_driver
to do the expected thing.

Acked-by: Sam Ravnborg <sam at ravnborg.org>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 include/driver.h | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/driver.h b/include/driver.h
index 693d5cb3e580..0ea5799d0dfb 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -442,13 +442,22 @@ int platform_driver_register(struct driver *drv);
 	register_driver_macro(device,platform,drv)
 #define console_platform_driver(drv)	\
 	register_driver_macro(console,platform,drv)
-#define mem_platform_driver(drv)	\
-	register_driver_macro(mem,platform,drv)
 #define fs_platform_driver(drv)	\
 	register_driver_macro(fs,platform,drv)
 #define late_platform_driver(drv)	\
 	register_driver_macro(late,platform,drv)
 
+#define mem_platform_driver(drv)						\
+	static int __init drv##_init(void)					\
+	{									\
+		int ret;							\
+		ret = platform_driver_register(&drv);				\
+		if (ret)							\
+			return ret;						\
+		return of_devices_ensure_probed_by_dev_id(drv.of_compatible);	\
+	}									\
+	mem_initcall(drv##_init);
+
 int platform_device_register(struct device *new_device);
 
 struct cdev_operations {
-- 
2.30.2




More information about the barebox mailing list