[PATCH v23 09/14] mmc: renesas_sdhi: Add write32_hook for CTL_SD_CARD_CLK_CTL register writes
Biju <[email protected]> Thu, 30 Jul 2026 12:31:47 +0100
| Newsgroups | org.kernel.vger.linux-mmc,org.kernel.vger.linux-kernel,org.kernel.vger.linux-renesas-soc |
|---|---|
| Message-ID | <[email protected]> |
From: Biju Das <[email protected]> Add a write32_hook, analogous to the existing write16_hook, so that sd_ctrl_write32() can wait for the SD bus to become idle before certain 32-bit register writes. renesas_sdhi_write32_hook() checks whether the target register is CTL_SD_CARD_CLK_CTL and, if so, waits for TMIO_STAT_SCLKDIVEN via renesas_sdhi_wait_idle() before the write proceeds. Other registers are unaffected. As with write16_hook, the write is skipped if the hook returns a non-zero error. Signed-off-by: Biju Das <[email protected]> --- v23: * New patch. --- drivers/mmc/host/renesas_sdhi_core.c | 9 +++++++++ drivers/mmc/host/tmio_mmc.h | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index ebbce7f010be..ba109a15b47b 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -969,6 +969,14 @@ static int renesas_sdhi_write16_hook(struct tmio_mmc_host *host, int addr) return 0; } +static int renesas_sdhi_write32_hook(struct tmio_mmc_host *host, int addr) +{ + if (addr == CTL_SD_CARD_CLK_CTL) + return renesas_sdhi_wait_idle(host, TMIO_STAT_SCLKDIVEN); + + return 0; +} + static int renesas_sdhi_multi_io_quirk(struct mmc_card *card, unsigned int direction, int blk_size) { @@ -1203,6 +1211,7 @@ int renesas_sdhi_probe(struct platform_device *pdev, } host->write16_hook = renesas_sdhi_write16_hook; + host->write32_hook = renesas_sdhi_write32_hook; host->clk_enable = renesas_sdhi_clk_enable; host->clk_disable = renesas_sdhi_clk_disable; host->set_clock = renesas_sdhi_set_clock; diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index b9de03325c58..8d6d65a51be7 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -190,6 +190,7 @@ struct tmio_mmc_host { int (*multi_io_quirk)(struct mmc_card *card, unsigned int direction, int blk_size); int (*write16_hook)(struct tmio_mmc_host *host, int addr); + int (*write32_hook)(struct tmio_mmc_host *host, int addr); void (*reset)(struct tmio_mmc_host *host, bool preserve); bool (*check_retune)(struct tmio_mmc_host *host, struct mmc_request *mrq); void (*fixup_request)(struct tmio_mmc_host *host, struct mmc_request *mrq); @@ -284,6 +285,12 @@ static inline void sd_ctrl_write32_as_16_and_16(struct tmio_mmc_host *host, static inline void sd_ctrl_write32(struct tmio_mmc_host *host, int addr, u32 val) { + /* If there is a hook and it returns non-zero then there + * is an error and the write should be skipped + */ + if (host->write32_hook && host->write32_hook(host, addr)) + return; + iowrite32(val, host->ctl + (addr << host->bus_shift)); } -- 2.43.0