Module Name: src Committed By: jmcneill Date: Sat Aug 8 10:50:55 UTC 2015
Modified Files: src/sys/dev/sdmmc: sdmmc_mem.c sdmmcreg.h Log Message: eMMC fixes To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/dev/sdmmc/sdmmc_mem.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/sdmmc/sdmmcreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/sdmmc/sdmmc_mem.c diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.45 src/sys/dev/sdmmc/sdmmc_mem.c:1.46 --- src/sys/dev/sdmmc/sdmmc_mem.c:1.45 Wed Aug 5 10:29:37 2015 +++ src/sys/dev/sdmmc/sdmmc_mem.c Sat Aug 8 10:50:55 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_mem.c,v 1.45 2015/08/05 10:29:37 jmcneill Exp $ */ +/* $NetBSD: sdmmc_mem.c,v 1.46 2015/08/08 10:50:55 jmcneill Exp $ */ /* $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $ */ /* @@ -45,7 +45,7 @@ /* Routines for SD/MMC memory cards. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.45 2015/08/05 10:29:37 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.46 2015/08/08 10:50:55 jmcneill Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -204,13 +204,17 @@ mmc_mode: host_ocr &= card_ocr; /* only allow the common voltages */ if (!ISSET(sc->sc_caps, SMC_CAPS_SPI_MODE)) { - /* Check SD Ver.2 */ - error = sdmmc_mem_send_if_cond(sc, 0x1aa, &card_ocr); - if (error == 0 && card_ocr == 0x1aa) - SET(ocr, MMC_OCR_HCS); + if (ISSET(sc->sc_flags, SMF_SD_MODE)) { + /* Check SD Ver.2 */ + error = sdmmc_mem_send_if_cond(sc, 0x1aa, &card_ocr); + if (error == 0 && card_ocr == 0x1aa) + SET(ocr, MMC_OCR_HCS); - if (sdmmc_chip_host_ocr(sc->sc_sct, sc->sc_sch) & MMC_OCR_S18A) - SET(ocr, MMC_OCR_S18A); + if (sdmmc_chip_host_ocr(sc->sc_sct, sc->sc_sch) & MMC_OCR_S18A) + SET(ocr, MMC_OCR_S18A); + } else { + SET(ocr, MMC_OCR_ACCESS_MODE_SECTOR); + } } host_ocr |= ocr; @@ -221,7 +225,7 @@ mmc_mode: goto out; } - if (ISSET(new_ocr, MMC_OCR_S18A) && sc->sc_sct->signal_voltage) { + if (ISSET(sc->sc_flags, SMF_SD_MODE) && ISSET(new_ocr, MMC_OCR_S18A)) { /* * Card and host support low voltage mode, begin switch * sequence. @@ -946,13 +950,6 @@ sdmmc_mem_mmc_init(struct sdmmc_softc *s return ENOTSUP; } - if (hs_timing == 2) { - error = sdmmc_chip_signal_voltage(sc->sc_sct, - sc->sc_sch, SDMMC_SIGNAL_VOLTAGE_180); - if (error) - hs_timing = 1; - } - if (ISSET(sc->sc_caps, SMC_CAPS_8BIT_MODE)) { width = 8; value = EXT_CSD_BUS_WIDTH_8; @@ -977,6 +974,7 @@ sdmmc_mem_mmc_init(struct sdmmc_softc *s } /* XXXX: need bus test? (using by CMD14 & CMD19) */ + delay(10000); } sf->width = width; @@ -989,7 +987,8 @@ sdmmc_mem_mmc_init(struct sdmmc_softc *s EXT_CSD_HS_TIMING, hs_timing); if (error) { aprint_error_dev(sc->sc_dev, - "can't change high speed\n"); + "can't change high speed %d, error %d\n", + hs_timing, error); return error; } } Index: src/sys/dev/sdmmc/sdmmcreg.h diff -u src/sys/dev/sdmmc/sdmmcreg.h:1.19 src/sys/dev/sdmmc/sdmmcreg.h:1.20 --- src/sys/dev/sdmmc/sdmmcreg.h:1.19 Wed Aug 5 10:29:37 2015 +++ src/sys/dev/sdmmc/sdmmcreg.h Sat Aug 8 10:50:55 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmcreg.h,v 1.19 2015/08/05 10:29:37 jmcneill Exp $ */ +/* $NetBSD: sdmmcreg.h,v 1.20 2015/08/08 10:50:55 jmcneill Exp $ */ /* $OpenBSD: sdmmcreg.h,v 1.4 2009/01/09 10:55:22 jsg Exp $ */ /* @@ -70,7 +70,10 @@ /* OCR bits */ #define MMC_OCR_MEM_READY (1U<<31)/* memory power-up status bit */ -#define MMC_OCR_HCS (1<<30) +#define MMC_OCR_HCS (1<<30) /* SD only */ +#define MMC_OCR_ACCESS_MODE_MASK (3<<29) /* MMC only */ +#define MMC_OCR_ACCESS_MODE_BYTE (0<<29) /* MMC only */ +#define MMC_OCR_ACCESS_MODE_SECTOR (2<<29) /* MMC only */ #define MMC_OCR_S18A (1<<24) #define MMC_OCR_3_5V_3_6V (1<<23) #define MMC_OCR_3_4V_3_5V (1<<22)