|
8 | 8 | #include <linux/regmap.h>
|
9 | 9 | #include <linux/platform_device.h>
|
10 | 10 | #include <linux/clk-provider.h>
|
| 11 | +#include <linux/interconnect-clk.h> |
11 | 12 | #include <linux/reset-controller.h>
|
12 | 13 | #include <linux/of.h>
|
13 | 14 |
|
@@ -252,6 +253,38 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec,
|
252 | 253 | return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL;
|
253 | 254 | }
|
254 | 255 |
|
| 256 | +static int qcom_cc_icc_register(struct device *dev, |
| 257 | + const struct qcom_cc_desc *desc) |
| 258 | +{ |
| 259 | + struct icc_clk_data *icd; |
| 260 | + struct clk_hw *hws; |
| 261 | + int i; |
| 262 | + |
| 263 | + if (!IS_ENABLED(CONFIG_INTERCONNECT_CLK)) |
| 264 | + return 0; |
| 265 | + |
| 266 | + if (!desc->icc_hws) |
| 267 | + return 0; |
| 268 | + |
| 269 | + icd = devm_kcalloc(dev, desc->num_icc_hws, sizeof(*icd), GFP_KERNEL); |
| 270 | + if (!icd) |
| 271 | + return -ENOMEM; |
| 272 | + |
| 273 | + for (i = 0; i < desc->num_icc_hws; i++) { |
| 274 | + icd[i].master_id = desc->icc_hws[i].master_id; |
| 275 | + icd[i].slave_id = desc->icc_hws[i].slave_id; |
| 276 | + hws = &desc->clks[desc->icc_hws[i].clk_id]->hw; |
| 277 | + icd[i].clk = devm_clk_hw_get_clk(dev, hws, "icc"); |
| 278 | + if (!icd[i].clk) |
| 279 | + return dev_err_probe(dev, -ENOENT, |
| 280 | + "(%d) clock entry is null\n", i); |
| 281 | + icd[i].name = clk_hw_get_name(hws); |
| 282 | + } |
| 283 | + |
| 284 | + return devm_icc_clk_register(dev, desc->icc_first_node_id, |
| 285 | + desc->num_icc_hws, icd); |
| 286 | +} |
| 287 | + |
255 | 288 | int qcom_cc_really_probe(struct device *dev,
|
256 | 289 | const struct qcom_cc_desc *desc, struct regmap *regmap)
|
257 | 290 | {
|
@@ -320,7 +353,7 @@ int qcom_cc_really_probe(struct device *dev,
|
320 | 353 | if (ret)
|
321 | 354 | return ret;
|
322 | 355 |
|
323 |
| - return 0; |
| 356 | + return qcom_cc_icc_register(dev, desc); |
324 | 357 | }
|
325 | 358 | EXPORT_SYMBOL_GPL(qcom_cc_really_probe);
|
326 | 359 |
|
|
0 commit comments