Skip to content

Commit aeb84c5

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 eec9b04 commit aeb84c5

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
@@ -2119,6 +2119,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21192119
struct sdhci_host *host;
21202120
int ret, bar = first_bar + slotno;
21212121
size_t priv_size = chip->fixes ? chip->fixes->priv_size : 0;
2122+
u32 cd_debounce_delay_ms;
21222123

21232124
if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
21242125
dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar);
@@ -2185,6 +2186,10 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21852186
if (host->mmc->caps & MMC_CAP_CD_WAKE)
21862187
device_init_wakeup(&pdev->dev, true);
21872188

2189+
if (device_property_read_u32(&pdev->dev, "cd-debounce-delay-ms",
2190+
&cd_debounce_delay_ms))
2191+
cd_debounce_delay_ms = 200;
2192+
21882193
if (slot->cd_idx >= 0) {
21892194
struct gpiod_lookup_table *cd_gpio_lookup_table;
21902195

@@ -2203,7 +2208,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
22032208
ret = mmc_gpiod_request_cd(host->mmc, NULL,
22042209
slot->cd_idx,
22052210
slot->cd_override_level,
2206-
0);
2211+
cd_debounce_delay_ms * 1000);
22072212
if (ret == -EPROBE_DEFER)
22082213
goto remove;
22092214

@@ -2215,7 +2220,8 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
22152220
/* Allow all OF systems to use a CD GPIO if provided */
22162221

22172222
ret = mmc_gpiod_request_cd(host->mmc, "cd", 0,
2218-
slot->cd_override_level, 0);
2223+
slot->cd_override_level,
2224+
cd_debounce_delay_ms * 1000);
22192225
if (ret == -EPROBE_DEFER)
22202226
goto remove;
22212227
else if (ret == 0)

0 commit comments

Comments
 (0)