Skip to contentSkip to conversation

mmc: sdhci-acpi: Fix Braswell eMMC timeout clock frequency

PATCH Applied Adrian Hunter 2 participants 5 messages Oct 6, 2014

Subsystems (2)
lore
Share & tools
lore

Adrian Hunter

author maintainer
#0 lore raw

cover mmc: sdhci-acpi: Fix Braswell eMMC timeout clock frequency

Hi

Here are 3 patches that fix Fix Braswell eMMC timeout clock frequency. A fix has already been done for sdhci-pci, so please consider these for 3.18 also.

Adrian Hunter (3):
mmc: sdhci-acpi: Get UID directly from acpi_device
mmc: sdhci-acpi: Pass HID and UID to probe_slot
mmc: sdhci-acpi: Fix Braswell eMMC timeout clock frequency

 drivers/mmc/host/sdhci-acpi.c | 44 ++++++++++++++++++-------------------------
 1 file changed, 18 insertions(+), 26 deletions(-)

Regards
Adrian

author maintainer
#1 lore raw

PATCH 1/3 mmc: sdhci-acpi: Get UID directly from acpi_device

UID was made available on acpi_device since
commit ccf78040265b ("ACPI: Add _UID support for ACPI devices.") Use it from there instead of reprocessing the
ACPI object info.

---
 drivers/mmc/host/sdhci-acpi.c | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)
drivers/mmc/host/sdhci-acpi.c +5 -21
index e9a2c6f..839f26c 100644
@@ -225,8 +225,8 @@ static const struct acpi_device_id sdhci_acpi_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids);
 
-static const struct sdhci_acpi_slot *sdhci_acpi_get_slot_by_ids(const char *hid,
-								const char *uid)
+static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(const char *hid,
+							 const char *uid)
 {
 	const struct sdhci_acpi_uid_slot *u;
 
@@ -241,24 +241,6 @@ static const struct sdhci_acpi_slot *sdhci_acpi_get_slot_by_ids(const char *hid,
 	return NULL;
 }
 
-static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(acpi_handle handle,
-							 const char *hid)
-{
-	const struct sdhci_acpi_slot *slot;
-	struct acpi_device_info *info;
-	const char *uid = NULL;
-	acpi_status status;
-
-	status = acpi_get_object_info(handle, &info);
-	if (!ACPI_FAILURE(status) && (info->valid & ACPI_VALID_UID))
-		uid = info->unique_id.string;
-
-	slot = sdhci_acpi_get_slot_by_ids(hid, uid);
-
-	kfree(info);
-	return slot;
-}
-
 static int sdhci_acpi_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -269,6 +251,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
 	struct resource *iomem;
 	resource_size_t len;
 	const char *hid;
+	const char *uid;
 	int err;
 
 	if (acpi_bus_get_device(handle, &device))
@@ -278,6 +261,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
 		return -ENODEV;
 
 	hid = acpi_device_hid(device);
+	uid = device->pnp.unique_id;
 
 	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!iomem)
@@ -296,7 +280,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
 
 	c = sdhci_priv(host);
 	c->host = host;
-	c->slot = sdhci_acpi_get_slot(handle, hid);
+	c->slot = sdhci_acpi_get_slot(hid, uid);
 	c->pdev = pdev;
 	c->use_runtime_pm = sdhci_acpi_flag(c, SDHCI_ACPI_RUNTIME_PM);
 
Signature · 1 line
1.9.1
author maintainer
#2 lore raw

PATCH 2/3 mmc: sdhci-acpi: Pass HID and UID to probe_slot

In reply to Adrian Hunter

Pass HID and UID to probe_slot so extra setup
can be done for specific ids.

---
 drivers/mmc/host/sdhci-acpi.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/mmc/host/sdhci-acpi.c +8 -5
index 839f26c..7548261 100644
@@ -67,7 +67,7 @@ struct sdhci_acpi_slot {
 	unsigned int	caps2;
 	mmc_pm_flag_t	pm_caps;
 	unsigned int	flags;
-	int (*probe_slot)(struct platform_device *);
+	int (*probe_slot)(struct platform_device *, const char *, const char *);
 	int (*remove_slot)(struct platform_device *);
 };
 
@@ -124,7 +124,8 @@ static const struct sdhci_acpi_chip sdhci_acpi_chip_int = {
 	.ops = &sdhci_acpi_ops_int,
 };
 
-static int sdhci_acpi_emmc_probe_slot(struct platform_device *pdev)
+static int sdhci_acpi_emmc_probe_slot(struct platform_device *pdev,
+				      const char *hid, const char *uid)
 {
 	struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
 	struct sdhci_host *host;
@@ -139,7 +140,8 @@ static int sdhci_acpi_emmc_probe_slot(struct platform_device *pdev)
 	return 0;
 }
 
-static int sdhci_acpi_sdio_probe_slot(struct platform_device *pdev)
+static int sdhci_acpi_sdio_probe_slot(struct platform_device *pdev,
+				      const char *hid, const char *uid)
 {
 	struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
 	struct sdhci_host *host;
@@ -154,7 +156,8 @@ static int sdhci_acpi_sdio_probe_slot(struct platform_device *pdev)
 	return 0;
 }
 
-static int sdhci_acpi_sd_probe_slot(struct platform_device *pdev)
+static int sdhci_acpi_sd_probe_slot(struct platform_device *pdev,
+				    const char *hid, const char *uid)
 {
 	struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
 	struct sdhci_host *host;
@@ -314,7 +317,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
 
 	if (c->slot) {
 		if (c->slot->probe_slot) {
-			err = c->slot->probe_slot(pdev);
+			err = c->slot->probe_slot(pdev, hid, uid);
 			if (err)
 				goto err_free;
 		}
Signature · 1 line
1.9.1
author maintainer
#3 lore raw

PATCH 3/3 mmc: sdhci-acpi: 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. A similar fix was done for sdhci-pci, however in the sdhci-acpi case the HID/UID is not unique so the capabilities register values are matched also.

---
 drivers/mmc/host/sdhci-acpi.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mmc/host/sdhci-acpi.c +5 -0
index 7548261..9cccc0e 100644
@@ -137,6 +137,11 @@ static int sdhci_acpi_emmc_probe_slot(struct platform_device *pdev,
 
 	/* Platform specific code during emmc proble slot goes here */
 
+	if (hid && uid && !strcmp(hid, "80860F14") && !strcmp(uid, "1") &&
+	    sdhci_readl(host, SDHCI_CAPABILITIES) == 0x446cc8b2 &&
+	    sdhci_readl(host, SDHCI_CAPABILITIES_1) == 0x00000807)
+		host->timeout_clk = 1000; /* 1000 kHz i.e. 1 MHz */
+
 	return 0;
 }
 
Signature · 1 line
1.9.1
Applied
#4 lore raw
In reply to Adrian Hunter
Quoted 5 lines · Adrian Hunter

Hi

Here are 3 patches that fix Fix Braswell eMMC timeout clock frequency. A fix has already been done for sdhci-pci, so please consider these for 3.18 also.

Thanks! Applied for next.

Kind regards
Uffe

Quoted 13 lines

Adrian Hunter (3):
mmc: sdhci-acpi: Get UID directly from acpi_device
mmc: sdhci-acpi: Pass HID and UID to probe_slot
mmc: sdhci-acpi: Fix Braswell eMMC timeout clock frequency

 drivers/mmc/host/sdhci-acpi.c | 44 ++++++++++++++++++-------------------------
 1 file changed, 18 insertions(+), 26 deletions(-)

Regards
Adrian