Skip to content

Commit 198675b

Browse files
parakabebarino
authored andcommitted
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: - openwrt/openwrt#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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent d34db68 commit 198675b

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

drivers/clk/ralink/clk-mtmips.c

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ static struct mtmips_clk mt7620_pherip_clks[] = {
207207
{ CLK_PERIPH("10000b00.spi", "bus") },
208208
{ CLK_PERIPH("10000b40.spi", "bus") },
209209
{ CLK_PERIPH("10000c00.uartlite", "periph") },
210+
{ CLK_PERIPH("10130000.mmc", "sdhc") },
210211
{ CLK_PERIPH("10180000.wmac", "xtal") }
211212
};
212213

@@ -220,6 +221,7 @@ static struct mtmips_clk mt76x8_pherip_clks[] = {
220221
{ CLK_PERIPH("10000c00.uart0", "periph") },
221222
{ CLK_PERIPH("10000d00.uart1", "periph") },
222223
{ CLK_PERIPH("10000e00.uart2", "periph") },
224+
{ CLK_PERIPH("10130000.mmc", "sdhc") },
223225
{ CLK_PERIPH("10300000.wmac", "xtal") }
224226
};
225227

@@ -272,8 +274,13 @@ static struct mtmips_clk_fixed rt3352_fixed_clocks[] = {
272274
CLK_FIXED("periph", "xtal", 40000000)
273275
};
274276

277+
static struct mtmips_clk_fixed mt7620_fixed_clocks[] = {
278+
CLK_FIXED("bbppll", "xtal", 480000000)
279+
};
280+
275281
static struct mtmips_clk_fixed mt76x8_fixed_clocks[] = {
276-
CLK_FIXED("pcmi2s", "xtal", 480000000),
282+
CLK_FIXED("bbppll", "xtal", 480000000),
283+
CLK_FIXED("pcmi2s", "bbppll", 480000000),
277284
CLK_FIXED("periph", "xtal", 40000000)
278285
};
279286

@@ -328,6 +335,15 @@ static struct mtmips_clk_factor rt305x_factor_clocks[] = {
328335
CLK_FACTOR("bus", "cpu", 1, 3)
329336
};
330337

338+
static struct mtmips_clk_factor mt7620_factor_clocks[] = {
339+
CLK_FACTOR("sdhc", "bbppll", 1, 10)
340+
};
341+
342+
static struct mtmips_clk_factor mt76x8_factor_clocks[] = {
343+
CLK_FACTOR("bus", "cpu", 1, 3),
344+
CLK_FACTOR("sdhc", "bbppll", 1, 10)
345+
};
346+
331347
static int mtmips_register_factor_clocks(struct clk_hw_onecell_data *clk_data,
332348
struct mtmips_clk_priv *priv)
333349
{
@@ -811,10 +827,10 @@ static const struct mtmips_clk_data rt5350_clk_data = {
811827
static const struct mtmips_clk_data mt7620_clk_data = {
812828
.clk_base = mt7620_clks_base,
813829
.num_clk_base = ARRAY_SIZE(mt7620_clks_base),
814-
.clk_fixed = NULL,
815-
.num_clk_fixed = 0,
816-
.clk_factor = NULL,
817-
.num_clk_factor = 0,
830+
.clk_fixed = mt7620_fixed_clocks,
831+
.num_clk_fixed = ARRAY_SIZE(mt7620_fixed_clocks),
832+
.clk_factor = mt7620_factor_clocks,
833+
.num_clk_factor = ARRAY_SIZE(mt7620_factor_clocks),
818834
.clk_periph = mt7620_pherip_clks,
819835
.num_clk_periph = ARRAY_SIZE(mt7620_pherip_clks),
820836
};
@@ -824,8 +840,8 @@ static const struct mtmips_clk_data mt76x8_clk_data = {
824840
.num_clk_base = ARRAY_SIZE(mt76x8_clks_base),
825841
.clk_fixed = mt76x8_fixed_clocks,
826842
.num_clk_fixed = ARRAY_SIZE(mt76x8_fixed_clocks),
827-
.clk_factor = rt305x_factor_clocks,
828-
.num_clk_factor = ARRAY_SIZE(rt305x_factor_clocks),
843+
.clk_factor = mt76x8_factor_clocks,
844+
.num_clk_factor = ARRAY_SIZE(mt76x8_factor_clocks),
829845
.clk_periph = mt76x8_pherip_clks,
830846
.num_clk_periph = ARRAY_SIZE(mt76x8_pherip_clks),
831847
};

0 commit comments

Comments
 (0)