[PATCH 3/3] mmc: renesas_sdhi: Add RZ/G3L HS400 support
From: Biju Das
Date: Mon Nov 16 2026 - 07:02:32 EST
From: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
Add HS400 support for the RZ/G3L SoC.
RZ/G3L needs a second HS400 enable register, SDm_SCC_HS400MODE2
(offset 0x020), alongside the existing TMPPORT2 path. Add a
TMIO_MMC_HS400MODE2 flag (bit 16) for controllers that need it.
RZ/G3L HS400 mode does not use internal divider and supports
only one divider value "0" in the SD_CLK_CTRL register.
Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
---
drivers/mmc/host/renesas_sdhi_core.c | 38 ++++++++++++++++++++++++---
drivers/mmc/host/renesas_sdhi_internal_dmac.c | 3 ++-
include/linux/platform_data/tmio.h | 3 +++
3 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 7dfcf7f970aa..f15f766b7666 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -135,7 +135,8 @@ static unsigned int renesas_sdhi_clk_get_rate(struct tmio_mmc_host *host,
{
unsigned int freq = clk_get_rate(clk);
- if (host->pdata->flags & TMIO_MMC_INTERNAL_DIVIDER)
+ if ((host->pdata->flags & TMIO_MMC_INTERNAL_DIVIDER) &&
+ host->mmc->ios.timing != MMC_TIMING_MMC_HS400)
freq /= 2;
return freq;
@@ -259,6 +260,14 @@ static void renesas_sdhi_set_clock(struct tmio_mmc_host *host,
clk &= ~SDHI_SD_CLK_CTL_DIV1;
}
+ /*
+ * RZ/G3L SoC HS400 mode has only 1 divider value.
+ * Other divider values are prohibited
+ */
+ if ((host->pdata->flags & TMIO_MMC_HS400MODE2) &&
+ host->mmc->ios.timing == MMC_TIMING_MMC_HS400)
+ clk = 0;
+
clock = clk & host->pdata->clk_div_mask;
if (clock != SDHI_SD_CLK_CTL_DIV1)
host->mmc->actual_clock /= (1 << (ffs(clock) + 1));
@@ -315,6 +324,7 @@ static int renesas_sdhi_card_busy(struct mmc_host *mmc)
#define SH_MOBILE_SDHI_SCC_TMPPORT5 0x018
#define SH_MOBILE_SDHI_SCC_TMPPORT6 0x01A
#define SH_MOBILE_SDHI_SCC_TMPPORT7 0x01C
+#define RZG3L_SDHI_SCC_HS400MODE2 0x020
#define RZG3L_SDHI_SCC_HWADJ4 0x022
#define SH_MOBILE_SDHI_SCC_DTCNTL_TAPEN BIT(0)
@@ -350,6 +360,9 @@ static int renesas_sdhi_card_busy(struct mmc_host *mmc)
#define SH_MOBILE_SDHI_SCC_TMPPORT_DISABLE_WP_CODE 0xa5000000
#define SH_MOBILE_SDHI_SCC_TMPPORT_CALIB_CODE_MASK 0x1f
#define SH_MOBILE_SDHI_SCC_TMPPORT_MANUAL_MODE BIT(7)
+#define RZG3L_SDHI_SCC_HS400MODE2_HS400EN2 BIT(0)
+
+#define RZG2L_SDHI_SCC_TMPPORT2_TMPOUT GENMASK(15, 0)
static inline u32 sd_scc_read32(struct tmio_mmc_host *host,
struct renesas_sdhi *priv, int addr)
@@ -364,6 +377,18 @@ static inline void sd_scc_write32(struct tmio_mmc_host *host,
writel(val, priv->scc_ctl + (addr << host->bus_shift));
}
+static void renesas_sdhi_set_tmpport(struct tmio_mmc_host *host, u32 tmpport)
+{
+ struct renesas_sdhi *priv = host_to_priv(host);
+ u32 val = tmpport;
+
+ if (host->pdata->flags & TMIO_MMC_HS400MODE2)
+ val |= sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2) &
+ ~RZG2L_SDHI_SCC_TMPPORT2_TMPOUT;
+
+ sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2, val);
+}
+
static void renesas_sdhi_set_hw_adjustment_delay(struct tmio_mmc_host *host,
bool force_clear)
{
@@ -374,12 +399,12 @@ static void renesas_sdhi_set_hw_adjustment_delay(struct tmio_mmc_host *host,
return;
if (host->mmc->ios.signal_voltage == MMC_SIGNAL_VOLTAGE_330 || force_clear) {
- sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2, 0x0);
+ renesas_sdhi_set_tmpport(host, 0x0);
if (hwadj2)
sd_scc_write32(host, priv, RZG3L_SDHI_SCC_HWADJ2,
RZG3L_SDHI_SCC_HWADJ2_3_3V);
} else {
- sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2, 0x1);
+ renesas_sdhi_set_tmpport(host, 0x1);
if (hwadj2)
sd_scc_write32(host, priv, RZG3L_SDHI_SCC_HWADJ2,
RZG3L_SDHI_SCC_HWADJ2_1_8V);
@@ -486,6 +511,10 @@ static void renesas_sdhi_hs400_complete(struct mmc_host *mmc)
host->pdata->osel_tmpout) |
sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2));
+ if (host->pdata->flags & TMIO_MMC_HS400MODE2)
+ sd_scc_write32(host, priv, RZG3L_SDHI_SCC_HS400MODE2,
+ RZG3L_SDHI_SCC_HS400MODE2_HS400EN2);
+
sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_DTCNTL,
SH_MOBILE_SDHI_SCC_DTCNTL_TAPEN |
sd_scc_read32(host, priv,
@@ -623,6 +652,9 @@ static void renesas_sdhi_reset_hs400_mode(struct tmio_mmc_host *host,
host->pdata->osel_tmpout) &
sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2));
+ if (host->pdata->flags & TMIO_MMC_HS400MODE2)
+ sd_scc_write32(host, priv, RZG3L_SDHI_SCC_HS400MODE2, 0x0);
+
if (sdhi_has_quirk(priv, hs400_calib_table) || sdhi_has_quirk(priv, hs400_bad_taps))
renesas_sdhi_adjust_hs400_mode_disable(host);
diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
index 37eeaa52f011..d9b9f9663386 100644
--- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c
+++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
@@ -165,7 +165,8 @@ static const struct renesas_sdhi_of_data of_data_rzg3l = {
.tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL |
TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2 |
TMIO_MMC_64BIT_DATA_PORT | TMIO_MMC_TUNING_DELAY |
- TMIO_MMC_INTERNAL_DIVIDER | TMIO_MMC_HWADJ,
+ TMIO_MMC_INTERNAL_DIVIDER | TMIO_MMC_HWADJ |
+ TMIO_MMC_HS400MODE2,
.capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
MMC_CAP_CMD23 | MMC_CAP_WAIT_WHILE_BUSY,
.capabilities2 = MMC_CAP2_NO_WRITE_PROTECT | MMC_CAP2_MERGE_CAPABLE,
diff --git a/include/linux/platform_data/tmio.h b/include/linux/platform_data/tmio.h
index 501ca4355c34..81a37d6baefc 100644
--- a/include/linux/platform_data/tmio.h
+++ b/include/linux/platform_data/tmio.h
@@ -59,6 +59,9 @@
/* Some controllers have hw adjustment delay */
#define TMIO_MMC_HWADJ BIT(15)
+/* Some controllers have HS400MODE2 */
+#define TMIO_MMC_HS400MODE2 BIT(16)
+
struct tmio_mmc_data {
void *chan_priv_tx;
void *chan_priv_rx;
--
2.43.0