Commit 987fd49b authored by Balaji T K's avatar Balaji T K Committed by Chris Ball

mmc: omap_hsmmc: handle vcc and vcc_aux independently

handle vcc and vcc_aux independently to reduce indent.
Signed-off-by: default avatarBalaji T K <balajitk@ti.com>
Acked-by: default avatarTony Lindgren <tony@atomide.com>
Tested-by: default avatarFlorian Vaussard <florian.vaussard@epfl.ch>
Tested-by: default avatarStefan Roese <sr@denx.de>
Signed-off-by: default avatarChris Ball <chris@printf.net>
parent f2ddc1da
...@@ -291,11 +291,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on, ...@@ -291,11 +291,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
* chips/cards need an interface voltage rail too. * chips/cards need an interface voltage rail too.
*/ */
if (power_on) { if (power_on) {
if (host->vcc)
ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd); ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
/* Enable interface voltage rail, if needed */ /* Enable interface voltage rail, if needed */
if (ret == 0 && host->vcc_aux) { if (ret == 0 && host->vcc_aux) {
ret = regulator_enable(host->vcc_aux); ret = regulator_enable(host->vcc_aux);
if (ret < 0) if (ret < 0 && host->vcc)
ret = mmc_regulator_set_ocr(host->mmc, ret = mmc_regulator_set_ocr(host->mmc,
host->vcc, 0); host->vcc, 0);
} }
...@@ -303,7 +304,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on, ...@@ -303,7 +304,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
/* Shut down the rail */ /* Shut down the rail */
if (host->vcc_aux) if (host->vcc_aux)
ret = regulator_disable(host->vcc_aux); ret = regulator_disable(host->vcc_aux);
if (!ret) { if (host->vcc) {
/* Then proceed to shut down the local regulator */ /* Then proceed to shut down the local regulator */
ret = mmc_regulator_set_ocr(host->mmc, ret = mmc_regulator_set_ocr(host->mmc,
host->vcc, 0); host->vcc, 0);
...@@ -323,10 +324,10 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) ...@@ -323,10 +324,10 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
reg = devm_regulator_get(host->dev, "vmmc"); reg = devm_regulator_get(host->dev, "vmmc");
if (IS_ERR(reg)) { if (IS_ERR(reg)) {
dev_err(host->dev, "vmmc regulator missing\n"); dev_err(host->dev, "unable to get vmmc regulator %ld\n",
PTR_ERR(reg));
return PTR_ERR(reg); return PTR_ERR(reg);
} else { } else {
mmc_slot(host).set_power = omap_hsmmc_set_power;
host->vcc = reg; host->vcc = reg;
ocr_value = mmc_regulator_get_ocrmask(reg); ocr_value = mmc_regulator_get_ocrmask(reg);
if (!mmc_slot(host).ocr_mask) { if (!mmc_slot(host).ocr_mask) {
...@@ -339,6 +340,8 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) ...@@ -339,6 +340,8 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
return -EINVAL; return -EINVAL;
} }
} }
}
mmc_slot(host).set_power = omap_hsmmc_set_power;
/* Allow an aux regulator */ /* Allow an aux regulator */
reg = devm_regulator_get_optional(host->dev, "vmmc_aux"); reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
...@@ -348,22 +351,15 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) ...@@ -348,22 +351,15 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
if (mmc_slot(host).no_regulator_off_init) if (mmc_slot(host).no_regulator_off_init)
return 0; return 0;
/* /*
* UGLY HACK: workaround regulator framework bugs. * To disable boot_on regulator, enable regulator
* When the bootloader leaves a supply active, it's * to increase usecount and then disable it.
* initialized with zero usecount ... and we can't
* disable it without first enabling it. Until the
* framework is fixed, we need a workaround like this
* (which is safe for MMC, but not in general).
*/ */
if (regulator_is_enabled(host->vcc) > 0 || if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
(host->vcc_aux && regulator_is_enabled(host->vcc_aux))) { (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
int vdd = ffs(mmc_slot(host).ocr_mask) - 1; int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
mmc_slot(host).set_power(host->dev, host->slot_id, mmc_slot(host).set_power(host->dev, host->slot_id, 1, vdd);
1, vdd); mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
mmc_slot(host).set_power(host->dev, host->slot_id,
0, 0);
}
} }
return 0; return 0;
......
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