[PATCH 1/4] mmc: sdhci: Add delay after power off

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add delay after power off to ensure that full power cycle is
successful. Otherwise, some controllers, at lease for Hisilicon
eMMC controller, may not be unstable sometimes for full power
cycle operation.

Signed-off-by: Jun Nie <jun.nie@xxxxxxxxxx>
---
 drivers/mmc/host/sdhci.c | 7 +++++++
 drivers/mmc/host/sdhci.h | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 3140fe2e5dba..a654f0aeb438 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1761,6 +1761,13 @@ void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode,
 		sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
 		if (host->quirks2 & SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON)
 			sdhci_runtime_pm_bus_off(host);
+
+		/*
+		 * Some controllers need an extra 100ms delay to secure
+		 * full power cycle is successful.
+		 */
+		if (host->quirks2 & SDHCI_QUIRK2_DELAY_AFTER_POWER_OFF)
+			msleep(100);
 	} else {
 		/*
 		 * Spec says that we should clear the power reg before setting
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 0ed3e0eaef5f..0e6f97eaa796 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -482,6 +482,8 @@ struct sdhci_host {
  * block count.
  */
 #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT			(1<<18)
+/* Controllers need an extra 100ms delay to make sure power off completely */
+#define SDHCI_QUIRK2_DELAY_AFTER_POWER_OFF		(1<<19)
 
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */
-- 
2.17.1




[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux