From owner-dev-commits-src-main@freebsd.org Tue Sep 21 16:17:43 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E12B067698E; Tue, 21 Sep 2021 16:17:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HDRRC635Dz3J6V; Tue, 21 Sep 2021 16:17:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A51F027029; Tue, 21 Sep 2021 16:17:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18LGHhVd036065; Tue, 21 Sep 2021 16:17:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18LGHhCQ036064; Tue, 21 Sep 2021 16:17:43 GMT (envelope-from git) Date: Tue, 21 Sep 2021 16:17:43 GMT Message-Id: <202109211617.18LGHhCQ036064@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: af32e2cc32b2 - main - dwmmc: Properly implement power_off/power_up MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: af32e2cc32b2516826e301d5f857ff7343b1210e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Sep 2021 16:17:43 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=af32e2cc32b2516826e301d5f857ff7343b1210e commit af32e2cc32b2516826e301d5f857ff7343b1210e Author: Emmanuel Vadot AuthorDate: 2021-09-21 14:10:11 +0000 Commit: Emmanuel Vadot 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 */