From a2565e09d8d653143223db92babcc99de63d45ce Mon Sep 17 00:00:00 2001
From: Ong Boon Leong <boon.leong.ong@intel.com>
Date: Thu, 23 Jan 2014 13:28:26 +0800
Subject: [PATCH] valleyisland-io: Force BYT SDCARD host to run with SDR25

SD Card v3.01 in the market is not compatible with BYT SDHC IP
in SoC because this IP only support SD v3.0 only. So, we are
forcing DDR50 mode to always step down to SDR25.

Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
 ...BYT-SDCARD-host-to-run-with-SDR25-mo.patch | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 features/valleyisland-io/0017-mmc-sdhci-Force-BYT-SDCARD-host-to-run-with-SDR25-mo.patch

diff --git a/features/valleyisland-io/0017-mmc-sdhci-Force-BYT-SDCARD-host-to-run-with-SDR25-mo.patch b/features/valleyisland-io/0017-mmc-sdhci-Force-BYT-SDCARD-host-to-run-with-SDR25-mo.patch
new file mode 100644
index 000000000..89a50c517
--- /dev/null
+++ b/features/valleyisland-io/0017-mmc-sdhci-Force-BYT-SDCARD-host-to-run-with-SDR25-mo.patch
@@ -0,0 +1,78 @@
+From 2a04e9579aaebe6263e9f32bb6b507c9c451cc83 Mon Sep 17 00:00:00 2001
+From: Chew, Kean Ho <kean.ho.chew@intel.com>
+Date: Mon, 23 Dec 2013 16:14:27 +0800
+Subject: [PATCH 17/17] mmc: sdhci: Force BYT SDCARD host to run with SDR25
+ mode
+
+SD Card v3.01 in the market is not compatible with BYT SDHC IP in SoC
+because this IP only support SD v3.0 only. So, we are forcing DDR50 mode
+to always step down to SDR25.
+
+Signed-off-by: Chew, Kean Ho <kean.ho.chew@intel.com>
+Signed-off-by: Chew, Chiau Ee <chiau.ee.chew@intel.com>
+---
+ drivers/mmc/host/sdhci-acpi.c |    3 ++-
+ drivers/mmc/host/sdhci-pci.c  |    3 ++-
+ drivers/mmc/host/sdhci.c      |    3 ++-
+ include/linux/mmc/sdhci.h     |    3 ++
+ 4 files changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
+index 119568f..11acee1 100644
+--- a/drivers/mmc/host/sdhci-acpi.c
++++ b/drivers/mmc/host/sdhci-acpi.c
+@@ -130,7 +130,8 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sdio = {
+
+ static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sd = {
+ 	.flags   = SDHCI_ACPI_SD_CD | SDHCI_ACPI_RUNTIME_PM,
+-	.quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON,
++	.quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON |
++		   SDHCI_QUIRK2_BROKEN_DDR50,
+ };
+
+ struct sdhci_acpi_uid_slot {
+diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
+index 33593e7..8848182 100644
+--- a/drivers/mmc/host/sdhci-pci.c
++++ b/drivers/mmc/host/sdhci-pci.c
+@@ -354,7 +354,8 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_sdio = {
+ };
+
+ static const struct sdhci_pci_fixes sdhci_intel_byt_sd = {
+-	.quirks2	= SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON,
++	.quirks2	= SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON |
++			  SDHCI_QUIRK2_BROKEN_DDR50,
+ 	.allow_runtime_pm = true,
+ 	.own_cd_for_runtime_pm = true,
+ };
+diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
+index 22d91ec..10bd57d 100644
+--- a/drivers/mmc/host/sdhci.c
++++ b/drivers/mmc/host/sdhci.c
+@@ -2972,7 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host)
+ 	else if (caps[1] & SDHCI_SUPPORT_SDR50)
+ 		mmc->caps |= MMC_CAP_UHS_SDR50;
+
+-	if (caps[1] & SDHCI_SUPPORT_DDR50)
++	if ((caps[1] & SDHCI_SUPPORT_DDR50) &&
++	    !(host->quirks2 & SDHCI_QUIRK2_BROKEN_DDR50))
+ 		mmc->caps |= MMC_CAP_UHS_DDR50;
+
+ 	/* Does the host need tuning for SDR50? */
+diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
+index ba35bdb..7c9d2d1 100644
+--- a/include/linux/mmc/sdhci.h
++++ b/include/linux/mmc/sdhci.h
+@@ -96,6 +96,9 @@ struct sdhci_host {
+ #define SDHCI_QUIRK2_NO_1_8_V				(1<<2)
+ #define SDHCI_QUIRK2_PRESET_VALUE_BROKEN		(1<<3)
+ #define SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON		(1<<4)
++/* bit 5 is used by SDHCI_QUIRK2_BROKEN_HOST_CONTROL in upstream */
++/* Controller has a broken DDR50 Time Spec */
++#define SDHCI_QUIRK2_BROKEN_DDR50			(1<<6)
+
+ 	int irq;		/* Device IRQ */
+ 	void __iomem *ioaddr;	/* Mapped address */
+--
+1.7.4.4
+
-- 
GitLab