From 91a0a07085dc644f2831fa0e993ba2ddcb8613f5 Mon Sep 17 00:00:00 2001 From: jmcneill Date: Mon, 23 Oct 2017 13:47:17 +0000 Subject: [PATCH] - Get SDIO reset working (from OpenBSD). - After switching bus width, notify the host controller of the change. --- sys/dev/sdmmc/sdmmc_io.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sys/dev/sdmmc/sdmmc_io.c b/sys/dev/sdmmc/sdmmc_io.c index 86fbdc407f3d..9f57eda6d122 100644 --- a/sys/dev/sdmmc/sdmmc_io.c +++ b/sys/dev/sdmmc/sdmmc_io.c @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_io.c,v 1.12 2015/10/06 14:32:51 mlelstv Exp $ */ +/* $NetBSD: sdmmc_io.c,v 1.13 2017/10/23 13:47:17 jmcneill Exp $ */ /* $OpenBSD: sdmmc_io.c,v 1.10 2007/09/17 01:33:33 krw Exp $ */ /* @@ -20,7 +20,7 @@ /* Routines for SD I/O cards. */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.12 2015/10/06 14:32:51 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.13 2017/10/23 13:47:17 jmcneill Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -122,9 +122,6 @@ sdmmc_io_enable(struct sdmmc_softc *sc) goto out; } - /* Reset I/O functions (again). */ - sdmmc_io_reset(sc); - /* Send the new OCR value until all cards are ready. */ error = sdmmc_io_send_op_cond(sc, host_ocr, NULL); if (error) { @@ -203,6 +200,11 @@ sdmmc_io_init(struct sdmmc_softc *sc, struct sdmmc_function *sf) sdmmc_io_write_1(sf, SD_IO_CCCR_BUS_WIDTH, CCCR_BUS_WIDTH_4); sf->width = 4; + error = sdmmc_chip_bus_width(sc->sc_sct, sc->sc_sch, + sf->width); + if (error) + aprint_error_dev(sc->sc_dev, + "can't change bus width\n"); } error = sdmmc_read_cis(sf, &sf->cis); @@ -535,12 +537,10 @@ sdmmc_io_xchg(struct sdmmc_softc *sc, struct sdmmc_function *sf, static void sdmmc_io_reset(struct sdmmc_softc *sc) { + u_char data = CCCR_CTL_RES; - /* Don't lock */ -#if 0 /* XXX command fails */ - (void)sdmmc_io_write(sc, NULL, SD_IO_REG_CCCR_CTL, CCCR_CTL_RES); - sdmmc_delay(100000); -#endif + if (sdmmc_io_rw_direct(sc, NULL, SD_IO_CCCR_CTL, &data, SD_ARG_CMD52_WRITE) == 0) + sdmmc_delay(100000); } /*