aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorBalaji T K <balajitk@ti.com>2014-02-19 09:56:40 -0500
committerChris Ball <chris@printf.net>2014-03-04 11:44:44 -0500
commit987fd49b894ec964231dfc5b6bbb2bc12e2b56b5 (patch)
treec5cf9ccf388f5cd8ab6e580c6d4c59994e014ec3 /drivers/mmc
parentf2ddc1dab61018becf4c5e275bb559d96eec8035 (diff)
mmc: omap_hsmmc: handle vcc and vcc_aux independently
handle vcc and vcc_aux independently to reduce indent. Signed-off-by: Balaji T K <balajitk@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Tested-by: Florian Vaussard <florian.vaussard@epfl.ch> Tested-by: Stefan Roese <sr@denx.de> Signed-off-by: Chris Ball <chris@printf.net>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/omap_hsmmc.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 36fb91eefd82..6f4b6b47c1c0 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -291,11 +291,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
291 * chips/cards need an interface voltage rail too. 291 * chips/cards need an interface voltage rail too.
292 */ 292 */
293 if (power_on) { 293 if (power_on) {
294 ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd); 294 if (host->vcc)
295 ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
295 /* Enable interface voltage rail, if needed */ 296 /* Enable interface voltage rail, if needed */
296 if (ret == 0 && host->vcc_aux) { 297 if (ret == 0 && host->vcc_aux) {
297 ret = regulator_enable(host->vcc_aux); 298 ret = regulator_enable(host->vcc_aux);
298 if (ret < 0) 299 if (ret < 0 && host->vcc)
299 ret = mmc_regulator_set_ocr(host->mmc, 300 ret = mmc_regulator_set_ocr(host->mmc,
300 host->vcc, 0); 301 host->vcc, 0);
301 } 302 }
@@ -303,7 +304,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
303 /* Shut down the rail */ 304 /* Shut down the rail */
304 if (host->vcc_aux) 305 if (host->vcc_aux)
305 ret = regulator_disable(host->vcc_aux); 306 ret = regulator_disable(host->vcc_aux);
306 if (!ret) { 307 if (host->vcc) {
307 /* Then proceed to shut down the local regulator */ 308 /* Then proceed to shut down the local regulator */
308 ret = mmc_regulator_set_ocr(host->mmc, 309 ret = mmc_regulator_set_ocr(host->mmc,
309 host->vcc, 0); 310 host->vcc, 0);
@@ -323,10 +324,10 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
323 324
324 reg = devm_regulator_get(host->dev, "vmmc"); 325 reg = devm_regulator_get(host->dev, "vmmc");
325 if (IS_ERR(reg)) { 326 if (IS_ERR(reg)) {
326 dev_err(host->dev, "vmmc regulator missing\n"); 327 dev_err(host->dev, "unable to get vmmc regulator %ld\n",
328 PTR_ERR(reg));
327 return PTR_ERR(reg); 329 return PTR_ERR(reg);
328 } else { 330 } else {
329 mmc_slot(host).set_power = omap_hsmmc_set_power;
330 host->vcc = reg; 331 host->vcc = reg;
331 ocr_value = mmc_regulator_get_ocrmask(reg); 332 ocr_value = mmc_regulator_get_ocrmask(reg);
332 if (!mmc_slot(host).ocr_mask) { 333 if (!mmc_slot(host).ocr_mask) {
@@ -339,31 +340,26 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
339 return -EINVAL; 340 return -EINVAL;
340 } 341 }
341 } 342 }
343 }
344 mmc_slot(host).set_power = omap_hsmmc_set_power;
342 345
343 /* Allow an aux regulator */ 346 /* Allow an aux regulator */
344 reg = devm_regulator_get_optional(host->dev, "vmmc_aux"); 347 reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
345 host->vcc_aux = IS_ERR(reg) ? NULL : reg; 348 host->vcc_aux = IS_ERR(reg) ? NULL : reg;
346 349
347 /* For eMMC do not power off when not in sleep state */ 350 /* For eMMC do not power off when not in sleep state */
348 if (mmc_slot(host).no_regulator_off_init) 351 if (mmc_slot(host).no_regulator_off_init)
349 return 0; 352 return 0;
350 /* 353 /*
351 * UGLY HACK: workaround regulator framework bugs. 354 * To disable boot_on regulator, enable regulator
352 * When the bootloader leaves a supply active, it's 355 * to increase usecount and then disable it.
353 * initialized with zero usecount ... and we can't 356 */
354 * disable it without first enabling it. Until the 357 if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
355 * framework is fixed, we need a workaround like this 358 (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
356 * (which is safe for MMC, but not in general). 359 int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
357 */
358 if (regulator_is_enabled(host->vcc) > 0 ||
359 (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
360 int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
361 360
362 mmc_slot(host).set_power(host->dev, host->slot_id, 361 mmc_slot(host).set_power(host->dev, host->slot_id, 1, vdd);
363 1, vdd); 362 mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
364 mmc_slot(host).set_power(host->dev, host->slot_id,
365 0, 0);
366 }
367 } 363 }
368 364
369 return 0; 365 return 0;