Add support for power-off-delay-us property to allow additional delay
after mmc_power_off(). Boards with slow RC discharge on MMC VDD rails
can use this to fully discharge the card before power-on.

Default delay is 0 (no additional delay). Boards requiring longer
discharge can override via DT property power-off-delay-us in microseconds.

Signed-off-by: Judith Mendez <[email protected]>
---
 drivers/mmc/mmc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 670e92ee12b..4adcf424195 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2909,6 +2909,8 @@ static int mmc_power_on(struct mmc *mmc)
 
 static int mmc_power_off(struct mmc *mmc)
 {
+       u32 delay_us = 0;
+
        mmc_set_clock(mmc, 0, MMC_CLK_DISABLE);
 #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_REGULATOR)
        if (mmc->vmmc_supply) {
@@ -2930,6 +2932,12 @@ static int mmc_power_off(struct mmc *mmc)
                        return ret;
                }
        }
+
+       if (mmc->dev)
+               dev_read_u32(mmc->dev, "power-off-delay-us", &delay_us);
+
+       if (delay_us)
+               udelay(delay_us);
 #endif
        return 0;
 }
-- 
2.34.1

Reply via email to