Commit 760be658 authored by Jeffrey Hugo's avatar Jeffrey Hugo Committed by Stephen Boyd

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: default avatarJeffrey Hugo <jhugo@codeaurora.org>
Suggested-by: default avatarStephen Boyd <sboyd@kernel.org>
Reviewed-by: default avatarVinod Koul <vkoul@kernel.org>
Tested-by: default avatarVinod Koul <vkoul@kernel.org>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent 6131dc81
...@@ -231,6 +231,8 @@ int qcom_cc_really_probe(struct platform_device *pdev, ...@@ -231,6 +231,8 @@ int qcom_cc_really_probe(struct platform_device *pdev,
struct gdsc_desc *scd; struct gdsc_desc *scd;
size_t num_clks = desc->num_clks; size_t num_clks = desc->num_clks;
struct clk_regmap **rclks = desc->clks; struct clk_regmap **rclks = desc->clks;
size_t num_clk_hws = desc->num_clk_hws;
struct clk_hw **clk_hws = desc->clk_hws;
cc = devm_kzalloc(dev, sizeof(*cc), GFP_KERNEL); cc = devm_kzalloc(dev, sizeof(*cc), GFP_KERNEL);
if (!cc) if (!cc)
...@@ -269,6 +271,12 @@ int qcom_cc_really_probe(struct platform_device *pdev, ...@@ -269,6 +271,12 @@ int qcom_cc_really_probe(struct platform_device *pdev,
qcom_cc_drop_protected(dev, cc); qcom_cc_drop_protected(dev, cc);
for (i = 0; i < num_clk_hws; i++) {
ret = devm_clk_hw_register(dev, clk_hws[i]);
if (ret)
return ret;
}
for (i = 0; i < num_clks; i++) { for (i = 0; i < num_clks; i++) {
if (!rclks[i]) if (!rclks[i])
continue; continue;
......
...@@ -27,6 +27,8 @@ struct qcom_cc_desc { ...@@ -27,6 +27,8 @@ struct qcom_cc_desc {
size_t num_resets; size_t num_resets;
struct gdsc **gdscs; struct gdsc **gdscs;
size_t num_gdscs; size_t num_gdscs;
struct clk_hw **clk_hws;
size_t num_clk_hws;
}; };
/** /**
......
...@@ -4715,18 +4715,12 @@ static const struct qcom_cc_desc gcc_ipq8074_desc = { ...@@ -4715,18 +4715,12 @@ static const struct qcom_cc_desc gcc_ipq8074_desc = {
.num_clks = ARRAY_SIZE(gcc_ipq8074_clks), .num_clks = ARRAY_SIZE(gcc_ipq8074_clks),
.resets = gcc_ipq8074_resets, .resets = gcc_ipq8074_resets,
.num_resets = ARRAY_SIZE(gcc_ipq8074_resets), .num_resets = ARRAY_SIZE(gcc_ipq8074_resets),
.clk_hws = gcc_ipq8074_hws,
.num_clk_hws = ARRAY_SIZE(gcc_ipq8074_hws),
}; };
static int gcc_ipq8074_probe(struct platform_device *pdev) static int gcc_ipq8074_probe(struct platform_device *pdev)
{ {
int ret, i;
for (i = 0; i < ARRAY_SIZE(gcc_ipq8074_hws); i++) {
ret = devm_clk_hw_register(&pdev->dev, gcc_ipq8074_hws[i]);
if (ret)
return ret;
}
return qcom_cc_probe(pdev, &gcc_ipq8074_desc); return qcom_cc_probe(pdev, &gcc_ipq8074_desc);
} }
......
...@@ -1702,6 +1702,8 @@ static const struct qcom_cc_desc gcc_mdm9615_desc = { ...@@ -1702,6 +1702,8 @@ static const struct qcom_cc_desc gcc_mdm9615_desc = {
.num_clks = ARRAY_SIZE(gcc_mdm9615_clks), .num_clks = ARRAY_SIZE(gcc_mdm9615_clks),
.resets = gcc_mdm9615_resets, .resets = gcc_mdm9615_resets,
.num_resets = ARRAY_SIZE(gcc_mdm9615_resets), .num_resets = ARRAY_SIZE(gcc_mdm9615_resets),
.clk_hws = gcc_mdm9615_hws,
.num_clk_hws = ARRAY_SIZE(gcc_mdm9615_hws),
}; };
static const struct of_device_id gcc_mdm9615_match_table[] = { static const struct of_device_id gcc_mdm9615_match_table[] = {
...@@ -1712,21 +1714,12 @@ MODULE_DEVICE_TABLE(of, gcc_mdm9615_match_table); ...@@ -1712,21 +1714,12 @@ MODULE_DEVICE_TABLE(of, gcc_mdm9615_match_table);
static int gcc_mdm9615_probe(struct platform_device *pdev) static int gcc_mdm9615_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev;
struct regmap *regmap; struct regmap *regmap;
int ret;
int i;
regmap = qcom_cc_map(pdev, &gcc_mdm9615_desc); regmap = qcom_cc_map(pdev, &gcc_mdm9615_desc);
if (IS_ERR(regmap)) if (IS_ERR(regmap))
return PTR_ERR(regmap); return PTR_ERR(regmap);
for (i = 0; i < ARRAY_SIZE(gcc_mdm9615_hws); i++) {
ret = devm_clk_hw_register(dev, gcc_mdm9615_hws[i]);
if (ret)
return ret;
}
return qcom_cc_really_probe(pdev, &gcc_mdm9615_desc, regmap); return qcom_cc_really_probe(pdev, &gcc_mdm9615_desc, regmap);
} }
......
...@@ -3656,6 +3656,8 @@ static const struct qcom_cc_desc gcc_msm8996_desc = { ...@@ -3656,6 +3656,8 @@ static const struct qcom_cc_desc gcc_msm8996_desc = {
.num_resets = ARRAY_SIZE(gcc_msm8996_resets), .num_resets = ARRAY_SIZE(gcc_msm8996_resets),
.gdscs = gcc_msm8996_gdscs, .gdscs = gcc_msm8996_gdscs,
.num_gdscs = ARRAY_SIZE(gcc_msm8996_gdscs), .num_gdscs = ARRAY_SIZE(gcc_msm8996_gdscs),
.clk_hws = gcc_msm8996_hws,
.num_clk_hws = ARRAY_SIZE(gcc_msm8996_hws),
}; };
static const struct of_device_id gcc_msm8996_match_table[] = { static const struct of_device_id gcc_msm8996_match_table[] = {
...@@ -3666,8 +3668,6 @@ MODULE_DEVICE_TABLE(of, gcc_msm8996_match_table); ...@@ -3666,8 +3668,6 @@ MODULE_DEVICE_TABLE(of, gcc_msm8996_match_table);
static int gcc_msm8996_probe(struct platform_device *pdev) static int gcc_msm8996_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev;
int i, ret;
struct regmap *regmap; struct regmap *regmap;
regmap = qcom_cc_map(pdev, &gcc_msm8996_desc); regmap = qcom_cc_map(pdev, &gcc_msm8996_desc);
...@@ -3680,12 +3680,6 @@ static int gcc_msm8996_probe(struct platform_device *pdev) ...@@ -3680,12 +3680,6 @@ static int gcc_msm8996_probe(struct platform_device *pdev)
*/ */
regmap_update_bits(regmap, 0x52008, BIT(21), BIT(21)); regmap_update_bits(regmap, 0x52008, BIT(21), BIT(21));
for (i = 0; i < ARRAY_SIZE(gcc_msm8996_hws); i++) {
ret = devm_clk_hw_register(dev, gcc_msm8996_hws[i]);
if (ret)
return ret;
}
return qcom_cc_really_probe(pdev, &gcc_msm8996_desc, regmap); return qcom_cc_really_probe(pdev, &gcc_msm8996_desc, regmap);
} }
......
...@@ -2959,6 +2959,10 @@ static const struct regmap_config gcc_msm8998_regmap_config = { ...@@ -2959,6 +2959,10 @@ static const struct regmap_config gcc_msm8998_regmap_config = {
.fast_io = true, .fast_io = true,
}; };
static struct clk_hw *gcc_msm8998_hws[] = {
&xo.hw,
};
static const struct qcom_cc_desc gcc_msm8998_desc = { static const struct qcom_cc_desc gcc_msm8998_desc = {
.config = &gcc_msm8998_regmap_config, .config = &gcc_msm8998_regmap_config,
.clks = gcc_msm8998_clocks, .clks = gcc_msm8998_clocks,
...@@ -2967,6 +2971,8 @@ static const struct qcom_cc_desc gcc_msm8998_desc = { ...@@ -2967,6 +2971,8 @@ static const struct qcom_cc_desc gcc_msm8998_desc = {
.num_resets = ARRAY_SIZE(gcc_msm8998_resets), .num_resets = ARRAY_SIZE(gcc_msm8998_resets),
.gdscs = gcc_msm8998_gdscs, .gdscs = gcc_msm8998_gdscs,
.num_gdscs = ARRAY_SIZE(gcc_msm8998_gdscs), .num_gdscs = ARRAY_SIZE(gcc_msm8998_gdscs),
.clk_hws = gcc_msm8998_hws,
.num_clk_hws = ARRAY_SIZE(gcc_msm8998_hws),
}; };
static int gcc_msm8998_probe(struct platform_device *pdev) static int gcc_msm8998_probe(struct platform_device *pdev)
...@@ -2986,10 +2992,6 @@ static int gcc_msm8998_probe(struct platform_device *pdev) ...@@ -2986,10 +2992,6 @@ static int gcc_msm8998_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
ret = devm_clk_hw_register(&pdev->dev, &xo.hw);
if (ret)
return ret;
return qcom_cc_really_probe(pdev, &gcc_msm8998_desc, regmap); return qcom_cc_really_probe(pdev, &gcc_msm8998_desc, regmap);
} }
......
...@@ -2692,6 +2692,8 @@ static const struct qcom_cc_desc gcc_qcs404_desc = { ...@@ -2692,6 +2692,8 @@ static const struct qcom_cc_desc gcc_qcs404_desc = {
.num_clks = ARRAY_SIZE(gcc_qcs404_clocks), .num_clks = ARRAY_SIZE(gcc_qcs404_clocks),
.resets = gcc_qcs404_resets, .resets = gcc_qcs404_resets,
.num_resets = ARRAY_SIZE(gcc_qcs404_resets), .num_resets = ARRAY_SIZE(gcc_qcs404_resets),
.clk_hws = gcc_qcs404_hws,
.num_clk_hws = ARRAY_SIZE(gcc_qcs404_hws),
}; };
static const struct of_device_id gcc_qcs404_match_table[] = { static const struct of_device_id gcc_qcs404_match_table[] = {
...@@ -2703,7 +2705,6 @@ MODULE_DEVICE_TABLE(of, gcc_qcs404_match_table); ...@@ -2703,7 +2705,6 @@ MODULE_DEVICE_TABLE(of, gcc_qcs404_match_table);
static int gcc_qcs404_probe(struct platform_device *pdev) static int gcc_qcs404_probe(struct platform_device *pdev)
{ {
struct regmap *regmap; struct regmap *regmap;
int ret, i;
regmap = qcom_cc_map(pdev, &gcc_qcs404_desc); regmap = qcom_cc_map(pdev, &gcc_qcs404_desc);
if (IS_ERR(regmap)) if (IS_ERR(regmap))
...@@ -2711,12 +2712,6 @@ static int gcc_qcs404_probe(struct platform_device *pdev) ...@@ -2711,12 +2712,6 @@ static int gcc_qcs404_probe(struct platform_device *pdev)
clk_alpha_pll_configure(&gpll3_out_main, regmap, &gpll3_config); clk_alpha_pll_configure(&gpll3_out_main, regmap, &gpll3_config);
for (i = 0; i < ARRAY_SIZE(gcc_qcs404_hws); i++) {
ret = devm_clk_hw_register(&pdev->dev, gcc_qcs404_hws[i]);
if (ret)
return ret;
}
return qcom_cc_really_probe(pdev, &gcc_qcs404_desc, regmap); return qcom_cc_really_probe(pdev, &gcc_qcs404_desc, regmap);
} }
......
...@@ -2420,6 +2420,8 @@ static const struct qcom_cc_desc gcc_sdm660_desc = { ...@@ -2420,6 +2420,8 @@ static const struct qcom_cc_desc gcc_sdm660_desc = {
.num_resets = ARRAY_SIZE(gcc_sdm660_resets), .num_resets = ARRAY_SIZE(gcc_sdm660_resets),
.gdscs = gcc_sdm660_gdscs, .gdscs = gcc_sdm660_gdscs,
.num_gdscs = ARRAY_SIZE(gcc_sdm660_gdscs), .num_gdscs = ARRAY_SIZE(gcc_sdm660_gdscs),
.clk_hws = gcc_sdm660_hws,
.num_clk_hws = ARRAY_SIZE(gcc_sdm660_hws),
}; };
static const struct of_device_id gcc_sdm660_match_table[] = { static const struct of_device_id gcc_sdm660_match_table[] = {
...@@ -2431,7 +2433,7 @@ MODULE_DEVICE_TABLE(of, gcc_sdm660_match_table); ...@@ -2431,7 +2433,7 @@ MODULE_DEVICE_TABLE(of, gcc_sdm660_match_table);
static int gcc_sdm660_probe(struct platform_device *pdev) static int gcc_sdm660_probe(struct platform_device *pdev)
{ {
int i, ret; int ret;
struct regmap *regmap; struct regmap *regmap;
regmap = qcom_cc_map(pdev, &gcc_sdm660_desc); regmap = qcom_cc_map(pdev, &gcc_sdm660_desc);
...@@ -2446,13 +2448,6 @@ static int gcc_sdm660_probe(struct platform_device *pdev) ...@@ -2446,13 +2448,6 @@ static int gcc_sdm660_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
/* Register the hws */
for (i = 0; i < ARRAY_SIZE(gcc_sdm660_hws); i++) {
ret = devm_clk_hw_register(&pdev->dev, gcc_sdm660_hws[i]);
if (ret)
return ret;
}
return qcom_cc_really_probe(pdev, &gcc_sdm660_desc, regmap); return qcom_cc_really_probe(pdev, &gcc_sdm660_desc, regmap);
} }
......
...@@ -3347,6 +3347,8 @@ static const struct qcom_cc_desc mmcc_msm8996_desc = { ...@@ -3347,6 +3347,8 @@ static const struct qcom_cc_desc mmcc_msm8996_desc = {
.num_resets = ARRAY_SIZE(mmcc_msm8996_resets), .num_resets = ARRAY_SIZE(mmcc_msm8996_resets),
.gdscs = mmcc_msm8996_gdscs, .gdscs = mmcc_msm8996_gdscs,
.num_gdscs = ARRAY_SIZE(mmcc_msm8996_gdscs), .num_gdscs = ARRAY_SIZE(mmcc_msm8996_gdscs),
.clk_hws = mmcc_msm8996_hws,
.num_clk_hws = ARRAY_SIZE(mmcc_msm8996_hws),
}; };
static const struct of_device_id mmcc_msm8996_match_table[] = { static const struct of_device_id mmcc_msm8996_match_table[] = {
...@@ -3357,8 +3359,6 @@ MODULE_DEVICE_TABLE(of, mmcc_msm8996_match_table); ...@@ -3357,8 +3359,6 @@ MODULE_DEVICE_TABLE(of, mmcc_msm8996_match_table);
static int mmcc_msm8996_probe(struct platform_device *pdev) static int mmcc_msm8996_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev;
int i, ret;
struct regmap *regmap; struct regmap *regmap;
regmap = qcom_cc_map(pdev, &mmcc_msm8996_desc); regmap = qcom_cc_map(pdev, &mmcc_msm8996_desc);
...@@ -3370,12 +3370,6 @@ static int mmcc_msm8996_probe(struct platform_device *pdev) ...@@ -3370,12 +3370,6 @@ static int mmcc_msm8996_probe(struct platform_device *pdev)
/* Disable the NoC FSM for mmss_mmagic_cfg_ahb_clk */ /* Disable the NoC FSM for mmss_mmagic_cfg_ahb_clk */
regmap_update_bits(regmap, 0x5054, BIT(15), 0); regmap_update_bits(regmap, 0x5054, BIT(15), 0);
for (i = 0; i < ARRAY_SIZE(mmcc_msm8996_hws); i++) {
ret = devm_clk_hw_register(dev, mmcc_msm8996_hws[i]);
if (ret)
return ret;
}
return qcom_cc_really_probe(pdev, &mmcc_msm8996_desc, regmap); return qcom_cc_really_probe(pdev, &mmcc_msm8996_desc, regmap);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment