Skip to content

Commit a1e0878

Browse files
committed
mmc: sdhci-pci: Support setting CD debounce delay
Some systems (e.g. 2021 MacBook Pro 14/16") have noncompliant connectors where CD activates before the card is fully inserted. We need debounce delay support on these to avoid detection failures when the card isn't inserted very quickly. Set the default to 200ms for all systems instead of 0. This is the default on non-PCI platforms, and will probably help other systems too. The naughty MacBooks will need closer to 750ms in the device tree to be reliable... Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 571bfb1 commit a1e0878

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,6 +2036,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
20362036
struct sdhci_host *host;
20372037
int ret, bar = first_bar + slotno;
20382038
size_t priv_size = chip->fixes ? chip->fixes->priv_size : 0;
2039+
u32 cd_debounce_delay_ms;
20392040

20402041
if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
20412042
dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar);
@@ -2102,14 +2103,18 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21022103
if (host->mmc->caps & MMC_CAP_CD_WAKE)
21032104
device_init_wakeup(&pdev->dev, true);
21042105

2106+
if (device_property_read_u32(&pdev->dev, "cd-debounce-delay-ms",
2107+
&cd_debounce_delay_ms))
2108+
cd_debounce_delay_ms = 200;
2109+
21052110
if (slot->cd_idx >= 0) {
21062111
ret = mmc_gpiod_request_cd(host->mmc, "cd", slot->cd_idx,
21072112
slot->cd_override_level, 0);
21082113
if (ret && ret != -EPROBE_DEFER)
21092114
ret = mmc_gpiod_request_cd(host->mmc, NULL,
21102115
slot->cd_idx,
21112116
slot->cd_override_level,
2112-
0);
2117+
cd_debounce_delay_ms * 1000);
21132118
if (ret == -EPROBE_DEFER)
21142119
goto remove;
21152120

@@ -2121,7 +2126,8 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21212126
/* Allow all OF systems to use a CD GPIO if provided */
21222127

21232128
ret = mmc_gpiod_request_cd(host->mmc, "cd", 0,
2124-
slot->cd_override_level, 0);
2129+
slot->cd_override_level,
2130+
cd_debounce_delay_ms * 1000);
21252131
if (ret == -EPROBE_DEFER)
21262132
goto remove;
21272133
else if (ret == 0)

0 commit comments

Comments
 (0)