Commit b958a67c authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Chris Ball

mmc: tmio: add regulator support

Currently the TMIO MMC driver derives the OCR mask from the platform data
and uses a platform callback to turn card power on and off. This patch adds
regulator support to the driver.
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Liam Girdwood <lrg@ti.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 56c49287
...@@ -768,6 +768,18 @@ static int tmio_mmc_clk_update(struct mmc_host *mmc) ...@@ -768,6 +768,18 @@ static int tmio_mmc_clk_update(struct mmc_host *mmc)
return ret; return ret;
} }
static void tmio_mmc_set_power(struct tmio_mmc_host *host, struct mmc_ios *ios)
{
struct mmc_host *mmc = host->mmc;
if (host->set_pwr)
host->set_pwr(host->pdev, 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);
}
/* Set MMC clock / power. /* Set MMC clock / power.
* Note: This controller uses a simple divider scheme therefore it cannot * Note: This controller uses a simple divider scheme therefore it cannot
* run a MMC card at full speed (20MHz). The max clock is 24MHz on SD, but as * run a MMC card at full speed (20MHz). The max clock is 24MHz on SD, but as
...@@ -820,13 +832,12 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) ...@@ -820,13 +832,12 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
} }
tmio_mmc_set_clock(host, ios->clock); tmio_mmc_set_clock(host, ios->clock);
/* power up SD bus */ /* power up SD bus */
if (host->set_pwr) tmio_mmc_set_power(host, ios);
host->set_pwr(host->pdev, 1);
/* start bus clock */ /* start bus clock */
tmio_mmc_clk_start(host); tmio_mmc_clk_start(host);
} else if (ios->power_mode != MMC_POWER_UP) { } else if (ios->power_mode != MMC_POWER_UP) {
if (host->set_pwr && ios->power_mode == MMC_POWER_OFF) if (ios->power_mode == MMC_POWER_OFF)
host->set_pwr(host->pdev, 0); tmio_mmc_set_power(host, ios);
if (host->power) { if (host->power) {
struct tmio_mmc_data *pdata = host->pdata; struct tmio_mmc_data *pdata = host->pdata;
tmio_mmc_clk_stop(host); tmio_mmc_clk_stop(host);
...@@ -888,6 +899,19 @@ static const struct mmc_host_ops tmio_mmc_ops = { ...@@ -888,6 +899,19 @@ static const struct mmc_host_ops tmio_mmc_ops = {
.enable_sdio_irq = tmio_mmc_enable_sdio_irq, .enable_sdio_irq = tmio_mmc_enable_sdio_irq,
}; };
static void tmio_mmc_init_ocr(struct tmio_mmc_host *host)
{
struct tmio_mmc_data *pdata = host->pdata;
struct mmc_host *mmc = host->mmc;
mmc_regulator_get_supply(mmc);
if (!mmc->ocr_avail)
mmc->ocr_avail = pdata->ocr_mask ? : MMC_VDD_32_33 | MMC_VDD_33_34;
else if (pdata->ocr_mask)
dev_warn(mmc_dev(mmc), "Platform OCR mask is ignored\n");
}
int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host,
struct platform_device *pdev, struct platform_device *pdev,
struct tmio_mmc_data *pdata) struct tmio_mmc_data *pdata)
...@@ -933,10 +957,7 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, ...@@ -933,10 +957,7 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host,
mmc->max_segs; mmc->max_segs;
mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
mmc->max_seg_size = mmc->max_req_size; mmc->max_seg_size = mmc->max_req_size;
if (pdata->ocr_mask) tmio_mmc_init_ocr(_host);
mmc->ocr_avail = pdata->ocr_mask;
else
mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
_host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD || _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD ||
mmc->caps & MMC_CAP_NEEDS_POLL || mmc->caps & MMC_CAP_NEEDS_POLL ||
......
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