Skip to content

Commit 760be65

Browse files
Jeffrey Hugobebarino
authored andcommitted
clk: qcom: Make common clk_hw registrations
Several clock controller drivers define a list of clk_hw devices, and then register those devices in probe() before using common code to process the rest of initialization. Extend the common code to accept a list of clk_hw devices to process, thus eliminating many duplicate implementations. Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org> Suggested-by: Stephen Boyd <sboyd@kernel.org> Reviewed-by: Vinod Koul <vkoul@kernel.org> Tested-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 6131dc8 commit 760be65

File tree

9 files changed

+29
-52
lines changed

9 files changed

+29
-52
lines changed

drivers/clk/qcom/common.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ int qcom_cc_really_probe(struct platform_device *pdev,
231231
struct gdsc_desc *scd;
232232
size_t num_clks = desc->num_clks;
233233
struct clk_regmap **rclks = desc->clks;
234+
size_t num_clk_hws = desc->num_clk_hws;
235+
struct clk_hw **clk_hws = desc->clk_hws;
234236

235237
cc = devm_kzalloc(dev, sizeof(*cc), GFP_KERNEL);
236238
if (!cc)
@@ -269,6 +271,12 @@ int qcom_cc_really_probe(struct platform_device *pdev,
269271

270272
qcom_cc_drop_protected(dev, cc);
271273

274+
for (i = 0; i < num_clk_hws; i++) {
275+
ret = devm_clk_hw_register(dev, clk_hws[i]);
276+
if (ret)
277+
return ret;
278+
}
279+
272280
for (i = 0; i < num_clks; i++) {
273281
if (!rclks[i])
274282
continue;

drivers/clk/qcom/common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ struct qcom_cc_desc {
2727
size_t num_resets;
2828
struct gdsc **gdscs;
2929
size_t num_gdscs;
30+
struct clk_hw **clk_hws;
31+
size_t num_clk_hws;
3032
};
3133

3234
/**

drivers/clk/qcom/gcc-ipq8074.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4715,18 +4715,12 @@ static const struct qcom_cc_desc gcc_ipq8074_desc = {
47154715
.num_clks = ARRAY_SIZE(gcc_ipq8074_clks),
47164716
.resets = gcc_ipq8074_resets,
47174717
.num_resets = ARRAY_SIZE(gcc_ipq8074_resets),
4718+
.clk_hws = gcc_ipq8074_hws,
4719+
.num_clk_hws = ARRAY_SIZE(gcc_ipq8074_hws),
47184720
};
47194721

47204722
static int gcc_ipq8074_probe(struct platform_device *pdev)
47214723
{
4722-
int ret, i;
4723-
4724-
for (i = 0; i < ARRAY_SIZE(gcc_ipq8074_hws); i++) {
4725-
ret = devm_clk_hw_register(&pdev->dev, gcc_ipq8074_hws[i]);
4726-
if (ret)
4727-
return ret;
4728-
}
4729-
47304724
return qcom_cc_probe(pdev, &gcc_ipq8074_desc);
47314725
}
47324726

drivers/clk/qcom/gcc-mdm9615.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,8 @@ static const struct qcom_cc_desc gcc_mdm9615_desc = {
17021702
.num_clks = ARRAY_SIZE(gcc_mdm9615_clks),
17031703
.resets = gcc_mdm9615_resets,
17041704
.num_resets = ARRAY_SIZE(gcc_mdm9615_resets),
1705+
.clk_hws = gcc_mdm9615_hws,
1706+
.num_clk_hws = ARRAY_SIZE(gcc_mdm9615_hws),
17051707
};
17061708

17071709
static const struct of_device_id gcc_mdm9615_match_table[] = {
@@ -1712,21 +1714,12 @@ MODULE_DEVICE_TABLE(of, gcc_mdm9615_match_table);
17121714

17131715
static int gcc_mdm9615_probe(struct platform_device *pdev)
17141716
{
1715-
struct device *dev = &pdev->dev;
17161717
struct regmap *regmap;
1717-
int ret;
1718-
int i;
17191718

17201719
regmap = qcom_cc_map(pdev, &gcc_mdm9615_desc);
17211720
if (IS_ERR(regmap))
17221721
return PTR_ERR(regmap);
17231722

1724-
for (i = 0; i < ARRAY_SIZE(gcc_mdm9615_hws); i++) {
1725-
ret = devm_clk_hw_register(dev, gcc_mdm9615_hws[i]);
1726-
if (ret)
1727-
return ret;
1728-
}
1729-
17301723
return qcom_cc_really_probe(pdev, &gcc_mdm9615_desc, regmap);
17311724
}
17321725

drivers/clk/qcom/gcc-msm8996.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3656,6 +3656,8 @@ static const struct qcom_cc_desc gcc_msm8996_desc = {
36563656
.num_resets = ARRAY_SIZE(gcc_msm8996_resets),
36573657
.gdscs = gcc_msm8996_gdscs,
36583658
.num_gdscs = ARRAY_SIZE(gcc_msm8996_gdscs),
3659+
.clk_hws = gcc_msm8996_hws,
3660+
.num_clk_hws = ARRAY_SIZE(gcc_msm8996_hws),
36593661
};
36603662

36613663
static const struct of_device_id gcc_msm8996_match_table[] = {
@@ -3666,8 +3668,6 @@ MODULE_DEVICE_TABLE(of, gcc_msm8996_match_table);
36663668

36673669
static int gcc_msm8996_probe(struct platform_device *pdev)
36683670
{
3669-
struct device *dev = &pdev->dev;
3670-
int i, ret;
36713671
struct regmap *regmap;
36723672

36733673
regmap = qcom_cc_map(pdev, &gcc_msm8996_desc);
@@ -3680,12 +3680,6 @@ static int gcc_msm8996_probe(struct platform_device *pdev)
36803680
*/
36813681
regmap_update_bits(regmap, 0x52008, BIT(21), BIT(21));
36823682

3683-
for (i = 0; i < ARRAY_SIZE(gcc_msm8996_hws); i++) {
3684-
ret = devm_clk_hw_register(dev, gcc_msm8996_hws[i]);
3685-
if (ret)
3686-
return ret;
3687-
}
3688-
36893683
return qcom_cc_really_probe(pdev, &gcc_msm8996_desc, regmap);
36903684
}
36913685

drivers/clk/qcom/gcc-msm8998.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,6 +2959,10 @@ static const struct regmap_config gcc_msm8998_regmap_config = {
29592959
.fast_io = true,
29602960
};
29612961

2962+
static struct clk_hw *gcc_msm8998_hws[] = {
2963+
&xo.hw,
2964+
};
2965+
29622966
static const struct qcom_cc_desc gcc_msm8998_desc = {
29632967
.config = &gcc_msm8998_regmap_config,
29642968
.clks = gcc_msm8998_clocks,
@@ -2967,6 +2971,8 @@ static const struct qcom_cc_desc gcc_msm8998_desc = {
29672971
.num_resets = ARRAY_SIZE(gcc_msm8998_resets),
29682972
.gdscs = gcc_msm8998_gdscs,
29692973
.num_gdscs = ARRAY_SIZE(gcc_msm8998_gdscs),
2974+
.clk_hws = gcc_msm8998_hws,
2975+
.num_clk_hws = ARRAY_SIZE(gcc_msm8998_hws),
29702976
};
29712977

29722978
static int gcc_msm8998_probe(struct platform_device *pdev)
@@ -2986,10 +2992,6 @@ static int gcc_msm8998_probe(struct platform_device *pdev)
29862992
if (ret)
29872993
return ret;
29882994

2989-
ret = devm_clk_hw_register(&pdev->dev, &xo.hw);
2990-
if (ret)
2991-
return ret;
2992-
29932995
return qcom_cc_really_probe(pdev, &gcc_msm8998_desc, regmap);
29942996
}
29952997

drivers/clk/qcom/gcc-qcs404.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,6 +2692,8 @@ static const struct qcom_cc_desc gcc_qcs404_desc = {
26922692
.num_clks = ARRAY_SIZE(gcc_qcs404_clocks),
26932693
.resets = gcc_qcs404_resets,
26942694
.num_resets = ARRAY_SIZE(gcc_qcs404_resets),
2695+
.clk_hws = gcc_qcs404_hws,
2696+
.num_clk_hws = ARRAY_SIZE(gcc_qcs404_hws),
26952697
};
26962698

26972699
static const struct of_device_id gcc_qcs404_match_table[] = {
@@ -2703,20 +2705,13 @@ MODULE_DEVICE_TABLE(of, gcc_qcs404_match_table);
27032705
static int gcc_qcs404_probe(struct platform_device *pdev)
27042706
{
27052707
struct regmap *regmap;
2706-
int ret, i;
27072708

27082709
regmap = qcom_cc_map(pdev, &gcc_qcs404_desc);
27092710
if (IS_ERR(regmap))
27102711
return PTR_ERR(regmap);
27112712

27122713
clk_alpha_pll_configure(&gpll3_out_main, regmap, &gpll3_config);
27132714

2714-
for (i = 0; i < ARRAY_SIZE(gcc_qcs404_hws); i++) {
2715-
ret = devm_clk_hw_register(&pdev->dev, gcc_qcs404_hws[i]);
2716-
if (ret)
2717-
return ret;
2718-
}
2719-
27202715
return qcom_cc_really_probe(pdev, &gcc_qcs404_desc, regmap);
27212716
}
27222717

drivers/clk/qcom/gcc-sdm660.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,6 +2420,8 @@ static const struct qcom_cc_desc gcc_sdm660_desc = {
24202420
.num_resets = ARRAY_SIZE(gcc_sdm660_resets),
24212421
.gdscs = gcc_sdm660_gdscs,
24222422
.num_gdscs = ARRAY_SIZE(gcc_sdm660_gdscs),
2423+
.clk_hws = gcc_sdm660_hws,
2424+
.num_clk_hws = ARRAY_SIZE(gcc_sdm660_hws),
24232425
};
24242426

24252427
static const struct of_device_id gcc_sdm660_match_table[] = {
@@ -2431,7 +2433,7 @@ MODULE_DEVICE_TABLE(of, gcc_sdm660_match_table);
24312433

24322434
static int gcc_sdm660_probe(struct platform_device *pdev)
24332435
{
2434-
int i, ret;
2436+
int ret;
24352437
struct regmap *regmap;
24362438

24372439
regmap = qcom_cc_map(pdev, &gcc_sdm660_desc);
@@ -2446,13 +2448,6 @@ static int gcc_sdm660_probe(struct platform_device *pdev)
24462448
if (ret)
24472449
return ret;
24482450

2449-
/* Register the hws */
2450-
for (i = 0; i < ARRAY_SIZE(gcc_sdm660_hws); i++) {
2451-
ret = devm_clk_hw_register(&pdev->dev, gcc_sdm660_hws[i]);
2452-
if (ret)
2453-
return ret;
2454-
}
2455-
24562451
return qcom_cc_really_probe(pdev, &gcc_sdm660_desc, regmap);
24572452
}
24582453

drivers/clk/qcom/mmcc-msm8996.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3347,6 +3347,8 @@ static const struct qcom_cc_desc mmcc_msm8996_desc = {
33473347
.num_resets = ARRAY_SIZE(mmcc_msm8996_resets),
33483348
.gdscs = mmcc_msm8996_gdscs,
33493349
.num_gdscs = ARRAY_SIZE(mmcc_msm8996_gdscs),
3350+
.clk_hws = mmcc_msm8996_hws,
3351+
.num_clk_hws = ARRAY_SIZE(mmcc_msm8996_hws),
33503352
};
33513353

33523354
static const struct of_device_id mmcc_msm8996_match_table[] = {
@@ -3357,8 +3359,6 @@ MODULE_DEVICE_TABLE(of, mmcc_msm8996_match_table);
33573359

33583360
static int mmcc_msm8996_probe(struct platform_device *pdev)
33593361
{
3360-
struct device *dev = &pdev->dev;
3361-
int i, ret;
33623362
struct regmap *regmap;
33633363

33643364
regmap = qcom_cc_map(pdev, &mmcc_msm8996_desc);
@@ -3370,12 +3370,6 @@ static int mmcc_msm8996_probe(struct platform_device *pdev)
33703370
/* Disable the NoC FSM for mmss_mmagic_cfg_ahb_clk */
33713371
regmap_update_bits(regmap, 0x5054, BIT(15), 0);
33723372

3373-
for (i = 0; i < ARRAY_SIZE(mmcc_msm8996_hws); i++) {
3374-
ret = devm_clk_hw_register(dev, mmcc_msm8996_hws[i]);
3375-
if (ret)
3376-
return ret;
3377-
}
3378-
33793373
return qcom_cc_really_probe(pdev, &mmcc_msm8996_desc, regmap);
33803374
}
33813375

0 commit comments

Comments
 (0)