]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mmc: sdhci-pci: Fix BYT sd card getting stuck in runtime suspend
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 13 Jan 2014 07:49:16 +0000 (09:49 +0200)
committerChris Ball <chris@printf.net>
Mon, 20 Jan 2014 15:31:08 +0000 (10:31 -0500)
A host controller for a SD card may need a GPIO for card detect in order
to wake up from runtime suspend when a card is inserted.  If that GPIO is
not configured, then the host controller will not wake up.  Fix that for
the affected devices by not enabling runtime PM unless the GPIO is
successfully set up.

This affects BYT sd card host controller which had runtime PM enabled from
v3.11.  For completeness, the MFD sd card host controller is flagged also.

The original patch before rebasing (see link below) was tested on v3.11.10
and v3.12.4 although the patch applied with some offsets and fuzz.  The
original patch is here:

    http://marc.info/?l=linux-mmc&m=138676702327057

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable <stable@vger.kernel.org> # 3.11+
Signed-off-by: Chris Ball <chris@printf.net>
drivers/mmc/host/sdhci-pci.c
drivers/mmc/host/sdhci-pci.h

index f46b84ce4ec8dc13ab8d5412117373478591e0bf..92e6e81b4de2f9dcdfddadbf1f815183f971766c 100644 (file)
@@ -225,6 +225,7 @@ static const struct sdhci_pci_fixes sdhci_intel_mrst_hc1_hc2 = {
 static const struct sdhci_pci_fixes sdhci_intel_mfd_sd = {
        .quirks         = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
        .allow_runtime_pm = true,
+       .own_cd_for_runtime_pm = true,
 };
 
 static const struct sdhci_pci_fixes sdhci_intel_mfd_sdio = {
@@ -289,6 +290,7 @@ 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,
        .allow_runtime_pm = true,
+       .own_cd_for_runtime_pm = true,
 };
 
 /* Define Host controllers for Intel Merrifield platform */
@@ -1371,6 +1373,14 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 
        sdhci_pci_add_own_cd(slot);
 
+       /*
+        * Check if the chip needs a separate GPIO for card detect to wake up
+        * from runtime suspend.  If it is not there, don't allow runtime PM.
+        * Note sdhci_pci_add_own_cd() sets slot->cd_gpio to -EINVAL on failure.
+        */
+       if (chip->fixes->own_cd_for_runtime_pm && !gpio_is_valid(slot->cd_gpio))
+               chip->allow_runtime_pm = false;
+
        return slot;
 
 remove:
index 0347804eda80003777378d73c24632b77fcee0db..6d718719659e48abbc63ff7376f26b0dd6696d3b 100644 (file)
@@ -39,6 +39,7 @@ struct sdhci_pci_fixes {
        unsigned int            quirks;
        unsigned int            quirks2;
        bool                    allow_runtime_pm;
+       bool                    own_cd_for_runtime_pm;
 
        int                     (*probe) (struct sdhci_pci_chip *);