Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: host: renesas_sdhi: Fix the actual clock

Wrong actual clock reported, if the SD clock division ratio is other
than 1:1(bits DIV[7:0] in SD_CLK_CTRL are set to 11111111).

On high speed mode, cat /sys/kernel/debug/mmc1/ios
Without the patch:
clock: 50000000 Hz
actual clock: 200000000 Hz

After the fix:
clock: 50000000 Hz
actual clock: 50000000 Hz

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20250629203859.170850-1-biju.das.jz@bp.renesas.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Biju Das and committed by
Ulf Hansson
9c174e4d fef12d9f

+5 -1
+5 -1
drivers/mmc/host/renesas_sdhi_core.c
··· 222 222 clk &= ~0xff; 223 223 } 224 224 225 - sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clk & CLK_CTL_DIV_MASK); 225 + clock = clk & CLK_CTL_DIV_MASK; 226 + if (clock != 0xff) 227 + host->mmc->actual_clock /= (1 << (ffs(clock) + 1)); 228 + 229 + sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clock); 226 230 if (!(host->pdata->flags & TMIO_MMC_MIN_RCAR2)) 227 231 usleep_range(10000, 11000); 228 232