The Bay Trail SoC SD controller for the SD card slot doesn't use the
Card Detect bit in the standard register.  Instead there is a separate
gpio that signals the presence of a card in the slot.  The diff below
introduces a function pointer in the sdhc softc that, if non-NULL,
gets called instead of checking the bit in the standard register.

ok?


Index: sdhc.c
===================================================================
RCS file: /cvs/src/sys/dev/sdmmc/sdhc.c,v
retrieving revision 1.41
diff -u -p -r1.41 sdhc.c
--- sdhc.c      11 Jan 2016 06:54:53 -0000      1.41
+++ sdhc.c      2 Feb 2016 18:57:57 -0000
@@ -381,6 +381,10 @@ int
 sdhc_card_detect(sdmmc_chipset_handle_t sch)
 {
        struct sdhc_host *hp = sch;
+
+       if (hp->sc->sc_card_detect)
+               return hp->sc->sc_card_detect(hp->sc);
+
        return ISSET(HREAD4(hp, SDHC_PRESENT_STATE), SDHC_CARD_INSERTED) ?
            1 : 0;
 }
Index: sdhcvar.h
===================================================================
RCS file: /cvs/src/sys/dev/sdmmc/sdhcvar.h,v
retrieving revision 1.6
diff -u -p -r1.6 sdhcvar.h
--- sdhcvar.h   31 Jul 2011 16:55:01 -0000      1.6
+++ sdhcvar.h   2 Feb 2016 18:57:57 -0000
@@ -28,6 +28,8 @@ struct sdhc_softc {
        struct sdhc_host **sc_host;
        int sc_nhosts;
        u_int sc_flags;
+
+       int (*sc_card_detect)(struct sdhc_softc *);
 };
 
 /* Host controller functions called by the attachment driver. */

Reply via email to