From nobody Mon Mar 07 16:00:09 2022 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 D0EE219F75BD; 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 4KC37t3rqjz4SN4; Mon, 7 Mar 2022 16:00:10 +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=bteOlFJudBUuZAUorZbmKnhAbnp1u1qQGycVunNwMfM=; b=FOJ1e/ICeN6eHN5gTu3U/KWWA2tU2E4nsLRDiPAZsfJtmLxjCT1bXluSNq1ZlE3UibZES2 asqtP/NK2ehNwB7Pq/sDQvYbRpi+D8IRx0nK+UkXcQ+lgYHyTVdUnr4Z3Qd8EVYtcfMAJa TzjkhODKF6qLnETOINkWYI7AN44u7PawFifkbaFVLSnNDtISBkJ2V8unw+wOszl7GaTtnk 01Y/o1v+KWSGWTN6Ux8UPWbRkrF6aKzFrzpEpgHA2KdASeZ0x9xsYkYMVnIRIRdjfxv8tU 3mPEgCpl8ZlSIw83v4lI7RIVpZHABBXkUz+KC0F7nKSGIx2//3k/km55xp5Pxg== 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 199F33393; Mon, 7 Mar 2022 16:00:10 +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 227G0A0m067021; Mon, 7 Mar 2022 16:00:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 227G09EQ067019; Mon, 7 Mar 2022 16:00:09 GMT (envelope-from git) Date: Mon, 7 Mar 2022 16:00:09 GMT Message-Id: <202203071600.227G09EQ067019@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: 8bb448b66e9d - stable/13 - sdhci_xenon: add UHS support 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: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8bb448b66e9d5e162b9960291851550baa3083c1 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=bteOlFJudBUuZAUorZbmKnhAbnp1u1qQGycVunNwMfM=; b=uPVA1k7fR7ltFHgKQAalGniUokZAYjmUh48PnQRt93pqMIOf5WMHVBwt9zbc6T/Av0ECfa 9TXYEldy/lZhGS8jOiwliro65Cvs0C/K+d/6k1lR9yDqnzRbJs19pA338yqj28MalKwYFR rhRejYip3ZEbcbOK63uaVWVBqwJdrGGaNxpeH5kBE4QPhzmqCG4vxScmrpQcxyHSbp2+yv g11wVuveid5EYhZSJJ/XvCqXOo8Ob3WufPpyv5fhxIxzLbLoQC2AC1Fbaf5BpCF1REfY4p 2wxTMdYWGGgbIg8pq0liOZ/dKsx0MFh7ft7PQFOnxEkLvKtGa2rekedtwBmx6w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646668810; a=rsa-sha256; cv=none; b=wVm4F4jGV0nekbgJ0pWxhlqoijsf9ihGVqw/fKiQRaZ+PH1Frj1szcZi7tsCv9kS8ONJOu v6MjOHI3ciFfyVCAj0A8h4bcFMT/Nwye25m3NYB1Txgs+0YIaPumQOlocVhIOSLOXonkk8 Sbx1yUZTH09P+bHUhK9pl5+kcbGcHTwe5179UStCJh20PHcS1ZbKoFyhjPkMawGdwAoSYP O8gAVJZ7PAXjaY0NWqeRmI7mzJ4H+Dry+W6y+Hlv93qcZSqDp+XUBCNk5DzmExiiuaV6gX VXlN8F/hqEafj8x3HVy6v4kVf2wtGvMDoqeuIrhxsPW9TOyZHj/JZ0l4363zxg== 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=8bb448b66e9d5e162b9960291851550baa3083c1 commit 8bb448b66e9d5e162b9960291851550baa3083c1 Author: Marcin Wojtas AuthorDate: 2021-05-04 23:47:37 +0000 Commit: Marcin Wojtas CommitDate: 2022-03-07 15:59:51 +0000 sdhci_xenon: add UHS support This patch adds the necessary methods resolution to the sdhci_xenon driver which are required to configure UHS modes for SD/MMC devices. Apart from the two generic routines, the custom sdhci_xenon_set_uhs_timing function is responsible for setting the SDHCI_HOST_CONTROL2 register with appropriate mode select values - in case of HS200 and HS400 they are non-standard. Reviewed by: manu Obtained from: Semihalf Sponsored by: Marvell Differential Revision: https://reviews.freebsd.org/D30565 MFC after: 2 weeks (cherry picked from commit 4fa977f854e27c93c22acfa6a3ba38f5c4959e15) --- sys/dev/sdhci/sdhci_xenon.c | 40 ++++++++++++++++++++++++++++++++++++++++ sys/dev/sdhci/sdhci_xenon.h | 4 ++++ 2 files changed, 44 insertions(+) diff --git a/sys/dev/sdhci/sdhci_xenon.c b/sys/dev/sdhci/sdhci_xenon.c index 42f36b619b36..3f312921154f 100644 --- a/sys/dev/sdhci/sdhci_xenon.c +++ b/sys/dev/sdhci/sdhci_xenon.c @@ -197,6 +197,43 @@ sdhci_xenon_get_card_present(device_t dev, struct sdhci_slot *slot) return (sdhci_fdt_gpio_get_present(sc->gpio)); } +static void +sdhci_xenon_set_uhs_timing(device_t brdev, struct sdhci_slot *slot) +{ + const struct mmc_ios *ios; + uint16_t hostctrl2; + + if (slot->version < SDHCI_SPEC_300) + return; + + mtx_assert(&slot->mtx, MA_OWNED); + ios = &slot->host.ios; + + /* Update timing parameteres in SDHCI_HOST_CONTROL2 register. */ + hostctrl2 = sdhci_xenon_read_2(brdev, slot, SDHCI_HOST_CONTROL2); + hostctrl2 &= ~SDHCI_CTRL2_UHS_MASK; + if (ios->clock > SD_SDR50_MAX) { + if (ios->timing == bus_timing_mmc_hs400 || + ios->timing == bus_timing_mmc_hs400es) + hostctrl2 |= XENON_CTRL2_MMC_HS400; + else if (ios->timing == bus_timing_mmc_hs200) + hostctrl2 |= XENON_CTRL2_MMC_HS200; + else + hostctrl2 |= SDHCI_CTRL2_UHS_SDR104; + } + else if (ios->clock > SD_SDR25_MAX) + hostctrl2 |= SDHCI_CTRL2_UHS_SDR50; + else if (ios->clock > SD_SDR12_MAX) { + if (ios->timing == bus_timing_uhs_ddr50 || + ios->timing == bus_timing_mmc_ddr52) + hostctrl2 |= SDHCI_CTRL2_UHS_DDR50; + else + hostctrl2 |= SDHCI_CTRL2_UHS_SDR25; + } else if (ios->clock > SD_MMC_CARD_ID_FREQUENCY) + hostctrl2 |= SDHCI_CTRL2_UHS_SDR12; + sdhci_xenon_write_2(brdev, slot, SDHCI_HOST_CONTROL2, hostctrl2); +} + static int sdhci_xenon_phy_init(device_t brdev, struct mmc_ios *ios) { @@ -663,6 +700,8 @@ static device_method_t sdhci_xenon_methods[] = { DEVMETHOD(mmcbr_acquire_host, sdhci_generic_acquire_host), DEVMETHOD(mmcbr_release_host, sdhci_generic_release_host), DEVMETHOD(mmcbr_switch_vccq, sdhci_xenon_switch_vccq), + DEVMETHOD(mmcbr_tune, sdhci_generic_tune), + DEVMETHOD(mmcbr_retune, sdhci_generic_retune), /* SDHCI registers accessors */ DEVMETHOD(sdhci_read_1, sdhci_xenon_read_1), @@ -674,6 +713,7 @@ static device_method_t sdhci_xenon_methods[] = { DEVMETHOD(sdhci_write_4, sdhci_xenon_write_4), DEVMETHOD(sdhci_write_multi_4, sdhci_xenon_write_multi_4), DEVMETHOD(sdhci_get_card_present, sdhci_xenon_get_card_present), + DEVMETHOD(sdhci_set_uhs_timing, sdhci_xenon_set_uhs_timing), DEVMETHOD_END }; diff --git a/sys/dev/sdhci/sdhci_xenon.h b/sys/dev/sdhci/sdhci_xenon.h index b79dab6bab55..07ed99339b8d 100644 --- a/sys/dev/sdhci/sdhci_xenon.h +++ b/sys/dev/sdhci/sdhci_xenon.h @@ -46,6 +46,10 @@ #define XENON_ENABLE_DATA_STROBE (1 << 24) #define XENON_ENABLE_RESP_STROBE (1 << 25) +/* Custom HS200 / HS400 Mode Select values in SDHCI_HOST_CONTROL2 register. */ +#define XENON_CTRL2_MMC_HS200 0x5 +#define XENON_CTRL2_MMC_HS400 0x6 + /* eMMC PHY */ #define XENON_EMMC_PHY_REG_BASE 0x170