From nobody Mon Mar 07 16:00:08 2022 X-Original-To: dev-commits-src-branches@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 AC04719F754C; Mon, 7 Mar 2022 16:00:10 +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 4KC37s3KF7z4S4s; Mon, 7 Mar 2022 16:00:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646668810; 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=ytysuf9HdKqWTXOC6N+xhxbMA0biOFU0/A6XKcmGE5o=; b=wCxsI/38P0FBIIOqVOioX9S32WVA3uSxypCmlVE9k2qQka94ziBEZ7ZY9o0vBHMDKvTunI M4XdBiLkjfL6/ZyXwghwIZ8V33bkH150NfdRPBMRQfG9Nc1tcQw47+JPEO5pydzzV8OR5J v20Tn16UtOK7itzOwKPppAZmXqRJlbWkQO00aGLp7v/7uEmnFpcfsDBV1yK1T5i36no5dS cpyoIoRhIjyMGdp+V2FnOGlGLVTG9YmjrYU8hOwZccxMYC4NMu8uNcYyRqs9zeZrGmpDTz bZc2RqTirRpqBUskqs81R+pthQq9d+637oL8k1x7OyHkgqhVYYyO17QKkk8vOQ== 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 0E3FB304D; Mon, 7 Mar 2022 16:00:09 +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 227G08tP066810; Mon, 7 Mar 2022 16:00:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 227G0879066807; Mon, 7 Mar 2022 16:00:08 GMT (envelope-from git) Date: Mon, 7 Mar 2022 16:00:08 GMT Message-Id: <202203071600.227G0879066807@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: 7518736826a2 - stable/13 - sdhci_xenon: improve the VCCQ voltage switch sequence List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7518736826a2569e2799595d444cbdf0c9c82e5a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646668810; 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=ytysuf9HdKqWTXOC6N+xhxbMA0biOFU0/A6XKcmGE5o=; b=lInIlofbfpQOa7jUznR55dQzG3CnJpc1KWvPBMGCYoP42HthfDUE5/OH6k1RH027e8rG6x ro3cHzvi6KpeMC08koZcSFSjDWaNchLrB1Q2AmC9HxgMhzbkFR8XFmCoYKav2PeAKUYpe2 HNQ3zhWLF3v3Wsa6pDUNjpzd0l+uhZ1pD+E8YsgEe+T9np713R+eDpnrACetSCu/dgkm2U TisI2DMh1RMl4Nyd2AsdCGVK2xXUoZHNbMHgZ5SnUfI5Pok/d05Yee0WvOzbBWANUuWLh5 t4U/IVqXbEwiJ5Htr+b1kMTguDVimi+WJJfnRNQmnSowb/PsUi7Gujmhx/cRpw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646668810; a=rsa-sha256; cv=none; b=D1RbW7ZKIfXTv7pdP1EuDBvakfDIw09tiG/djNB3nGs3sro+0JsYnjY9nwKT06M0PBEbG3 sNok75Plq2Dl7uvcMchTLWVzyePNejciFzcpwvOVFS/+iFaDdKs77jj6/gx1W/x+MPyyDF uqAW03KTGVut27C1JlO0mkOsNaIHaVjAPwFg4oRYHnuCDcHXAW2EgormC7hhly4+ThOdBo viSMDdndXAVZFGndWhitJAOz86msVt6saqbMDoN1t3ahSO2nKgdq2x7ywmWrJLahDvC+GS Q/A0937cNzvkGkyY3tLqIqjZgY0sQNWsyvBdoVrZQnUX74Yh4tv9EiztTpdg5w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=7518736826a2569e2799595d444cbdf0c9c82e5a commit 7518736826a2569e2799595d444cbdf0c9c82e5a Author: Marcin Wojtas AuthorDate: 2021-05-27 18:39:12 +0000 Commit: Marcin Wojtas CommitDate: 2022-03-07 15:59:50 +0000 sdhci_xenon: improve the VCCQ voltage switch sequence Improve the VCCQ voltage switch, so that to properly handle the SDHCI_HOST_CONTROL2 register signaling flags and along with manipulating the regulator. Reviewed by: manu Obtained from: Semihalf Sponsored by: Marvell Differential Revision: https://reviews.freebsd.org/D30564 MFC after: 2 weeks (cherry picked from commit c80e2ca57e0c1b3647b55471584c6d32214232ea) --- sys/dev/sdhci/sdhci_xenon.c | 84 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 68 insertions(+), 16 deletions(-) diff --git a/sys/dev/sdhci/sdhci_xenon.c b/sys/dev/sdhci/sdhci_xenon.c index f92d02608abb..42f36b619b36 100644 --- a/sys/dev/sdhci/sdhci_xenon.c +++ b/sys/dev/sdhci/sdhci_xenon.c @@ -388,35 +388,87 @@ sdhci_xenon_switch_vccq(device_t brdev, device_t reqdev) { struct sdhci_xenon_softc *sc; struct sdhci_slot *slot; + uint16_t hostctrl2; int uvolt, err; + slot = device_get_ivars(reqdev); + + if (slot->version < SDHCI_SPEC_300) + return (0); + sc = device_get_softc(brdev); if (sc->mmc_helper.vqmmc_supply == NULL) return EOPNOTSUPP; - slot = device_get_ivars(reqdev); + err = 0; + + hostctrl2 = bus_read_2(sc->mem_res, SDHCI_HOST_CONTROL2); switch (slot->host.ios.vccq) { - case vccq_180: - uvolt = 1800000; - break; case vccq_330: + if (!(hostctrl2 & SDHCI_CTRL2_S18_ENABLE)) + return (0); + hostctrl2 &= ~SDHCI_CTRL2_S18_ENABLE; + bus_write_2(sc->mem_res, SDHCI_HOST_CONTROL2, hostctrl2); + uvolt = 3300000; - break; + err = regulator_set_voltage(sc->mmc_helper.vqmmc_supply, + uvolt, uvolt); + if (err != 0) { + device_printf(sc->dev, + "Cannot set vqmmc to %d<->%d\n", + uvolt, + uvolt); + return (err); + } + + /* + * According to the 'SD Host Controller Simplified + * Specification 4.20 the host driver should take more + * than 5ms for stable time of host voltage regulator + * from changing 1.8V Signaling Enable. + */ + DELAY(5000); + hostctrl2 = bus_read_2(sc->mem_res, SDHCI_HOST_CONTROL2); + if (!(hostctrl2 & SDHCI_CTRL2_S18_ENABLE)) + return (0); + return EAGAIN; + case vccq_180: + if (!(slot->host.caps & MMC_CAP_SIGNALING_180)) { + return EINVAL; + } + if (hostctrl2 & SDHCI_CTRL2_S18_ENABLE) + return (0); + hostctrl2 |= SDHCI_CTRL2_S18_ENABLE; + bus_write_2(sc->mem_res, SDHCI_HOST_CONTROL2, hostctrl2); + + uvolt = 1800000; + err = regulator_set_voltage(sc->mmc_helper.vqmmc_supply, + uvolt, uvolt); + if (err != 0) { + device_printf(sc->dev, + "Cannot set vqmmc to %d<->%d\n", + uvolt, + uvolt); + return (err); + } + + /* + * According to the 'SD Host Controller Simplified + * Specification 4.20 the host driver should take more + * than 5ms for stable time of host voltage regulator + * from changing 1.8V Signaling Enable. + */ + DELAY(5000); + hostctrl2 = bus_read_2(sc->mem_res, SDHCI_HOST_CONTROL2); + if (hostctrl2 & SDHCI_CTRL2_S18_ENABLE) + return (0); + return EAGAIN; default: + device_printf(brdev, + "Attempt to set unsupported signaling voltage\n"); return EINVAL; } - - err = regulator_set_voltage(sc->mmc_helper.vqmmc_supply, uvolt, uvolt); - if (err != 0) { - device_printf(sc->dev, - "Cannot set vqmmc to %d<->%d\n", - uvolt, - uvolt); - return (err); - } - - return (0); } static int