mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 19:00:25 +00:00
ARM: 7620/1: mmc: mmci: Convert to use mmc_regulator_get_supply
By using the mmc_regulator_get_supply API we are able to do some cleanups of the regulator code. Additionally let the regulator API handle the error printing. Cc: Chris Ball <cjb@laptop.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
parent
70be208f0b
commit
599c1d5c75
2 changed files with 11 additions and 44 deletions
|
@ -1093,7 +1093,6 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
||||||
struct variant_data *variant = host->variant;
|
struct variant_data *variant = host->variant;
|
||||||
u32 pwr = 0;
|
u32 pwr = 0;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int ret;
|
|
||||||
|
|
||||||
pm_runtime_get_sync(mmc_dev(mmc));
|
pm_runtime_get_sync(mmc_dev(mmc));
|
||||||
|
|
||||||
|
@ -1103,23 +1102,13 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
||||||
|
|
||||||
switch (ios->power_mode) {
|
switch (ios->power_mode) {
|
||||||
case MMC_POWER_OFF:
|
case MMC_POWER_OFF:
|
||||||
if (host->vcc)
|
if (!IS_ERR(mmc->supply.vmmc))
|
||||||
ret = mmc_regulator_set_ocr(mmc, host->vcc, 0);
|
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
|
||||||
break;
|
break;
|
||||||
case MMC_POWER_UP:
|
case MMC_POWER_UP:
|
||||||
if (host->vcc) {
|
if (!IS_ERR(mmc->supply.vmmc))
|
||||||
ret = mmc_regulator_set_ocr(mmc, host->vcc, ios->vdd);
|
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
|
||||||
if (ret) {
|
|
||||||
dev_err(mmc_dev(mmc), "unable to set OCR\n");
|
|
||||||
/*
|
|
||||||
* The .set_ios() function in the mmc_host_ops
|
|
||||||
* struct return void, and failing to set the
|
|
||||||
* power should be rare so we print an error
|
|
||||||
* and return here.
|
|
||||||
*/
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* The ST Micro variant doesn't have the PL180s MCI_PWR_UP
|
* The ST Micro variant doesn't have the PL180s MCI_PWR_UP
|
||||||
* and instead uses MCI_PWR_ON so apply whatever value is
|
* and instead uses MCI_PWR_ON so apply whatever value is
|
||||||
|
@ -1168,7 +1157,6 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
||||||
|
|
||||||
spin_unlock_irqrestore(&host->lock, flags);
|
spin_unlock_irqrestore(&host->lock, flags);
|
||||||
|
|
||||||
out:
|
|
||||||
pm_runtime_mark_last_busy(mmc_dev(mmc));
|
pm_runtime_mark_last_busy(mmc_dev(mmc));
|
||||||
pm_runtime_put_autosuspend(mmc_dev(mmc));
|
pm_runtime_put_autosuspend(mmc_dev(mmc));
|
||||||
}
|
}
|
||||||
|
@ -1391,29 +1379,13 @@ static int mmci_probe(struct amba_device *dev,
|
||||||
} else
|
} else
|
||||||
dev_warn(&dev->dev, "could not get default pinstate\n");
|
dev_warn(&dev->dev, "could not get default pinstate\n");
|
||||||
|
|
||||||
#ifdef CONFIG_REGULATOR
|
/* Get regulators and the supported OCR mask */
|
||||||
/* If we're using the regulator framework, try to fetch a regulator */
|
mmc_regulator_get_supply(mmc);
|
||||||
host->vcc = regulator_get(&dev->dev, "vmmc");
|
if (!mmc->ocr_avail)
|
||||||
if (IS_ERR(host->vcc))
|
|
||||||
host->vcc = NULL;
|
|
||||||
else {
|
|
||||||
int mask = mmc_regulator_get_ocrmask(host->vcc);
|
|
||||||
|
|
||||||
if (mask < 0)
|
|
||||||
dev_err(&dev->dev, "error getting OCR mask (%d)\n",
|
|
||||||
mask);
|
|
||||||
else {
|
|
||||||
host->mmc->ocr_avail = (u32) mask;
|
|
||||||
if (plat->ocr_mask)
|
|
||||||
dev_warn(&dev->dev,
|
|
||||||
"Provided ocr_mask/setpower will not be used "
|
|
||||||
"(using regulator instead)\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* Fall back to platform data if no regulator is found */
|
|
||||||
if (host->vcc == NULL)
|
|
||||||
mmc->ocr_avail = plat->ocr_mask;
|
mmc->ocr_avail = plat->ocr_mask;
|
||||||
|
else if (plat->ocr_mask)
|
||||||
|
dev_warn(mmc_dev(mmc), "Platform OCR mask is ignored\n");
|
||||||
|
|
||||||
mmc->caps = plat->capabilities;
|
mmc->caps = plat->capabilities;
|
||||||
mmc->caps2 = plat->capabilities2;
|
mmc->caps2 = plat->capabilities2;
|
||||||
|
|
||||||
|
@ -1595,10 +1567,6 @@ static int mmci_remove(struct amba_device *dev)
|
||||||
clk_disable_unprepare(host->clk);
|
clk_disable_unprepare(host->clk);
|
||||||
clk_put(host->clk);
|
clk_put(host->clk);
|
||||||
|
|
||||||
if (host->vcc)
|
|
||||||
mmc_regulator_set_ocr(mmc, host->vcc, 0);
|
|
||||||
regulator_put(host->vcc);
|
|
||||||
|
|
||||||
mmc_free_host(mmc);
|
mmc_free_host(mmc);
|
||||||
|
|
||||||
amba_release_regions(dev);
|
amba_release_regions(dev);
|
||||||
|
|
|
@ -193,7 +193,6 @@ struct mmci_host {
|
||||||
/* pio stuff */
|
/* pio stuff */
|
||||||
struct sg_mapping_iter sg_miter;
|
struct sg_mapping_iter sg_miter;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
struct regulator *vcc;
|
|
||||||
|
|
||||||
/* pinctrl handles */
|
/* pinctrl handles */
|
||||||
struct pinctrl *pinctrl;
|
struct pinctrl *pinctrl;
|
||||||
|
|
Loading…
Reference in a new issue