clk: qcom: Add SM8350 camera clock controller
Subsystems (5)
cover clk: qcom: Add SM8350 camera clock controller
Add the camera clock controller (CAMCC) for Qualcomm SM8350 SoC, the clock configuration was taken from camcc-lahaina.c from msm-5.10.
CAM_CC_PLL0 runs at 1200MHz, which requires the SVS_L1 level of the MX rail, so it is set as the MX performance state in the device tree node.
Vladimir Zapolskiy (3):
dt-bindings: clock: qcom: Add SM8350 camera clock controller
clk: qcom: Add SM8350 camera clock controller driver
arm64: dts: qcom: sm8350: Add camera clock controller
.../bindings/clock/qcom,sm8350-camcc.yaml | 69 + arch/arm64/boot/dts/qcom/sm8350.dtsi | 15 + drivers/clk/qcom/Kconfig | 9 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/camcc-sm8350.c | 2650 +++++++++++++++++ include/dt-bindings/clock/qcom,sm8350-camcc.h | 149 + 6 files changed, 2893 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/qcom,sm8350-camcc.yaml create mode 100644 drivers/clk/qcom/camcc-sm8350.c create mode 100644 include/dt-bindings/clock/qcom,sm8350-camcc.h
Signature · 1 line
2.51.0
PATCH 1/3 dt-bindings: clock: qcom: Add SM8350 camera clock controller
Add device tree bindings for the camera clock controller on Qualcomm SM8350 SoC.
--- .../bindings/clock/qcom,sm8350-camcc.yaml | 69 ++++++++ include/dt-bindings/clock/qcom,sm8350-camcc.h | 149 ++++++++++++++++++ 2 files changed, 218 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/qcom,sm8350-camcc.yaml create mode 100644 include/dt-bindings/clock/qcom,sm8350-camcc.h
Documentation/devicetree/bindings/clock/qcom,sm8350-camcc.yaml new file +69 -0
@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/qcom,sm8350-camcc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Camera Clock & Reset Controller on SM8350 + +maintainers: + - Vladimir Zapolskiy <[email protected]> + +description: | + Qualcomm camera clock control module provides the clocks, + resets and power domains on SM8350. + + See also: + include/dt-bindings/clock/qcom,sm8350-camcc.h + +properties: + compatible: + const: qcom,sm8350-camcc + + clocks: + items: + - description: Board XO source + - description: Board active XO source + - description: Sleep clock source + + power-domains: + items: + - description: MMCX power domain + - description: MX power domain + + required-opps: + items: + - description: MMCX performance point + - description: MX performance point + +required: + - compatible + - clocks + - power-domains + - required-opps + +allOf: + - $ref: qcom,gcc.yaml# + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/qcom,rpmh.h> + #include <dt-bindings/power/qcom,rpmhpd.h> + + clock-controller@ad00000 { + compatible = "qcom,sm8350-camcc"; + reg = <0x0ad00000 0x10000>; + clocks = <&rpmhcc RPMH_CXO_CLK>, + <&rpmhcc RPMH_CXO_CLK_A>, + <&sleep_clk>; + power-domains = <&rpmhpd RPMHPD_MMCX>, + <&rpmhpd RPMHPD_MX>; + required-opps = <&rpmhpd_opp_low_svs>, + <&rpmhpd_opp_svs_l1>; + #clock-cells = <1>; + #reset-cells = <1>; + #power-domain-cells = <1>; + }; +...
include/dt-bindings/clock/qcom,sm8350-camcc.h new file +149 -0
149 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH 2/3 clk: qcom: Add SM8350 camera clock controller driver
In reply to Vladimir ZapolskiyAdd a driver for the camera clock controller on Qualcomm SM8350 SoC.
The clock controller has six Lucid 5LPE PLLs and one Zonda 5LPE PLL, clock and GDSC data is taken from the downstream Qualcomm msm-5.4 kernel.
--- drivers/clk/qcom/Kconfig | 9 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/camcc-sm8350.c | 2650 +++++++++++++++++++++++++++++++ 3 files changed, 2660 insertions(+) create mode 100644 drivers/clk/qcom/camcc-sm8350.c
drivers/clk/qcom/Kconfig +9 -0
@@ -1527,6 +1527,15 @@ config SM_CAMCC_8250 Support for the camera clock controller on SM8250 devices. Say Y if you want to support camera devices and camera functionality. +config SM_CAMCC_8350 + tristate "SM8350 Camera Clock Controller" + depends on ARM64 || COMPILE_TEST + select SM_GCC_8350 + default m if ARCH_QCOM + help + Support for the camera clock controller on SM8350 devices. + Say Y if you want to support camera devices and camera functionality. + config SM_CAMCC_8450 tristate "SM8450 Camera Clock Controller" depends on ARM64 || COMPILE_TEST
drivers/clk/qcom/Makefile +1 -0
@@ -170,6 +170,7 @@ obj-$(CONFIG_SM_CAMCC_6350) += camcc-sm6350.o obj-$(CONFIG_SM_CAMCC_7150) += camcc-sm7150.o obj-$(CONFIG_SM_CAMCC_8150) += camcc-sm8150.o obj-$(CONFIG_SM_CAMCC_8250) += camcc-sm8250.o +obj-$(CONFIG_SM_CAMCC_8350) += camcc-sm8350.o obj-$(CONFIG_SM_CAMCC_8450) += camcc-sm8450.o obj-$(CONFIG_SM_CAMCC_8550) += camcc-sm8550.o obj-$(CONFIG_SM_CAMCC_8650) += camcc-sm8650.o
drivers/clk/qcom/camcc-sm8350.c new file +2650 -0
2,650 lines not on this page · raw message
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH 2/3] clk: qcom: Add SM8350 camera clock controller driver
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] clk: qcom: Lucid 5LPE PLLs in camcc-sm8350 use clk_trion_pll_configure() - [Medium] clk: qcom…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] clk: qcom: Lucid 5LPE PLLs in camcc-sm8350 use clk_trion_pll_configure()
- [Medium] clk: qcom: camcc-sm8350: duplicate cam_cc_pll2 parent in cam_cc_parent_data_1 --
commit 0c4b57cb98acf493d0d1fffca035f3d8996aea87
Author: Vladimir Zapolskiy <[email protected]>
clk: qcom: Add SM8350 camera clock controller driver
This commit adds the camera clock controller (CAMCC) driver for the Qualcomm SM8350 SoC, including six Lucid 5LPE PLLs, one Zonda 5LPE PLL, clocks, resets, and GDSCs.
Quoted 6 lines
drivers/clk/qcom/camcc-sm8350.c new file +0
-0@@ -0,0 +1,2650 @@
[ ... ]
Quoted 15 lines
drivers/clk/qcom/camcc-sm8350.c new file +15
-0+static struct clk_alpha_pll cam_cc_pll0 = { + .offset =0x0 , + .config = &cam_cc_pll0_config, + .vco_table = lucid_5lpe_vco, + .num_vco =ARRAY_SIZE (lucid_5lpe_vco), + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID ], + .clkr = { + .hw.init = &(const struct clk_init_data ) { + .name ="cam_cc_pll0" , + .parent_data = &pll_parent_data_tcxo, + .num_parents =1 , + .ops = &clk_alpha_pll_lucid_5lpe_ops, + }, + }, +};
[ ... ]
drivers/clk/qcom/camcc-sm8350.c line 400
Quoted 11 lines
drivers/clk/qcom/camcc-sm8350.c new file +11
-0+static const struct parent_map cam_cc_parent_map_1[] = { + {P_BI_TCXO ,0 }, + {P_CAM_CC_PLL2_OUT_AUX2 ,3 }, + {P_CAM_CC_PLL2_OUT_EARLY ,5 }, +}; + +static const struct clk_parent_data cam_cc_parent_data_1[] = { + { .index =DT_BI_TCXO }, + { .hw = &cam_cc_pll2.clkr.hw }, + { .hw = &cam_cc_pll2.clkr.hw }, +};
[Severity: Medium]
Does having two entries in cam_cc_parent_data_1 point to the same &cam_cc_pll2.clkr.hw cause clk_fetch_parent_index() to select the wrong parent index for cam_cc_mclk0_clk_src through cam_cc_mclk5_clk_src?
In cam_cc_parent_map_1, index 1 is P_CAM_CC_PLL2_OUT_AUX2 (cfg = 3) and index 2 is P_CAM_CC_PLL2_OUT_EARLY (cfg = 5), while ftbl_cam_cc_mclk0_clk_src only uses P_BI_TCXO and P_CAM_CC_PLL2_OUT_EARLY:
static const struct freq_tbl ftbl_cam_cc_mclk0_clk_src[] = {
F(19200000, P_BI_TCXO, 1, 0, 0),
F(24000000, P_CAM_CC_PLL2_OUT_EARLY, 10, 1, 4),
F(68571429, P_CAM_CC_PLL2_OUT_EARLY, 14, 0, 0),
{ }
};When clk_fetch_parent_index() in drivers/clk/clk.c looks up cam_cc_pll2, it scans linearly from index 0:
drivers/clk/clk.c:clk_fetch_parent_index() {
for (i = 0; i < core->num_parents; i++) {
/* Found it first try! */
if (core->parents[i].core == parent)
return i;
/* Something else is here, so keep looking */
if (core->parents[i].core)
continue;
/* Maybe core hasn't been cached but the hw is all we know? */
if (core->parents[i].hw) {
if (core->parents[i].hw == parent->hw)
break;Even after _freq_tbl_determine_rate() populates core->parents[2].core via clk_hw_get_parent_by_index(hw, 2), core->parents[1].core remains NULL and core->parents[1].hw == parent->hw matches at index 1, caching core->parents[1].core = parent and returning index 1 instead of index 2.
If clk_set_parent() is called on cam_cc_mclk0_clk_src..cam_cc_mclk5_clk_src with cam_cc_pll2 (for example via assigned-clock-parents), clk_rcg2_shared_set_parent() receives index 1 and programs rcg->parent_map[1].cfg (3, P_CAM_CC_PLL2_OUT_AUX2) into CFG_SRC_SEL instead of rcg->parent_map[2].cfg (5, P_CAM_CC_PLL2_OUT_EARLY).
Should P_CAM_CC_PLL2_OUT_AUX2 and the duplicate &cam_cc_pll2.clkr.hw entry be removed from cam_cc_parent_map_1 and cam_cc_parent_data_1, as in camcc-sm8150.c and camcc-sm8250.c?
[ ... ]
Quoted 18 lines
drivers/clk/qcom/camcc-sm8350.c new file +18
-0+static struct clk_alpha_pll *cam_cc_sm8350_plls[] = { + &cam_cc_pll0, + &cam_cc_pll1, + &cam_cc_pll2, + &cam_cc_pll3, + &cam_cc_pll4, + &cam_cc_pll5, + &cam_cc_pll6, +}; + +static const u32 cam_cc_sm8350_critical_cbcrs[] = { +0xc148 ,/* CAM_CC_GDSC_CLK */ +}; + +static const struct regmap_config cam_cc_sm8350_regmap_config = { + .reg_bits =32 , + .reg_stride =4 , + .val_bits =32 ,
drivers/clk/qcom/camcc-sm8350.c line 2614
Quoted 10 lines
drivers/clk/qcom/camcc-sm8350.c new file +10
-0+ .max_register = 0xf008, + .fast_io = true, +}; + +static const struct qcom_cc_driver_data cam_cc_sm8350_driver_data = { + .alpha_plls = cam_cc_sm8350_plls, + .num_alpha_plls =ARRAY_SIZE (cam_cc_sm8350_plls), + .clk_cbcrs = cam_cc_sm8350_critical_cbcrs, + .num_clk_cbcrs =ARRAY_SIZE (cam_cc_sm8350_critical_cbcrs), +};
[Severity: Medium]
Will passing cam_cc_sm8350_plls via cam_cc_sm8350_driver_data.alpha_plls configure the six Lucid 5LPE PLLs (cam_cc_pll0, cam_cc_pll1, cam_cc_pll3, cam_cc_pll4, cam_cc_pll5, and cam_cc_pll6) with clk_trion_pll_configure() instead of clk_lucid_5lpe_pll_configure()?
During probe, the call chain is:
cam_cc_sm8350_probe()
-> qcom_cc_probe()
-> qcom_cc_really_probe()
-> qcom_cc_clk_pll_configure()
-> qcom_clk_alpha_pll_configure()Those six PLLs use clk_alpha_pll_lucid_5lpe_ops and clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID]. Because CLK_ALPHA_PLL_TYPE_LUCID is aliased to CLK_ALPHA_PLL_TYPE_TRION in drivers/clk/qcom/clk-alpha-pll.h, GET_PLL_TYPE(pll) in qcom_clk_alpha_pll_configure() matches CLK_ALPHA_PLL_TYPE_TRION:
drivers/clk/qcom/clk-alpha-pll.c:qcom_clk_alpha_pll_configure() {
...
case CLK_ALPHA_PLL_TYPE_TRION:
clk_trion_pll_configure(pll, regmap, pll->config);
break;clk_trion_pll_configure() sets PLL_UPDATE_BYPASS in PLL_MODE:
drivers/clk/qcom/clk-alpha-pll.c:clk_trion_pll_configure() {
...
regmap_update_bits(regmap, PLL_MODE(pll), PLL_UPDATE_BYPASS,
PLL_UPDATE_BYPASS);As noted in commit 362be5cbaec2a6 ("clk: qcom: dispcc-sm8250: use special function for Lucid 5LPE PLL"), Lucid 5LPE PLLs require clk_lucid_5lpe_pll_configure(), which omits setting PLL_UPDATE_BYPASS.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH 2/3] clk: qcom: Add SM8350 camera clock controller driver
Quoted 2 lines · On 11/5/26 18:06, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] clk: qcom: Lucid 5LPE PLLs in camcc-sm8350 useclk_trion_pll_configure()
That's a valid issue, and it requires to make a formal introduction of Lucid 5LPE PLLs.
Quoted 1 line
- [Medium] clk: qcom: camcc-sm8350: duplicate
cam_cc_pll2parent incam_cc_parent_data_1
This is also a valid review comment, fortunately this one is easy to fix.
Will prepare v2.
Signature · 2 lines
Best wishes, Vladimir
Re: [PATCH 2/3] clk: qcom: Add SM8350 camera clock controller driver
In reply to Vladimir Zapolskiydrivers/clk/qcom/camcc-sm8350.c line 9
Quoted 3 lines · Vladimir Zapolskiy
drivers/clk/qcom/camcc-sm8350.c new file +2
-0+#include <linux/mod_devicetable.h> +#include <linux/platform_device.h>
Please don't use <linux/mod_devicetable.h>. <linux/platform_device.h> is good enough to provide of_device_id already. If you insist on full iwyu, please use <linux/device-id/of.h> instead.
Best regards
Uwe
PATCH 3/3 arm64: dts: qcom: sm8350: Add camera clock controller
In reply to Vladimir ZapolskiyAdd the camera clock controller device tree node to SM8350 SoC dtsi.
The camera clock controller PLLs are powered by MX rail, CAM_CC_PLL0 runs at 1200MHz, which requires SVS_L1 level of MX, while all other camera clock controller PLLs can run at SVS level of MX or lower.
--- arch/arm64/boot/dts/qcom/sm8350.dtsi | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/arm64/boot/dts/qcom/sm8350.dtsi +15 -0
@@ -2830,6 +2830,21 @@ videocc: clock-controller@abf0000 { #power-domain-cells = <1>; }; + camcc: clock-controller@ad00000 { + compatible = "qcom,sm8350-camcc"; + reg = <0 0x0ad00000 0 0x10000>; + clocks = <&rpmhcc RPMH_CXO_CLK>, + <&rpmhcc RPMH_CXO_CLK_A>, + <&sleep_clk>; + power-domains = <&rpmhpd RPMHPD_MMCX>, + <&rpmhpd RPMHPD_MX>; + required-opps = <&rpmhpd_opp_low_svs>, + <&rpmhpd_opp_svs_l1>; + #clock-cells = <1>; + #reset-cells = <1>; + #power-domain-cells = <1>; + }; + mdss: display-subsystem@ae00000 { compatible = "qcom,sm8350-mdss"; reg = <0 0x0ae00000 0 0x1000>;
Signature · 1 line
2.51.0