[PATCH 13/15] ARM: rpi: add heuristic for skipping detection of SDIO card

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



mci0 is normally the WiFi while mci1 is the SD-Card on the Raspberry Pi
4. The proper way would be to use aliases, but as we accept device trees
from outside, we can apply a simple heuristic to disfavor the SDIO
controller: The SDIO controller tends to have a child node.

If this is not the case, use mci0 as before. As probing the SDIO in
barebox leads to many annoying error messages, disable its detection, so
device_detect_all done by ifup -a (which doesn't find the Ethernet
controller yet), doesn't spam the console.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 arch/arm/boards/raspberry-pi/rpi-common.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index 0db03098e564..efa3157d61b9 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -230,13 +230,31 @@ static int rpi_mem_init(void)
 }
 mem_initcall(rpi_mem_init);
 
+static bool mci_hwdev_has_child(struct device_d *dev)
+{
+	return dev && dev->parent && dev->parent->device_node &&
+		of_get_next_available_child(dev->parent->device_node, NULL);
+}
+
 static int rpi_env_init(void)
 {
 	struct stat s;
 	const char *diskdev = "/dev/disk0.0";
-	int ret;
+	int ret = -ENODEV;
 
-	device_detect_by_name("mci0");
+	struct device_d *mci0dev = get_device_by_name("mci0");
+	if (mci0dev) {
+		struct device_d *mci1dev = get_device_by_name("mci1");
+
+		if (mci_hwdev_has_child(mci0dev) && mci1dev &&
+		    !mci_hwdev_has_child(mci1dev))
+			ret = device_detect(mci1dev);
+
+		if (ret)
+			device_detect(mci0dev);
+		else
+			mci0dev->detect = mci0dev->parent->detect = NULL;
+	}
 
 	ret = stat(diskdev, &s);
 	if (ret) {
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux