Skip to content

Commit d34db68

Browse files
parakabebarino
authored andcommitted
clk: ralink: mtmips: fix clocks probe order in oldest ralink SoCs
Base clocks are the first in being probed and are real dependencies of the rest of fixed, factor and peripheral clocks. For old ralink SoCs RT2880, RT305x and RT3883 'xtal' must be defined first since in any other case, when fixed clocks are probed they are delayed until 'xtal' is probed so the following warning appears: WARNING: CPU: 0 PID: 0 at drivers/clk/ralink/clk-mtmips.c:499 rt3883_bus_recalc_rate+0x98/0x138 Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 6.6.43 #0 Stack : 805e58d0 00000000 00000004 8004f950 00000000 00000004 00000000 00000000 80669c54 80830000 80700000 805ae570 80670068 00000001 80669bf8 00000000 00000000 00000000 805ae570 80669b38 00000020 804db7dc 00000000 00000000 203a6d6d 80669b78 80669e48 70617773 00000000 805ae570 00000000 00000009 00000000 00000001 00000004 00000001 00000000 00000000 83fe43b0 00000000 ... Call Trace: [<800065d0>] show_stack+0x64/0xf4 [<804bca14>] dump_stack_lvl+0x38/0x60 [<800218ac>] __warn+0x94/0xe4 [<8002195c>] warn_slowpath_fmt+0x60/0x94 [<80259ff8>] rt3883_bus_recalc_rate+0x98/0x138 [<80254530>] __clk_register+0x568/0x688 [<80254838>] of_clk_hw_register+0x18/0x2c [<8070b910>] rt2880_clk_of_clk_init_driver+0x18c/0x594 [<8070b628>] of_clk_init+0x1c0/0x23c [<806fc448>] plat_time_init+0x58/0x18c [<806fdaf0>] time_init+0x10/0x6c [<806f9bc4>] start_kernel+0x458/0x67c ---[ end trace 0000000000000000 ]--- When this driver was mainlined we could not find any active users of old ralink SoCs so we cannot perform any real tests for them. Now, one user of a Belkin f9k1109 version 1 device which uses RT3883 SoC appeared and reported some issues in openWRT: - openwrt/openwrt#16054 Thus, define a 'rt2880_xtal_recalc_rate()' just returning the expected frequency 40Mhz and use it along the old ralink SoCs to have a correct boot trace with no warnings and a working clock plan from the beggining. Fixes: 6f3b155 ("clk: ralink: add clock and reset driver for MTMIPS SoCs") Signed-off-by: Sergio Paracuellos <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 3323915 commit d34db68

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

drivers/clk/ralink/clk-mtmips.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,6 @@ static int mtmips_register_pherip_clocks(struct device_node *np,
263263
.rate = _rate \
264264
}
265265

266-
static struct mtmips_clk_fixed rt305x_fixed_clocks[] = {
267-
CLK_FIXED("xtal", NULL, 40000000)
268-
};
269-
270266
static struct mtmips_clk_fixed rt3883_fixed_clocks[] = {
271267
CLK_FIXED("xtal", NULL, 40000000),
272268
CLK_FIXED("periph", "xtal", 40000000)
@@ -371,6 +367,12 @@ static inline struct mtmips_clk *to_mtmips_clk(struct clk_hw *hw)
371367
return container_of(hw, struct mtmips_clk, hw);
372368
}
373369

370+
static unsigned long rt2880_xtal_recalc_rate(struct clk_hw *hw,
371+
unsigned long parent_rate)
372+
{
373+
return 40000000;
374+
}
375+
374376
static unsigned long rt5350_xtal_recalc_rate(struct clk_hw *hw,
375377
unsigned long parent_rate)
376378
{
@@ -682,10 +684,12 @@ static unsigned long mt76x8_cpu_recalc_rate(struct clk_hw *hw,
682684
}
683685

684686
static struct mtmips_clk rt2880_clks_base[] = {
687+
{ CLK_BASE("xtal", NULL, rt2880_xtal_recalc_rate) },
685688
{ CLK_BASE("cpu", "xtal", rt2880_cpu_recalc_rate) }
686689
};
687690

688691
static struct mtmips_clk rt305x_clks_base[] = {
692+
{ CLK_BASE("xtal", NULL, rt2880_xtal_recalc_rate) },
689693
{ CLK_BASE("cpu", "xtal", rt305x_cpu_recalc_rate) }
690694
};
691695

@@ -695,6 +699,7 @@ static struct mtmips_clk rt3352_clks_base[] = {
695699
};
696700

697701
static struct mtmips_clk rt3883_clks_base[] = {
702+
{ CLK_BASE("xtal", NULL, rt2880_xtal_recalc_rate) },
698703
{ CLK_BASE("cpu", "xtal", rt3883_cpu_recalc_rate) },
699704
{ CLK_BASE("bus", "cpu", rt3883_bus_recalc_rate) }
700705
};
@@ -751,8 +756,8 @@ static int mtmips_register_clocks(struct device_node *np,
751756
static const struct mtmips_clk_data rt2880_clk_data = {
752757
.clk_base = rt2880_clks_base,
753758
.num_clk_base = ARRAY_SIZE(rt2880_clks_base),
754-
.clk_fixed = rt305x_fixed_clocks,
755-
.num_clk_fixed = ARRAY_SIZE(rt305x_fixed_clocks),
759+
.clk_fixed = NULL,
760+
.num_clk_fixed = 0,
756761
.clk_factor = rt2880_factor_clocks,
757762
.num_clk_factor = ARRAY_SIZE(rt2880_factor_clocks),
758763
.clk_periph = rt2880_pherip_clks,
@@ -762,8 +767,8 @@ static const struct mtmips_clk_data rt2880_clk_data = {
762767
static const struct mtmips_clk_data rt305x_clk_data = {
763768
.clk_base = rt305x_clks_base,
764769
.num_clk_base = ARRAY_SIZE(rt305x_clks_base),
765-
.clk_fixed = rt305x_fixed_clocks,
766-
.num_clk_fixed = ARRAY_SIZE(rt305x_fixed_clocks),
770+
.clk_fixed = NULL,
771+
.num_clk_fixed = 0,
767772
.clk_factor = rt305x_factor_clocks,
768773
.num_clk_factor = ARRAY_SIZE(rt305x_factor_clocks),
769774
.clk_periph = rt305x_pherip_clks,

0 commit comments

Comments
 (0)