Commit 120c1552 authored by Stephen Boyd's avatar Stephen Boyd Committed by Stephen Boyd

clk: qcom: Migrate to clk_hw based registration and OF APIs

Now that we have clk_hw based provider APIs to register clks, we
can get rid of struct clk pointers in this driver, allowing us to
move closer to a clear split of consumer and provider clk APIs.
Signed-off-by: default avatarStephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent cc671d13
...@@ -101,14 +101,13 @@ EXPORT_SYMBOL_GPL(clk_disable_regmap); ...@@ -101,14 +101,13 @@ EXPORT_SYMBOL_GPL(clk_disable_regmap);
* clk_regmap struct via this function so that the regmap is initialized * clk_regmap struct via this function so that the regmap is initialized
* and so that the clock is registered with the common clock framework. * and so that the clock is registered with the common clock framework.
*/ */
struct clk *devm_clk_register_regmap(struct device *dev, int devm_clk_register_regmap(struct device *dev, struct clk_regmap *rclk)
struct clk_regmap *rclk)
{ {
if (dev && dev_get_regmap(dev, NULL)) if (dev && dev_get_regmap(dev, NULL))
rclk->regmap = dev_get_regmap(dev, NULL); rclk->regmap = dev_get_regmap(dev, NULL);
else if (dev && dev->parent) else if (dev && dev->parent)
rclk->regmap = dev_get_regmap(dev->parent, NULL); rclk->regmap = dev_get_regmap(dev->parent, NULL);
return devm_clk_register(dev, &rclk->hw); return devm_clk_hw_register(dev, &rclk->hw);
} }
EXPORT_SYMBOL_GPL(devm_clk_register_regmap); EXPORT_SYMBOL_GPL(devm_clk_register_regmap);
...@@ -39,7 +39,6 @@ struct clk_regmap { ...@@ -39,7 +39,6 @@ struct clk_regmap {
int clk_is_enabled_regmap(struct clk_hw *hw); int clk_is_enabled_regmap(struct clk_hw *hw);
int clk_enable_regmap(struct clk_hw *hw); int clk_enable_regmap(struct clk_hw *hw);
void clk_disable_regmap(struct clk_hw *hw); void clk_disable_regmap(struct clk_hw *hw);
struct clk * int devm_clk_register_regmap(struct device *dev, struct clk_regmap *rclk);
devm_clk_register_regmap(struct device *dev, struct clk_regmap *rclk);
#endif #endif
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
struct qcom_cc { struct qcom_cc {
struct qcom_reset_controller reset; struct qcom_reset_controller reset;
struct clk_onecell_data data; struct clk_regmap **rclks;
struct clk *clks[]; size_t num_rclks;
}; };
const const
...@@ -102,8 +102,8 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path, ...@@ -102,8 +102,8 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
struct device_node *clocks_node; struct device_node *clocks_node;
struct clk_fixed_factor *factor; struct clk_fixed_factor *factor;
struct clk_fixed_rate *fixed; struct clk_fixed_rate *fixed;
struct clk *clk;
struct clk_init_data init_data = { }; struct clk_init_data init_data = { };
int ret;
clocks_node = of_find_node_by_path("/clocks"); clocks_node = of_find_node_by_path("/clocks");
if (clocks_node) if (clocks_node)
...@@ -121,9 +121,9 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path, ...@@ -121,9 +121,9 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
init_data.name = path; init_data.name = path;
init_data.ops = &clk_fixed_rate_ops; init_data.ops = &clk_fixed_rate_ops;
clk = devm_clk_register(dev, &fixed->hw); ret = devm_clk_hw_register(dev, &fixed->hw);
if (IS_ERR(clk)) if (ret)
return PTR_ERR(clk); return ret;
} }
of_node_put(node); of_node_put(node);
...@@ -141,9 +141,9 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path, ...@@ -141,9 +141,9 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
init_data.flags = 0; init_data.flags = 0;
init_data.ops = &clk_fixed_factor_ops; init_data.ops = &clk_fixed_factor_ops;
clk = devm_clk_register(dev, &factor->hw); ret = devm_clk_hw_register(dev, &factor->hw);
if (IS_ERR(clk)) if (ret)
return PTR_ERR(clk); return ret;
} }
return 0; return 0;
...@@ -174,42 +174,48 @@ int qcom_cc_register_sleep_clk(struct device *dev) ...@@ -174,42 +174,48 @@ int qcom_cc_register_sleep_clk(struct device *dev)
} }
EXPORT_SYMBOL_GPL(qcom_cc_register_sleep_clk); EXPORT_SYMBOL_GPL(qcom_cc_register_sleep_clk);
static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec,
void *data)
{
struct qcom_cc *cc = data;
unsigned int idx = clkspec->args[0];
if (idx >= cc->num_rclks) {
pr_err("%s: invalid index %u\n", __func__, idx);
return ERR_PTR(-EINVAL);
}
return cc->rclks[idx] ? &cc->rclks[idx]->hw : ERR_PTR(-ENOENT);
}
int qcom_cc_really_probe(struct platform_device *pdev, int qcom_cc_really_probe(struct platform_device *pdev,
const struct qcom_cc_desc *desc, struct regmap *regmap) const struct qcom_cc_desc *desc, struct regmap *regmap)
{ {
int i, ret; int i, ret;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct clk *clk;
struct clk_onecell_data *data;
struct clk **clks;
struct qcom_reset_controller *reset; struct qcom_reset_controller *reset;
struct qcom_cc *cc; struct qcom_cc *cc;
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;
cc = devm_kzalloc(dev, sizeof(*cc) + sizeof(*clks) * num_clks, cc = devm_kzalloc(dev, sizeof(*cc), GFP_KERNEL);
GFP_KERNEL);
if (!cc) if (!cc)
return -ENOMEM; return -ENOMEM;
clks = cc->clks; cc->rclks = rclks;
data = &cc->data; cc->num_rclks = num_clks;
data->clks = clks;
data->clk_num = num_clks;
for (i = 0; i < num_clks; i++) { for (i = 0; i < num_clks; i++) {
if (!rclks[i]) { if (!rclks[i])
clks[i] = ERR_PTR(-ENOENT);
continue; continue;
}
clk = devm_clk_register_regmap(dev, rclks[i]); ret = devm_clk_register_regmap(dev, rclks[i]);
if (IS_ERR(clk)) if (ret)
return PTR_ERR(clk); return ret;
clks[i] = clk;
} }
ret = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, data); ret = of_clk_add_hw_provider(dev->of_node, qcom_cc_clk_hw_get, cc);
if (ret) if (ret)
return ret; return ret;
......
...@@ -1686,7 +1686,7 @@ static int gcc_mdm9615_probe(struct platform_device *pdev) ...@@ -1686,7 +1686,7 @@ static int gcc_mdm9615_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct regmap *regmap; struct regmap *regmap;
struct clk *clk; int ret;
int i; int i;
regmap = qcom_cc_map(pdev, &gcc_mdm9615_desc); regmap = qcom_cc_map(pdev, &gcc_mdm9615_desc);
...@@ -1694,9 +1694,9 @@ static int gcc_mdm9615_probe(struct platform_device *pdev) ...@@ -1694,9 +1694,9 @@ static int gcc_mdm9615_probe(struct platform_device *pdev)
return PTR_ERR(regmap); return PTR_ERR(regmap);
for (i = 0; i < ARRAY_SIZE(gcc_mdm9615_hws); i++) { for (i = 0; i < ARRAY_SIZE(gcc_mdm9615_hws); i++) {
clk = devm_clk_register(dev, gcc_mdm9615_hws[i]); ret = devm_clk_hw_register(dev, gcc_mdm9615_hws[i]);
if (IS_ERR(clk)) if (ret)
return PTR_ERR(clk); return ret;
} }
return qcom_cc_really_probe(pdev, &gcc_mdm9615_desc, regmap); return qcom_cc_really_probe(pdev, &gcc_mdm9615_desc, regmap);
......
...@@ -3447,9 +3447,8 @@ MODULE_DEVICE_TABLE(of, gcc_msm8996_match_table); ...@@ -3447,9 +3447,8 @@ 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 clk *clk;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int i; 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);
...@@ -3463,9 +3462,9 @@ static int gcc_msm8996_probe(struct platform_device *pdev) ...@@ -3463,9 +3462,9 @@ 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++) { for (i = 0; i < ARRAY_SIZE(gcc_msm8996_hws); i++) {
clk = devm_clk_register(dev, gcc_msm8996_hws[i]); ret = devm_clk_hw_register(dev, gcc_msm8996_hws[i]);
if (IS_ERR(clk)) if (ret)
return PTR_ERR(clk); return ret;
} }
return qcom_cc_really_probe(pdev, &gcc_msm8996_desc, regmap); return qcom_cc_really_probe(pdev, &gcc_msm8996_desc, regmap);
......
...@@ -3314,9 +3314,8 @@ MODULE_DEVICE_TABLE(of, mmcc_msm8996_match_table); ...@@ -3314,9 +3314,8 @@ 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 clk *clk;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int i; 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);
...@@ -3329,9 +3328,9 @@ static int mmcc_msm8996_probe(struct platform_device *pdev) ...@@ -3329,9 +3328,9 @@ static int mmcc_msm8996_probe(struct platform_device *pdev)
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++) { for (i = 0; i < ARRAY_SIZE(mmcc_msm8996_hws); i++) {
clk = devm_clk_register(dev, mmcc_msm8996_hws[i]); ret = devm_clk_hw_register(dev, mmcc_msm8996_hws[i]);
if (IS_ERR(clk)) if (ret)
return PTR_ERR(clk); 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