Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Sep 2021 16:17:43 GMT
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: af32e2cc32b2 - main - dwmmc: Properly implement power_off/power_up
Message-ID:  <202109211617.18LGHhCQ036064@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=af32e2cc32b2516826e301d5f857ff7343b1210e

commit af32e2cc32b2516826e301d5f857ff7343b1210e
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2021-09-21 14:10:11 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2021-09-21 16:17:20 +0000

    dwmmc: Properly implement power_off/power_up
    
    Write to the PWREN register should be done in update_ios based
    on the power_mode value in the ios struct.
    Also none of the manual (RockChip and Altera) and Linux talks about
    the needed for an inverted PWREN value so just remove this.
    This fixes eMMC (and possibly SD) when u-boot didn't setup the controller.
    
    Reported by:    avg
    Tested-on:      Rock64, RockPro64
---
 sys/dev/mmc/host/dwmmc.c          | 20 +++++++++++---------
 sys/dev/mmc/host/dwmmc_rockchip.c |  2 --
 sys/dev/mmc/host/dwmmc_var.h      |  1 -
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/sys/dev/mmc/host/dwmmc.c b/sys/dev/mmc/host/dwmmc.c
index dce684ed8c7b..df7ac374a265 100644
--- a/sys/dev/mmc/host/dwmmc.c
+++ b/sys/dev/mmc/host/dwmmc.c
@@ -670,7 +670,6 @@ dwmmc_attach(device_t dev)
 {
 	struct dwmmc_softc *sc;
 	int error;
-	int slot;
 
 	sc = device_get_softc(dev);
 
@@ -703,14 +702,6 @@ dwmmc_attach(device_t dev)
 	device_printf(dev, "Hardware version ID is %04x\n",
 		READ4(sc, SDMMC_VERID) & 0xffff);
 
-	/* XXX: we support operation for slot index 0 only */
-	slot = 0;
-	if (sc->pwren_inverted) {
-		WRITE4(sc, SDMMC_PWREN, (0 << slot));
-	} else {
-		WRITE4(sc, SDMMC_PWREN, (1 << slot));
-	}
-
 	/* Reset all */
 	if (dwmmc_ctrl_reset(sc, (SDMMC_CTRL_RESET |
 				  SDMMC_CTRL_FIFO_RESET |
@@ -892,6 +883,17 @@ dwmmc_update_ios(device_t brdev, device_t reqdev)
 	dprintf("Setting up clk %u bus_width %d, timming: %d\n",
 		ios->clock, ios->bus_width, ios->timing);
 
+	switch (ios->power_mode) {
+	case power_on:
+		break;
+	case power_off:
+		WRITE4(sc, SDMMC_PWREN, 0);
+		break;
+	case power_up:
+		WRITE4(sc, SDMMC_PWREN, 1);
+		break;
+	}
+
 	mmc_fdt_set_power(&sc->mmc_helper, ios->power_mode);
 
 	if (ios->bus_width == bus_width_8)
diff --git a/sys/dev/mmc/host/dwmmc_rockchip.c b/sys/dev/mmc/host/dwmmc_rockchip.c
index 25baffb267e3..c025e531e27b 100644
--- a/sys/dev/mmc/host/dwmmc_rockchip.c
+++ b/sys/dev/mmc/host/dwmmc_rockchip.c
@@ -94,8 +94,6 @@ rockchip_dwmmc_attach(device_t dev)
 		break;
 	}
 
-	sc->pwren_inverted = 1;
-
 #ifdef EXT_RESOURCES
 	sc->update_ios = &dwmmc_rockchip_update_ios;
 #endif
diff --git a/sys/dev/mmc/host/dwmmc_var.h b/sys/dev/mmc/host/dwmmc_var.h
index a3f20278ad2a..33210f547dff 100644
--- a/sys/dev/mmc/host/dwmmc_var.h
+++ b/sys/dev/mmc/host/dwmmc_var.h
@@ -69,7 +69,6 @@ struct dwmmc_softc {
 	uint32_t		hwtype;
 	uint32_t		use_auto_stop;
 	uint32_t		use_pio;
-	uint32_t		pwren_inverted;
 	device_t		child;
 	struct task		card_task;	/* Card presence check task */
 	struct timeout_task	card_delayed_task;/* Card insert delayed task */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109211617.18LGHhCQ036064>