svn commit: r308187 - head/sys/dev/sdhci

Justin Hibbits jhibbits at FreeBSD.org
Wed Nov 2 00:54:41 UTC 2016


Author: jhibbits
Date: Wed Nov  2 00:54:39 2016
New Revision: 308187
URL: https://svnweb.freebsd.org/changeset/base/308187

Log:
  Toggle card insert/remove interrupt enable bits on events
  
  Some controllers (namely Freescale's eSDHC, tested) will continue to assert
  the card removed or card insert interrupts even after being handled.  To work
  around this, disable watching the interrupt that just occurred until the
  opposite interrupt is triggered.
  
  Linux has a similar change in its driver to address the same problem.

Modified:
  head/sys/dev/sdhci/sdhci.c

Modified: head/sys/dev/sdhci/sdhci.c
==============================================================================
--- head/sys/dev/sdhci/sdhci.c	Wed Nov  2 00:51:09 2016	(r308186)
+++ head/sys/dev/sdhci/sdhci.c	Wed Nov  2 00:54:39 2016	(r308187)
@@ -1309,7 +1309,7 @@ sdhci_acmd_irq(struct sdhci_slot *slot)
 void
 sdhci_generic_intr(struct sdhci_slot *slot)
 {
-	uint32_t intmask;
+	uint32_t intmask, present;
 	
 	SDHCI_LOCK(slot);
 	/* Read slot interrupt status. */
@@ -1323,6 +1323,13 @@ sdhci_generic_intr(struct sdhci_slot *sl
 
 	/* Handle card presence interrupts. */
 	if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)) {
+		present = RD4(slot, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT;
+		slot->intmask &=
+		    ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE);
+		slot->intmask |= present ? SDHCI_INT_CARD_REMOVE :
+		    SDHCI_INT_CARD_INSERT;
+		WR4(slot, SDHCI_INT_ENABLE, slot->intmask);
+		WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask);
 		WR4(slot, SDHCI_INT_STATUS, intmask & 
 		    (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE));
 


More information about the svn-src-head mailing list