Skip to contentSkip to conversation

mmc: Some Braswell patches

PATCH Applied Adrian Hunter 2 participants 12 messages Sep 24, 2014 – Oct 3, 2014

Subsystems (2)
lore
Share & tools
lore

Adrian Hunter

author maintainer
#0 lore raw

cover mmc: Some Braswell patches

Hi

Here are some patches to further support for Intel Braswell SoC.

Adrian Hunter (7):
mmc: sdhci: Add quirk for always getting TC with stop cmd
mmc: sdhci-acpi: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel host controllers
mmc: sdhci-acpi: Add a HID and UID for a SD Card host controller
mmc: sdhci-pci: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel BYT host controllers
mmc: sdhci-pci: Add Bay Trail and Braswell SD card detect
mmc: sdhci: Let a driver override timeout clock frequency
mmc: sdhci-pci: Fix Braswell eMMC timeout clock frequency

 drivers/mmc/host/sdhci-acpi.c |  6 ++++--
 drivers/mmc/host/sdhci-pci.c  | 28 +++++++++++++++++++++++++---
 drivers/mmc/host/sdhci-pci.h  |  4 ++++
 drivers/mmc/host/sdhci.c      | 14 ++++++++++++--
 include/linux/mmc/sdhci.h     |  2 ++
 5 files changed, 47 insertions(+), 7 deletions(-)

Regards
Adrian

author maintainer
#1 lore raw

PATCH 1/7 mmc: sdhci: Add quirk for always getting TC with stop cmd

Add a quirk for a host controller that always sets a Transfer Complete interrupt status for the stop command even when a busy response is not indicated.

---
 drivers/mmc/host/sdhci.c  | 8 ++++++--
 include/linux/mmc/sdhci.h | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +6 -2
index 7a8586f..abad5e5 100644
@@ -2224,7 +2224,7 @@ static void sdhci_tuning_timer(unsigned long data)
  *                                                                           *
 \*****************************************************************************/
 
-static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
+static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *mask)
 {
 	BUG_ON(intmask == 0);
 
@@ -2271,6 +2271,9 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
 
 		/* The controller does not support the end-of-busy IRQ,
 		 * fall through and take the SDHCI_INT_RESPONSE */
+	} else if ((host->quirks2 & SDHCI_QUIRK2_STOP_WITH_TC) &&
+		   host->cmd->opcode == MMC_STOP_TRANSMISSION && !host->data) {
+		*mask &= ~SDHCI_INT_DATA_END;
 	}
 
 	if (intmask & SDHCI_INT_RESPONSE)
@@ -2481,7 +2484,8 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
 		}
 
 		if (intmask & SDHCI_INT_CMD_MASK)
-			sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK);
+			sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK,
+				      &intmask);
 
 		if (intmask & SDHCI_INT_DATA_MASK)
 			sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK);
include/linux/mmc/sdhci.h +2 -0
index 0aa85ca..dba793e 100644
@@ -98,6 +98,8 @@ struct sdhci_host {
 #define SDHCI_QUIRK2_BROKEN_HS200			(1<<6)
 /* Controller does not support DDR50 */
 #define SDHCI_QUIRK2_BROKEN_DDR50			(1<<7)
+/* Stop command (CMD12) can set Transfer Complete when not using MMC_RSP_BUSY */
+#define SDHCI_QUIRK2_STOP_WITH_TC			(1<<8)
 
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */
Signature · 1 line
1.8.3.2
author maintainer
#2 lore raw

PATCH 2/7 mmc: sdhci-acpi: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel host controllers

In reply to Adrian Hunter

Add quirk SDHCI_QUIRK2_STOP_WITH_TC for Intel host controllers.

---
 drivers/mmc/host/sdhci-acpi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-acpi.c +3 -2
index 3483c08..1bc92c6 100644
@@ -175,7 +175,7 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_int_emmc = {
 		   MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR,
 	.caps2   = MMC_CAP2_HC_ERASE_SZ,
 	.flags   = SDHCI_ACPI_RUNTIME_PM,
-	.quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
+	.quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | SDHCI_QUIRK2_STOP_WITH_TC,
 	.probe_slot	= sdhci_acpi_emmc_probe_slot,
 };
 
@@ -191,7 +191,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_SD_CD_OVERRIDE_LEVEL |
 		   SDHCI_ACPI_RUNTIME_PM,
-	.quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON,
+	.quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON |
+		   SDHCI_QUIRK2_STOP_WITH_TC,
 	.probe_slot	= sdhci_acpi_sd_probe_slot,
 };
 
