Seems the voltage bit defenitions in sdmmcreg.h for voltages below 2V
are not quite right.  At least I can't find them in any of the MMC and
SD card documentation I can find on the interwebs.  Instead there is a
single "low voltage bit" that indicates support for the 1.65-1.95V or
1.70-1.95V range depending on the document you're reading.  Linux
seems to use the slightly wider range, so that is what I did as well.

This diff is necessary to support the eMMC storage on my ASUS X205TA,
where the SDHC only supports 1.8V.  Wihout this diff our code
concludes there is no common voltage supported by both the card and
the host controller and the card isn't enabled.

ok?


Index: sdhc.c
===================================================================
RCS file: /cvs/src/sys/dev/sdmmc/sdhc.c,v
retrieving revision 1.39
diff -u -p -r1.39 sdhc.c
--- sdhc.c      14 Mar 2015 03:38:49 -0000      1.39
+++ sdhc.c      10 Jan 2016 11:19:53 -0000
@@ -198,7 +198,7 @@ sdhc_host_found(struct sdhc_softc *sc, b
         * Determine SD bus voltage levels supported by the controller.
         */
        if (ISSET(caps, SDHC_VOLTAGE_SUPP_1_8V))
-               SET(hp->ocr, MMC_OCR_1_7V_1_8V | MMC_OCR_1_8V_1_9V);
+               SET(hp->ocr, MMC_OCR_1_65V_1_95V);
        if (ISSET(caps, SDHC_VOLTAGE_SUPP_3_0V))
                SET(hp->ocr, MMC_OCR_2_9V_3_0V | MMC_OCR_3_0V_3_1V);
        if (ISSET(caps, SDHC_VOLTAGE_SUPP_3_3V))
@@ -406,7 +406,7 @@ sdhc_bus_power(sdmmc_chipset_handle_t sc
                vdd = SDHC_VOLTAGE_3_3V;
        else if (ISSET(ocr, MMC_OCR_2_9V_3_0V|MMC_OCR_3_0V_3_1V))
                vdd = SDHC_VOLTAGE_3_0V;
-       else if (ISSET(ocr, MMC_OCR_1_7V_1_8V|MMC_OCR_1_8V_1_9V))
+       else if (ISSET(ocr, MMC_OCR_1_65V_1_95V))
                vdd = SDHC_VOLTAGE_1_8V;
        else {
                /* Unsupported voltage level requested. */
Index: sdmmcreg.h
===================================================================
RCS file: /cvs/src/sys/dev/sdmmc/sdmmcreg.h,v
retrieving revision 1.7
diff -u -p -r1.7 sdmmcreg.h
--- sdmmcreg.h  8 Nov 2015 12:10:27 -0000       1.7
+++ sdmmcreg.h  10 Jan 2016 11:19:53 -0000
@@ -67,10 +67,7 @@
 #define MMC_OCR_2_2V_2_3V              (1<<10)
 #define MMC_OCR_2_1V_2_2V              (1<<9)
 #define MMC_OCR_2_0V_2_1V              (1<<8)
-#define MMC_OCR_1_9V_2_0V              (1<<7)
-#define MMC_OCR_1_8V_1_9V              (1<<6)
-#define MMC_OCR_1_7V_1_8V              (1<<5)
-#define MMC_OCR_1_6V_1_7V              (1<<4)
+#define MMC_OCR_1_65V_1_95V            (1<<7)
 
 #define SD_OCR_SDHC_CAP                        (1<<30)
 #define SD_OCR_VOL_MASK                        0xFF8000 /* bits 23:15 */

Reply via email to