[U-Boot] [PATCH 13/22] mmc: Add a new callback function to enable/disable vdd

Jean-Jacques Hiblot jjhiblot at ti.com
Fri May 12 18:16:31 UTC 2017


From: Kishon Vijay Abraham I <kishon at ti.com>

Add a new callback function *set_vdd* which can be used
by the platform mmc driver to enable or disable vdd.
The mmc core can use *mmc_set_vdd* in order to invoke
the callback function. This will be used during power cycle
where the specification requires vdd to be disabled for
1ms and enabled again.

Signed-off-by: Kishon Vijay Abraham I <kishon at ti.com>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
---
 drivers/mmc/mmc-uclass.c | 14 ++++++++++++++
 drivers/mmc/mmc.c        | 12 +++++++++++-
 include/mmc.h            | 12 ++++++++++++
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 9c07871..e1f7995 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -52,6 +52,20 @@ int mmc_set_ios(struct mmc *mmc)
 	return dm_mmc_set_ios(mmc->dev);
 }
 
+int dm_mmc_set_vdd(struct udevice *dev, bool enable)
+{
+	struct dm_mmc_ops *ops = mmc_get_ops(dev);
+
+	if (!ops->set_vdd)
+		return -ENOSYS;
+	return ops->set_vdd(dev, enable);
+}
+
+int mmc_set_vdd(struct mmc *mmc, bool enable)
+{
+	return dm_mmc_set_vdd(mmc->dev, enable);
+}
+
 int dm_mmc_get_wp(struct udevice *dev)
 {
 	struct dm_mmc_ops *ops = mmc_get_ops(dev);
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 10af81d..d40a22b 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1194,6 +1194,16 @@ static inline int bus_width(uint cap)
 }
 
 #ifndef CONFIG_DM_MMC_OPS
+static int mmc_set_vdd(struct mmc *mmc, bool enable)
+{
+	int ret = 0;
+
+	if (mmc->cfg->ops->set_vdd)
+		ret = mmc->cfg->ops->set_vdd(mmc, enable);
+
+	return ret;
+}
+
 static int mmc_set_ios(struct mmc *mmc)
 {
 	int ret = 0;
@@ -1942,7 +1952,7 @@ int mmc_start_init(struct mmc *mmc)
 		return err;
 #endif
 	mmc->ddr_mode = 0;
-
+	mmc_set_vdd(mmc, true);
 	/* First try to set 3.3V. If it fails set to 1.8V */
 	err = mmc_set_signal_voltage(mmc, MMC_SIGNAL_VOLTAGE_330);
 	if (err != 0)
diff --git a/include/mmc.h b/include/mmc.h
index 89cb26c..43d37a4 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -352,6 +352,15 @@ struct dm_mmc_ops {
 	int (*set_ios)(struct udevice *dev);
 
 	/**
+	 * set_vdd() - Enable or Disable the Vdd line
+	 *
+	 * @dev:	Device to update
+	 * @enable:	true or false to enable or disable Vdd respectively
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*set_vdd)(struct udevice *dev, bool enable);
+
+	/**
 	 * get_cd() - See whether a card is present
 	 *
 	 * @dev:	Device to check
@@ -373,11 +382,13 @@ struct dm_mmc_ops {
 int dm_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
 		    struct mmc_data *data);
 int dm_mmc_set_ios(struct udevice *dev);
+int dm_mmc_set_vdd(struct udevice *dev, bool enable);
 int dm_mmc_get_cd(struct udevice *dev);
 int dm_mmc_get_wp(struct udevice *dev);
 
 /* Transition functions for compatibility */
 int mmc_set_ios(struct mmc *mmc);
+int mmc_set_vdd(struct mmc *mmc, bool enable);
 int mmc_getcd(struct mmc *mmc);
 int mmc_getwp(struct mmc *mmc);
 
@@ -387,6 +398,7 @@ struct mmc_ops {
 			struct mmc_cmd *cmd, struct mmc_data *data);
 	int (*set_ios)(struct mmc *mmc);
 	int (*init)(struct mmc *mmc);
+	int (*set_vdd)(struct mmc *mmc, bool enable);
 	int (*getcd)(struct mmc *mmc);
 	int (*getwp)(struct mmc *mmc);
 };
-- 
1.9.1



More information about the U-Boot mailing list