Signature · 1 line
1.8.3.2
author maintainer
#3 lore raw

PATCH 3/7 mmc: sdhci-acpi: Add a HID and UID for a SD Card host controller

In reply to Adrian Hunter

Add a HID (INT33BB) and UID (3) for a SD Card host controller.

---
 drivers/mmc/host/sdhci-acpi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci-acpi.c +1 -0
index 1bc92c6..c38f089 100644
@@ -207,6 +207,7 @@ static const struct sdhci_acpi_uid_slot sdhci_acpi_uids[] = {
 	{ "80860F14" , "3" , &sdhci_acpi_slot_int_sd   },
 	{ "80860F16" , NULL, &sdhci_acpi_slot_int_sd   },
 	{ "INT33BB"  , "2" , &sdhci_acpi_slot_int_sdio },
+	{ "INT33BB"  , "3" , &sdhci_acpi_slot_int_sd },
 	{ "INT33C6"  , NULL, &sdhci_acpi_slot_int_sdio },
 	{ "INT3436"  , NULL, &sdhci_acpi_slot_int_sdio },
 	{ "PNP0D40"  },
Signature · 1 line
1.8.3.2
author maintainer
#4 lore raw

PATCH 4/7 mmc: sdhci-pci: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel BYT host controllers

In reply to Adrian Hunter

Add quirk SDHCI_QUIRK2_STOP_WITH_TC for Intel BYT host controllers.

---
 drivers/mmc/host/sdhci-pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-pci.c +4 -2
index 580073b..31181d8 100644
@@ -283,7 +283,8 @@ static int byt_sdio_probe_slot(struct sdhci_pci_slot *slot)
 static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = {
 	.allow_runtime_pm = true,
 	.probe_slot	= byt_emmc_probe_slot,
-	.quirks2	= SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
+	.quirks2	= SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
+			  SDHCI_QUIRK2_STOP_WITH_TC,
 };
 
 static const struct sdhci_pci_fixes sdhci_intel_byt_sdio = {
@@ -295,7 +296,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 |
-			SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
+			  SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
+			  SDHCI_QUIRK2_STOP_WITH_TC,
 	.allow_runtime_pm = true,
 	.own_cd_for_runtime_pm = true,
 };
Signature · 1 line
1.8.3.2
author maintainer
#5 lore raw

PATCH 5/7 mmc: sdhci-pci: Add Bay Trail and Braswell SD card detect

In reply to Adrian Hunter

Add support for card detect for Bay Trail
and Braswell SD Card host controllers in PCI
mode.

This uses the gpio descriptor API which can find gpio descriptors, for example, on an ACPI comapnion device.

---
 drivers/mmc/host/sdhci-pci.c | 20 +++++++++++++++++++-
 drivers/mmc/host/sdhci-pci.h |  4 ++++
 2 files changed, 23 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-pci.c +19 -1
index 31181d8..39499fb 100644
@@ -24,6 +24,7 @@
 #include <linux/io.h>
 #include <linux/gpio.h>
 #include <linux/pm_runtime.h>
+#include <linux/mmc/slot-gpio.h>
 #include <linux/mmc/sdhci-pci-data.h>
 
 #include "sdhci.h"
@@ -280,6 +281,14 @@ static int byt_sdio_probe_slot(struct sdhci_pci_slot *slot)
 	return 0;
 }
 
+static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
+{
+	slot->cd_con_id = NULL;
+	slot->cd_idx = 0;
+	slot->cd_override_level = true;
+	return 0;
+}
+
 static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = {
 	.allow_runtime_pm = true,
 	.probe_slot	= byt_emmc_probe_slot,
@@ -300,6 +309,7 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_sd = {
 			  SDHCI_QUIRK2_STOP_WITH_TC,
 	.allow_runtime_pm = true,
 	.own_cd_for_runtime_pm = true,
+	.probe_slot	= byt_sd_probe_slot,
 };
 
 /* Define Host controllers for Intel Merrifield platform */
@@ -1354,6 +1364,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 	slot->pci_bar = bar;
 	slot->rst_n_gpio = -EINVAL;
 	slot->cd_gpio = -EINVAL;
+	slot->cd_idx = -1;
 
 	/* Retrieve platform data if there is any */
 	if (*sdhci_pci_get_data)
@@ -1412,6 +1423,13 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 	host->mmc->slotno = slotno;
 	host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
 
+	if (slot->cd_idx >= 0 &&
+	    mmc_gpiod_request_cd(host->mmc, slot->cd_con_id, slot->cd_idx,
+				 slot->cd_override_level, 0)) {
+		dev_warn(&pdev->dev, "failed to setup card detect gpio\n");
+		slot->cd_idx = -1;
+	}
+
 	ret = sdhci_add_host(host);
 	if (ret)
 		goto remove;
@@ -1424,7 +1442,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 	 * Note sdhci_pci_add_own_cd() sets slot->cd_gpio to -EINVAL on failure.
 	 */
 	if (chip->fixes && chip->fixes->own_cd_for_runtime_pm &&
-	    !gpio_is_valid(slot->cd_gpio))
+	    !gpio_is_valid(slot->cd_gpio) && slot->cd_idx < 0)
 		chip->allow_runtime_pm = false;
 
 	return slot;
