mmc: Add power_off_delay_us support
Subsystems (2)
v3 cover mmc: Add power_off_delay_us support
This series adds power_off_delay_us support for MMC controllers, enabling boards to specify custom delays after MMC power off to work around hardware issues such as slow RC circuites on MMC VDD rails.
Rather than adding host driver-specific workarounds, we abstract the implementation into the MMC core and pickup the delay value with a device tree property (power-off-delay-us). This allows any board with slow power off requirements to configure the necessary delay without code changes.
The solution is minimal and follows existing patterns as with power_delay_ms. The allowed minimum value = 0 ms (early return). The default value is 1000us to not deviate from the original 1ms delay set in mmc_power_off().
Link to v1:
https://lore.kernel.org/all/[email protected]/
Link to v2:
https://lore.kernel.org/all/[email protected]/
Changes since v2:
- allow 0us as lowest possible value (early return)
- Change custom logic in mmc_delay_us() to use fsleep()
- drop dt parsing checkers
Judith Mendez (2):
dt-bindings: mmc: Add power-off-delay-us property
mmc: core: Add power-off-delay-us support
.../devicetree/bindings/mmc/mmc-controller-common.yaml | 10 ++++++++++ drivers/mmc/core/core.c | 2 +- drivers/mmc/core/core.h | 8 ++++++++ drivers/mmc/core/host.c | 4 ++++ include/linux/mmc/host.h | 1 + 5 files changed, 24 insertions(+), 1 deletion(-)
Signature · 1 line
2.54.0
PATCH v3 1/2 dt-bindings: mmc: Add power-off-delay-us property
Add power-off-delay-us property to MMC controller common.
This property shall be used to specify value of delay after deasserting power during MMC power cycles. Default for delay is 1000us but custom delay can be passed in to work around hardware issues such as slow RC discharge on MMC VDD rails.
---
Changes since v2:
- Make minimum 0 instead of 1 (for no delay, early return)
- Add Rob's review tag
--- .../devicetree/bindings/mmc/mmc-controller-common.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/mmc/mmc-controller-common.yaml +10 -0
@@ -275,6 +275,16 @@ properties: not available. default: 10 + power-off-delay-us: + description: + Delay in microseconds after card power is deasserted during a power + cycle to allow time for proper power discharge. Larger values can be + configured to work around hardware issues such as slow RC discharge + on MMC VDD rails. + minimum: 0 + maximum: 10000000 + default: 1000 + supports-cqe: $ref: /schemas/types.yaml#/definitions/flag description:
Signature · 1 line
2.54.0
PATCH v3 2/2 mmc: core: Add power-off-delay-us support
In reply to Judith MendezAdd support for power-off-delay-us which shall be used to specify value of delay after deasserting power during MMC power cycles. Default for delay is 1000us but custom delay can be passed in to work around hardware issues such as slow RC discharge on MMC VDD rails.
---
Changes since v2:
- Drop < 0 check when parsing DT property, device_property_read_u32 should allow only positive values. Change also per Ulf's review
- Remove upper limit check, also per Ulf's review
- Use fsleep() instead of custom logic in mmc_delay_us(), per Sebastian's review
- Return immediately if 0 in mmc_delay_us(), since no delay should now be valid as per Ulf's review
--- drivers/mmc/core/core.c | 2 +- drivers/mmc/core/core.h | 8 ++++++++ drivers/mmc/core/host.c | 4 ++++ include/linux/mmc/host.h | 1 + 4 files changed, 14 insertions(+), 1 deletion(-)
drivers/mmc/core/core.c +1 -1
@@ -1388,7 +1388,7 @@ void mmc_power_off(struct mmc_host *host)* XO-1.5, require a short delay after poweroff before the card * can be successfully turned on again. */ -mmc_delay (1 ); +mmc_delay_us (host->ios.power_off_delay_us); }void mmc_power_cycle (struct mmc_host *host,u32 ocr)
drivers/mmc/core/core.h +8 -0
@@ -73,6 +73,14 @@ static inline void mmc_delay(unsigned int ms)msleep (ms); } +static inline void mmc_delay_us (unsigned int us) +{ +if (us ==0 ) +return ; + +fsleep (us); +} +void mmc_rescan (struct work_struct *work);void mmc_start_host (struct mmc_host *host);void __mmc_stop_host (struct mmc_host *host);
drivers/mmc/core/host.c +4 -0
@@ -421,6 +421,9 @@ int mmc_of_parse(struct mmc_host *host)device_property_read_u32 (dev,"post-power-on-delay-ms" , &host->ios.power_delay_ms); +device_property_read_u32 (dev,"power-off-delay-us" , + &host->ios.power_off_delay_us); +return mmc_pwrseq_alloc (host); }
@@ -574,6 +577,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) host->fixed_drv_type = -EINVAL ; host->ios.power_delay_ms =10 ; + host->ios.power_off_delay_us =1000 ; host->ios.power_mode =MMC_POWER_UNDEFINED ;return host;
include/linux/mmc/host.h +1 -0
@@ -23,6 +23,7 @@ struct mmc_ios {unsigned int clock;/* clock rate */ unsigned short vdd;unsigned int power_delay_ms;/* waiting for stable power */ +unsigned int power_off_delay_us;/* waiting for power discharge */ /* vdd stores the bit number of the selected voltage range from below. */
Signature · 1 line
2.54.0
Quoted 37 lines · Judith Mendez
This series adds
power_off_delay_ussupport for MMC controllers, enabling boards to specify custom delays after MMC power off to work around hardware issues such as slow RC circuites on MMC VDD rails.Rather than adding host driver-specific workarounds, we abstract the implementation into the MMC core and pickup the delay value with a device tree property (power-off-delay-us). This allows any board with slow power off requirements to configure the necessary delay without code changes.
The solution is minimal and follows existing patterns as with
power_delay_ms. The allowed minimum value = 0 ms (early return). The default value is 1000us to not deviate from the original 1ms delay set inmmc_power_off().Link to v1:
https://lore.kernel.org/all/[email protected]/
Link to v2:
https://lore.kernel.org/all/[email protected]/Changes since v2:
- allow 0us as lowest possible value (early return)
- Change custom logic inmmc_delay_us()to usefsleep()
- drop dt parsing checkersJudith Mendez (2):
dt-bindings: mmc: Add power-off-delay-us property
mmc: core: Add power-off-delay-us support.../devicetree/bindings/mmc/mmc-controller-common.yaml | 10 ++++++++++ drivers/mmc/core/core.c | 2 +- drivers/mmc/core/core.h | 8 ++++++++ drivers/mmc/core/host.c | 4 ++++ include/linux/mmc/host.h | 1 + 5 files changed, 24 insertions(+), 1 deletion(-)
Quoted 3 lines
--
2.54.0
The series applied for next, thanks!
Kind regards
Uffe