Skip to content

Commit 8737ec8

Browse files
quic-varadaandersson
authored andcommitted
clk: qcom: common: Add interconnect clocks support
Unlike MSM platforms that manage NoC related clocks and scaling from RPM, IPQ SoCs dont involve RPM in managing NoC related clocks and there is no NoC scaling. However, there is a requirement to enable some NoC interface clocks for accessing the peripheral controllers present on these NoCs. Though exposing these as normal clocks would work, having a minimalistic interconnect driver to handle these clocks would make it consistent with other Qualcomm platforms resulting in common code paths. This is similar to msm8996-cbf's usage of icc-clk framework. Signed-off-by: Varadarajan Narayanan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent d315311 commit 8737ec8

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

drivers/clk/qcom/common.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/regmap.h>
99
#include <linux/platform_device.h>
1010
#include <linux/clk-provider.h>
11+
#include <linux/interconnect-clk.h>
1112
#include <linux/reset-controller.h>
1213
#include <linux/of.h>
1314

@@ -252,6 +253,38 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec,
252253
return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL;
253254
}
254255

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+
255288
int qcom_cc_really_probe(struct device *dev,
256289
const struct qcom_cc_desc *desc, struct regmap *regmap)
257290
{
@@ -320,7 +353,7 @@ int qcom_cc_really_probe(struct device *dev,
320353
if (ret)
321354
return ret;
322355

323-
return 0;
356+
return qcom_cc_icc_register(dev, desc);
324357
}
325358
EXPORT_SYMBOL_GPL(qcom_cc_really_probe);
326359

drivers/clk/qcom/common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ struct clk_hw;
1919
#define PLL_VOTE_FSM_ENA BIT(20)
2020
#define PLL_VOTE_FSM_RESET BIT(21)
2121

22+
struct qcom_icc_hws_data {
23+
int master_id;
24+
int slave_id;
25+
int clk_id;
26+
};
27+
2228
struct qcom_cc_desc {
2329
const struct regmap_config *config;
2430
struct clk_regmap **clks;
@@ -29,6 +35,9 @@ struct qcom_cc_desc {
2935
size_t num_gdscs;
3036
struct clk_hw **clk_hws;
3137
size_t num_clk_hws;
38+
struct qcom_icc_hws_data *icc_hws;
39+
size_t num_icc_hws;
40+
unsigned int icc_first_node_id;
3241
};
3342

3443
/**

0 commit comments

Comments
 (0)