mmc: renesas_sdhi: Fix rounding errors
authorBiju Das <biju.das.jz@bp.renesas.com>
Wed, 28 Sep 2022 11:07:55 +0000 (12:07 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Fri, 7 Oct 2022 08:53:22 +0000 (10:53 +0200)
commitf0c00454bf78975925eccc9737faaa4d4951edbf
treeadaaf7473fd0b82ec6b656d5d9aa2158d68d5d4f
parent07d2872bf4c864eb83d034263c155746a2fb7a3b
mmc: renesas_sdhi: Fix rounding errors

Due to clk rounding errors on RZ/G2L platforms, it selects a clock source
with a lower clock rate compared to a higher one.
For eg: The rounding error (533333333 Hz / 4 * 4 = 533333332 Hz < 5333333
33 Hz) selects a clk source of 400 MHz instead of 533.333333 MHz.

This patch fixes this issue by adding a margin of (1/1024) higher to
the clock rate.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Fixes: bb6d3fa98a41 ("clk: renesas: rcar-gen3: Switch to new SD clock handling")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220928110755.849275-1-biju.das.jz@bp.renesas.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/renesas_sdhi_core.c