mmc: sh_mmcif: add regulator support
Add regulator support to the sh_mmcif driver, but also preserve the current power-callback. Also note, that the card power is not switched off during clock gating periods, hence there's no need to power it on every time the card is re-activated. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Simon Horman <horms@verge.net.au> Signed-off-by: Chris Ball <cjb@laptop.org>
This commit is contained in:
parent
e2ee996eaa
commit
7d17baa05d
|
@ -923,10 +923,22 @@ static int sh_mmcif_clk_update(struct sh_mmcif_host *host)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sh_mmcif_set_power(struct sh_mmcif_host *host, struct mmc_ios *ios)
|
||||||
|
{
|
||||||
|
struct sh_mmcif_plat_data *pd = host->pd->dev.platform_data;
|
||||||
|
struct mmc_host *mmc = host->mmc;
|
||||||
|
|
||||||
|
if (pd->set_pwr)
|
||||||
|
pd->set_pwr(host->pd, ios->power_mode != MMC_POWER_OFF);
|
||||||
|
if (!IS_ERR(mmc->supply.vmmc))
|
||||||
|
/* Errors ignored... */
|
||||||
|
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc,
|
||||||
|
ios->power_mode ? ios->vdd : 0);
|
||||||
|
}
|
||||||
|
|
||||||
static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
||||||
{
|
{
|
||||||
struct sh_mmcif_host *host = mmc_priv(mmc);
|
struct sh_mmcif_host *host = mmc_priv(mmc);
|
||||||
struct sh_mmcif_plat_data *p = host->pd->dev.platform_data;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&host->lock, flags);
|
spin_lock_irqsave(&host->lock, flags);
|
||||||
|
@ -944,6 +956,7 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
||||||
sh_mmcif_request_dma(host, host->pd->dev.platform_data);
|
sh_mmcif_request_dma(host, host->pd->dev.platform_data);
|
||||||
host->card_present = true;
|
host->card_present = true;
|
||||||
}
|
}
|
||||||
|
sh_mmcif_set_power(host, ios);
|
||||||
} else if (ios->power_mode == MMC_POWER_OFF || !ios->clock) {
|
} else if (ios->power_mode == MMC_POWER_OFF || !ios->clock) {
|
||||||
/* clock stop */
|
/* clock stop */
|
||||||
sh_mmcif_clock_control(host, 0);
|
sh_mmcif_clock_control(host, 0);
|
||||||
|
@ -957,8 +970,8 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
||||||
pm_runtime_put(&host->pd->dev);
|
pm_runtime_put(&host->pd->dev);
|
||||||
clk_disable(host->hclk);
|
clk_disable(host->hclk);
|
||||||
host->power = false;
|
host->power = false;
|
||||||
if (p->set_pwr && ios->power_mode == MMC_POWER_OFF)
|
if (ios->power_mode == MMC_POWER_OFF)
|
||||||
p->set_pwr(host->pd, 0);
|
sh_mmcif_set_power(host, ios);
|
||||||
}
|
}
|
||||||
host->state = STATE_IDLE;
|
host->state = STATE_IDLE;
|
||||||
return;
|
return;
|
||||||
|
@ -966,8 +979,6 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
||||||
|
|
||||||
if (ios->clock) {
|
if (ios->clock) {
|
||||||
if (!host->power) {
|
if (!host->power) {
|
||||||
if (p->set_pwr)
|
|
||||||
p->set_pwr(host->pd, ios->power_mode);
|
|
||||||
sh_mmcif_clk_update(host);
|
sh_mmcif_clk_update(host);
|
||||||
pm_runtime_get_sync(&host->pd->dev);
|
pm_runtime_get_sync(&host->pd->dev);
|
||||||
host->power = true;
|
host->power = true;
|
||||||
|
@ -1251,6 +1262,19 @@ static void mmcif_timeout_work(struct work_struct *work)
|
||||||
mmc_request_done(host->mmc, mrq);
|
mmc_request_done(host->mmc, mrq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sh_mmcif_init_ocr(struct sh_mmcif_host *host)
|
||||||
|
{
|
||||||
|
struct sh_mmcif_plat_data *pd = host->pd->dev.platform_data;
|
||||||
|
struct mmc_host *mmc = host->mmc;
|
||||||
|
|
||||||
|
mmc_regulator_get_supply(mmc);
|
||||||
|
|
||||||
|
if (!mmc->ocr_avail)
|
||||||
|
mmc->ocr_avail = pd->ocr;
|
||||||
|
else if (pd->ocr)
|
||||||
|
dev_warn(mmc_dev(mmc), "Platform OCR mask is ignored\n");
|
||||||
|
}
|
||||||
|
|
||||||
static int __devinit sh_mmcif_probe(struct platform_device *pdev)
|
static int __devinit sh_mmcif_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
int ret = 0, irq[2];
|
int ret = 0, irq[2];
|
||||||
|
@ -1298,8 +1322,8 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
|
||||||
spin_lock_init(&host->lock);
|
spin_lock_init(&host->lock);
|
||||||
|
|
||||||
mmc->ops = &sh_mmcif_ops;
|
mmc->ops = &sh_mmcif_ops;
|
||||||
if (pd->ocr)
|
sh_mmcif_init_ocr(host);
|
||||||
mmc->ocr_avail = pd->ocr;
|
|
||||||
mmc->caps = MMC_CAP_MMC_HIGHSPEED;
|
mmc->caps = MMC_CAP_MMC_HIGHSPEED;
|
||||||
if (pd->caps)
|
if (pd->caps)
|
||||||
mmc->caps |= pd->caps;
|
mmc->caps |= pd->caps;
|
||||||
|
|
Loading…
Reference in New Issue