[U-Boot] [PATCH 2/2] drivers: omap_hsmmc: move to DM_MMC_OPS

Jean-Jacques Hiblot jjhiblot at ti.com
Fri Apr 14 17:50:02 UTC 2017


Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
---
 drivers/mmc/Kconfig      |  1 +
 drivers/mmc/omap_hsmmc.c | 39 ++++++++++++++++++++++++++++++++-------
 2 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 560391f..caa3c3c 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -132,6 +132,7 @@ config MMC_PCI
 
 config MMC_OMAP_HS
 	bool "TI OMAP High Speed Multimedia Card Interface support"
+	select DM_MMC_OPS if DM_MMC
 	help
 	  This selects the TI OMAP High Speed Multimedia card Interface.
 	  If you have an omap2plus board with a Multimedia Card slot,
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 83dda09..f18f19b 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -327,11 +327,17 @@ static void mmc_reset_controller_fsm(struct hsmmc *mmc_base, u32 bit)
 		}
 	}
 }
-
+#ifndef CONFIG_DM_MMC
 static int omap_hsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 			struct mmc_data *data)
 {
 	struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc);
+#else
+static int omap_hsmmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
+			struct mmc_data *data)
+{
+	struct omap_hsmmc_data *priv = dev_get_priv(dev);
+#endif
 	struct hsmmc *mmc_base;
 	unsigned int flags, mmc_stat;
 	ulong start;
@@ -559,9 +565,17 @@ static int mmc_write_data(struct hsmmc *mmc_base, const char *buf,
 	return 0;
 }
 
+#ifndef CONFIG_DM_MMC
 static int omap_hsmmc_set_ios(struct mmc *mmc)
 {
 	struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc);
+#else
+static int omap_hsmmc_set_ios(struct udevice *dev)
+{
+	struct omap_hsmmc_data *priv = dev_get_priv(dev);
+	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+	struct mmc *mmc = upriv->mmc;
+#endif
 	struct hsmmc *mmc_base;
 	unsigned int dsor = 0;
 	ulong start;
@@ -618,9 +632,9 @@ static int omap_hsmmc_set_ios(struct mmc *mmc)
 
 #ifdef OMAP_HSMMC_USE_GPIO
 #ifdef CONFIG_DM_MMC
-static int omap_hsmmc_getcd(struct mmc *mmc)
+static int omap_hsmmc_getcd(struct udevice *dev)
 {
-	struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc);
+	struct omap_hsmmc_data *priv = dev_get_priv(dev);
 	int value;
 
 	value = dm_gpio_get_value(&priv->cd_gpio);
@@ -633,9 +647,9 @@ static int omap_hsmmc_getcd(struct mmc *mmc)
 	return value;
 }
 
-static int omap_hsmmc_getwp(struct mmc *mmc)
+static int omap_hsmmc_getwp(struct udevice *dev)
 {
-	struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc);
+	struct omap_hsmmc_data *priv = dev_get_priv(dev);
 	int value;
 
 	value = dm_gpio_get_value(&priv->wp_gpio);
@@ -675,6 +689,16 @@ static int omap_hsmmc_getwp(struct mmc *mmc)
 #endif
 #endif
 
+#ifdef CONFIG_DM_MMC
+static const struct dm_mmc_ops omap_hsmmc_ops = {
+	.send_cmd	= omap_hsmmc_send_cmd,
+	.set_ios	= omap_hsmmc_set_ios,
+#ifdef OMAP_HSMMC_USE_GPIO
+	.get_cd		= omap_hsmmc_getcd,
+	.get_wp		= omap_hsmmc_getwp,
+#endif
+};
+#else
 static const struct mmc_ops omap_hsmmc_ops = {
 	.send_cmd	= omap_hsmmc_send_cmd,
 	.set_ios	= omap_hsmmc_set_ios,
@@ -684,6 +708,7 @@ static const struct mmc_ops omap_hsmmc_ops = {
 	.getwp		= omap_hsmmc_getwp,
 #endif
 };
+#endif
 
 #ifndef CONFIG_DM_MMC
 int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio,
@@ -833,7 +858,6 @@ static int omap_hsmmc_probe(struct udevice *dev)
 	struct mmc *mmc;
 
 	cfg->name = "OMAP SD/MMC";
-	cfg->ops = &omap_hsmmc_ops;
 
 #ifdef CONFIG_BLK
 	mmc = &plat->mmc;
@@ -851,7 +875,7 @@ static int omap_hsmmc_probe(struct udevice *dev)
 	mmc->dev = dev;
 	upriv->mmc = mmc;
 
-	return 0;
+	return omap_hsmmc_init_setup(mmc);
 }
 
 static const struct udevice_id omap_hsmmc_ids[] = {
@@ -869,6 +893,7 @@ U_BOOT_DRIVER(omap_hsmmc) = {
 #ifdef CONFIG_BLK
 	.bind = omap_hsmmc_bind,
 #endif
+	.ops = &omap_hsmmc_ops,
 	.probe	= omap_hsmmc_probe,
 	.priv_auto_alloc_size = sizeof(struct omap_hsmmc_data),
 	.platdata_auto_alloc_size = sizeof(struct omap_hsmmc_plat),
-- 
1.9.1



More information about the U-Boot mailing list