Add RPMh and global clock controller support for Qualcomm Halliday (SXR2250P)
v2 cover Add RPMh and global clock controller support for Qualcomm Halliday (SXR2250P)
Add the RPMh clocks and the Global Clock Controller of the Qualcomm Halliday SoC.
The GCC has the clkref_en gates on the outputs of the QREF block, whose supplies are shared with the UFS PHY. Patch 4 lets drivers built on qcom_cc_desc register clk_ref clocks next to their other clocks, so that the GCC can vote for those supplies.
Halliday (SXR2250P / Snapdragon XR2+ Gen 2) is the SoC in the Samsung Galaxy XR headset. The DT changes follow in a separate series.
The series is based on v7.4-rc1, like clk-for-7.5. Patch 4 conflicts with commit 4dd10fbbeb9c ("treewide: Convert devm_kmalloc() family to the devm_kmalloc_obj() family") in v7.4-rc2, which touches qcom_clk_ref_register(): the resolution is to take that function from this series.
This work was made together with Claude, ChatGPT and Gemini. Reviewed and tested on my Galaxy XR.
---
Changes in v2:
- common: Return a NULL clock, not -EINVAL, for a protected clk_ref
with an ID above the last regmap clock (Sashiko)
- common, clk-ref: Use devm_kzalloc_obj() and devm_kzalloc_objs() for
the clk_ref allocations
- gcc-halliday: Reuse the wrap0 S0 frequency table for wrap1 S0/S1 (Sashiko)
- Link to v1: https://patch.msgid.link/[email protected]
---
Stanislav Aleksandrov (5):
dt-bindings: clock: qcom: document the Halliday RPMh Clock Controller
clk: qcom: rpmh: Add support for RPMh clocks on Halliday
dt-bindings: clock: qcom: document the Halliday Global Clock Controller
clk: qcom: common: Register clk_ref clocks from qcom_cc_desc
clk: qcom: Add support for Global clock controller on Halliday
.../bindings/clock/qcom,halliday-gcc.yaml | 84 + .../devicetree/bindings/clock/qcom,rpmhcc.yaml | 1 + drivers/clk/qcom/Kconfig | 11 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/clk-ref.c | 90 +- drivers/clk/qcom/clk-rpmh.c | 22 + drivers/clk/qcom/common.c | 68 +- drivers/clk/qcom/common.h | 9 + drivers/clk/qcom/gcc-halliday.c | 3533 ++++++++++++++++++++ include/dt-bindings/clock/qcom,halliday-gcc.h | 249 ++ 10 files changed, 4016 insertions(+), 52 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261108-halliday-clk-362190f4f5dd
Best regards,
Signature · 1 line
Stanislav Aleksandrov <[email protected]>
PATCH v2 1/5 dt-bindings: clock: qcom: document the Halliday RPMh Clock Controller
Document the RPMh Clock Controller on the Qualcomm Halliday SoC (SXR2250P).
--- Documentation/devicetree/bindings/clock/qcom,rpmhcc.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/clock/qcom,rpmhcc.yaml +1 -0
@@ -20,6 +20,7 @@ properties: - enum: - qcom,eliza-rpmh-clk - qcom,glymur-rpmh-clk + - qcom,halliday-rpmh-clk - qcom,hawi-rpmh-clk - qcom,kaanapali-rpmh-clk - qcom,kuno-rpmh-clk
Signature · 1 line
2.55.0
PATCH v2 2/5 clk: qcom: rpmh: Add support for RPMh clocks on Halliday
In reply to Stanislav AleksandrovAdd the RPMh clocks on the Qualcomm Halliday SoC as Qualcomm's downstream clk-rpmh driver describes them: XO (divided by 4), RF_CLK1, IPA, and the clka7, clka8 and clka9 resources (downstream LN_BB_CLK7-9). As on the other SoCs with clkaN resources, clkaN is LN_BB_CLK(N - 5), so these are LN_BB_CLK2-4.
--- drivers/clk/qcom/clk-rpmh.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/clk/qcom/clk-rpmh.c +22 -0
@@ -383,8 +383,10 @@ DEFINE_CLK_RPMH_VRM(clk5, _a2, "clka5", 2);DEFINE_CLK_RPMH_VRM (clk6, _a2,"clka6" ,2 );DEFINE_CLK_RPMH_VRM (clk7, _a2,"clka7" ,2 );DEFINE_CLK_RPMH_VRM (clk8, _a2,"clka8" ,2 ); +DEFINE_CLK_RPMH_VRM (clk9, _a2,"clka9" ,2 );DEFINE_CLK_RPMH_VRM (clk7, _a4,"clka7" ,4 ); +DEFINE_CLK_RPMH_VRM (clk8, _a4,"clka8" ,4 );DEFINE_CLK_RPMH_VRM (div_clk1, _div2,"divclka1" ,2 );
@@ -413,6 +415,25 @@ DEFINE_CLK_RPMH_BCM(ipa, "IP0");DEFINE_CLK_RPMH_BCM (pka,"PKA0" );DEFINE_CLK_RPMH_BCM (qpic_clk,"QP0" ); +static struct clk_hw *halliday_rpmh_clocks[] = { + [RPMH_CXO_CLK ] = &clk_rpmh_bi_tcxo_div4.hw, + [RPMH_CXO_CLK_A ] = &clk_rpmh_bi_tcxo_div4_ao.hw, + [RPMH_LN_BB_CLK2 ] = &clk_rpmh_clk7_a2.hw, + [RPMH_LN_BB_CLK2_A ] = &clk_rpmh_clk7_a2_ao.hw, + [RPMH_LN_BB_CLK3 ] = &clk_rpmh_clk8_a4.hw, + [RPMH_LN_BB_CLK3_A ] = &clk_rpmh_clk8_a4_ao.hw, + [RPMH_LN_BB_CLK4 ] = &clk_rpmh_clk9_a2.hw, + [RPMH_LN_BB_CLK4_A ] = &clk_rpmh_clk9_a2_ao.hw, + [RPMH_RF_CLK1 ] = &clk_rpmh_clk1_a1.hw, + [RPMH_RF_CLK1_A ] = &clk_rpmh_clk1_a1_ao.hw, + [RPMH_IPA_CLK ] = &clk_rpmh_ipa.hw, +}; + +static const struct clk_rpmh_desc clk_rpmh_halliday = { + .clks = halliday_rpmh_clocks, + .num_clks =ARRAY_SIZE (halliday_rpmh_clocks), +}; +static struct clk_hw *sar2130p_rpmh_clocks[] = { [RPMH_CXO_CLK ] = &clk_rpmh_bi_tcxo_div1.hw, [RPMH_CXO_CLK_A ] = &clk_rpmh_bi_tcxo_div1_ao.hw,
@@ -1137,6 +1158,7 @@ static int clk_rpmh_probe(struct platform_device *pdev)static const struct of_device_id clk_rpmh_match_table[] = { { .compatible ="qcom,eliza-rpmh-clk" , .data = &clk_rpmh_eliza}, { .compatible ="qcom,glymur-rpmh-clk" , .data = &clk_rpmh_glymur}, + { .compatible ="qcom,halliday-rpmh-clk" , .data = &clk_rpmh_halliday}, { .compatible ="qcom,hawi-rpmh-clk" , .data = &clk_rpmh_hawi}, { .compatible ="qcom,kaanapali-rpmh-clk" , .data = &clk_rpmh_kaanapali}, { .compatible ="qcom,kuno-rpmh-clk" , .data = &clk_rpmh_kuno},
Signature · 1 line
2.55.0
Re: [PATCH v2 2/5] clk: qcom: rpmh: Add support for RPMh clocks on Halliday
Quoted 9 lines · Stanislav Aleksandrov
Add the RPMh clocks on the Qualcomm Halliday SoC as Qualcomm's downstream clk-rpmh driver describes them: XO (divided by 4),
RF_CLK1, IPA, and the clka7, clka8 and clka9 resources (downstream LN_BB_CLK7-9). As on the other SoCs with clkaN resources, clkaN isLN_BB_CLK(N - 5), so these are LN_BB_CLK2-4.Reviewed-by Abel Vesa <[email protected]>Signed-off-by Stanislav Aleksandrov <[email protected]>---
Konrad
PATCH v2 3/5 dt-bindings: clock: qcom: document the Halliday Global Clock Controller
In reply to Stanislav AleksandrovAdd the bindings and the dt-bindings header for the Global Clock Controller on the Qualcomm Halliday SoC (SXR2250P).
The clkref_en clocks gate the reference clock from the QREF block to the PHYs. QREF is powered by two supplies, vdda-refgen-0p9 and vdda-refgen-1p2. Downstream only lists the 0.9 V one, as the USB PHYs' refgen-supply, and keeps the 1.2 V one on as the USB3 PHY's supply, but the USB HS PHY stops working when either of them is off.
--- .../bindings/clock/qcom,halliday-gcc.yaml | 84 +++++++ include/dt-bindings/clock/qcom,halliday-gcc.h | 249 +++++++++++++++++++++ 2 files changed, 333 insertions(+)
Documentation/devicetree/bindings/clock/qcom,halliday-gcc.yaml new file +84 -0
@@ -0,0 +1,84 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/qcom,halliday-gcc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Global Clock & Reset Controller on Halliday + +maintainers: + - Stanislav Aleksandrov <[email protected]> + +description: | + Qualcomm global clock control module provides the clocks, resets and power + domains on Halliday. Its clkref_en clocks gate the XO reference to the PHYs + through the QREF block, which needs the vdda-refgen supplies. + + See also: include/dt-bindings/clock/qcom,halliday-gcc.h + +properties: + compatible: + const: qcom,halliday-gcc + + clocks: + items: + - description: Board XO source + - description: Sleep clock source + - description: PCIE 0 Pipe clock source + - description: PCIE 1 Pipe clock source + - description: PCIE 2 Phy Auxiliary clock source + - description: PCIE 2 Pipe clock source + - description: UFS Phy Rx symbol 0 clock source + - description: UFS Phy Rx symbol 1 clock source + - description: UFS Phy Tx symbol 0 clock source + - description: USB3 Phy wrapper pipe clock source + + power-domains: + items: + - description: CX domain + + vdda-refgen-0p9-supply: + description: QREF 0.9 V supply + + vdda-refgen-1p2-supply: + description: QREF 1.2 V supply + +required: + - compatible + - clocks + - power-domains + - '#power-domain-cells' + - vdda-refgen-0p9-supply + - vdda-refgen-1p2-supply + +allOf: + - $ref: qcom,gcc.yaml# + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/qcom,rpmh.h> + #include <dt-bindings/power/qcom,rpmhpd.h> + clock-controller@100000 { + compatible = "qcom,halliday-gcc"; + reg = <0x00100000 0x1f4200>; + clocks = <&rpmhcc RPMH_CXO_CLK>, + <&sleep_clk>, + <&pcie0_phy>, + <&pcie1_phy>, + <&pcie2_phy 1>, + <&pcie2_phy 0>, + <&ufs_mem_phy 0>, + <&ufs_mem_phy 1>, + <&ufs_mem_phy 2>, + <&usb_1_qmpphy>; + power-domains = <&rpmhpd RPMHPD_CX>; + vdda-refgen-0p9-supply = <&vreg_l2f_0p88>; + vdda-refgen-1p2-supply = <&vreg_l2c_1p2>; + #clock-cells = <1>; + #reset-cells = <1>; + #power-domain-cells = <1>; + }; + +...
include/dt-bindings/clock/qcom,halliday-gcc.h new file +249 -0
249 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH v2 4/5 clk: qcom: common: Register clk_ref clocks from qcom_cc_desc
In reply to Stanislav AleksandrovThe clk_ref clocks model a clkref_en gate together with the supplies of the QREF block that feeds it. So far they can only be registered as a standalone clock provider with qcom_clk_ref_probe(), as on the TCSR of X1E80100 and Glymur.
On Halliday the clkref_en registers are part of GCC, and the QREF supplies are shared with the UFS PHY: when UFS runtime suspend turns them off, the USB HS PHY loses its reference clock. The GCC driver needs to provide its clkrefs as clk_ref clocks next to its other clocks, so that their users keep the supplies on.
Let a qcom_cc_desc carry clk_ref descriptions, indexed by clock ID like its other clocks. qcom_clk_ref_register() now registers a single clock, so qcom_cc_really_probe() allocates and registers only the populated entries, and qcom_cc_clk_hw_get() returns them for their indices. As with the other clocks, entries listed in protected-clocks are skipped. A clock ID used by both a clk_ref and a regmap clock fails the probe.
--- drivers/clk/qcom/clk-ref.c | 90 +++++++++++++++++++++------------------------- drivers/clk/qcom/common.c | 68 +++++++++++++++++++++++++++++++++-- drivers/clk/qcom/common.h | 9 +++++ 3 files changed, 115 insertions(+), 52 deletions(-)
drivers/clk/qcom/clk-ref.c +40 -50
@@ -13,6 +13,8 @@#include <linux/regulator/consumer.h> #include <linux/slab.h> +#include "common.h" +#define QCOM_CLK_REF_EN_MASK BIT(0)struct qcom_clk_ref_provider {
@@ -96,63 +98,45 @@ static const struct clk_ops qcom_clk_ref_ops = { .is_enabled = qcom_clk_ref_is_enabled, }; -static int qcom_clk_ref_register (struct device *dev,struct regmap *regmap, -struct qcom_clk_ref *clk_refs, -const struct qcom_clk_ref_desc *const *descs, -size_t num_clk_refs) +int qcom_clk_ref_register (struct device *dev,struct regmap *regmap, +struct qcom_clk_ref *clk_ref, +const struct qcom_clk_ref_desc *desc) { -const struct qcom_clk_ref_desc *desc;struct clk_init_data init_data = {}; -struct qcom_clk_ref *clk_ref; -size_t clk_idx;unsigned int i;int ret; -for (clk_idx =0 ; clk_idx < num_clk_refs; clk_idx++) { - clk_ref = &clk_refs[clk_idx]; - desc = descs[clk_idx]; +if (WARN_ON (!desc->name)) +return -EINVAL ; -/* Skip unpopulated indices; the array is indexed by clock ID. */ -if (!desc) -continue ; + clk_ref->regmap = regmap; + clk_ref->desc = *desc; -if (WARN_ON (!desc->name)) -continue ; +if (clk_ref->desc.num_regulators) { + clk_ref->regulators =devm_kzalloc_objs (dev, *clk_ref->regulators, + clk_ref->desc.num_regulators); +if (!clk_ref->regulators) +return -ENOMEM ; - clk_ref->regmap = regmap; - clk_ref->desc = *desc; - -if (clk_ref->desc.num_regulators) { - clk_ref->regulators =devm_kcalloc (dev, clk_ref->desc.num_regulators, -sizeof (*clk_ref->regulators), -GFP_KERNEL ); -if (!clk_ref->regulators) -return -ENOMEM ; - -for (i =0 ; i < clk_ref->desc.num_regulators; i++) - clk_ref->regulators[i].supply = - clk_ref->desc.regulator_names[i]; - - ret =devm_regulator_bulk_get (dev, clk_ref->desc.num_regulators, - clk_ref->regulators); -if (ret) -return dev_err_probe (dev, ret, -"Failed to get regulators for %s\n" , - clk_ref->desc.name); - } - - init_data.name = clk_ref->desc.name; - init_data.parent_data = &qcom_clk_ref_parent_data; - init_data.num_parents =1 ; - init_data.ops = &qcom_clk_ref_ops; - clk_ref->hw.init = &init_data; - - ret =devm_clk_hw_register (dev, &clk_ref->hw); +for (i =0 ; i < clk_ref->desc.num_regulators; i++) + clk_ref->regulators[i].supply = + clk_ref->desc.regulator_names[i]; + + ret =devm_regulator_bulk_get (dev, clk_ref->desc.num_regulators, + clk_ref->regulators);if (ret) -return ret; +return dev_err_probe (dev, ret, +"Failed to get regulators for %s\n" , + clk_ref->desc.name); } -return 0 ; + init_data.name = clk_ref->desc.name; + init_data.parent_data = &qcom_clk_ref_parent_data; + init_data.num_parents =1 ; + init_data.ops = &qcom_clk_ref_ops; + clk_ref->hw.init = &init_data; + +return devm_clk_hw_register (dev, &clk_ref->hw); }static struct clk_hw *qcom_clk_ref_provider_get (struct of_phandle_args *clkspec,void *data)
@@ -178,6 +162,7 @@ int qcom_clk_ref_probe(struct platform_device *pdev,struct device *dev = &pdev->dev;struct regmap *regmap;void __iomem *base; +size_t i;int ret; base =devm_platform_ioremap_resource (pdev,0 );
@@ -195,10 +180,15 @@ int qcom_clk_ref_probe(struct platform_device *pdev, provider->num_refs = num_clk_refs; - ret =qcom_clk_ref_register (dev, regmap, provider->refs, descs, - provider->num_refs); -if (ret) -return ret; +for (i =0 ; i < num_clk_refs; i++) { +/* Skip unpopulated indices; the array is indexed by clock ID. */ +if (!descs[i]) +continue ; + + ret =qcom_clk_ref_register (dev, regmap, &provider->refs[i], descs[i]); +if (ret) +return ret; + }return devm_of_clk_add_hw_provider (dev, qcom_clk_ref_provider_get, provider); }
drivers/clk/qcom/common.c +66 -2
97 lines not on this page · raw message
drivers/clk/qcom/common.h +9 -0
@@ -19,6 +19,9 @@ struct clk_hw;#define PLL_VOTE_FSM_ENA BIT(20)#define PLL_VOTE_FSM_RESET BIT(21) +struct qcom_clk_ref ; +struct qcom_clk_ref_desc ; +struct qcom_icc_hws_data {int master_id;int slave_id;
@@ -45,6 +48,8 @@ struct qcom_cc_desc {size_t num_gdscs;struct clk_hw **clk_hws;size_t num_clk_hws; +const struct qcom_clk_ref_desc *const *clk_refs; +size_t num_clk_refs;const struct qcom_icc_hws_data *icc_hws;size_t num_icc_hws;unsigned int icc_first_node_id;
@@ -89,4 +94,8 @@ extern int qcom_cc_probe(struct platform_device *pdev,extern int qcom_cc_probe_by_index (struct platform_device *pdev,int index,const struct qcom_cc_desc *desc); +int qcom_clk_ref_register (struct device *dev,struct regmap *regmap, +struct qcom_clk_ref *clk_ref, +const struct qcom_clk_ref_desc *desc); +#endif
Signature · 1 line
2.55.0
Re: [PATCH v2 4/5] clk: qcom: common: Register clk_ref clocks from qcom_cc_desc
Quoted 11 lines · Stanislav Aleksandrov
The
clk_refclocks model aclkref_engate together with the supplies of the QREF block that feeds it. So far they can only be registered as a standalone clock provider withqcom_clk_ref_probe(), as on the TCSR of X1E80100 and Glymur.On Halliday the
clkref_enregisters are part of GCC, and the QREF supplies are shared with the UFS PHY: when UFS runtime suspend turns them off, the USB HS PHY loses its reference clock. The GCC driver needs to provide its clkrefs asclk_refclocks next to its other clocks, so that their users keep the supplies on.
Quoted 8 lines
Let a
qcom_cc_desccarryclk_refdescriptions, indexed by clock ID like its other clocks.qcom_clk_ref_register()now registers a single clock, soqcom_cc_really_probe()allocates and registers only the populated entries, andqcom_cc_clk_hw_get()returns them for their indices. As with the other clocks, entries listed in protected-clocks are skipped. A clock ID used by both aclk_refand a regmap clock fails the probe.Signed-off-by Stanislav Aleksandrov <[email protected]>
PATCH v2 5/5 clk: qcom: Add support for Global clock controller on Halliday
In reply to Stanislav AleksandrovAdd the driver for the Global Clock Controller on the Qualcomm Halliday SoC. The clock tables are based on Qualcomm's downstream gcc-anorak driver, without its hardware-control and HLOS vote clocks.
The eight clkref_en clocks are clk_ref clocks that vote for the QREF supplies.
--- drivers/clk/qcom/Kconfig | 11 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/gcc-halliday.c | 3533 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 3545 insertions(+)
drivers/clk/qcom/Kconfig +11 -0
@@ -151,6 +151,17 @@ config CLK_GLYMUR_VIDEOCC Say Y if you want to support video devices and functionality such as video encode and decode. +config CLK_HALLIDAY_GCC + tristate "Halliday Global Clock Controller" + depends on ARM64 || COMPILE_TEST + select QCOM_GDSC + default ARCH_QCOM + help + Support for the global clock controller on Halliday devices + (SXR2250P / Snapdragon XR2+ Gen 2). + Say Y if you want to use peripheral devices such as UART, + SPI, I2C, USB, SD/UFS, PCIe etc. + config CLK_KAANAPALI_CAMCC tristate "Kaanapali Camera Clock Controller" depends on ARM64 || COMPILE_TEST
drivers/clk/qcom/Makefile +1 -0
@@ -35,6 +35,7 @@ obj-$(CONFIG_CLK_GLYMUR_GCC) += gcc-glymur.o obj-$(CONFIG_CLK_GLYMUR_GPUCC) += gpucc-glymur.o gxclkctl-kaanapali.o obj-$(CONFIG_CLK_GLYMUR_TCSRCC) += tcsrcc-glymur.o obj-$(CONFIG_CLK_GLYMUR_VIDEOCC) += videocc-glymur.o +obj-$(CONFIG_CLK_HALLIDAY_GCC) += gcc-halliday.o obj-$(CONFIG_CLK_HAWI_CAMCC) += cambistmclkcc-kaanapali.o camcc-hawi.o obj-$(CONFIG_CLK_HAWI_GCC) += gcc-hawi.o obj-$(CONFIG_CLK_HAWI_GPUCC) += gpucc-hawi.o gxclkctl-kaanapali.o
drivers/clk/qcom/gcc-halliday.c new file +3533 -0
2,976 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.55.0
Part of the diff is not shown here. View the raw message.
Re: [PATCH v2 5/5] clk: qcom: Add support for Global clock controller on Halliday
Quoted 8 lines · Stanislav Aleksandrov
Add the driver for the Global Clock Controller on the Qualcomm Halliday SoC. The clock tables are based on Qualcomm's downstream gcc-anorak driver, without its hardware-control and HLOS vote clocks.
The eight
clkref_enclocks areclk_refclocks that vote for the QREF supplies.Signed-off-by Stanislav Aleksandrov <[email protected]>
LGTM, so: