clk: qcom: Support to add hardware clocks to of_clk_provider

Currently the hardware clocks are added from each clock controller
individually and are not added to the of_clk_provider. But there could be
clocks which are required by clients to be used. Add the hardware clocks to
the of_clk_provider list.

Change-Id: I9a36a52c77672fba13813656a58f7b8cc14a4c27
Signed-off-by: Taniya Das <tdas@codeaurora.org>
This commit is contained in:
Taniya Das 2016-09-12 15:40:49 +05:30
parent 4f983fd1aa
commit 55d4764dee
2 changed files with 26 additions and 7 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. * Copyright (c) 2013-2014, 2016, The Linux Foundation. All rights reserved.
* *
* This software is licensed under the terms of the GNU General Public * This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and * License version 2, as published by the Free Software Foundation, and
@ -177,7 +177,7 @@ EXPORT_SYMBOL_GPL(qcom_cc_register_sleep_clk);
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 = 0, ret, j = 0;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct clk *clk; struct clk *clk;
struct clk_onecell_data *data; struct clk_onecell_data *data;
@ -187,8 +187,10 @@ 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;
struct clk_hw **hw_clks = desc->hwclks;
cc = devm_kzalloc(dev, sizeof(*cc) + sizeof(*clks) * num_clks, cc = devm_kzalloc(dev, sizeof(*cc) + sizeof(*clks) *
(num_clks + desc->num_hwclks),
GFP_KERNEL); GFP_KERNEL);
if (!cc) if (!cc)
return -ENOMEM; return -ENOMEM;
@ -196,17 +198,32 @@ int qcom_cc_really_probe(struct platform_device *pdev,
clks = cc->clks; clks = cc->clks;
data = &cc->data; data = &cc->data;
data->clks = clks; data->clks = clks;
data->clk_num = num_clks; data->clk_num = num_clks + desc->num_hwclks;
for (i = 0; i < num_clks; i++) { for (i = 0; i < desc->num_hwclks; i++) {
if (!rclks[i]) { if (!hw_clks[i]) {
clks[i] = ERR_PTR(-ENOENT); clks[i] = ERR_PTR(-ENOENT);
continue; continue;
} }
clk = devm_clk_register_regmap(dev, rclks[i]); clk = devm_clk_register(dev, hw_clks[i]);
if (IS_ERR(clk)) if (IS_ERR(clk))
return PTR_ERR(clk); return PTR_ERR(clk);
clks[i] = clk; clks[i] = clk;
pr_debug("Index for hw_clocks %d added %s\n", i,
__clk_get_name(clk));
}
for (j = i; j < num_clks; j++) {
if (!rclks[j]) {
clks[j] = ERR_PTR(-ENOENT);
continue;
}
clk = devm_clk_register_regmap(dev, rclks[j]);
if (IS_ERR(clk))
return PTR_ERR(clk);
clks[j] = clk;
pr_debug("Index for Regmap clocks %d added %s\n", j,
__clk_get_name(clk));
} }
ret = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, data); ret = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, data);

View file

@ -25,7 +25,9 @@ struct parent_map;
struct qcom_cc_desc { struct qcom_cc_desc {
const struct regmap_config *config; const struct regmap_config *config;
struct clk_regmap **clks; struct clk_regmap **clks;
struct clk_hw **hwclks;
size_t num_clks; size_t num_clks;
size_t num_hwclks;
const struct qcom_reset_map *resets; const struct qcom_reset_map *resets;
size_t num_resets; size_t num_resets;
struct gdsc **gdscs; struct gdsc **gdscs;