diff options
author | Kishon Vijay Abraham I <kishon@ti.com> | 2015-08-27 05:14:03 -0400 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2015-08-27 08:54:07 -0400 |
commit | c8518efa6de999bcbd638702c2a2d72fe83431e4 (patch) | |
tree | 74e70bef2e36b6151da56910cea7ebfa8f7e5491 | |
parent | 97fe7e5ab6318ea5716f86be3b4ca8776a9e609c (diff) |
mmc: host: omap_hsmmc: don't use ->set_power to set initial regulator state
If the regulator is enabled on boot (checked using regulator_is_enabled),
invoke regulator_enable() so that the usecount reflects the correct
state of the regulator and then disable the regulator so that the
initial state of the regulator is disabled. Avoid using ->set_power,
since set_power also takes care of setting the voltages which is not
needed at this point.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r-- | drivers/mmc/host/omap_hsmmc.c | 66 |
1 files changed, 56 insertions, 10 deletions
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index eec69752a189..cd4bd6d4c71e 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c | |||
@@ -409,6 +409,59 @@ err_set_voltage: | |||
409 | return ret; | 409 | return ret; |
410 | } | 410 | } |
411 | 411 | ||
412 | static int omap_hsmmc_disable_boot_regulator(struct regulator *reg) | ||
413 | { | ||
414 | int ret; | ||
415 | |||
416 | if (!reg) | ||
417 | return 0; | ||
418 | |||
419 | if (regulator_is_enabled(reg)) { | ||
420 | ret = regulator_enable(reg); | ||
421 | if (ret) | ||
422 | return ret; | ||
423 | |||
424 | ret = regulator_disable(reg); | ||
425 | if (ret) | ||
426 | return ret; | ||
427 | } | ||
428 | |||
429 | return 0; | ||
430 | } | ||
431 | |||
432 | static int omap_hsmmc_disable_boot_regulators(struct omap_hsmmc_host *host) | ||
433 | { | ||
434 | struct mmc_host *mmc = host->mmc; | ||
435 | int ret; | ||
436 | |||
437 | /* | ||
438 | * disable regulators enabled during boot and get the usecount | ||
439 | * right so that regulators can be enabled/disabled by checking | ||
440 | * the return value of regulator_is_enabled | ||
441 | */ | ||
442 | ret = omap_hsmmc_disable_boot_regulator(mmc->supply.vmmc); | ||
443 | if (ret) { | ||
444 | dev_err(host->dev, "fail to disable boot enabled vmmc reg\n"); | ||
445 | return ret; | ||
446 | } | ||
447 | |||
448 | ret = omap_hsmmc_disable_boot_regulator(mmc->supply.vqmmc); | ||
449 | if (ret) { | ||
450 | dev_err(host->dev, | ||
451 | "fail to disable boot enabled vmmc_aux reg\n"); | ||
452 | return ret; | ||
453 | } | ||
454 | |||
455 | ret = omap_hsmmc_disable_boot_regulator(host->pbias); | ||
456 | if (ret) { | ||
457 | dev_err(host->dev, | ||
458 | "failed to disable boot enabled pbias reg\n"); | ||
459 | return ret; | ||
460 | } | ||
461 | |||
462 | return 0; | ||
463 | } | ||
464 | |||
412 | static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) | 465 | static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) |
413 | { | 466 | { |
414 | int ocr_value = 0; | 467 | int ocr_value = 0; |
@@ -456,17 +509,10 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) | |||
456 | /* For eMMC do not power off when not in sleep state */ | 509 | /* For eMMC do not power off when not in sleep state */ |
457 | if (mmc_pdata(host)->no_regulator_off_init) | 510 | if (mmc_pdata(host)->no_regulator_off_init) |
458 | return 0; | 511 | return 0; |
459 | /* | ||
460 | * To disable boot_on regulator, enable regulator | ||
461 | * to increase usecount and then disable it. | ||
462 | */ | ||
463 | if ((mmc->supply.vmmc && regulator_is_enabled(mmc->supply.vmmc) > 0) || | ||
464 | (mmc->supply.vqmmc && regulator_is_enabled(mmc->supply.vqmmc))) { | ||
465 | int vdd = ffs(mmc_pdata(host)->ocr_mask) - 1; | ||
466 | 512 | ||
467 | omap_hsmmc_set_power(host->dev, 1, vdd); | 513 | ret = omap_hsmmc_disable_boot_regulators(host); |
468 | omap_hsmmc_set_power(host->dev, 0, 0); | 514 | if (ret) |
469 | } | 515 | return ret; |
470 | 516 | ||
471 | return 0; | 517 | return 0; |
472 | } | 518 | } |