mmc: pxamci: let mmc core handle regulators

Strip some code by letting the mmc core handle the regulators. The old
.gpio_power pdata handling is kept around for now.

This also set the voltage on the regulator and handles -EPROBE_DEFER
correctly.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
Daniel Mack 2018-06-30 20:14:05 +02:00 committed by Ulf Hansson
parent f37216de6e
commit 61951fd6cb

View File

@ -73,58 +73,46 @@ struct pxamci_host {
dma_cookie_t dma_cookie; dma_cookie_t dma_cookie;
unsigned int dma_len; unsigned int dma_len;
unsigned int dma_dir; unsigned int dma_dir;
struct regulator *vcc;
}; };
static inline void pxamci_init_ocr(struct pxamci_host *host) static int pxamci_init_ocr(struct pxamci_host *host)
{ {
#ifdef CONFIG_REGULATOR struct mmc_host *mmc = host->mmc;
host->vcc = devm_regulator_get_optional(mmc_dev(host->mmc), "vmmc"); int ret;
if (IS_ERR(host->vcc)) ret = mmc_regulator_get_supply(mmc);
host->vcc = NULL; if (ret < 0)
else { return ret;
host->mmc->ocr_avail = mmc_regulator_get_ocrmask(host->vcc);
if (host->pdata && host->pdata->ocr_mask) if (IS_ERR(mmc->supply.vmmc)) {
dev_warn(mmc_dev(host->mmc),
"ocr_mask/setpower will not be used\n");
}
#endif
if (host->vcc == NULL) {
/* fall-back to platform data */ /* fall-back to platform data */
host->mmc->ocr_avail = host->pdata ? mmc->ocr_avail = host->pdata ?
host->pdata->ocr_mask : host->pdata->ocr_mask :
MMC_VDD_32_33 | MMC_VDD_33_34; MMC_VDD_32_33 | MMC_VDD_33_34;
} }
return 0;
} }
static inline int pxamci_set_power(struct pxamci_host *host, static inline int pxamci_set_power(struct pxamci_host *host,
unsigned char power_mode, unsigned char power_mode,
unsigned int vdd) unsigned int vdd)
{ {
struct mmc_host *mmc = host->mmc;
struct regulator *supply = mmc->supply.vmmc;
int on; int on;
if (host->vcc) { if (!IS_ERR(supply))
int ret; return mmc_regulator_set_ocr(mmc, supply, vdd);
if (power_mode == MMC_POWER_UP) { if (host->pdata &&
ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
if (ret)
return ret;
} else if (power_mode == MMC_POWER_OFF) {
ret = mmc_regulator_set_ocr(host->mmc, host->vcc, 0);
if (ret)
return ret;
}
}
if (!host->vcc && host->pdata &&
gpio_is_valid(host->pdata->gpio_power)) { gpio_is_valid(host->pdata->gpio_power)) {
on = ((1 << vdd) & host->pdata->ocr_mask); on = ((1 << vdd) & host->pdata->ocr_mask);
gpio_set_value(host->pdata->gpio_power, gpio_set_value(host->pdata->gpio_power,
!!on ^ host->pdata->gpio_power_invert); !!on ^ host->pdata->gpio_power_invert);
} }
if (!host->vcc && host->pdata && host->pdata->setpower)
if (host->pdata && host->pdata->setpower)
return host->pdata->setpower(mmc_dev(host->mmc), vdd); return host->pdata->setpower(mmc_dev(host->mmc), vdd);
return 0; return 0;
@ -691,7 +679,9 @@ static int pxamci_probe(struct platform_device *pdev)
mmc->f_min = (host->clkrate + 63) / 64; mmc->f_min = (host->clkrate + 63) / 64;
mmc->f_max = (mmc_has_26MHz()) ? 26000000 : host->clkrate; mmc->f_max = (mmc_has_26MHz()) ? 26000000 : host->clkrate;
pxamci_init_ocr(host); ret = pxamci_init_ocr(host);
if (ret < 0)
return ret;
mmc->caps = 0; mmc->caps = 0;
host->cmdat = 0; host->cmdat = 0;