Skip to content

Commit 8e2774b

Browse files
marcanjannau
authored andcommitted
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 be84a42 commit 8e2774b

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
@@ -2063,6 +2063,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
20632063
struct sdhci_host *host;
20642064
int ret, bar = first_bar + slotno;
20652065
size_t priv_size = chip->fixes ? chip->fixes->priv_size : 0;
2066+
u32 cd_debounce_delay_ms;
20662067

20672068
if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
20682069
dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar);
@@ -2129,14 +2130,18 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21292130
if (host->mmc->caps & MMC_CAP_CD_WAKE)
21302131
device_init_wakeup(&pdev->dev, true);
21312132

2133+
if (device_property_read_u32(&pdev->dev, "cd-debounce-delay-ms",
2134+
&cd_debounce_delay_ms))
2135+
cd_debounce_delay_ms = 200;
2136+
21322137
if (slot->cd_idx >= 0) {
21332138
ret = mmc_gpiod_request_cd(host->mmc, "cd", slot->cd_idx,
21342139
slot->cd_override_level, 0);
21352140
if (ret && ret != -EPROBE_DEFER)
21362141
ret = mmc_gpiod_request_cd(host->mmc, NULL,
21372142
slot->cd_idx,
21382143
slot->cd_override_level,
2139-
0);
2144+
cd_debounce_delay_ms * 1000);
21402145
if (ret == -EPROBE_DEFER)
21412146
goto remove;
21422147

@@ -2148,7 +2153,8 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21482153
/* Allow all OF systems to use a CD GPIO if provided */
21492154

21502155
ret = mmc_gpiod_request_cd(host->mmc, "cd", 0,
2151-
slot->cd_override_level, 0);
2156+
slot->cd_override_level,
2157+
cd_debounce_delay_ms * 1000);
21522158
if (ret == -EPROBE_DEFER)
21532159
goto remove;
21542160
else if (ret == 0)

0 commit comments

Comments
 (0)