drivers/mmc/host/sdhci-pci.h +4 -0
index 9c1909b..d57c3d1 100644
@@ -64,6 +64,10 @@ struct sdhci_pci_slot {
 	int			cd_gpio;
 	int			cd_irq;
 
+	char			*cd_con_id;
+	int			cd_idx;
+	bool			cd_override_level;
+
 	void (*hw_reset)(struct sdhci_host *host);
 };
 
Signature · 1 line
1.8.3.2
author maintainer
#6 lore raw

PATCH 6/7 mmc: sdhci: Let a driver override timeout clock frequency

In reply to Adrian Hunter

Let a driver override the timeout clock frequency by populating it before calling sdhci_add_host(). Note the value will otherwise be zero because sdhci_host is zeroed when allocated.

---
 drivers/mmc/host/sdhci.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/mmc/host/sdhci.c +6 -0
index abad5e5..6ada726 100644
@@ -2791,6 +2791,7 @@ int sdhci_add_host(struct sdhci_host *host)
 	u32 caps[2] = {0, 0};
 	u32 max_current_caps;
 	unsigned int ocr_avail;
+	unsigned int override_timeout_clk;
 	int ret;
 
 	WARN_ON(host == NULL);
@@ -2804,6 +2805,8 @@ int sdhci_add_host(struct sdhci_host *host)
 	if (debug_quirks2)
 		host->quirks2 = debug_quirks2;
 
+	override_timeout_clk = host->timeout_clk;
+
 	sdhci_do_reset(host, SDHCI_RESET_ALL);
 
 	host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
@@ -2972,6 +2975,9 @@ int sdhci_add_host(struct sdhci_host *host)
 		mmc->max_busy_timeout /= host->timeout_clk;
 	}
 
+	if (override_timeout_clk)
+		host->timeout_clk = override_timeout_clk;
+
 	mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
 	mmc->caps2 |= MMC_CAP2_SDIO_IRQ_NOTHREAD;
 
Signature · 1 line
1.8.3.2
author maintainer
#7 lore raw

PATCH 7/7 mmc: sdhci-pci: Fix Braswell eMMC timeout clock frequency

In reply to Adrian Hunter

Braswell eMMC host controller specifies an incorrect timeout clock frequncy in the capabilities registers. The correct value is 1 MHz.

---
 drivers/mmc/host/sdhci-pci.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/host/sdhci-pci.c +2 -0
index 39499fb..9e791e9 100644
@@ -272,6 +272,8 @@ static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
 				 MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR;
 	slot->host->mmc->caps2 |= MMC_CAP2_HC_ERASE_SZ;
 	slot->hw_reset = sdhci_pci_int_hw_reset;
+	if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BSW_EMMC)
+		slot->host->timeout_clk = 1000; /* 1000 kHz i.e. 1 MHz */
 	return 0;
 }
 
Signature · 1 line
1.8.3.2
author maintainer
#8 lore raw
In reply to Adrian Hunter

Hi

Any comments on these?

Quoted 25 lines · Adrian Hunter

Hi

Here are some patches to further support for Intel Braswell SoC.

