From 77d9cce604d32005ddb90e91c6cc9b9cf35068d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Thu, 29 Sep 2022 05:51:25 +0200 Subject: [PATCH] bcm53xx: backport clk driver fix for DT nodes names MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It allows dropping downstream patch renaming DT nodes. Signed-off-by: Rafał Miłecki --- ...-rely-on-node-name-for-correct-PLL-s.patch | 72 +++++++++++++++++++ ...-Switch-back-to-old-clock-nodes-name.patch | 62 ---------------- ...-rely-on-node-name-for-correct-PLL-s.patch | 72 +++++++++++++++++++ ...-Switch-back-to-old-clock-nodes-name.patch | 62 ---------------- 4 files changed, 144 insertions(+), 124 deletions(-) create mode 100644 target/linux/bcm53xx/patches-5.10/083-v6.0-clk-iproc-Do-not-rely-on-node-name-for-correct-PLL-s.patch delete mode 100644 target/linux/bcm53xx/patches-5.10/320-ARM-dts-BCM5301X-Switch-back-to-old-clock-nodes-name.patch create mode 100644 target/linux/bcm53xx/patches-5.15/082-v6.0-clk-iproc-Do-not-rely-on-node-name-for-correct-PLL-s.patch delete mode 100644 target/linux/bcm53xx/patches-5.15/320-ARM-dts-BCM5301X-Switch-back-to-old-clock-nodes-name.patch diff --git a/target/linux/bcm53xx/patches-5.10/083-v6.0-clk-iproc-Do-not-rely-on-node-name-for-correct-PLL-s.patch b/target/linux/bcm53xx/patches-5.10/083-v6.0-clk-iproc-Do-not-rely-on-node-name-for-correct-PLL-s.patch new file mode 100644 index 00000000000..12c60ce297a --- /dev/null +++ b/target/linux/bcm53xx/patches-5.10/083-v6.0-clk-iproc-Do-not-rely-on-node-name-for-correct-PLL-s.patch @@ -0,0 +1,72 @@ +From 1b24a132eba7a1c19475ba2510ec1c00af3ff914 Mon Sep 17 00:00:00 2001 +From: Florian Fainelli +Date: Mon, 5 Sep 2022 09:15:03 -0700 +Subject: [PATCH] clk: iproc: Do not rely on node name for correct PLL setup +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +After commit 31fd9b79dc58 ("ARM: dts: BCM5301X: update CRU block +description") a warning from clk-iproc-pll.c was generated due to a +duplicate PLL name as well as the console stopped working. Upon closer +inspection it became clear that iproc_pll_clk_setup() used the Device +Tree node unit name as an unique identifier as well as a parent name to +parent all clocks under the PLL. + +BCM5301X was the first platform on which that got noticed because of the +DT node unit name renaming but the same assumptions hold true for any +user of the iproc_pll_clk_setup() function. + +The first 'clock-output-names' property is always guaranteed to be +unique as well as providing the actual desired PLL clock name, so we +utilize that to register the PLL and as a parent name of all children +clock. + +Fixes: 5fe225c105fd ("clk: iproc: add initial common clock support") +Signed-off-by: Florian Fainelli +Acked-by: Rafał Miłecki +Link: https://lore.kernel.org/r/20220905161504.1526-1-f.fainelli@gmail.com +Signed-off-by: Stephen Boyd +--- + drivers/clk/bcm/clk-iproc-pll.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +--- a/drivers/clk/bcm/clk-iproc-pll.c ++++ b/drivers/clk/bcm/clk-iproc-pll.c +@@ -736,6 +736,7 @@ void iproc_pll_clk_setup(struct device_n + const char *parent_name; + struct iproc_clk *iclk_array; + struct clk_hw_onecell_data *clk_data; ++ const char *clk_name; + + if (WARN_ON(!pll_ctrl) || WARN_ON(!clk_ctrl)) + return; +@@ -783,7 +784,12 @@ void iproc_pll_clk_setup(struct device_n + iclk = &iclk_array[0]; + iclk->pll = pll; + +- init.name = node->name; ++ ret = of_property_read_string_index(node, "clock-output-names", ++ 0, &clk_name); ++ if (WARN_ON(ret)) ++ goto err_pll_register; ++ ++ init.name = clk_name; + init.ops = &iproc_pll_ops; + init.flags = 0; + parent_name = of_clk_get_parent_name(node, 0); +@@ -803,13 +809,11 @@ void iproc_pll_clk_setup(struct device_n + goto err_pll_register; + + clk_data->hws[0] = &iclk->hw; ++ parent_name = clk_name; + + /* now initialize and register all leaf clocks */ + for (i = 1; i < num_clks; i++) { +- const char *clk_name; +- + memset(&init, 0, sizeof(init)); +- parent_name = node->name; + + ret = of_property_read_string_index(node, "clock-output-names", + i, &clk_name); diff --git a/target/linux/bcm53xx/patches-5.10/320-ARM-dts-BCM5301X-Switch-back-to-old-clock-nodes-name.patch b/target/linux/bcm53xx/patches-5.10/320-ARM-dts-BCM5301X-Switch-back-to-old-clock-nodes-name.patch deleted file mode 100644 index cee37732ab9..00000000000 --- a/target/linux/bcm53xx/patches-5.10/320-ARM-dts-BCM5301X-Switch-back-to-old-clock-nodes-name.patch +++ /dev/null @@ -1,62 +0,0 @@ -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= -Date: Tue, 23 Nov 2021 13:13:05 +0100 -Subject: [PATCH] ARM: dts: BCM5301X: Switch back to old clock nodes names -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -First of all using the same node name prefix resulted in trying to -register 2 clocks under the same "clock-controller" name: - -[ 0.000000] __clk_core_init: clk clock-controller already initialized -[ 0.000000] ------------[ cut here ]------------ -[ 0.000000] WARNING: CPU: 0 PID: 0 at drivers/clk/bcm/clk-iproc-pll.c:802 iproc_pll_clk_setup+0x4c8/0x4f4 -[ 0.000000] Modules linked in: -[ 0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.10.80 #0 -[ 0.000000] Hardware name: BCM5301X -[ 0.000000] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) -[ 0.000000] [] (show_stack) from [] (dump_stack+0x94/0xa8) -[ 0.000000] [] (dump_stack) from [] (__warn+0xb8/0x114) -[ 0.000000] [] (__warn) from [] (warn_slowpath_fmt+0x68/0x78) -[ 0.000000] [] (warn_slowpath_fmt) from [] (iproc_pll_clk_setup+0x4c8/0x4f4) -[ 0.000000] [] (iproc_pll_clk_setup) from [] (nsp_genpll_clk_init+0x30/0x38) -[ 0.000000] [] (nsp_genpll_clk_init) from [] (of_clk_init+0x118/0x1f8) -[ 0.000000] [] (of_clk_init) from [] (time_init+0x24/0x30) -[ 0.000000] [] (time_init) from [] (start_kernel+0x398/0x50c) -[ 0.000000] [] (start_kernel) from [<00000000>] (0x0) -[ 0.000000] ---[ end trace fe236bfe9559ee50 ]--- - -Secondly using any other names than "lcpll0" and "genpll" breaks output -clocks: - -$ cat /sys/kernel/debug/clk/usbclk/clk_rate -0 - -For some reason iproc_clk_recalc_rate() gets called with "parent_rate" -argument 0 whenever clocks aren't named "lcpll0" and "genpll". - -Signed-off-by: Rafał Miłecki ---- - arch/arm/boot/dts/bcm5301x.dtsi | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/arch/arm/boot/dts/bcm5301x.dtsi -+++ b/arch/arm/boot/dts/bcm5301x.dtsi -@@ -421,7 +421,7 @@ - #address-cells = <1>; - #size-cells = <1>; - -- lcpll0: clock-controller@100 { -+ lcpll0: lcpll0@100 { - #clock-cells = <1>; - compatible = "brcm,nsp-lcpll0"; - reg = <0x100 0x14>; -@@ -430,7 +430,7 @@ - "sdio", "ddr_phy"; - }; - -- genpll: clock-controller@140 { -+ genpll: genpll@140 { - #clock-cells = <1>; - compatible = "brcm,nsp-genpll"; - reg = <0x140 0x24>; diff --git a/target/linux/bcm53xx/patches-5.15/082-v6.0-clk-iproc-Do-not-rely-on-node-name-for-correct-PLL-s.patch b/target/linux/bcm53xx/patches-5.15/082-v6.0-clk-iproc-Do-not-rely-on-node-name-for-correct-PLL-s.patch new file mode 100644 index 00000000000..12c60ce297a --- /dev/null +++ b/target/linux/bcm53xx/patches-5.15/082-v6.0-clk-iproc-Do-not-rely-on-node-name-for-correct-PLL-s.patch @@ -0,0 +1,72 @@ +From 1b24a132eba7a1c19475ba2510ec1c00af3ff914 Mon Sep 17 00:00:00 2001 +From: Florian Fainelli +Date: Mon, 5 Sep 2022 09:15:03 -0700 +Subject: [PATCH] clk: iproc: Do not rely on node name for correct PLL setup +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +After commit 31fd9b79dc58 ("ARM: dts: BCM5301X: update CRU block +description") a warning from clk-iproc-pll.c was generated due to a +duplicate PLL name as well as the console stopped working. Upon closer +inspection it became clear that iproc_pll_clk_setup() used the Device +Tree node unit name as an unique identifier as well as a parent name to +parent all clocks under the PLL. + +BCM5301X was the first platform on which that got noticed because of the +DT node unit name renaming but the same assumptions hold true for any +user of the iproc_pll_clk_setup() function. + +The first 'clock-output-names' property is always guaranteed to be +unique as well as providing the actual desired PLL clock name, so we +utilize that to register the PLL and as a parent name of all children +clock. + +Fixes: 5fe225c105fd ("clk: iproc: add initial common clock support") +Signed-off-by: Florian Fainelli +Acked-by: Rafał Miłecki +Link: https://lore.kernel.org/r/20220905161504.1526-1-f.fainelli@gmail.com +Signed-off-by: Stephen Boyd +--- + drivers/clk/bcm/clk-iproc-pll.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +--- a/drivers/clk/bcm/clk-iproc-pll.c ++++ b/drivers/clk/bcm/clk-iproc-pll.c +@@ -736,6 +736,7 @@ void iproc_pll_clk_setup(struct device_n + const char *parent_name; + struct iproc_clk *iclk_array; + struct clk_hw_onecell_data *clk_data; ++ const char *clk_name; + + if (WARN_ON(!pll_ctrl) || WARN_ON(!clk_ctrl)) + return; +@@ -783,7 +784,12 @@ void iproc_pll_clk_setup(struct device_n + iclk = &iclk_array[0]; + iclk->pll = pll; + +- init.name = node->name; ++ ret = of_property_read_string_index(node, "clock-output-names", ++ 0, &clk_name); ++ if (WARN_ON(ret)) ++ goto err_pll_register; ++ ++ init.name = clk_name; + init.ops = &iproc_pll_ops; + init.flags = 0; + parent_name = of_clk_get_parent_name(node, 0); +@@ -803,13 +809,11 @@ void iproc_pll_clk_setup(struct device_n + goto err_pll_register; + + clk_data->hws[0] = &iclk->hw; ++ parent_name = clk_name; + + /* now initialize and register all leaf clocks */ + for (i = 1; i < num_clks; i++) { +- const char *clk_name; +- + memset(&init, 0, sizeof(init)); +- parent_name = node->name; + + ret = of_property_read_string_index(node, "clock-output-names", + i, &clk_name); diff --git a/target/linux/bcm53xx/patches-5.15/320-ARM-dts-BCM5301X-Switch-back-to-old-clock-nodes-name.patch b/target/linux/bcm53xx/patches-5.15/320-ARM-dts-BCM5301X-Switch-back-to-old-clock-nodes-name.patch deleted file mode 100644 index cee37732ab9..00000000000 --- a/target/linux/bcm53xx/patches-5.15/320-ARM-dts-BCM5301X-Switch-back-to-old-clock-nodes-name.patch +++ /dev/null @@ -1,62 +0,0 @@ -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= -Date: Tue, 23 Nov 2021 13:13:05 +0100 -Subject: [PATCH] ARM: dts: BCM5301X: Switch back to old clock nodes names -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -First of all using the same node name prefix resulted in trying to -register 2 clocks under the same "clock-controller" name: - -[ 0.000000] __clk_core_init: clk clock-controller already initialized -[ 0.000000] ------------[ cut here ]------------ -[ 0.000000] WARNING: CPU: 0 PID: 0 at drivers/clk/bcm/clk-iproc-pll.c:802 iproc_pll_clk_setup+0x4c8/0x4f4 -[ 0.000000] Modules linked in: -[ 0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.10.80 #0 -[ 0.000000] Hardware name: BCM5301X -[ 0.000000] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) -[ 0.000000] [] (show_stack) from [] (dump_stack+0x94/0xa8) -[ 0.000000] [] (dump_stack) from [] (__warn+0xb8/0x114) -[ 0.000000] [] (__warn) from [] (warn_slowpath_fmt+0x68/0x78) -[ 0.000000] [] (warn_slowpath_fmt) from [] (iproc_pll_clk_setup+0x4c8/0x4f4) -[ 0.000000] [] (iproc_pll_clk_setup) from [] (nsp_genpll_clk_init+0x30/0x38) -[ 0.000000] [] (nsp_genpll_clk_init) from [] (of_clk_init+0x118/0x1f8) -[ 0.000000] [] (of_clk_init) from [] (time_init+0x24/0x30) -[ 0.000000] [] (time_init) from [] (start_kernel+0x398/0x50c) -[ 0.000000] [] (start_kernel) from [<00000000>] (0x0) -[ 0.000000] ---[ end trace fe236bfe9559ee50 ]--- - -Secondly using any other names than "lcpll0" and "genpll" breaks output -clocks: - -$ cat /sys/kernel/debug/clk/usbclk/clk_rate -0 - -For some reason iproc_clk_recalc_rate() gets called with "parent_rate" -argument 0 whenever clocks aren't named "lcpll0" and "genpll". - -Signed-off-by: Rafał Miłecki ---- - arch/arm/boot/dts/bcm5301x.dtsi | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/arch/arm/boot/dts/bcm5301x.dtsi -+++ b/arch/arm/boot/dts/bcm5301x.dtsi -@@ -421,7 +421,7 @@ - #address-cells = <1>; - #size-cells = <1>; - -- lcpll0: clock-controller@100 { -+ lcpll0: lcpll0@100 { - #clock-cells = <1>; - compatible = "brcm,nsp-lcpll0"; - reg = <0x100 0x14>; -@@ -430,7 +430,7 @@ - "sdio", "ddr_phy"; - }; - -- genpll: clock-controller@140 { -+ genpll: genpll@140 { - #clock-cells = <1>; - compatible = "brcm,nsp-genpll"; - reg = <0x140 0x24>; -- 2.30.2