git: 68be9ab5bd53 - stable/13 - sdhci_xenon: allow to properly disable the UHS signaling

From: Marcin Wojtas <mw_at_FreeBSD.org>
Date: Mon, 07 Mar 2022 16:00:07 UTC
The branch stable/13 has been updated by mw:

URL: https://cgit.FreeBSD.org/src/commit/?id=68be9ab5bd532e8dbae5fff50c0bb836d2a21645

commit 68be9ab5bd532e8dbae5fff50c0bb836d2a21645
Author:     Marcin Wojtas <mw@FreeBSD.org>
AuthorDate: 2021-05-27 17:48:17 +0000
Commit:     Marcin Wojtas <mw@FreeBSD.org>
CommitDate: 2022-03-07 15:59:50 +0000

    sdhci_xenon: allow to properly disable the UHS signaling
    
    Until now the "no-1-8-v" DT flag wrongly disabled the SDHCI_CAN_VDD_180
    - slot 1.8V power supply capability, whereas it refers to the signaling
    voltage. Fix the sdhci_xenon_read_4 and allow to disable the UHS modes
    depending on the DT property or PHY slow mode. While at it - make sure
    the unsupported 1.2V signaling is always disabled and not reported
    in the bootverbose log.
    
    Reviewed by: manu
    Obtained from: Semihalf
    Sponsored by: Marvell
    Differential Revision: https://reviews.freebsd.org/D30563
    MFC after: 2 weeks
    
    (cherry picked from commit df868762841b93d934413651818e510ea443def8)
---
 sys/dev/sdhci/sdhci_xenon.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sys/dev/sdhci/sdhci_xenon.c b/sys/dev/sdhci/sdhci_xenon.c
index c230f0ef9752..f92d02608abb 100644
--- a/sys/dev/sdhci/sdhci_xenon.c
+++ b/sys/dev/sdhci/sdhci_xenon.c
@@ -141,13 +141,8 @@ sdhci_xenon_read_4(device_t dev, struct sdhci_slot *slot __unused,
     bus_size_t off)
 {
 	struct sdhci_xenon_softc *sc = device_get_softc(dev);
-	uint32_t val32;
 
-	val32 = bus_read_4(sc->mem_res, off);
-	if (off == SDHCI_CAPABILITIES && sc->no_18v)
-		val32 &= ~SDHCI_CAN_VDD_180;
-
-	return (val32);
+	return bus_read_4(sc->mem_res, off);
 }
 
 static void
@@ -519,6 +514,13 @@ sdhci_xenon_attach(device_t dev)
 	if (sdhci_init_slot(dev, sc->slot, 0))
 		goto fail;
 
+	/* 1.2V signaling is not supported. */
+	sc->slot->host.caps &= ~MMC_CAP_SIGNALING_120;
+
+	/* Disable UHS in case of lack of 1.8V VCCQ or the PHY slow mode. */
+	if (sc->no_18v || sc->slow_mode)
+		sc->slot->host.caps &= ~MMC_CAP_SIGNALING_180;
+
 	/* Activate the interrupt */
 	err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
 	    NULL, sdhci_xenon_intr, sc, &sc->intrhand);