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

clk: ralink: mtmips: add mmc related clocks for SoCs MT7620, MT7628 and MT7688

Original architecture clock code from where this driver was derived did not
include nothing related to mmc clocks. OpenWRT people started to use mtk-sd
upstream driver recently and they were forced to use a dts 'fixed-clock'
node with 48 MHz clock:
- https://github.com/openwrt/openwrt/pull/15896
The proper thing to do to avoid that is to add the mmc related clocks to the
driver to avoid a dts with fixed clocks nodes. The minimal documentation in
the mt7620 programming guide says that there is a BBP_PLL clock of 480 MHz
derived from the 40 MHz XTAL and from there a clock divider by ten produces
the desired SDHC clock of 48 MHz for the mmc. Hence add a fixed clock 'bbppll'
and factor clock 'sdhc' ten divider child to properly set the 'mmc' peripheral
clock with the desired 48 Mhz rate.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Link: https://lore.kernel.org/r/20240910044024.120009-4-sergio.paracuellos@gmail.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Sergio Paracuellos and committed by
Stephen Boyd
198675bb d34db686

+23 -7
+23 -7
drivers/clk/ralink/clk-mtmips.c
··· 207 207 { CLK_PERIPH("10000b00.spi", "bus") }, 208 208 { CLK_PERIPH("10000b40.spi", "bus") }, 209 209 { CLK_PERIPH("10000c00.uartlite", "periph") }, 210 + { CLK_PERIPH("10130000.mmc", "sdhc") }, 210 211 { CLK_PERIPH("10180000.wmac", "xtal") } 211 212 }; 212 213 ··· 221 220 { CLK_PERIPH("10000c00.uart0", "periph") }, 222 221 { CLK_PERIPH("10000d00.uart1", "periph") }, 223 222 { CLK_PERIPH("10000e00.uart2", "periph") }, 223 + { CLK_PERIPH("10130000.mmc", "sdhc") }, 224 224 { CLK_PERIPH("10300000.wmac", "xtal") } 225 225 }; 226 226 ··· 274 272 CLK_FIXED("periph", "xtal", 40000000) 275 273 }; 276 274 275 + static struct mtmips_clk_fixed mt7620_fixed_clocks[] = { 276 + CLK_FIXED("bbppll", "xtal", 480000000) 277 + }; 278 + 277 279 static struct mtmips_clk_fixed mt76x8_fixed_clocks[] = { 278 - CLK_FIXED("pcmi2s", "xtal", 480000000), 280 + CLK_FIXED("bbppll", "xtal", 480000000), 281 + CLK_FIXED("pcmi2s", "bbppll", 480000000), 279 282 CLK_FIXED("periph", "xtal", 40000000) 280 283 }; 281 284 ··· 333 326 334 327 static struct mtmips_clk_factor rt305x_factor_clocks[] = { 335 328 CLK_FACTOR("bus", "cpu", 1, 3) 329 + }; 330 + 331 + static struct mtmips_clk_factor mt7620_factor_clocks[] = { 332 + CLK_FACTOR("sdhc", "bbppll", 1, 10) 333 + }; 334 + 335 + static struct mtmips_clk_factor mt76x8_factor_clocks[] = { 336 + CLK_FACTOR("bus", "cpu", 1, 3), 337 + CLK_FACTOR("sdhc", "bbppll", 1, 10) 336 338 }; 337 339 338 340 static int mtmips_register_factor_clocks(struct clk_hw_onecell_data *clk_data, ··· 827 811 static const struct mtmips_clk_data mt7620_clk_data = { 828 812 .clk_base = mt7620_clks_base, 829 813 .num_clk_base = ARRAY_SIZE(mt7620_clks_base), 830 - .clk_fixed = NULL, 831 - .num_clk_fixed = 0, 832 - .clk_factor = NULL, 833 - .num_clk_factor = 0, 814 + .clk_fixed = mt7620_fixed_clocks, 815 + .num_clk_fixed = ARRAY_SIZE(mt7620_fixed_clocks), 816 + .clk_factor = mt7620_factor_clocks, 817 + .num_clk_factor = ARRAY_SIZE(mt7620_factor_clocks), 834 818 .clk_periph = mt7620_pherip_clks, 835 819 .num_clk_periph = ARRAY_SIZE(mt7620_pherip_clks), 836 820 }; ··· 840 824 .num_clk_base = ARRAY_SIZE(mt76x8_clks_base), 841 825 .clk_fixed = mt76x8_fixed_clocks, 842 826 .num_clk_fixed = ARRAY_SIZE(mt76x8_fixed_clocks), 843 - .clk_factor = rt305x_factor_clocks, 844 - .num_clk_factor = ARRAY_SIZE(rt305x_factor_clocks), 827 + .clk_factor = mt76x8_factor_clocks, 828 + .num_clk_factor = ARRAY_SIZE(mt76x8_factor_clocks), 845 829 .clk_periph = mt76x8_pherip_clks, 846 830 .num_clk_periph = ARRAY_SIZE(mt76x8_pherip_clks), 847 831 };