diff mbox series

[08/10] mmc: Add init() API

Message ID 20200123152435.6793-9-faiz_abbas@ti.com
State New
Headers show
Series Add Support for eMMC boot in AM65x and J721e | expand

Commit Message

Faiz Abbas Jan. 23, 2020, 3:24 p.m. UTC
Add an init() API for platform specific init() operations.

Signed-off-by: Faiz Abbas <faiz_abbas at ti.com>
---
 drivers/mmc/mmc.c | 15 +++++++--------
 include/mmc.h     |  7 +++++++
 2 files changed, 14 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 364d39bf3b..a055ecbc9d 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2752,6 +2752,7 @@  static int mmc_power_cycle(struct mmc *mmc)
 
 int mmc_get_op_cond(struct mmc *mmc)
 {
+	struct dm_mmc_ops *ops = mmc_get_ops(mmc->dev);
 	bool uhs_en = supports_uhs(mmc->cfg->host_caps);
 	int err;
 
@@ -2786,14 +2787,12 @@  int mmc_get_op_cond(struct mmc *mmc)
 	if (err)
 		return err;
 
-#if CONFIG_IS_ENABLED(DM_MMC)
-	/* The device has already been probed ready for use */
-#else
-	/* made sure it's not NULL earlier */
-	err = mmc->cfg->ops->init(mmc);
-	if (err)
-		return err;
-#endif
+	if (ops->init) {
+		err = ops->init(mmc->dev);
+		if (err)
+			return err;
+	}
+
 	mmc->ddr_mode = 0;
 
 retry:
diff --git a/include/mmc.h b/include/mmc.h
index 3c763670f2..a96833c1ca 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -406,6 +406,13 @@  struct mmc;
 
 #if CONFIG_IS_ENABLED(DM_MMC)
 struct dm_mmc_ops {
+	/**
+	 * init() - platform specific initialization for the host controller
+	 *
+	 * @dev:	Device to init
+	 * @return 0 if Ok, -ve if error
+	 */
+	int (*init)(struct udevice *dev);
 	/**
 	 * send_cmd() - Send a command to the MMC device
 	 *