lede/target/linux/silicon/patches-5.19/0061-mmc-sdhci-pci-Support-setting-CD-debounce-delay.patch

66 lines
2.4 KiB
Diff

From 5f9f115872ee614c22a9417f68ae9100ec32b5c7 Mon Sep 17 00:00:00 2001
From: Hector Martin <marcan@marcan.st>
Date: Thu, 5 May 2022 02:27:35 +0900
Subject: [PATCH 061/171] 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>
---
drivers/mmc/host/sdhci-pci-core.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index a711b4be3867..2fd4221b24aa 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -2015,6 +2015,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
struct sdhci_host *host;
int ret, bar = first_bar + slotno;
size_t priv_size = chip->fixes ? chip->fixes->priv_size : 0;
+ u32 cd_debounce_delay_ms;
if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar);
@@ -2081,6 +2082,10 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
if (host->mmc->caps & MMC_CAP_CD_WAKE)
device_init_wakeup(&pdev->dev, true);
+ if (device_property_read_u32(&pdev->dev, "cd-debounce-delay-ms",
+ &cd_debounce_delay_ms))
+ cd_debounce_delay_ms = 200;
+
if (slot->cd_idx >= 0) {
ret = mmc_gpiod_request_cd(host->mmc, "cd", slot->cd_idx,
slot->cd_override_level, 0);
@@ -2088,7 +2093,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
ret = mmc_gpiod_request_cd(host->mmc, NULL,
slot->cd_idx,
slot->cd_override_level,
- 0);
+ cd_debounce_delay_ms * 1000);
if (ret == -EPROBE_DEFER)
goto remove;
@@ -2100,7 +2105,8 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
/* Allow all OF systems to use a CD GPIO if provided */
ret = mmc_gpiod_request_cd(host->mmc, "cd", 0,
- slot->cd_override_level, 0);
+ slot->cd_override_level,
+ cd_debounce_delay_ms * 1000);
if (ret == -EPROBE_DEFER)
goto remove;
else if (ret == 0)
--
2.34.1