Skip to content

Commit

Permalink
mmc: host: omap_hsmmc: enable/disable vmmc_aux regulator based on pre…
Browse files Browse the repository at this point in the history
…vious state

enable vmmc_aux regulator only if it is in disabled state and disable
vmmc_aux regulator only if it is in enabled state.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
  • Loading branch information
Kishon Vijay Abraham I authored and Ulf Hansson committed Aug 27, 2015
1 parent c8518ef commit 3f77f70
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/mmc/host/omap_hsmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ struct omap_hsmmc_host {
struct regulator *pbias;
bool pbias_enabled;
void __iomem *base;
int vqmmc_enabled;
resource_size_t mapbase;
spinlock_t irq_lock; /* Prevent races with irq handler */
unsigned int dma_len;
Expand Down Expand Up @@ -249,6 +250,7 @@ static int omap_hsmmc_get_cover_state(struct device *dev)
static int omap_hsmmc_enable_supply(struct mmc_host *mmc, int vdd)
{
int ret;
struct omap_hsmmc_host *host = mmc_priv(mmc);

if (mmc->supply.vmmc) {
ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
Expand All @@ -257,12 +259,13 @@ static int omap_hsmmc_enable_supply(struct mmc_host *mmc, int vdd)
}

/* Enable interface voltage rail, if needed */
if (mmc->supply.vqmmc) {
if (mmc->supply.vqmmc && !host->vqmmc_enabled) {
ret = regulator_enable(mmc->supply.vqmmc);
if (ret) {
dev_err(mmc_dev(mmc), "vmmc_aux reg enable failed\n");
goto err_vqmmc;
}
host->vqmmc_enabled = 1;
}

return 0;
Expand All @@ -278,13 +281,15 @@ static int omap_hsmmc_disable_supply(struct mmc_host *mmc)
{
int ret;
int status;
struct omap_hsmmc_host *host = mmc_priv(mmc);

if (mmc->supply.vqmmc) {
if (mmc->supply.vqmmc && host->vqmmc_enabled) {
ret = regulator_disable(mmc->supply.vqmmc);
if (ret) {
dev_err(mmc_dev(mmc), "vmmc_aux reg disable failed\n");
return ret;
}
host->vqmmc_enabled = 0;
}

if (mmc->supply.vmmc) {
Expand Down Expand Up @@ -2077,6 +2082,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
host->power_mode = MMC_POWER_OFF;
host->next_data.cookie = 1;
host->pbias_enabled = 0;
host->vqmmc_enabled = 0;

ret = omap_hsmmc_gpio_init(mmc, host, pdata);
if (ret)
Expand Down

0 comments on commit 3f77f70

Please sign in to comment.