[PATCH v3 05/11] mmc: arm_pl180: Power down card supplies at OS handoff
Linus Walleij <[email protected]>
| Newsgroups | org.u-boot-project.lists.u-boot |
|---|---|
| Message-ID | <[email protected]> |
PL180 card supplies remain enabled after probing and while U-Boot is running. They are no longer needed once control is handed to the operating system. Mark the driver for removal during OS preparation and disable its VMMC and VQMMC supplies from the remove callback. Signed-off-by: Linus Walleij <[email protected]> --- drivers/mmc/arm_pl180_mmci.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c index a2ea5cf03120..dd913f963c82 100644 --- a/drivers/mmc/arm_pl180_mmci.c +++ b/drivers/mmc/arm_pl180_mmci.c @@ -46,6 +46,20 @@ static int arm_pl180_set_supply_voltage(struct udevice *supply, int target_uV) target_uV, SD_VOLTAGE_MAX_UV); } +static int arm_pl180_disable_supply(struct udevice *supply) +{ + int ret; + + if (!supply) + return 0; + + ret = regulator_set_enable_if_allowed(supply, false); + if (ret == -ENOSYS) + return 0; + + return ret; +} + static int wait_for_command_end(struct mmc *dev, struct mmc_cmd *cmd) { u32 hoststatus, statusmask; @@ -497,6 +511,20 @@ static int arm_pl180_mmc_probe(struct udevice *dev) return 0; } +static int arm_pl180_mmc_remove(struct udevice *dev) +{ + struct mmc *mmc = mmc_get_mmc_dev(dev); + int ret, vmmc_ret; + + ret = arm_pl180_disable_supply(mmc->vqmmc_supply); + if (mmc->vmmc_supply != mmc->vqmmc_supply) + vmmc_ret = arm_pl180_disable_supply(mmc->vmmc_supply); + else + vmmc_ret = 0; + + return ret ? ret : vmmc_ret; +} + int arm_pl180_mmc_bind(struct udevice *dev) { struct arm_pl180_mmc_plat *plat = dev_get_plat(dev); @@ -560,8 +588,10 @@ U_BOOT_DRIVER(arm_pl180_mmc) = { .of_match = arm_pl180_mmc_match, .ops = &arm_pl180_dm_mmc_ops, .probe = arm_pl180_mmc_probe, + .remove = arm_pl180_mmc_remove, .of_to_plat = arm_pl180_mmc_of_to_plat, .bind = arm_pl180_mmc_bind, .priv_auto = sizeof(struct pl180_mmc_host), .plat_auto = sizeof(struct arm_pl180_mmc_plat), + .flags = DM_FLAG_OS_PREPARE, }; -- 2.55.0