Commit 74a20867 authored by Kishon Vijay Abraham I's avatar Kishon Vijay Abraham I Committed by Jason Liu

mmc: Add a new callback function to enable/disable vdd

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: default avatarKishon Vijay Abraham I <>
Signed-off-by: default avatarJean-Jacques Hiblot <>
parent 920adc57
......@@ -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);
......@@ -1194,6 +1194,16 @@ static inline int bus_width(uint cap)
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;
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)
......@@ -351,6 +351,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
......@@ -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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment