Skip to content

Commit 39d9105

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 a1bca3e commit 39d9105

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
@@ -2125,6 +2125,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21252125
struct sdhci_host *host;
21262126
int ret, bar = first_bar + slotno;
21272127
size_t priv_size = chip->fixes ? chip->fixes->priv_size : 0;
2128+
u32 cd_debounce_delay_ms;
21282129

21292130
if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
21302131
dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar);
@@ -2191,6 +2192,10 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21912192
if (host->mmc->caps & MMC_CAP_CD_WAKE)
21922193
device_init_wakeup(&pdev->dev, true);
21932194

2195+
if (device_property_read_u32(&pdev->dev, "cd-debounce-delay-ms",
2196+
&cd_debounce_delay_ms))
2197+
cd_debounce_delay_ms = 200;
2198+
21942199
if (slot->cd_idx >= 0) {
21952200
struct gpiod_lookup_table *cd_gpio_lookup_table;
21962201

@@ -2209,7 +2214,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
22092214
ret = mmc_gpiod_request_cd(host->mmc, NULL,
22102215
slot->cd_idx,
22112216
slot->cd_override_level,
2212-
0);
2217+
cd_debounce_delay_ms * 1000);
22132218
if (ret == -EPROBE_DEFER)
22142219
goto remove;
22152220

@@ -2221,7 +2226,8 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
22212226
/* Allow all OF systems to use a CD GPIO if provided */
22222227

22232228
ret = mmc_gpiod_request_cd(host->mmc, "cd", 0,
2224-
slot->cd_override_level, 0);
2229+
slot->cd_override_level,
2230+
cd_debounce_delay_ms * 1000);
22252231
if (ret == -EPROBE_DEFER)
22262232
goto remove;
22272233
else if (ret == 0)

0 commit comments

Comments
 (0)