Skip to content

Commit ddfb070

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 4ddd43a commit ddfb070

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
@@ -2130,6 +2130,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21302130
struct sdhci_host *host;
21312131
int ret, bar = first_bar + slotno;
21322132
size_t priv_size = chip->fixes ? chip->fixes->priv_size : 0;
2133+
u32 cd_debounce_delay_ms;
21332134

21342135
if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
21352136
dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar);
@@ -2196,6 +2197,10 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21962197
if (host->mmc->caps & MMC_CAP_CD_WAKE)
21972198
device_init_wakeup(&pdev->dev, true);
21982199

2200+
if (device_property_read_u32(&pdev->dev, "cd-debounce-delay-ms",
2201+
&cd_debounce_delay_ms))
2202+
cd_debounce_delay_ms = 200;
2203+
21992204
if (slot->cd_idx >= 0) {
22002205
struct gpiod_lookup_table *cd_gpio_lookup_table;
22012206

@@ -2214,7 +2219,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
22142219
ret = mmc_gpiod_request_cd(host->mmc, NULL,
22152220
slot->cd_idx,
22162221
slot->cd_override_level,
2217-
0);
2222+
cd_debounce_delay_ms * 1000);
22182223
if (ret == -EPROBE_DEFER)
22192224
goto remove;
22202225

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

22282233
ret = mmc_gpiod_request_cd(host->mmc, "cd", 0,
2229-
slot->cd_override_level, 0);
2234+
slot->cd_override_level,
2235+
cd_debounce_delay_ms * 1000);
22302236
if (ret == -EPROBE_DEFER)
22312237
goto remove;
22322238
else if (ret == 0)

0 commit comments

Comments
 (0)