Skip to content

Commit 163cbe3

Browse files
ahunter6storulf
authored andcommitted
mmc: sdhci-pci: Fix card detect race for Intel BXT/APL
Intel BXT/APL use a card detect GPIO however the host controller will not enable bus power unless it's card detect also reflects the presence of a card. Unfortunately those 2 things race which can result in commands not starting, after which the controller does nothing and there is a 10 second wait for the driver's 10-second timer to timeout. That is fixed by having the driver look also at the present state register to determine if the card is present. Consequently, provide a 'get_cd' mmc host operation for BXT/APL that does that. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: stable@vger.kernel.org # v4.4+ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 8d28b7a commit 163cbe3

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

drivers/mmc/host/sdhci-pci-core.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,33 @@ static void spt_read_drive_strength(struct sdhci_host *host)
330330
sdhci_pci_spt_drive_strength = 0x10 | ((val >> 12) & 0xf);
331331
}
332332

333+
static int bxt_get_cd(struct mmc_host *mmc)
334+
{
335+
int gpio_cd = mmc_gpio_get_cd(mmc);
336+
struct sdhci_host *host = mmc_priv(mmc);
337+
unsigned long flags;
338+
int ret = 0;
339+
340+
if (!gpio_cd)
341+
return 0;
342+
343+
pm_runtime_get_sync(mmc->parent);
344+
345+
spin_lock_irqsave(&host->lock, flags);
346+
347+
if (host->flags & SDHCI_DEVICE_DEAD)
348+
goto out;
349+
350+
ret = !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
351+
out:
352+
spin_unlock_irqrestore(&host->lock, flags);
353+
354+
pm_runtime_mark_last_busy(mmc->parent);
355+
pm_runtime_put_autosuspend(mmc->parent);
356+
357+
return ret;
358+
}
359+
333360
static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
334361
{
335362
slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE |
@@ -362,6 +389,10 @@ static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
362389
slot->cd_con_id = NULL;
363390
slot->cd_idx = 0;
364391
slot->cd_override_level = true;
392+
if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BXT_SD ||
393+
slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_APL_SD)
394+
slot->host->mmc_host_ops.get_cd = bxt_get_cd;
395+
365396
return 0;
366397
}
367398

0 commit comments

Comments
 (0)