Add NSS clock controller support for IPQ9574
Subsystems (8)
v4 cover Add NSS clock controller support for IPQ9574
Add bindings, driver and devicetree node for networking sub system clock controller on IPQ9574. Also add support for NSS Huayra type alpha PLL and add support for gpll0_out_aux clock which serves as the parent for some nss clocks.
This series depends on the below patch series which adds support for Interconnect driver
https://lore.kernel.org/linux-arm-msm/[email protected]/
Changes in V4:
- Detailed change logs are added to the respective patches.
V3 can be found at:
https://lore.kernel.org/linux-arm-msm/[email protected]/
V2 can be found at:
https://lore.kernel.org/linux-arm-msm/[email protected]/
Devi Priya (7):
clk: qcom: clk-alpha-pll: Add NSS HUAYRA ALPHA PLL support for ipq9574
dt-bindings: clock: gcc-ipq9574: Add definition for GPLL0_OUT_AUX
clk: qcom: gcc-ipq9574: Add support for gpll0_out_aux clock
dt-bindings: clock: Add ipq9574 NSSCC clock and reset definitions
clk: qcom: Add NSS clock Controller driver for IPQ9574
arm64: dts: qcom: ipq9574: Add support for nsscc node
arm64: defconfig: Build NSS Clock Controller driver for IPQ9574
.../bindings/clock/qcom,ipq9574-nsscc.yaml | 75 + arch/arm64/boot/dts/qcom/ipq9574.dtsi | 44 + arch/arm64/configs/defconfig | 1 + drivers/clk/qcom/Kconfig | 7 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/clk-alpha-pll.c | 11 + drivers/clk/qcom/clk-alpha-pll.h | 1 + drivers/clk/qcom/gcc-ipq9574.c | 15 + drivers/clk/qcom/nsscc-ipq9574.c | 3082 +++++++++++++++++ include/dt-bindings/clock/qcom,ipq9574-gcc.h | 1 + .../dt-bindings/clock/qcom,ipq9574-nsscc.h | 152 + .../dt-bindings/reset/qcom,ipq9574-nsscc.h | 134 + 12 files changed, 3524 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/qcom,ipq9574-nsscc.yaml create mode 100644 drivers/clk/qcom/nsscc-ipq9574.c create mode 100644 include/dt-bindings/clock/qcom,ipq9574-nsscc.h create mode 100644 include/dt-bindings/reset/qcom,ipq9574-nsscc.h
base-commit: 62c97045b8f720c2eac807a5f38e26c9ed512371
prerequisite-patch-id: 513cb089a74b49996b46345595d1aacf60dcda64
prerequisite-patch-id: 480a3d98ed862604edd8b6375b96f3b452471668
prerequisite-patch-id: c26478e61e583eb879385598f26b42b8271036f5
prerequisite-patch-id: 0f009298418d78a45a208f043f86c4ce500f2390
prerequisite-patch-id: 353eb53cd192489d5b0c4654a0b922f23e1f7217
prerequisite-patch-id: 8c6142689c760536e3dd8fb569545cf751cb714c
Signature · 1 line
2.34.1
PATCH v4 1/7 clk: qcom: clk-alpha-pll: Add NSS HUAYRA ALPHA PLL support for ipq9574
Add support for NSS Huayra alpha pll found on ipq9574 SoCs. Programming sequence is the same as that of Huayra type Alpha PLL, so we can re-use the same.
---
Changes in V4:
- No change
drivers/clk/qcom/clk-alpha-pll.c | 11 +++++++++++ drivers/clk/qcom/clk-alpha-pll.h | 1 + 2 files changed, 12 insertions(+)
drivers/clk/qcom/clk-alpha-pll.c +11 -0
@@ -266,6 +266,17 @@ const u8 clk_alpha_pll_regs[][PLL_OFF_MAX_REGS] = { [PLL_OFF_OPMODE] = 0x30, [PLL_OFF_STATUS] = 0x3c, }, + [CLK_ALPHA_PLL_TYPE_NSS_HUAYRA] = { + [PLL_OFF_L_VAL] = 0x04, + [PLL_OFF_ALPHA_VAL] = 0x08, + [PLL_OFF_TEST_CTL] = 0x0c, + [PLL_OFF_TEST_CTL_U] = 0x10, + [PLL_OFF_USER_CTL] = 0x14, + [PLL_OFF_CONFIG_CTL] = 0x18, + [PLL_OFF_CONFIG_CTL_U] = 0x1c, + [PLL_OFF_STATUS] = 0x20, + }, + };EXPORT_SYMBOL_GPL (clk_alpha_pll_regs);
drivers/clk/qcom/clk-alpha-pll.h +1 -0
@@ -31,6 +31,7 @@ enum {CLK_ALPHA_PLL_TYPE_BRAMMO_EVO ,CLK_ALPHA_PLL_TYPE_STROMER ,CLK_ALPHA_PLL_TYPE_STROMER_PLUS , +CLK_ALPHA_PLL_TYPE_NSS_HUAYRA , CLK_ALPHA_PLL_TYPE_MAX, };
Signature · 1 line
2.34.1
PATCH v4 2/7 dt-bindings: clock: gcc-ipq9574: Add definition for GPLL0_OUT_AUX
In reply to Devi PriyaAdd the definition for GPLL0_OUT_AUX clock.
---
Changes in V4:
- No change
include/dt-bindings/clock/qcom,ipq9574-gcc.h | 1 + 1 file changed, 1 insertion(+)
include/dt-bindings/clock/qcom,ipq9574-gcc.h +1 -0
@@ -220,4 +220,5 @@#define GCC_PCIE1_PIPE_CLK 211#define GCC_PCIE2_PIPE_CLK 212#define GCC_PCIE3_PIPE_CLK 213 +#define GPLL0_OUT_AUX 214#endif
Signature · 1 line
2.34.1
PATCH v4 3/7 clk: qcom: gcc-ipq9574: Add support for gpll0_out_aux clock
In reply to Devi PriyaAdd support for gpll0_out_aux clock which acts as the parent for certain networking subsystem (nss) clocks.
---
Changes in V4:
- Reverted the changes to drop few nss clocks from the clock table and enabling them from the probe as they are being enabled by the consumer via interconnect.
drivers/clk/qcom/gcc-ipq9574.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/clk/qcom/gcc-ipq9574.c +15 -0
@@ -108,6 +108,20 @@ static struct clk_alpha_pll_postdiv gpll0 = { }, }; +static struct clk_alpha_pll_postdiv gpll0_out_aux = { + .offset =0x20000 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ], + .width =4 , + .clkr.hw.init = &(const struct clk_init_data ) { + .name ="gpll0_out_aux" , + .parent_hws = (const struct clk_hw *[]) { + &gpll0_main.clkr.hw + }, + .num_parents =1 , + .ops = &clk_alpha_pll_postdiv_ro_ops, + }, +}; +static struct clk_alpha_pll gpll4_main = { .offset =0x22000 , .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT ],
@@ -4222,6 +4236,7 @@ static struct clk_regmap *gcc_ipq9574_clks[] = { [GCC_PCIE1_PIPE_CLK] = &gcc_pcie1_pipe_clk.clkr, [GCC_PCIE2_PIPE_CLK] = &gcc_pcie2_pipe_clk.clkr, [GCC_PCIE3_PIPE_CLK] = &gcc_pcie3_pipe_clk.clkr, + [GPLL0_OUT_AUX] = &gpll0_out_aux.clkr, };static const struct qcom_reset_map gcc_ipq9574_resets[] = {
Signature · 1 line
2.34.1
PATCH v4 4/7 dt-bindings: clock: Add ipq9574 NSSCC clock and reset definitions
In reply to Devi PriyaAdd NSSCC clock and reset definitions for ipq9574.
---
Changes in V4:
- Added GCC_NSSCC_CLK source to the clocks
- Added support for interconnects and interconnect-names as the NoC clocks are being enabled via interconnect.
.../bindings/clock/qcom,ipq9574-nsscc.yaml | 75 +++++++++ .../dt-bindings/clock/qcom,ipq9574-nsscc.h | 152 ++++++++++++++++++ .../dt-bindings/reset/qcom,ipq9574-nsscc.h | 134 +++++++++++++++ 3 files changed, 361 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/qcom,ipq9574-nsscc.yaml create mode 100644 include/dt-bindings/clock/qcom,ipq9574-nsscc.h create mode 100644 include/dt-bindings/reset/qcom,ipq9574-nsscc.h
Documentation/devicetree/bindings/clock/qcom,ipq9574-nsscc.yaml new file +75 -0
@@ -0,0 +1,75 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/qcom,ipq9574-nsscc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Networking Sub System Clock & Reset Controller on IPQ9574 + +maintainers: + - Bjorn Andersson <[email protected]> + - Anusha Rao <[email protected]> + +description: | + Qualcomm networking sub system clock control module provides the clocks, + resets and power domains on IPQ9574 + + See also:: + include/dt-bindings/clock/qcom,ipq9574-nsscc.h + include/dt-bindings/reset/qcom,ipq9574-nsscc.h + +properties: + compatible: + const: qcom,ipq9574-nsscc + + clocks: + items: + - description: Board XO source + - description: Bias PLL cc clock source + - description: Bias PLL nss noc clock source + - description: Bias PLL ubi nc clock source + - description: GCC GPLL0 OUT AUX clock source + - description: Uniphy0 NSS Rx clock source + - description: Uniphy0 NSS Tx clock source + - description: Uniphy1 NSS Rx clock source + - description: Uniphy1 NSS Tx clock source + - description: Uniphy2 NSS Rx clock source + - description: Uniphy2 NSS Tx clock source + - description: GCC NSSCC clock source + + interconnect-names: true + + interconnects: true + +required: + - compatible + - clocks + +allOf: + - $ref: qcom,gcc.yaml# + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/qcom,ipq9574-gcc.h> + clock-controller@39b00000 { + compatible = "qcom,ipq9574-nsscc"; + reg = <0x39b00000 0x80000>; + clocks = <&xo_board_clk>, + <&bias_pll_cc_clk>, + <&bias_pll_nss_noc_clk>, + <&bias_pll_ubi_nc_clk>, + <&gcc GPLL0_OUT_AUX>, + <&uniphy 0>, + <&uniphy 1>, + <&uniphy 2>, + <&uniphy 3>, + <&uniphy 4>, + <&uniphy 5>, + <&gcc GCC_NSSCC_CLK>; + #clock-cells = <1>; + #reset-cells = <1>; + #power-domain-cells = <1>; + }; +...
include/dt-bindings/clock/qcom,ipq9574-nsscc.h new file +152 -0
152 lines not on this page · raw message
include/dt-bindings/reset/qcom,ipq9574-nsscc.h new file +134 -0
134 lines not on this page · raw message
Signature · 1 line
2.34.1
Rob Herring (Arm)
maintainerRe: [PATCH V4 4/7] dt-bindings: clock: Add ipq9574 NSSCC clock and reset definitions
Quoted 10 lines · Devi Priya
Add NSSCC clock and reset definitions for ipq9574.
Signed-off-by Devi Priya <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>---
Changes in V4:
- AddedGCC_NSSCC_CLKsource to the clocks
- Added support for interconnects and interconnect-names as the NoC clocks are being enabled via interconnect.
Quoted 8 lines
.../bindings/clock/qcom,ipq9574-nsscc.yaml | 75 +++++++++ .../dt-bindings/clock/qcom,ipq9574-nsscc.h | 152 ++++++++++++++++++ .../dt-bindings/reset/qcom,ipq9574-nsscc.h | 134 +++++++++++++++ 3 files changed, 361 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/qcom,ipq9574-nsscc.yaml create mode 100644 include/dt-bindings/clock/qcom,ipq9574-nsscc.h create mode 100644 include/dt-bindings/reset/qcom,ipq9574-nsscc.h
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
Error: Documentation/devicetree/bindings/clock/qcom,ipq9574-nsscc.example.dts:26.26-27 syntax error FATAL ERROR: Unable to parse input tree
make[2]: *** [scripts/Makefile.lib:427: Documentation/devicetree/bindings/clock/qcom,ipq9574-nsscc.example.dtb] Error 1 make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1430: dt_binding_check] Error 2
make: *** [Makefile:240: __sub-make] Error 2
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
PATCH v4 5/7 clk: qcom: Add NSS clock Controller driver for IPQ9574
In reply to Devi PriyaAdd Networking Sub System Clock Controller(NSSCC) driver for ipq9574 based devices.
---
Changes in V4:
- NSS being the consumer of GCC_NSSCC_CLK, added support for enabling it in the probe.
drivers/clk/qcom/Kconfig | 7 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/nsscc-ipq9574.c | 3082 ++++++++++++++++++++++++++++++ 3 files changed, 3090 insertions(+) create mode 100644 drivers/clk/qcom/nsscc-ipq9574.c
drivers/clk/qcom/Kconfig +7 -0
@@ -255,6 +255,13 @@ config IPQ_GCC_9574 i2c, USB, SD/eMMC, etc. Select this for the root clock of ipq9574. +config IPQ_NSSCC_9574 + tristate "IPQ9574 NSS Clock Controller" + depends on ARM64 || COMPILE_TEST + depends on IPQ_GCC_9574 + help + Support for NSS clock controller on ipq9574 devices. + config IPQ_NSSCC_QCA8K tristate "QCA8K(QCA8386 or QCA8084) NSS Clock Controller" depends on MDIO_BUS
drivers/clk/qcom/Makefile +1 -0
@@ -36,6 +36,7 @@ obj-$(CONFIG_IPQ_GCC_6018) += gcc-ipq6018.o obj-$(CONFIG_IPQ_GCC_806X) += gcc-ipq806x.o obj-$(CONFIG_IPQ_GCC_8074) += gcc-ipq8074.o obj-$(CONFIG_IPQ_GCC_9574) += gcc-ipq9574.o +obj-$(CONFIG_IPQ_NSSCC_9574) += nsscc-ipq9574.o obj-$(CONFIG_IPQ_LCC_806X) += lcc-ipq806x.o obj-$(CONFIG_IPQ_NSSCC_QCA8K) += nsscc-qca8k.o obj-$(CONFIG_MDM_GCC_9607) += gcc-mdm9607.o
drivers/clk/qcom/nsscc-ipq9574.c new file +3082 -0
2,980 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH V4 5/7] clk: qcom: Add NSS clock Controller driver for IPQ9574
Quoted 20 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +20
-0+static struct clk_alpha_pll ubi32_pll_main = { + .offset =0x28000 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_NSS_HUAYRA ], + .flags =SUPPORTS_DYNAMIC_UPDATE , + .clkr = { + .hw.init = &(const struct clk_init_data ) { + .name ="ubi32_pll_main" , + .parent_data = &(const struct clk_parent_data ) { + .index =DT_XO , + }, + .num_parents =1 , + .ops = &clk_alpha_pll_huayra_ops, + }, + }, +}; + +static struct clk_alpha_pll_postdiv ubi32_pll = { + .offset =0x28000 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_NSS_HUAYRA ], + .width =2 ,
drivers/clk/qcom/nsscc-ipq9574.c line 106
Quoted 10 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +10
-0+ .clkr.hw.init = &(const struct clk_init_data) { + .name ="ubi32_pll" , + .parent_hws = (const struct clk_hw *[]) { + &ubi32_pll_main.clkr.hw + }, + .num_parents =1 , + .ops = &clk_alpha_pll_postdiv_ro_ops, + .flags =CLK_SET_RATE_PARENT , + }, +};
Can these structures be made const? You have quite a few different structures in this driver, some of which are const, and some which are not.
Andrew
Re: [PATCH V4 5/7] clk: qcom: Add NSS clock Controller driver for IPQ9574
Quoted 26 lines · Andrew Lunn
Quoted 26 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +26
-0+static struct clk_alpha_pll ubi32_pll_main = { + .offset =0x28000 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_NSS_HUAYRA ], + .flags =SUPPORTS_DYNAMIC_UPDATE , + .clkr = { + .hw.init = &(const struct clk_init_data ) { + .name ="ubi32_pll_main" , + .parent_data = &(const struct clk_parent_data ) { + .index =DT_XO , + }, + .num_parents =1 , + .ops = &clk_alpha_pll_huayra_ops, + }, + }, +}; + +static struct clk_alpha_pll_postdiv ubi32_pll = { + .offset =0x28000 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_NSS_HUAYRA ], + .width =2 , + .clkr.hw.init = &(const struct clk_init_data ) { + .name ="ubi32_pll" , + .parent_hws = (const struct clk_hw *[]) { + &ubi32_pll_main.clkr.hw + }, + .num_parents =1 ,
Quoted 9 lines
drivers/clk/qcom/nsscc-ipq9574.c line 106
Quoted 4 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +4
-0+ .ops = &clk_alpha_pll_postdiv_ro_ops, + .flags = CLK_SET_RATE_PARENT, + }, +};Can these structures be made const? You have quite a few different structures in this driver, some of which are const, and some which are not.
Sure, will check and update this in V6
Thanks,
Devi Priya
Quoted 2 lines
Andrew
Re: [PATCH V4 5/7] clk: qcom: Add NSS clock Controller driver for IPQ9574
Quoted 38 lines · Devi Priya
Quoted 26 lines · Andrew Lunn
Quoted 26 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +26
-0+static struct clk_alpha_pll ubi32_pll_main = { + .offset = 0x28000, + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_NSS_HUAYRA], + .flags = SUPPORTS_DYNAMIC_UPDATE, + .clkr = { + .hw.init = &(const struct clk_init_data) { + .name = "ubi32_pll_main", + .parent_data = &(const struct clk_parent_data) { + .index = DT_XO, + }, + .num_parents = 1, + .ops = &clk_alpha_pll_huayra_ops, + }, + }, +}; + +static struct clk_alpha_pll_postdiv ubi32_pll = { + .offset = 0x28000, + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_NSS_HUAYRA], + .width = 2, + .clkr.hw.init = &(const struct clk_init_data) { + .name = "ubi32_pll", + .parent_hws = (const struct clk_hw *[]) { + &ubi32_pll_main.clkr.hw + }, + .num_parents = 1,Quoted 9 lines
Quoted 4 lines
+ .ops =
&clk_alpha_pll_postdiv_ro_ops,
+ .flags =CLK_SET_RATE_PARENT,
+ },
+};Can these structures be made const? You have quite a few different structures in this driver, some of which are const, and some which are not.
Quoted 6 lines
Sure, will check and update this in V6
Thanks,
Devi PriyaQuoted 2 lines
Andrew
Hi Andrew,
Sorry for the delayed response.
The ubi32_pll_main structure should be passed to clk_alpha_pll_configure() API to configure UBI32 PLL. clk_alpha_pll_configure() API expects a non-const structure. Declaring it as const will result in the following compilation warning
drivers/clk/qcom/nsscc-ipq9574.c:3067:26: warning: passing argument 1 of ‘clk_alpha_pll_configure’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
clk_alpha_pll_configure(&ubi32_pll_main, regmap, &ubi32_pll_config);
^
In file included from drivers/clk/qcom/nsscc-ipq9574.c:22:0:
drivers/clk/qcom/clk-alpha-pll.h:200:6: note: expected ‘struct clk_alpha_pll *’ but argument is of type ‘const struct clk_alpha_pll *’
void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
^~~~~~~~~~~~~~~~~~~~~~~The ubi32_pll is the source for nss_cc_ubi0_clk_src, nss_cc_ubi1_clk_src, nss_cc_ubi2_clk_src, nss_cc_ubi3_clk_src. Therefore, to register ubi32_pll with clock framework, it should be assigned to UBI32_PLL index of nss_cc_ipq9574_clocks array. This assignment will result in the following compilation warning if the ubi32_pll structure is declared as const.
drivers/clk/qcom/nsscc-ipq9574.c:2893:16: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
[UBI32_PLL] = &ubi32_pll.clkr,
Thanks & Regards,
Manikanta.
Re: [PATCH V4 5/7] clk: qcom: Add NSS clock Controller driver for IPQ9574
Quoted 54 lines · Manikanta Mylavarapu
Quoted 38 lines · Devi Priya
Quoted 26 lines · Andrew Lunn
Quoted 26 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +26
-0+static struct clk_alpha_pll ubi32_pll_main = { + .offset = 0x28000, + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_NSS_HUAYRA], + .flags = SUPPORTS_DYNAMIC_UPDATE, + .clkr = { + .hw.init = &(const struct clk_init_data) { + .name = "ubi32_pll_main", + .parent_data = &(const struct clk_parent_data) { + .index = DT_XO, + }, + .num_parents = 1, + .ops = &clk_alpha_pll_huayra_ops, + }, + }, +}; + +static struct clk_alpha_pll_postdiv ubi32_pll = { + .offset = 0x28000, + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_NSS_HUAYRA], + .width = 2, + .clkr.hw.init = &(const struct clk_init_data) { + .name = "ubi32_pll", + .parent_hws = (const struct clk_hw *[]) { + &ubi32_pll_main.clkr.hw + }, + .num_parents = 1,Quoted 9 lines
Quoted 4 lines
+ .ops =
&clk_alpha_pll_postdiv_ro_ops,
+ .flags =CLK_SET_RATE_PARENT,
+ },
+};Can these structures be made const? You have quite a few different structures in this driver, some of which are const, and some which are not.
Quoted 6 lines
Sure, will check and update this in V6
Thanks,
Devi PriyaQuoted 2 lines
Andrew
Hi Andrew,
Sorry for the delayed response.
The
ubi32_pll_mainstructure should be passed toclk_alpha_pll_configure()API to configure UBI32 PLL.clk_alpha_pll_configure()API expects a non-const structure. Declaring it as const will result in the following compilation warning
Quoted 7 lines
drivers/clk/qcom/nsscc-ipq9574.c:3067:26: warning: passing argument 1 of ‘clk_alpha_pll_configure’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]clk_alpha_pll_configure(&ubi32_pll_main, regmap, &ubi32_pll_config); ^ In file included from drivers/clk/qcom/nsscc-ipq9574.c:22:0: drivers/clk/qcom/clk-alpha-pll.h:200:6: note: expected ‘struct clk_alpha_pll *’ but argument is of type ‘const struct clk_alpha_pll *’ void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, ^~~~~~~~~~~~~~~~~~~~~~~
As far as i can see, clk_alpha_pll_configure() does not modify pll.
https://elixir.bootlin.com/linux/v6.12-rc1/source/drivers/clk/qcom/clk-alpha-pll.c#L391
So you can add a const there as well.
Quoted 4 lines
The
ubi32_pllis the source fornss_cc_ubi0_clk_src,nss_cc_ubi1_clk_src,nss_cc_ubi2_clk_src,nss_cc_ubi3_clk_src. Therefore, to registerubi32_pllwith clock framework, it should be assigned toUBI32_PLLindex ofnss_cc_ipq9574_clocksarray. This assignment will result in the following compilation warning if theubi32_pllstructure is declared as const.
drivers/clk/qcom/nsscc-ipq9574.c:2893:16: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
[UBI32_PLL] = &ubi32_pll.clkr,
Which suggests you are missing a const somewhere else.
Getting these structures const correct has a few benefits. It makes you code smaller, since at the moment at load time it needs to copy these structures in to the BSS so they are writable, rather than keeping them in the .rodata segment. Also, by making them const, you avoid a few security issues, they cannot be overwritten, the MMU will protect them. The compiler can also make some optimisations, since it knows the values cannot change.
Now, it could be getting this all const correct needs lots of patches, because it has knock-on effects in other places. If so, then don't bother. But if it is simple to do, please spend a little time to get this right.
Andrew
Re: [PATCH V4 5/7] clk: qcom: Add NSS clock Controller driver for IPQ9574
Quoted 63 lines · Andrew Lunn
Quoted 54 lines · Manikanta Mylavarapu
Quoted 38 lines · Devi Priya
Quoted 26 lines · Andrew Lunn
Quoted 26 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +26
-0+static struct clk_alpha_pll ubi32_pll_main = { + .offset = 0x28000, + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_NSS_HUAYRA], + .flags = SUPPORTS_DYNAMIC_UPDATE, + .clkr = { + .hw.init = &(const struct clk_init_data) { + .name = "ubi32_pll_main", + .parent_data = &(const struct clk_parent_data) { + .index = DT_XO, + }, + .num_parents = 1, + .ops = &clk_alpha_pll_huayra_ops, + }, + }, +}; + +static struct clk_alpha_pll_postdiv ubi32_pll = { + .offset = 0x28000, + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_NSS_HUAYRA], + .width = 2, + .clkr.hw.init = &(const struct clk_init_data) { + .name = "ubi32_pll", + .parent_hws = (const struct clk_hw *[]) { + &ubi32_pll_main.clkr.hw + }, + .num_parents = 1,Quoted 9 lines
Quoted 4 lines
+ .ops =
&clk_alpha_pll_postdiv_ro_ops,
+ .flags =CLK_SET_RATE_PARENT,
+ },
+};Can these structures be made const? You have quite a few different structures in this driver, some of which are const, and some which are not.
Quoted 6 lines
Sure, will check and update this in V6
Thanks,
Devi PriyaQuoted 2 lines
Andrew
Hi Andrew,
Sorry for the delayed response.
The
ubi32_pll_mainstructure should be passed toclk_alpha_pll_configure()API to configure UBI32 PLL.clk_alpha_pll_configure()API expects a non-const structure. Declaring it as const will result in the following compilation warningQuoted 7 lines
drivers/clk/qcom/nsscc-ipq9574.c:3067:26: warning: passing argument 1 of ‘clk_alpha_pll_configure’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]clk_alpha_pll_configure(&ubi32_pll_main, regmap, &ubi32_pll_config); ^ In file included from drivers/clk/qcom/nsscc-ipq9574.c:22:0: drivers/clk/qcom/clk-alpha-pll.h:200:6: note: expected ‘struct clk_alpha_pll *’ but argument is of type ‘const struct clk_alpha_pll *’ void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, ^~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
As far as i can see,
clk_alpha_pll_configure()does not modify pll.https://elixir.bootlin.com/linux/v6.12-rc1/source/drivers/clk/qcom/clk-alpha-pll.c#L391
So you can add a const there as well.
It appears that multiple targets are invoking clk_alpha_pll_configure(). I will make changes in a separate series after this.
Quoted 15 lines
Quoted 4 lines
The
ubi32_pllis the source fornss_cc_ubi0_clk_src,nss_cc_ubi1_clk_src,nss_cc_ubi2_clk_src,nss_cc_ubi3_clk_src. Therefore, to registerubi32_pllwith clock framework, it should be assigned toUBI32_PLLindex ofnss_cc_ipq9574_clocksarray. This assignment will result in the following compilation warning if theubi32_pllstructure is declared as const.
drivers/clk/qcom/nsscc-ipq9574.c:2893:16: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
[UBI32_PLL] = &ubi32_pll.clkr,Which suggests you are missing a const somewhere else.
Getting these structures const correct has a few benefits. It makes you code smaller, since at the moment at load time it needs to copy these structures in to the BSS so they are writable, rather than keeping them in the .rodata segment. Also, by making them const, you avoid a few security issues, they cannot be overwritten, the MMU will protect them. The compiler can also make some optimisations, since it knows the values cannot change.
Quoted 6 lines
Now, it could be getting this all const correct needs lots of patches, because it has knock-on effects in other places. If so, then don't bother. But if it is simple to do, please spend a little time to get this right.
Andrew
We can make these structures const. However, it will require exhaustive changes. Below is the rationale.
To declare the ubi32_pll and ubi32_pll_main (since it is also passed to nss_cc_ipq9574_clocks[] array) structures as const, the 'clks' member of 'struct qcom_cc_desc' needs to be const.
The following compilation errors are observed after making the 'clks' member of 'struct qcom_cc_desc' as const:drivers/clk/qcom/common.c: In function ‘qcom_cc_icc_register’:drivers/clk/qcom/common.c:274:7: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
hws = &desc->clks[desc->icc_hws[i].clk_id]->hw;
^drivers/clk/qcom/common.c: In function ‘qcom_cc_really_probe’:drivers/clk/qcom/common.c:294:30: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
struct clk_regmap **rclks = desc->clks;
^~~~The common.c code is designed in such a way that the 'clks' member needs to be assigned to non-const variables/pointers.
We need to update common.c and the drivers that utilize 'struct qcom_cc_desc'. I will make changes in a separate series after this.
Thanks & Regards,
Manikanta.
Re: [PATCH V4 5/7] clk: qcom: Add NSS clock Controller driver for IPQ9574
In reply to Devi PriyaQuoted 6 lines · Devi Priya
Add Networking Sub System Clock Controller(NSSCC) driver for ipq9574 based devices.
Signed-off-by Devi Priya <[email protected]>Tested-by Alexandru Gagniuc <[email protected]>---
[...]
drivers/clk/qcom/nsscc-ipq9574.c line 3048
Quoted 2 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +2
-0+struct regmap *regmap; +struct qcom_cc_desc nsscc_ipq9574_desc = nss_cc_ipq9574_desc;
Why?
drivers/clk/qcom/nsscc-ipq9574.c line 3057
Quoted 9 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +9
-0+struct clk *nsscc_clk; +struct device_node *np = (&pdev->dev)->of_node; +int ret; + + nsscc_clk =of_clk_get (np,11 ); +if (IS_ERR (nsscc_clk)) +return PTR_ERR (nsscc_clk); + + ret =clk_prepare_enable (nsscc_clk);
pm_clk_add()? And definitely drop the 11 literal, nobody could ever guess or maintain magic numbers
Konrad
Re: [PATCH V4 5/7] clk: qcom: Add NSS clock Controller driver for IPQ9574
Quoted 8 lines · Konrad Dybcio
Quoted 6 lines · Devi Priya
Add Networking Sub System Clock Controller(NSSCC) driver for ipq9574 based devices.
Signed-off-by Devi Priya <[email protected]>Tested-by Alexandru Gagniuc <[email protected]>---
Quoted 6 lines
[...]
drivers/clk/qcom/nsscc-ipq9574.c line 3048
Quoted 2 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +2
-0+struct regmap *regmap; +struct qcom_cc_desc nsscc_ipq9574_desc = nss_cc_ipq9574_desc;Why?
Sure, Will drop this in V6.
Quoted 13 lines
drivers/clk/qcom/nsscc-ipq9574.c line 3057
Quoted 10 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +9
-0+struct clk *nsscc_clk; +struct device_node *np = (&pdev->dev)->of_node; +int ret; + + nsscc_clk =of_clk_get (np,11 ); +if (IS_ERR (nsscc_clk)) +return PTR_ERR (nsscc_clk); + + ret =clk_prepare_enable (nsscc_clk);
pm_clk_add()? And definitely drop the 11 literal, nobody could ever guess or maintain magic numbers
Hi Konrad,
nsscc clk isn't related to power management clocks. Also, I believe it might require the usage of clock-names. Do you suggest adding a macro for the literal (11)? Please correct me if I'm wrong.
Thanks,
Devi Priya
Quoted 2 lines
Konrad
Re: [PATCH V4 5/7] clk: qcom: Add NSS clock Controller driver for IPQ9574
Quoted 32 lines · Devi Priya
Quoted 8 lines · Konrad Dybcio
Quoted 6 lines · Devi Priya
Add Networking Sub System Clock Controller(NSSCC) driver for ipq9574 based devices.
Signed-off-by Devi Priya <[email protected]>Tested-by Alexandru Gagniuc <[email protected]>---
Quoted 6 lines
[...]
drivers/clk/qcom/nsscc-ipq9574.c line 3048
Quoted 2 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +2
-0+struct regmap *regmap; +struct qcom_cc_desc nsscc_ipq9574_desc = nss_cc_ipq9574_desc;Why?
Sure, Will drop this in V6.
Quoted 13 lines
drivers/clk/qcom/nsscc-ipq9574.c line 3057
Quoted 10 lines
drivers/clk/qcom/nsscc-ipq9574.c new file +9
-0+struct clk *nsscc_clk; +struct device_node *np = (&pdev->dev)->of_node; +int ret; + + nsscc_clk =of_clk_get (np,11 ); +if (IS_ERR (nsscc_clk)) +return PTR_ERR (nsscc_clk); + + ret =clk_prepare_enable (nsscc_clk);
pm_clk_add()? And definitely drop the 11 literal, nobody could ever guess or maintain magic numbers
Quoted 4 lines
Hi Konrad,
nsscc clk isn't related to power management clocks. Also, I believe it might require the usage of clock-names.
No. First of all, you can use pm_clk_add_clk. And even better than that, you can add pm_clk_add_by_index().
Quoted 1 line
Do you suggest adding a macro for the literal (11)?
No, add it to DT_something enumeration.
Quoted 1 line
Please correct me if I'm wrong.
Signature · 2 lines
With best wishes Dmitry
PATCH v4 6/7 arm64: dts: qcom: ipq9574: Add support for nsscc node
In reply to Devi PriyaAdd a node for the nss clock controller found on ipq9574 based devices.
---
Changes in V4:
- Added GCC_NSSCC_CLK to the nsscc node
- Added interconnects and interconnect-names for enabling the NoC clocks.
arch/arm64/boot/dts/qcom/ipq9574.dtsi | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
arch/arm64/boot/dts/qcom/ipq9574.dtsi +44 -0
@@ -11,6 +11,8 @@ #include <dt-bindings/interconnect/qcom,ipq9574.h> #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/reset/qcom,ipq9574-gcc.h> +#include <dt-bindings/clock/qcom,ipq9574-nsscc.h> +#include <dt-bindings/reset/qcom,ipq9574-nsscc.h> #include <dt-bindings/thermal/thermal.h> / {
@@ -19,6 +21,24 @@ / { #size-cells = <2>; clocks { + bias_pll_cc_clk: bias-pll-cc-clk { + compatible = "fixed-clock"; + clock-frequency = <1200000000>; + #clock-cells = <0>; + }; + + bias_pll_nss_noc_clk: bias-pll-nss-noc-clk { + compatible = "fixed-clock"; + clock-frequency = <461500000>; + #clock-cells = <0>; + }; + + bias_pll_ubi_nc_clk: bias-pll-ubi-nc-clk { + compatible = "fixed-clock"; + clock-frequency = <353000000>; + #clock-cells = <0>; + }; + sleep_clk: sleep-clk { compatible = "fixed-clock"; #clock-cells = <0>;
@@ -756,6 +776,30 @@ frame@b128000 { status = "disabled"; }; }; + + nsscc: clock-controller@39b00000 { + compatible = "qcom,ipq9574-nsscc"; + reg = <0x39b00000 0x80000>; + clocks = <&xo_board_clk>, + <&bias_pll_cc_clk>, + <&bias_pll_nss_noc_clk>, + <&bias_pll_ubi_nc_clk>, + <&gcc GPLL0_OUT_AUX>, + <0>, + <0>, + <0>, + <0>, + <0>, + <0>, + <&gcc GCC_NSSCC_CLK>; + #clock-cells = <1>; + #reset-cells = <1>; + #power-domain-cells = <1>; + interconnects = <&gcc MASTER_NSSNOC_NSSCC &gcc MASTER_NSSNOC_NSSCC>, + <&gcc MASTER_NSSNOC_SNOC_0 &gcc MASTER_NSSNOC_SNOC_0>, + <&gcc MASTER_NSSNOC_SNOC_1 &gcc MASTER_NSSNOC_SNOC_1>; + interconnect-names = "nssnoc_nsscc", "nssnoc_snoc", "nssnoc_snoc_1"; + }; }; thermal-zones {
Signature · 1 line
2.34.1
PATCH v4 7/7 arm64: defconfig: Build NSS Clock Controller driver for IPQ9574
In reply to Devi PriyaNSSCC driver is needed to enable the ethernet interfaces and not necessary for the bootup of the SoC, hence build it as a module.
---
Changes in V4:
- No change
arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -1300,6 +1300,7 @@ CONFIG_IPQ_GCC_5332=y CONFIG_IPQ_GCC_6018=y CONFIG_IPQ_GCC_8074=y CONFIG_IPQ_GCC_9574=y +CONFIG_IPQ_NSSCC_9574=m CONFIG_MSM_GCC_8916=y CONFIG_MSM_MMCC_8994=m CONFIG_MSM_GCC_8994=y
Signature · 1 line
2.34.1