[PATCH v3 1/2] mmc: litex_mmc: Move litex_mmc_setclk() to bottom for reuse

Inochi Amaoto
2026-04-26T11:20:25Z

Move the litex_mmc_setclk() to the bottom of the driver, this
function is needed to set the idle clock for CMD0

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
drivers/mmc/host/litex_mmc.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/host/litex_mmc.c b/drivers/mmc/host/litex_mmc.c
index d2f19c2dc673..a8d9c0ece16a 100644
--- a/drivers/mmc/host/litex_mmc.c
+++ b/drivers/mmc/host/litex_mmc.c
@@ -99,6 +99,20 @@ struct litex_mmc_host {
bool app_cmd;
};

+static void litex_mmc_setclk(struct litex_mmc_host *host, unsigned int freq)
+{
+ struct device *dev = mmc_dev(host->mmc);
+ u32 div;
+
+ div = freq ? host->ref_clk / freq : 256U;
+ div = roundup_pow_of_two(div);
+ div = clamp(div, 2U, 256U);
+ dev_dbg(dev, "sd_clk_freq=%d: set to %d via div=%d\n",
+ freq, host->ref_clk / div, div);
+ litex_write16(host->sdphy + LITEX_PHY_CLOCKERDIV, div);
+ host->sd_clk = freq;
+}
+
static int litex_mmc_sdcard_wait_done(void __iomem *reg, struct device *dev)
{
u8 evt;
@@ -431,20 +445,6 @@ static void litex_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
mmc_request_done(mmc, mrq);
}

-static void litex_mmc_setclk(struct litex_mmc_host *host, unsigned int freq)
-{
- struct device *dev = mmc_dev(host->mmc);
- u32 div;
-
- div = freq ? host->ref_clk / freq : 256U;
- div = roundup_pow_of_two(div);
- div = clamp(div, 2U, 256U);
- dev_dbg(dev, "sd_clk_freq=%d: set to %d via div=%d\n",
- freq, host->ref_clk / div, div);
- litex_write16(host->sdphy + LITEX_PHY_CLOCKERDIV, div);
- host->sd_clk = freq;
-}
-
static void litex_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{
struct litex_mmc_host *host = mmc_priv(mmc);
--
2.54.0