Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: qcom: camcc-x1e80100: Move PLL & clk configuration to really probe

Camera PLLs on X1E80100 require both MMCX and MXC rails to be kept ON
to configure the PLLs properly. Hence move runtime power management,
PLL configuration and enabling critical clocks to qcom_cc_really_probe()
which ensures all required power domains are in enabled state before
configuring the PLLs or enabling the clocks.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # Dell Inspiron
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Jagadeesh Kona <quic_jkona@quicinc.com>
Link: https://lore.kernel.org/r/20250530-videocc-pll-multi-pd-voting-v5-12-02303b3a582d@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Jagadeesh Kona and committed by
Bjorn Andersson
d7eddaf0 3f8dd231

+32 -35
+32 -35
drivers/clk/qcom/camcc-x1e80100.c
··· 7 7 #include <linux/mod_devicetable.h> 8 8 #include <linux/module.h> 9 9 #include <linux/platform_device.h> 10 - #include <linux/pm_runtime.h> 11 10 #include <linux/regmap.h> 12 11 13 12 #include <dt-bindings/clock/qcom,x1e80100-camcc.h> ··· 66 67 67 68 static struct clk_alpha_pll cam_cc_pll0 = { 68 69 .offset = 0x0, 70 + .config = &cam_cc_pll0_config, 69 71 .vco_table = lucid_ole_vco, 70 72 .num_vco = ARRAY_SIZE(lucid_ole_vco), 71 73 .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE], ··· 144 144 145 145 static struct clk_alpha_pll cam_cc_pll1 = { 146 146 .offset = 0x1000, 147 + .config = &cam_cc_pll1_config, 147 148 .vco_table = lucid_ole_vco, 148 149 .num_vco = ARRAY_SIZE(lucid_ole_vco), 149 150 .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE], ··· 195 194 196 195 static struct clk_alpha_pll cam_cc_pll2 = { 197 196 .offset = 0x2000, 197 + .config = &cam_cc_pll2_config, 198 198 .vco_table = rivian_ole_vco, 199 199 .num_vco = ARRAY_SIZE(rivian_ole_vco), 200 200 .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_RIVIAN_EVO], ··· 227 225 228 226 static struct clk_alpha_pll cam_cc_pll3 = { 229 227 .offset = 0x3000, 228 + .config = &cam_cc_pll3_config, 230 229 .vco_table = lucid_ole_vco, 231 230 .num_vco = ARRAY_SIZE(lucid_ole_vco), 232 231 .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE], ··· 282 279 283 280 static struct clk_alpha_pll cam_cc_pll4 = { 284 281 .offset = 0x4000, 282 + .config = &cam_cc_pll4_config, 285 283 .vco_table = lucid_ole_vco, 286 284 .num_vco = ARRAY_SIZE(lucid_ole_vco), 287 285 .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE], ··· 337 333 338 334 static struct clk_alpha_pll cam_cc_pll6 = { 339 335 .offset = 0x6000, 336 + .config = &cam_cc_pll6_config, 340 337 .vco_table = lucid_ole_vco, 341 338 .num_vco = ARRAY_SIZE(lucid_ole_vco), 342 339 .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE], ··· 392 387 393 388 static struct clk_alpha_pll cam_cc_pll8 = { 394 389 .offset = 0x8000, 390 + .config = &cam_cc_pll8_config, 395 391 .vco_table = lucid_ole_vco, 396 392 .num_vco = ARRAY_SIZE(lucid_ole_vco), 397 393 .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID_OLE], ··· 2424 2418 [CAM_CC_SFE_0_BCR] = { 0x1327c }, 2425 2419 }; 2426 2420 2421 + static struct clk_alpha_pll *cam_cc_x1e80100_plls[] = { 2422 + &cam_cc_pll0, 2423 + &cam_cc_pll1, 2424 + &cam_cc_pll2, 2425 + &cam_cc_pll3, 2426 + &cam_cc_pll4, 2427 + &cam_cc_pll6, 2428 + &cam_cc_pll8, 2429 + }; 2430 + 2431 + static u32 cam_cc_x1e80100_critical_cbcrs[] = { 2432 + 0x13a9c, /* CAM_CC_GDSC_CLK */ 2433 + 0x13ab8, /* CAM_CC_SLEEP_CLK */ 2434 + }; 2435 + 2427 2436 static const struct regmap_config cam_cc_x1e80100_regmap_config = { 2428 2437 .reg_bits = 32, 2429 2438 .reg_stride = 4, 2430 2439 .val_bits = 32, 2431 2440 .max_register = 0x1603c, 2432 2441 .fast_io = true, 2442 + }; 2443 + 2444 + static struct qcom_cc_driver_data cam_cc_x1e80100_driver_data = { 2445 + .alpha_plls = cam_cc_x1e80100_plls, 2446 + .num_alpha_plls = ARRAY_SIZE(cam_cc_x1e80100_plls), 2447 + .clk_cbcrs = cam_cc_x1e80100_critical_cbcrs, 2448 + .num_clk_cbcrs = ARRAY_SIZE(cam_cc_x1e80100_critical_cbcrs), 2433 2449 }; 2434 2450 2435 2451 static const struct qcom_cc_desc cam_cc_x1e80100_desc = { ··· 2462 2434 .num_resets = ARRAY_SIZE(cam_cc_x1e80100_resets), 2463 2435 .gdscs = cam_cc_x1e80100_gdscs, 2464 2436 .num_gdscs = ARRAY_SIZE(cam_cc_x1e80100_gdscs), 2437 + .use_rpm = true, 2438 + .driver_data = &cam_cc_x1e80100_driver_data, 2465 2439 }; 2466 2440 2467 2441 static const struct of_device_id cam_cc_x1e80100_match_table[] = { ··· 2474 2444 2475 2445 static int cam_cc_x1e80100_probe(struct platform_device *pdev) 2476 2446 { 2477 - struct regmap *regmap; 2478 - int ret; 2479 - 2480 - ret = devm_pm_runtime_enable(&pdev->dev); 2481 - if (ret) 2482 - return ret; 2483 - 2484 - ret = pm_runtime_resume_and_get(&pdev->dev); 2485 - if (ret) 2486 - return ret; 2487 - 2488 - regmap = qcom_cc_map(pdev, &cam_cc_x1e80100_desc); 2489 - if (IS_ERR(regmap)) { 2490 - pm_runtime_put(&pdev->dev); 2491 - return PTR_ERR(regmap); 2492 - } 2493 - 2494 - clk_lucid_ole_pll_configure(&cam_cc_pll0, regmap, &cam_cc_pll0_config); 2495 - clk_lucid_ole_pll_configure(&cam_cc_pll1, regmap, &cam_cc_pll1_config); 2496 - clk_rivian_evo_pll_configure(&cam_cc_pll2, regmap, &cam_cc_pll2_config); 2497 - clk_lucid_ole_pll_configure(&cam_cc_pll3, regmap, &cam_cc_pll3_config); 2498 - clk_lucid_ole_pll_configure(&cam_cc_pll4, regmap, &cam_cc_pll4_config); 2499 - clk_lucid_ole_pll_configure(&cam_cc_pll6, regmap, &cam_cc_pll6_config); 2500 - clk_lucid_ole_pll_configure(&cam_cc_pll8, regmap, &cam_cc_pll8_config); 2501 - 2502 - /* Keep clocks always enabled */ 2503 - qcom_branch_set_clk_en(regmap, 0x13a9c); /* CAM_CC_GDSC_CLK */ 2504 - qcom_branch_set_clk_en(regmap, 0x13ab8); /* CAM_CC_SLEEP_CLK */ 2505 - 2506 - ret = qcom_cc_really_probe(&pdev->dev, &cam_cc_x1e80100_desc, regmap); 2507 - 2508 - pm_runtime_put(&pdev->dev); 2509 - 2510 - return ret; 2447 + return qcom_cc_probe(pdev, &cam_cc_x1e80100_desc); 2511 2448 } 2512 2449 2513 2450 static struct platform_driver cam_cc_x1e80100_driver = {