From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 29/30] mci: sdhci: support Linux SDHCI_QUIRK2_BROKEN_HS200 flag
Date: Wed, 7 May 2025 10:22:08 +0200 [thread overview]
Message-ID: <20250507082209.3289972-30-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250507082209.3289972-1-a.fatoum@pengutronix.de>
In Linux HS200 is opt-out for SDHCI. Let's do the same in barebox.
We intentionally keep MMC_CAP2_HS200 for Arasan, as I have not verified
on the hardware that the SDHCI implementation there correctly reports
SDR104 as supported (which would imply HS200 when used for eMMC).
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/mci/am654-sdhci.c | 3 +++
drivers/mci/arasan-sdhci.c | 3 +++
drivers/mci/dwcmshc-sdhci.c | 2 ++
drivers/mci/imx-esdhc.c | 3 +++
drivers/mci/rockchip-dwcmshc-sdhci.c | 3 +++
drivers/mci/sdhci.c | 32 ++++++++++++++++++++++++++++
drivers/mci/sdhci.h | 4 ++++
7 files changed, 50 insertions(+)
diff --git a/drivers/mci/am654-sdhci.c b/drivers/mci/am654-sdhci.c
index 13c8876573c7..be0a6e09f796 100644
--- a/drivers/mci/am654-sdhci.c
+++ b/drivers/mci/am654-sdhci.c
@@ -638,6 +638,9 @@ static int am654_sdhci_probe(struct device *dev)
if (ret)
return ret;
+ /* HS200 not supported by this driver at the moment */
+ plat->sdhci.quirks2 = SDHCI_QUIRK2_BROKEN_HS200;
+
plat->sdhci.mci = mci;
sdhci_setup_host(&plat->sdhci);
diff --git a/drivers/mci/arasan-sdhci.c b/drivers/mci/arasan-sdhci.c
index ceef0b63a8b9..4adaaa243d2c 100644
--- a/drivers/mci/arasan-sdhci.c
+++ b/drivers/mci/arasan-sdhci.c
@@ -773,6 +773,9 @@ static int arasan_sdhci_probe(struct device *dev)
mci->ops.execute_tuning = arasan_zynqmp_execute_tuning;
mci->caps2 |= MMC_CAP2_HS200;
arasan_sdhci->quirks |= SDHCI_ARASAN_QUIRK_CLOCK_25_BROKEN;
+ } else {
+ /* HS200 only supported for ZynqMP at the moment */
+ arasan_sdhci->sdhci.quirks2 = SDHCI_QUIRK2_BROKEN_HS200;
}
/*
diff --git a/drivers/mci/dwcmshc-sdhci.c b/drivers/mci/dwcmshc-sdhci.c
index 174cc3f76816..6fdbb61565f2 100644
--- a/drivers/mci/dwcmshc-sdhci.c
+++ b/drivers/mci/dwcmshc-sdhci.c
@@ -325,6 +325,8 @@ static int dwcmshc_probe(struct device *dev)
host->sdhci.base = IOMEM(iores->start);
host->sdhci.mci = mci;
host->sdhci.max_clk = clk_get_rate(clk);
+ /* HS200 not supported by this driver at the moment */
+ host->sdhci.quirks2 = SDHCI_QUIRK2_BROKEN_HS200;
host->cb = dwcmshc_cb;
mci->hw_dev = dev;
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index 00b7e0693fcc..4f2f02cfbdbe 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -466,6 +466,9 @@ static int fsl_esdhc_probe(struct device *dev)
host->mci.hw_dev = dev;
host->sdhci.mci = &host->mci;
+ if (!(host->socdata->flags & ESDHC_FLAG_HS200))
+ host->sdhci.quirks2 |= SDHCI_QUIRK2_BROKEN_HS200;
+
ret = sdhci_setup_host(&host->sdhci);
if (ret)
goto err_clk_disable;
diff --git a/drivers/mci/rockchip-dwcmshc-sdhci.c b/drivers/mci/rockchip-dwcmshc-sdhci.c
index 2f8d5ec140b5..c4c03f703a15 100644
--- a/drivers/mci/rockchip-dwcmshc-sdhci.c
+++ b/drivers/mci/rockchip-dwcmshc-sdhci.c
@@ -341,6 +341,9 @@ static int rk_sdhci_probe(struct device *dev)
mci_of_parse(&host->mci);
+ /* HS200 not supported by this driver at the moment */
+ host->sdhci.quirks2 = SDHCI_QUIRK2_BROKEN_HS200;
+
sdhci_setup_host(&host->sdhci);
dev->priv = host;
diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
index c8fd78a5e62d..17847a13ed5f 100644
--- a/drivers/mci/sdhci.c
+++ b/drivers/mci/sdhci.c
@@ -1044,6 +1044,38 @@ int sdhci_setup_host(struct sdhci *host)
if (sdhci_can_64bit_dma(host))
host->flags |= SDHCI_USE_64_BIT_DMA;
+ if (host->quirks2 & SDHCI_QUIRK2_NO_1_8_V) {
+ host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 |
+ SDHCI_SUPPORT_DDR50);
+ /*
+ * The SDHCI controller in a SoC might support HS200/HS400
+ * (indicated using mmc-hs200-1_8v/mmc-hs400-1_8v dt property),
+ * but if the board is modeled such that the IO lines are not
+ * connected to 1.8v then HS200/HS400 cannot be supported.
+ * Disable HS200/HS400 if the board does not have 1.8v connected
+ * to the IO lines. (Applicable for other modes in 1.8v)
+ */
+ mci->caps2 &= ~(MMC_CAP2_HSX00_1_8V | MMC_CAP2_HS400_ES);
+ mci->host_caps &= ~(MMC_CAP_1_8V_DDR | MMC_CAP_UHS);
+ }
+
+ /* Any UHS-I mode in caps implies SDR12 and SDR25 support. */
+ if (host->caps1 & (SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 |
+ SDHCI_SUPPORT_DDR50))
+ mci->host_caps |= MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25;
+
+ /* SDR104 supports also implies SDR50 support */
+ if (host->caps1 & SDHCI_SUPPORT_SDR104) {
+ mci->host_caps |= MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_SDR50;
+ /* SD3.0: SDR104 is supported so (for eMMC) the caps2
+ * field can be promoted to support HS200.
+ */
+ if (!(host->quirks2 & SDHCI_QUIRK2_BROKEN_HS200))
+ mci->caps2 |= MMC_CAP2_HS200;
+ } else if (host->caps1 & SDHCI_SUPPORT_SDR50) {
+ mci->host_caps |= MMC_CAP_UHS_SDR50;
+ }
+
if ((mci->caps2 & (MMC_CAP2_HS200_1_8V_SDR | MMC_CAP2_HS400_1_8V)))
host->flags |= SDHCI_SIGNALING_180;
diff --git a/drivers/mci/sdhci.h b/drivers/mci/sdhci.h
index 038b52cfe619..25d257b23145 100644
--- a/drivers/mci/sdhci.h
+++ b/drivers/mci/sdhci.h
@@ -249,6 +249,10 @@ struct sdhci {
unsigned int quirks;
#define SDHCI_QUIRK_MISSING_CAPS BIT(27)
unsigned int quirks2;
+/* The system physically doesn't support 1.8v, even if the host does */
+#define SDHCI_QUIRK2_NO_1_8_V BIT(2)
+/* Controller does not support HS200 */
+#define SDHCI_QUIRK2_BROKEN_HS200 BIT(6)
#define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN BIT(15)
#define SDHCI_QUIRK2_ISSUE_CMD_DAT_RESET_TOGETHER BIT(19)
u32 caps; /* CAPABILITY_0 */
--
2.39.5
next prev parent reply other threads:[~2025-05-07 9:27 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-07 8:21 [PATCH v2 00/30] mci: imx-esdhc: add HS200 support Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 01/30] mci: sdhci: fix SDHCI_TRNS_AUTO_CMD12 definition Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 02/30] mci: move most recent I/O settings into mci_host::ios Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 03/30] mci: use struct mci_host::ios inside mci_set_ios Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 04/30] mci: tuning: fix fallback to DDR52 Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 05/30] mci: sdhci: unmap DMA buffers on timeout Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 06/30] mci: add MMC_CAP_UHS constants Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 07/30] mci: rename MMC_CAP_MMC_x_yV_DDR to MMC_CAP_x_yV_DDR as in Linux Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 08/30] mci: compare host and card caps for supported speeds Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 09/30] mci: print HS200 capabilities in devinfo Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 10/30] mci: respect no-1-8-v OF property Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 11/30] mci: sdhci: add support for struct mci_data::timeout_ns Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 12/30] mci: imx-esdhc: use unsigned types where appropriate Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 13/30] mci: imx-esdhc: implement esdhc_poll using sdhci_read32_poll_timeout Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 14/30] mci: imx-esdhc: drop one extra read of SDHCI_INT_STATUS Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 15/30] mci: sdhci: add cmd parameter to sdhci_transfer_* Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 16/30] mci: arasan: introduce mmc_op_tuning helper Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 17/30] mci: imx-esdhc: flesh out register description Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 18/30] mci: imx-esdhc: add support for delay/tuning properties in DT Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 19/30] mci: add mci_set_timing helper Ahmad Fatoum
2025-05-07 8:21 ` [PATCH v2 20/30] mci: imx-esdhc: add support for setting drive strength Ahmad Fatoum
2025-05-07 8:22 ` [PATCH v2 21/30] mci: sdhci: move SDHCI_MAKE_BLKSZ definition to header Ahmad Fatoum
2025-05-07 8:22 ` [PATCH v2 22/30] mci: imx-esdhc: select different pinctrl state depending on frequency Ahmad Fatoum
2025-05-07 8:22 ` [PATCH v2 23/30] mci: core: retry MMC_CMD_SET_BLOCKLEN up to 4 times Ahmad Fatoum
2025-05-07 8:22 ` [PATCH v2 24/30] mci: imx-esdhc: don't reconfigure clock unless required Ahmad Fatoum
2025-05-07 8:22 ` [PATCH v2 25/30] mci: sdhci: fix sdhci_transfer_data MMC_SEND_TUNING compatibility Ahmad Fatoum
2025-05-07 8:22 ` [PATCH v2 26/30] mci: core: implement mmc_send_tuning Ahmad Fatoum
2025-05-07 8:22 ` [PATCH v2 27/30] mci: imx-esdhc: set burst_length_enable Ahmad Fatoum
2025-05-07 8:22 ` [PATCH v2 28/30] mci: imx-esdhc: fixup quirks in standard SDHCI registers Ahmad Fatoum
2025-05-07 8:22 ` Ahmad Fatoum [this message]
2025-05-07 8:22 ` [PATCH v2 30/30] mci: imx-esdhc: implement HS200 support Ahmad Fatoum
2025-05-08 7:30 ` [PATCH v2 00/30] mci: imx-esdhc: add " Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250507082209.3289972-30-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox