[PATCH v25 06/11] mmc: renesas_sdhi: Make clock divider mask configurable
From: Biju Das
Date: Wed Oct 28 2026 - 08:56:22 EST
From: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
Add a clk_div_mask field to renesas_sdhi_of_data and tmio_mmc_data
so each SoC can specify its own divider mask instead of the
hardcoded CLK_CTL_DIV_MASK used in renesas_sdhi_set_clock().
Default to CLK_CTL_DIV_MASK at probe time when unset.
This lets RZ/G3L, which has a wider divider field, reuse the same
clock-setting code.
Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
---
v24->v25:
* Updated commit description
* Dropped initializing clk_div_mask as it use default value.
v23->v24:
* Updated commit description.
* Replaced GENMASK(7, 0) with CLK_CTL_DIV_MASK.
v22->v23:
* Assigned of_data->clk_div_mask in renesas_sdhi_probe().
v21->v22:
* Updated commit description.
* Added clk_div_mask to of_default_cfg and of_rcar_gen2_compatible.
v21:
* New patch.
---
drivers/mmc/host/renesas_sdhi.h | 1 +
drivers/mmc/host/renesas_sdhi_core.c | 6 +++++-
include/linux/platform_data/tmio.h | 1 +
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h
index b759376103d7..3c991f6b988b 100644
--- a/drivers/mmc/host/renesas_sdhi.h
+++ b/drivers/mmc/host/renesas_sdhi.h
@@ -42,6 +42,7 @@ struct renesas_sdhi_of_data {
unsigned long sdhi_flags;
u64 clk_mask;
unsigned int max_divider;
+ u16 clk_div_mask;
};
#define SDHI_CALIB_TABLE_MAX 32
diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 500ecc357095..86778d83eb7d 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -232,7 +232,7 @@ static void renesas_sdhi_set_clock(struct tmio_mmc_host *host,
clk &= ~SDHI_SD_CLK_CTL_DIV1;
}
- clock = clk & CLK_CTL_DIV_MASK;
+ clock = clk & host->pdata->clk_div_mask;
if (clock != SDHI_SD_CLK_CTL_DIV1)
host->mmc->actual_clock /= (1 << (ffs(clock) + 1));
@@ -1146,6 +1146,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
mmc_data->max_segs = of_data->max_segs;
mmc_data->clk_mask = of_data->clk_mask;
mmc_data->max_divider = of_data->max_divider;
+ mmc_data->clk_div_mask = of_data->clk_div_mask;
dma_priv->dma_buswidth = of_data->dma_buswidth;
host->bus_shift = of_data->bus_shift;
/* Fallback for old DTs */
@@ -1194,6 +1195,9 @@ int renesas_sdhi_probe(struct platform_device *pdev,
if (!mmc_data->max_divider)
mmc_data->max_divider = SDHI_MAX_DIVIDER_DEFAULT;
+ if (!mmc_data->clk_div_mask)
+ mmc_data->clk_div_mask = CLK_CTL_DIV_MASK;
+
dma_priv->filter = shdma_chan_filter;
dma_priv->enable = renesas_sdhi_enable_dma;
diff --git a/include/linux/platform_data/tmio.h b/include/linux/platform_data/tmio.h
index 27ea21c00419..f684f4087a8f 100644
--- a/include/linux/platform_data/tmio.h
+++ b/include/linux/platform_data/tmio.h
@@ -63,5 +63,6 @@ struct tmio_mmc_data {
unsigned short max_segs;
u64 clk_mask;
unsigned int max_divider;
+ u16 clk_div_mask;
};
#endif
--
2.43.0