From nobody Fri Nov 5 09:19:20 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C3879184C061; Fri, 5 Nov 2021 09:19:20 +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 4Hlw1h33s1z4k9F; Fri, 5 Nov 2021 09:19:20 +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 3689915247; Fri, 5 Nov 2021 09:19:20 +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 1A59JKkQ078254; Fri, 5 Nov 2021 09:19:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A59JK1T078253; Fri, 5 Nov 2021 09:19:20 GMT (envelope-from git) Date: Fri, 5 Nov 2021 09:19:20 GMT Message-Id: <202111050919.1A59JK1T078253@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 36b80dba1742 - main - sdhci_fsl_fdt: Add full support for software reset List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 36b80dba1742acfeecfe8c26516c5cf16fd1346d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=36b80dba1742acfeecfe8c26516c5cf16fd1346d commit 36b80dba1742acfeecfe8c26516c5cf16fd1346d Author: Artur Rojek AuthorDate: 2021-11-05 09:16:30 +0000 Commit: Wojciech Macek CommitDate: 2021-11-05 09:18:57 +0000 sdhci_fsl_fdt: Add full support for software reset When performing software reset, this controller does not clear all the required hw registers. In particular, tuning block is left in enabled state, inhibiting operation of some eMMC cards. The existing solution was to disable the ability to call SDHCI_RESET_ALL. As this issue is now better understood, enable the SDHCI_RESET_ALL flag, provide a custom reset devmethod and clear selected registers by hand. Obtained from: Semihalf Sponsored by: Alstom Group Differential revision: https://reviews.freebsd.org/D32705 --- sys/dev/sdhci/sdhci_fsl_fdt.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/sys/dev/sdhci/sdhci_fsl_fdt.c b/sys/dev/sdhci/sdhci_fsl_fdt.c index 5aec394b9192..77af367c5366 100644 --- a/sys/dev/sdhci/sdhci_fsl_fdt.c +++ b/sys/dev/sdhci/sdhci_fsl_fdt.c @@ -86,6 +86,9 @@ __FBSDID("$FreeBSD$"); #define SDHCI_FSL_HOST_VERSION 0xfc #define SDHCI_FSL_CAPABILITIES2 0x114 +#define SDHCI_FSL_TBCTL 0x120 +#define SDHCI_FSL_TBCTL_TBEN (1 << 2) + #define SDHCI_FSL_ESDHC_CTRL 0x40c #define SDHCI_FSL_ESDHC_CTRL_SNOOP (1 << 6) #define SDHCI_FSL_ESDHC_CTRL_CLK_DIV2 (1 << 19) @@ -347,9 +350,6 @@ sdhci_fsl_fdt_write_1(device_t dev, struct sdhci_slot *slot, bus_size_t off, return; case SDHCI_POWER_CONTROL: return; - case SDHCI_SOFTWARE_RESET: - val &= ~SDHCI_RESET_ALL; - /* FALLTHROUGH. */ default: val32 = RD4(sc, off & ~3); val32 &= ~(UINT8_MAX << (off & 3) * 8); @@ -803,6 +803,27 @@ sdhci_fsl_fdt_read_ivar(device_t bus, device_t child, int which, return (sdhci_generic_read_ivar(bus, child, which, result)); } +static void +sdhci_fsl_fdt_reset(device_t dev, struct sdhci_slot *slot, uint8_t mask) +{ + struct sdhci_fsl_fdt_softc *sc; + uint32_t val; + + sdhci_generic_reset(dev, slot, mask); + + if (!(mask & SDHCI_RESET_ALL)) + return; + + sc = device_get_softc(dev); + + /* Some registers have to be cleared by hand. */ + if (slot->version >= SDHCI_SPEC_300) { + val = RD4(sc, SDHCI_FSL_TBCTL); + val &= ~SDHCI_FSL_TBCTL_TBEN; + WR4(sc, SDHCI_FSL_TBCTL, val); + } +} + static const device_method_t sdhci_fsl_fdt_methods[] = { /* Device interface. */ DEVMETHOD(device_probe, sdhci_fsl_fdt_probe), @@ -831,6 +852,7 @@ static const device_method_t sdhci_fsl_fdt_methods[] = { DEVMETHOD(sdhci_write_4, sdhci_fsl_fdt_write_4), DEVMETHOD(sdhci_write_multi_4, sdhci_fsl_fdt_write_multi_4), DEVMETHOD(sdhci_get_card_present, sdhci_fsl_fdt_get_card_present), + DEVMETHOD(sdhci_reset, sdhci_fsl_fdt_reset), DEVMETHOD_END };