mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 07/11] driver: always ensure probe of RAM registered with mem_platform_driver
Date: Wed, 14 Dec 2022 11:58:27 +0100	[thread overview]
Message-ID: <20221214105831.844421-8-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20221214105831.844421-1-a.fatoum@pengutronix.de>

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@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




  parent reply	other threads:[~2022-12-14 10:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14 10:58 [PATCH 00/11] ARM: at91: sama5d4: add basic Wifx L1 support Ahmad Fatoum
2022-12-14 10:58 ` [PATCH 01/11] ARM: at91: sama5: switch to nonnaked entry functions Ahmad Fatoum
2022-12-16  6:49   ` Sascha Hauer
2022-12-14 10:58 ` [PATCH 02/11] ARM: at91: sama5d4: add entry point helpers Ahmad Fatoum
2022-12-14 10:58 ` [PATCH 03/11] ARM: at91: sama5d4: enable for DT use Ahmad Fatoum
2022-12-14 10:58 ` [PATCH 04/11] net: macb: match atmel,sama5d4-gem compatible Ahmad Fatoum
2022-12-14 10:58 ` [PATCH 05/11] i2c: at91: extend for SAMA5D4 support Ahmad Fatoum
2022-12-14 10:58 ` [PATCH 06/11] eeprom: at24: add 24mac402/602 support Ahmad Fatoum
2022-12-14 10:58 ` Ahmad Fatoum [this message]
2022-12-14 10:58 ` [PATCH 08/11] common: deep-probe: don't build without CONFIG_OFDEVICE Ahmad Fatoum
2022-12-14 10:58 ` [PATCH 09/11] pinctrl: at91: make deep-probe compatible Ahmad Fatoum
2022-12-14 10:58 ` [PATCH 10/11] ARM: at91: make bootsource code generic to all SAMA5 Ahmad Fatoum
2022-12-14 10:58 ` [PATCH 11/11] ARM: at91: SAMA5D4: add Wifx L1 support Ahmad Fatoum
2022-12-27 10:26 ` [PATCH 00/11] ARM: at91: sama5d4: add basic " Sam Ravnborg
2022-12-27 20:40   ` Ahmad Fatoum
2022-12-28 10:46     ` Sam Ravnborg
2022-12-28 11:13       ` Ahmad Fatoum

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=20221214105831.844421-8-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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