From nobody Wed Dec 08 10:21:33 2021 X-Original-To: dev-commits-src-main@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 0BFA718D00DE; Wed, 8 Dec 2021 10:21:34 +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 4J8CrF4Hjdz4r21; Wed, 8 Dec 2021 10:21:33 +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 581AB11B1C; Wed, 8 Dec 2021 10:21:33 +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 1B8ALXO7041563; Wed, 8 Dec 2021 10:21:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B8ALXqs041562; Wed, 8 Dec 2021 10:21:33 GMT (envelope-from git) Date: Wed, 8 Dec 2021 10:21:33 GMT Message-Id: <202112081021.1B8ALXqs041562@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: ec9333c3aac3 - main - sdhci_fsl_fdt: Fix vccq reconfiguration List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: ec9333c3aac300d15009df9f24fe5cf37852578b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638958893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UbDj/j/XvGVTYI5vhVq7gSn3G4l9EMpjYMF2eTnsaQk=; b=A+dhiH3IVdJJqL28f15iX/yJNdAaU9PFhEEk8uGeWiEoxORff3udVLDShy/H/7KxbwpBaw Y8Pjb9qe9eXmaMbloAyrsK46WnG2HACujLLahu0DYegSSTow4TRuR2Z4dGxVfOT2qmLVFY xcc3kU+8m6De9sDLbq6pG7thYGiaygNAmAJbtJkl/eX26iAexnoyhrIt3ORuSmV2Tnd0YE FNIHdqrKPhRCyLK4gpGWALpEgQ+gjNIr4V0O6WWw8dEpJNTsJn/tNlVMRJWMz977PIasYA YCZr1zfC7hQPNEr1y5uVjtUIkVoFYDqQvPBjdNKXboUA+zdj+RES5MUznCBewA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638958893; a=rsa-sha256; cv=none; b=WR3/Pds9rvS/6v5ZuE5fu06FV+soo+eqLaf3neguVxJxm4B1S4BsN25Wve/Mayl/Aj+hD6 fS94xsHZWRDYx6W7MF9opbO2wR+BUSaJ4gbAnNe3yyOsm+7tQ914Evk/4LstcMRWpwsXI9 FWYi33K7w1NnTVFqP4+GpzkBMkNsMpwVAx5pMNXo8y6VlQi6ae72WtIDDPYpwMH39jCByD 6m0crPX1zOlBBamRS7EQ0Dr36rD13sHVVUN5+vs9YVO5nTWxIpZm82DzVjKmDbgzhwyraQ Ek7cUjhjHeysVZYPR1Xy92oOAnSmyfnuZr4O60ixFlrUtSyj9ljNTBQo2JJuYg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=ec9333c3aac300d15009df9f24fe5cf37852578b commit ec9333c3aac300d15009df9f24fe5cf37852578b Author: Artur Rojek AuthorDate: 2021-09-10 16:03:19 +0000 Commit: Wojciech Macek CommitDate: 2021-12-08 10:21:02 +0000 sdhci_fsl_fdt: Fix vccq reconfiguration As `vqmmc-supply` is an optional Device Tree property, don't skip vccq reconfiguration when the regulator is not specified. Instead, accept voltage specified by the `voltage-ranges` property. The actual voltage switch is done through a hw register in LS1028A. Add errata flag for other boards, as they are not supported. Return not supported error code when switching to 1.8V on affected platforms. Fixes: b08bf4c35ca ("sdhci_fsl_fdt: Skip vccq reconfiguration without regulator") Co-authored-by: Artur Rojek Reviewed by: manu, mw Obtained from: Semihalf Sponsored by: Alstom Group Differential revision: https://reviews.freebsd.org/D33319 --- sys/dev/sdhci/sdhci_fsl_fdt.c | 44 +++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/sys/dev/sdhci/sdhci_fsl_fdt.c b/sys/dev/sdhci/sdhci_fsl_fdt.c index 2d6c7115ff1e..d17811634353 100644 --- a/sys/dev/sdhci/sdhci_fsl_fdt.c +++ b/sys/dev/sdhci/sdhci_fsl_fdt.c @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); #define SDHCI_FSL_PROT_CTRL_BYTE_NATIVE (2 << 4) #define SDHCI_FSL_PROT_CTRL_BYTE_MASK (3 << 4) #define SDHCI_FSL_PROT_CTRL_DMA_MASK (3 << 8) +#define SDHCI_FSL_PROT_CTRL_VOLT_SEL (1 << 10) #define SDHCI_FSL_SYS_CTRL 0x2c #define SDHCI_FSL_CLK_IPGEN (1 << 0) @@ -102,6 +103,8 @@ __FBSDID("$FreeBSD$"); /* Some platforms do not detect pulse width correctly. */ #define SDHCI_FSL_UNRELIABLE_PULSE_DET (1 << 0) +/* On some platforms switching voltage to 1.8V is not supported */ +#define SDHCI_FSL_UNSUPP_1_8V (1 << 1) struct sdhci_fsl_fdt_softc { device_t dev; @@ -132,7 +135,7 @@ struct sdhci_fsl_fdt_soc_data { static const struct sdhci_fsl_fdt_soc_data sdhci_fsl_fdt_ls1012a_soc_data = { .quirks = 0, .baseclk_div = 1, - .errata = 0 + .errata = SDHCI_FSL_UNSUPP_1_8V, }; static const struct sdhci_fsl_fdt_soc_data sdhci_fsl_fdt_ls1028a_soc_data = { @@ -145,6 +148,7 @@ static const struct sdhci_fsl_fdt_soc_data sdhci_fsl_fdt_ls1028a_soc_data = { static const struct sdhci_fsl_fdt_soc_data sdhci_fsl_fdt_ls1046a_soc_data = { .quirks = SDHCI_QUIRK_DONT_SET_HISPD_BIT | SDHCI_QUIRK_BROKEN_AUTO_STOP, .baseclk_div = 2, + .errata = SDHCI_FSL_UNSUPP_1_8V, }; static const struct sdhci_fsl_fdt_soc_data sdhci_fsl_fdt_gen_data = { @@ -517,34 +521,46 @@ sdhci_fsl_fdt_switch_vccq(device_t brdev, device_t reqdev) { struct sdhci_fsl_fdt_softc *sc; struct sdhci_slot *slot; + regulator_t vqmmc_supply; + uint32_t val_old, val; int uvolt, err; sc = device_get_softc(brdev); + slot = device_get_ivars(reqdev); - if (sc->fdt_helper.vqmmc_supply == NULL) - return EOPNOTSUPP; - - err = sdhci_generic_switch_vccq(brdev, reqdev); - if (err != 0) - return (err); + val_old = val = RD4(sc, SDHCI_FSL_PROT_CTRL); - slot = device_get_ivars(reqdev); switch (slot->host.ios.vccq) { case vccq_180: + if (sc->soc_data->errata & SDHCI_FSL_UNSUPP_1_8V) + return (EOPNOTSUPP); + + val |= SDHCI_FSL_PROT_CTRL_VOLT_SEL; uvolt = 1800000; break; case vccq_330: + val &= ~SDHCI_FSL_PROT_CTRL_VOLT_SEL; uvolt = 3300000; break; default: - return EINVAL; + return (EOPNOTSUPP); } - err = regulator_set_voltage(sc->fdt_helper.vqmmc_supply, uvolt, uvolt); - if (err != 0) { - device_printf(sc->dev, - "Cannot set vqmmc to %d<->%d\n", uvolt, uvolt); - return (err); + WR4(sc, SDHCI_FSL_PROT_CTRL, val); + + vqmmc_supply = sc->fdt_helper.vqmmc_supply; + /* + * Even though we expect to find a fixed regulator in this controller + * family, let's play safe. + */ + if (vqmmc_supply != NULL) { + err = regulator_set_voltage(vqmmc_supply, uvolt, uvolt); + if (err != 0) { + device_printf(sc->dev, + "Cannot set vqmmc to %d<->%d\n", uvolt, uvolt); + WR4(sc, SDHCI_FSL_PROT_CTRL, val_old); + return (err); + } } return (0);