Linux MultiMedia Card development
 help / color / mirror / Atom feed
* [PATCH] mmc: Fix force card detect in sdhci
@ 2023-08-30  9:23 mathieu
  2023-09-04  7:38 ` Adrian Hunter
  0 siblings, 1 reply; 6+ messages in thread
From: mathieu @ 2023-08-30  9:23 UTC (permalink / raw)
  To: ludovic.desroches, adrian.hunter, ulf.hansson, nicolas.ferre,
	alexandre.belloni
  Cc: Mathieu Moneyron, linux-mmc, linux-arm-kernel, linux-kernel

From: Mathieu Moneyron <mathieu.moneyron@gmail.com>

On the ATMEL at91 when using the non-removable flag in device tree and not
using the card-detect pin inside the device-tree pinctrl, the card detect
pin is physically still used which can cause unknown behaviour when this
pin is used for other purposes.

From my interpretation this seems to be caused by a hardware design flaw
and the real hardware is not working as intended by the documentation.

Signed-off-by: Mathieu Moneyron <mathieu.moneyron@gmail.com>
---
 drivers/mmc/host/sdhci-of-at91.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
index 69fef88e7..4fd6bfbf6 100644
--- a/drivers/mmc/host/sdhci-of-at91.c
+++ b/drivers/mmc/host/sdhci-of-at91.c
@@ -51,10 +51,15 @@ struct sdhci_at91_priv {
 static void sdhci_at91_set_force_card_detect(struct sdhci_host *host)
 {
 	u8 mc1r;
+	u8 ctrl;
 
 	mc1r = readb(host->ioaddr + SDMMC_MC1R);
 	mc1r |= SDMMC_MC1R_FCD;
 	writeb(mc1r, host->ioaddr + SDMMC_MC1R);
+
+	ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
+	ctrl |= SDHCI_CTRL_CDTEST_INS | SDHCI_CTRL_CDTEST_EN;
+	writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
 }
 
 static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-14 11:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-30  9:23 [PATCH] mmc: Fix force card detect in sdhci mathieu
2023-09-04  7:38 ` Adrian Hunter
2023-09-23 12:44   ` Aubin Constans
2023-09-23 14:23     ` Mathieu Moneyron
2023-11-10 19:57       ` Aubin Constans
2023-11-14 11:06         ` Mathieu Moneyron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox