Skip to content

Commit

Permalink
mmc: core: add tunable delay waiting for power to be stable
Browse files Browse the repository at this point in the history
The hard-coded 10ms delay in mmc_power_up came from
commit 79bccc5 ("mmc: increase power up delay"), which said "The TI
controller on Toshiba Tecra M5 needs more time to power up or the cards
will init incorrectly or not at all." But it's too engineering solution
for a special board but force all platforms to wait for that long time,
especially painful for mmc_power_up for eMMC when booting.

However, it's added since 2009, and we can't tell if other platforms
benefit from it. But in practise, the modern hardware are most likely to
have a stable power supply with 1ms after setting it for no matter PMIC
or discrete power. And more importnatly, most regulators implement the
callback of ->set_voltage_time_sel() for regulator core to wait for
specific period of time for the power supply to be stable, which means
once regulator_set_voltage_* return, the power should reach the the
minimum voltage that works for initialization. Of course, if there
are some other ways for host to power the card, we should allow them
to argue a suitable delay as well.

With this patch, we could assign the delay from firmware, or we could
assigne it via ->set_ios() callback from host drivers.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
  • Loading branch information
Shawn Lin authored and Ulf Hansson committed May 21, 2018
1 parent 10a0ed7 commit 6d796c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/mmc/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,7 @@ void mmc_power_up(struct mmc_host *host, u32 ocr)
* This delay should be sufficient to allow the power supply
* to reach the minimum voltage.
*/
mmc_delay(10);
mmc_delay(host->ios.power_delay_ms);

mmc_pwrseq_post_power_on(host);

Expand All @@ -1673,7 +1673,7 @@ void mmc_power_up(struct mmc_host *host, u32 ocr)
* This delay must be at least 74 clock sizes, or 1 ms, or the
* time required to reach a stable voltage.
*/
mmc_delay(10);
mmc_delay(host->ios.power_delay_ms);
}

void mmc_power_off(struct mmc_host *host)
Expand Down
4 changes: 4 additions & 0 deletions drivers/mmc/core/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ int mmc_of_parse(struct mmc_host *host)
host->dsr_req = 0;
}

device_property_read_u32(dev, "post-power-on-delay-ms",
&host->ios.power_delay_ms);

return mmc_pwrseq_alloc(host);
}

Expand Down Expand Up @@ -408,6 +411,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
host->max_blk_count = PAGE_SIZE / 512;

host->fixed_drv_type = -EINVAL;
host->ios.power_delay_ms = 10;

return host;
}
Expand Down
1 change: 1 addition & 0 deletions include/linux/mmc/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
struct mmc_ios {
unsigned int clock; /* clock rate */
unsigned short vdd;
unsigned int power_delay_ms; /* waiting for stable power */

/* vdd stores the bit number of the selected voltage range from below. */

Expand Down

0 comments on commit 6d796c6

Please sign in to comment.