Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17fd4e70 authored by Shawn Lin's avatar Shawn Lin Committed by Sridhar Arra
Browse files

mmc: core: add tunable delay waiting for power to be stable



The hard-coded 10ms delay in mmc_power_up came from
commit 79bccc5a ("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: default avatarShawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Git-commit: 6d796c68cd15234a33a4bd2ef7231125fea2dc6c
Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git


Change-Id: I858ae1eb65212b1da070e914107162df4da3380d
Signed-off-by: default avatarSridhar Arra <sarra@codeaurora.org>
parent 83127d77
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3141,7 +3141,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);

@@ -3154,7 +3154,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);

	mmc_host_clk_release(host);
}
+1 −0
Original line number Diff line number Diff line
@@ -731,6 +731,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
	host->max_req_size = PAGE_SIZE;
	host->max_blk_size = 512;
	host->max_blk_count = PAGE_SIZE / 512;
	host->ios.power_delay_ms = 10;

	return host;
}
+3 −0
Original line number Diff line number Diff line
@@ -1996,6 +1996,9 @@ struct sdhci_msm_pltfm_data *sdhci_msm_populate_pdata(struct device *dev,
	if (!pdata)
		goto out;

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

	pdata->status_gpio = of_get_named_gpio_flags(np, "cd-gpios", 0, &flags);
	if (gpio_is_valid(pdata->status_gpio) && !(flags & OF_GPIO_ACTIVE_LOW))
		pdata->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ struct mmc_ios {
	unsigned int	old_rate;       /* saved clock rate */
	unsigned long	clk_ts;         /* time stamp of last updated clock */
	unsigned short	vdd;
	unsigned int    power_delay_ms;         /* waiting for stable power */

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