aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2014-09-24 03:27:31 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2014-10-03 08:24:52 -0400
commitff59c520b5fec9733d5402fdfa76fa4435a40bba (patch)
tree3a95e3a50726ec2b54d3099b2e986fab41cb5640
parente58e4a0d14a5b8b6ab2aa2942cb2440e45c1f8c9 (diff)
mmc: sdhci-pci: Add Bay Trail and Braswell SD card detect
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. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/host/sdhci-pci.c20
-rw-r--r--drivers/mmc/host/sdhci-pci.h4
2 files changed, 23 insertions, 1 deletions
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index 31181d8dc561..4ca6ae6a175d 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -24,6 +24,7 @@
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/gpio.h> 25#include <linux/gpio.h>
26#include <linux/pm_runtime.h> 26#include <linux/pm_runtime.h>
27#include <linux/mmc/slot-gpio.h>
27#include <linux/mmc/sdhci-pci-data.h> 28#include <linux/mmc/sdhci-pci-data.h>
28 29
29#include "sdhci.h" 30#include "sdhci.h"
@@ -280,6 +281,14 @@ static int byt_sdio_probe_slot(struct sdhci_pci_slot *slot)
280 return 0; 281 return 0;
281} 282}
282 283
284static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
285{
286 slot->cd_con_id = NULL;
287 slot->cd_idx = 0;
288 slot->cd_override_level = true;
289 return 0;
290}
291
283static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = { 292static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = {
284 .allow_runtime_pm = true, 293 .allow_runtime_pm = true,
285 .probe_slot = byt_emmc_probe_slot, 294 .probe_slot = byt_emmc_probe_slot,
@@ -300,6 +309,7 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_sd = {
300 SDHCI_QUIRK2_STOP_WITH_TC, 309 SDHCI_QUIRK2_STOP_WITH_TC,
301 .allow_runtime_pm = true, 310 .allow_runtime_pm = true,
302 .own_cd_for_runtime_pm = true, 311 .own_cd_for_runtime_pm = true,
312 .probe_slot = byt_sd_probe_slot,
303}; 313};
304 314
305/* Define Host controllers for Intel Merrifield platform */ 315/* Define Host controllers for Intel Merrifield platform */
@@ -1354,6 +1364,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
1354 slot->pci_bar = bar; 1364 slot->pci_bar = bar;
1355 slot->rst_n_gpio = -EINVAL; 1365 slot->rst_n_gpio = -EINVAL;
1356 slot->cd_gpio = -EINVAL; 1366 slot->cd_gpio = -EINVAL;
1367 slot->cd_idx = -1;
1357 1368
1358 /* Retrieve platform data if there is any */ 1369 /* Retrieve platform data if there is any */
1359 if (*sdhci_pci_get_data) 1370 if (*sdhci_pci_get_data)
@@ -1412,6 +1423,13 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
1412 host->mmc->slotno = slotno; 1423 host->mmc->slotno = slotno;
1413 host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP; 1424 host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
1414 1425
1426 if (slot->cd_idx >= 0 &&
1427 mmc_gpiod_request_cd(host->mmc, slot->cd_con_id, slot->cd_idx,
1428 slot->cd_override_level, 0, NULL)) {
1429 dev_warn(&pdev->dev, "failed to setup card detect gpio\n");
1430 slot->cd_idx = -1;
1431 }
1432
1415 ret = sdhci_add_host(host); 1433 ret = sdhci_add_host(host);
1416 if (ret) 1434 if (ret)
1417 goto remove; 1435 goto remove;
@@ -1424,7 +1442,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
1424 * Note sdhci_pci_add_own_cd() sets slot->cd_gpio to -EINVAL on failure. 1442 * Note sdhci_pci_add_own_cd() sets slot->cd_gpio to -EINVAL on failure.
1425 */ 1443 */
1426 if (chip->fixes && chip->fixes->own_cd_for_runtime_pm && 1444 if (chip->fixes && chip->fixes->own_cd_for_runtime_pm &&
1427 !gpio_is_valid(slot->cd_gpio)) 1445 !gpio_is_valid(slot->cd_gpio) && slot->cd_idx < 0)
1428 chip->allow_runtime_pm = false; 1446 chip->allow_runtime_pm = false;
1429 1447
1430 return slot; 1448 return slot;
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index 9c1909b2a3ad..d57c3d169914 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -64,6 +64,10 @@ struct sdhci_pci_slot {
64 int cd_gpio; 64 int cd_gpio;
65 int cd_irq; 65 int cd_irq;
66 66
67 char *cd_con_id;
68 int cd_idx;
69 bool cd_override_level;
70
67 void (*hw_reset)(struct sdhci_host *host); 71 void (*hw_reset)(struct sdhci_host *host);
68}; 72};
69 73