12c60ce297aaae2b7cf0a2c605565f62092b3486
[openwrt/openwrt.git] /
1 From 1b24a132eba7a1c19475ba2510ec1c00af3ff914 Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <f.fainelli@gmail.com>
3 Date: Mon, 5 Sep 2022 09:15:03 -0700
4 Subject: [PATCH] clk: iproc: Do not rely on node name for correct PLL setup
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 After commit 31fd9b79dc58 ("ARM: dts: BCM5301X: update CRU block
10 description") a warning from clk-iproc-pll.c was generated due to a
11 duplicate PLL name as well as the console stopped working. Upon closer
12 inspection it became clear that iproc_pll_clk_setup() used the Device
13 Tree node unit name as an unique identifier as well as a parent name to
14 parent all clocks under the PLL.
15
16 BCM5301X was the first platform on which that got noticed because of the
17 DT node unit name renaming but the same assumptions hold true for any
18 user of the iproc_pll_clk_setup() function.
19
20 The first 'clock-output-names' property is always guaranteed to be
21 unique as well as providing the actual desired PLL clock name, so we
22 utilize that to register the PLL and as a parent name of all children
23 clock.
24
25 Fixes: 5fe225c105fd ("clk: iproc: add initial common clock support")
26 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
27 Acked-by: Rafał Miłecki <rafal@milecki.pl>
28 Link: https://lore.kernel.org/r/20220905161504.1526-1-f.fainelli@gmail.com
29 Signed-off-by: Stephen Boyd <sboyd@kernel.org>
30 ---
31 drivers/clk/bcm/clk-iproc-pll.c | 12 ++++++++----
32 1 file changed, 8 insertions(+), 4 deletions(-)
33
34 --- a/drivers/clk/bcm/clk-iproc-pll.c
35 +++ b/drivers/clk/bcm/clk-iproc-pll.c
36 @@ -736,6 +736,7 @@ void iproc_pll_clk_setup(struct device_n
37 const char *parent_name;
38 struct iproc_clk *iclk_array;
39 struct clk_hw_onecell_data *clk_data;
40 + const char *clk_name;
41
42 if (WARN_ON(!pll_ctrl) || WARN_ON(!clk_ctrl))
43 return;
44 @@ -783,7 +784,12 @@ void iproc_pll_clk_setup(struct device_n
45 iclk = &iclk_array[0];
46 iclk->pll = pll;
47
48 - init.name = node->name;
49 + ret = of_property_read_string_index(node, "clock-output-names",
50 + 0, &clk_name);
51 + if (WARN_ON(ret))
52 + goto err_pll_register;
53 +
54 + init.name = clk_name;
55 init.ops = &iproc_pll_ops;
56 init.flags = 0;
57 parent_name = of_clk_get_parent_name(node, 0);
58 @@ -803,13 +809,11 @@ void iproc_pll_clk_setup(struct device_n
59 goto err_pll_register;
60
61 clk_data->hws[0] = &iclk->hw;
62 + parent_name = clk_name;
63
64 /* now initialize and register all leaf clocks */
65 for (i = 1; i < num_clks; i++) {
66 - const char *clk_name;
67 -
68 memset(&init, 0, sizeof(init));
69 - parent_name = node->name;
70
71 ret = of_property_read_string_index(node, "clock-output-names",
72 i, &clk_name);