Adrian Hunter (7):
mmc: sdhci: Add quirk for always getting TC with stop cmd
mmc: sdhci-acpi: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel host controllers
mmc: sdhci-acpi: Add a HID and UID for a SD Card host controller
mmc: sdhci-pci: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel BYT host controllers
mmc: sdhci-pci: Add Bay Trail and Braswell SD card detect
mmc: sdhci: Let a driver override timeout clock frequency
mmc: sdhci-pci: Fix Braswell eMMC timeout clock frequency

 drivers/mmc/host/sdhci-acpi.c |  6 ++++--
 drivers/mmc/host/sdhci-pci.c  | 28 +++++++++++++++++++++++++---
 drivers/mmc/host/sdhci-pci.h  |  4 ++++
 drivers/mmc/host/sdhci.c      | 14 ++++++++++++--
 include/linux/mmc/sdhci.h     |  2 ++
 5 files changed, 47 insertions(+), 7 deletions(-)

Regards
Adrian

author maintainer
#9 lore raw

Ping?

Quoted 34 lines · Adrian Hunter

Hi

Any comments on these?

Quoted 25 lines · Adrian Hunter

Hi

Here are some patches to further support for Intel Braswell SoC.

Adrian Hunter (7):
mmc: sdhci: Add quirk for always getting TC with stop cmd
mmc: sdhci-acpi: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel host controllers
mmc: sdhci-acpi: Add a HID and UID for a SD Card host controller
mmc: sdhci-pci: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel BYT host controllers
mmc: sdhci-pci: Add Bay Trail and Braswell SD card detect
mmc: sdhci: Let a driver override timeout clock frequency
mmc: sdhci-pci: Fix Braswell eMMC timeout clock frequency

 drivers/mmc/host/sdhci-acpi.c |  6 ++++--
 drivers/mmc/host/sdhci-pci.c  | 28 +++++++++++++++++++++++++---
 drivers/mmc/host/sdhci-pci.h  |  4 ++++
 drivers/mmc/host/sdhci.c      | 14 ++++++++++++--
 include/linux/mmc/sdhci.h     |  2 ++
 5 files changed, 47 insertions(+), 7 deletions(-)

Regards
Adrian

Applied
#10 lore raw
In reply to Adrian Hunter
Quoted 15 lines · Adrian Hunter

Hi

Here are some patches to further support for Intel Braswell SoC.

Adrian Hunter (7):
mmc: sdhci: Add quirk for always getting TC with stop cmd
mmc: sdhci-acpi: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel host controllers
mmc: sdhci-acpi: Add a HID and UID for a SD Card host controller
mmc: sdhci-pci: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel BYT host controllers
mmc: sdhci-pci: Add Bay Trail and Braswell SD card detect
mmc: sdhci: Let a driver override timeout clock frequency
mmc: sdhci-pci: Fix Braswell eMMC timeout clock frequency

Quoted 8 lines
 drivers/mmc/host/sdhci-acpi.c |  6 ++++--
 drivers/mmc/host/sdhci-pci.c  | 28 +++++++++++++++++++++++++---
 drivers/mmc/host/sdhci-pci.h  |  4 ++++
 drivers/mmc/host/sdhci.c      | 14 ++++++++++++--
 include/linux/mmc/sdhci.h     |  2 ++
 5 files changed, 47 insertions(+), 7 deletions(-)

Thanks! Applied for next. It required a minor fix for patch 5, since the mmc_gpiod_request_cd() now takes one more parameter.

Kind regards
Uffe

author maintainer
#11 lore raw
Quoted 25 lines · Ulf Hansson
Quoted 15 lines · Adrian Hunter

Hi

Here are some patches to further support for Intel Braswell SoC.

Adrian Hunter (7):
mmc: sdhci: Add quirk for always getting TC with stop cmd
mmc: sdhci-acpi: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel host controllers
mmc: sdhci-acpi: Add a HID and UID for a SD Card host controller
mmc: sdhci-pci: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel BYT host controllers
mmc: sdhci-pci: Add Bay Trail and Braswell SD card detect
mmc: sdhci: Let a driver override timeout clock frequency
mmc: sdhci-pci: Fix Braswell eMMC timeout clock frequency

Quoted 8 lines
 drivers/mmc/host/sdhci-acpi.c |  6 ++++--
 drivers/mmc/host/sdhci-pci.c  | 28 +++++++++++++++++++++++++---
 drivers/mmc/host/sdhci-pci.h  |  4 ++++
 drivers/mmc/host/sdhci.c      | 14 ++++++++++++--
 include/linux/mmc/sdhci.h     |  2 ++
 5 files changed, 47 insertions(+), 7 deletions(-)
Quoted 2 lines

Thanks! Applied for next. It required a minor fix for patch 5, since the mmc_gpiod_request_cd() now takes one more parameter.

Thank you!