[U-Boot] [PATCH] drivers: MMC: initialize MMC devices using the device model

Andre Przywara andre.przywara at arm.com
Tue Jul 28 19:19:51 CEST 2015


So far every MMC driver is relying on a board specific init routine,
but as the Rockchip MMC driver is the first MMC device model user,
it requires a generic DM MMC init routine.

Add that to the MMC init path to enable the Rockchip driver.

Signed-off-by: Andre Przywara <andre.przywara at arm.com>
---
Hi Simon,

this goes on top of your rockchip-working branch in the u-boot-dm
repo.
Not fully satisfied with this one, but the best I could come up with
without reading the whole of the device model code ;-)
This makes the SD card visible to U-Boot on my RK3288 dev board, I
can see partitions and load files from it. It gives me information
about the eMMC as well, but I haven't tested this so far except for
that mmc info.

Cheers,
Andre.

 drivers/mmc/mmc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index da47037..52e82b5 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -17,6 +17,7 @@
 #include <linux/list.h>
 #include <div64.h>
 #include "mmc_private.h"
+#include <dm.h>
 
 static struct list_head mmc_devices;
 static int cur_dev_num = -1;
@@ -1765,7 +1766,13 @@ int mmc_initialize(bd_t *bis)
 	INIT_LIST_HEAD (&mmc_devices);
 	cur_dev_num = 0;
 
-#ifndef CONFIG_DM_MMC
+#ifdef CONFIG_DM_MMC
+	struct udevice *udev;
+
+	for (;;cur_dev_num++)
+		if (uclass_get_device(UCLASS_MMC, cur_dev_num, &udev))
+			break;
+#else
 	if (board_mmc_init(bis) < 0)
 		cpu_mmc_init(bis);
 #endif
-- 
2.3.5



More information about the U-Boot mailing list