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

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Dec 14 02:58:27 PST 2022


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.

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 2386949c312a..f6d99d26454c 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -439,13 +439,22 @@ int platform_driver_register(struct driver_d *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_d *new_device);
 
 struct cdev_operations {
-- 
2.30.2




More information about the barebox mailing list