* [PATCH 1/2] clk: qcom: common: Add API to register board clocks backwards compatibly
@ 2015-10-27 1:20 Stephen Boyd
2015-10-27 1:20 ` [PATCH 2/2] clk: qcom: msm8960: Move cxo/pxo into dt files Stephen Boyd
2015-10-27 23:01 ` [PATCH 1/2] clk: qcom: common: Add API to register board clocks backwards compatibly Stephen Boyd
0 siblings, 2 replies; 3+ messages in thread
From: Stephen Boyd @ 2015-10-27 1:20 UTC (permalink / raw)
To: Mike Turquette, Stephen Boyd
Cc: linux-kernel, linux-clk, linux-arm-msm, Georgi Djakov
We want to put the XO board clocks into the dt files. Add an API
to do this generically. This also makes a place for us to handle
the case where the RPM driver is enabled or disabled.
Cc: Georgi Djakov <georgi.djakov@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
I'm also thinking that maybe we should register the board clock if it
isn't there in DT and then we'll either register the pass through or
we'll skip it depending on if the RPM driver is enabled. That
way the RPM driver doesn't need to know anything, just register the
clock with parent as the board clock.
drivers/clk/qcom/common.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
drivers/clk/qcom/common.h | 3 +++
2 files changed, 50 insertions(+)
diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c
index 8fa477293ae0..84d4d6fc0dec 100644
--- a/drivers/clk/qcom/common.c
+++ b/drivers/clk/qcom/common.c
@@ -88,6 +88,53 @@ static void qcom_cc_gdsc_unregister(void *data)
gdsc_unregister(data);
}
+int qcom_cc_register_board_clk(struct device *dev, const char *path,
+ const char *name, unsigned long rate)
+{
+ struct device_node *node = NULL;
+ struct device_node *clocks_node;
+ struct clk_fixed_factor *factor;
+ struct clk_fixed_rate *fixed;
+ struct clk_hw *hw;
+ struct clk_init_data init_data = { .name = name };
+
+ clocks_node = of_find_node_by_path("/clocks");
+ if (clocks_node)
+ node = of_find_node_by_name(clocks_node, path);
+ of_node_put(clocks_node);
+
+ if (node) {
+ factor = devm_kzalloc(dev, sizeof(*factor), GFP_KERNEL);
+ if (!factor)
+ return -EINVAL;
+
+ factor->mult = factor->div = 1;
+ factor->hw.init = &init_data;
+
+ init_data.parent_names = &path;
+ init_data.num_parents = 1;
+ init_data.ops = &clk_fixed_factor_ops;
+
+ hw = &factor->hw;
+ } else {
+ fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL);
+ if (!fixed)
+ return -EINVAL;
+
+ fixed->fixed_rate = rate;
+ fixed->hw.init = &init_data;
+
+ init_data.flags = CLK_IS_ROOT;
+ init_data.ops = &clk_fixed_rate_ops;
+
+ hw = &fixed->hw;
+ }
+ of_node_put(node);
+
+ return PTR_ERR_OR_ZERO(devm_clk_register(dev, hw));
+}
+EXPORT_SYMBOL(qcom_cc_register_board_clk);
+
int qcom_cc_really_probe(struct platform_device *pdev,
const struct qcom_cc_desc *desc, struct regmap *regmap)
{
diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h
index 7c1fba3ebc03..70e68a8d82a7 100644
--- a/drivers/clk/qcom/common.h
+++ b/drivers/clk/qcom/common.h
@@ -37,6 +37,9 @@ extern const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f,
extern int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map,
u8 src);
+extern int qcom_cc_register_board_clk(struct device *dev, const char *path,
+ const char *name, unsigned long rate);
+
extern struct regmap *qcom_cc_map(struct platform_device *pdev,
const struct qcom_cc_desc *desc);
extern int qcom_cc_really_probe(struct platform_device *pdev,
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] clk: qcom: msm8960: Move cxo/pxo into dt files
2015-10-27 1:20 [PATCH 1/2] clk: qcom: common: Add API to register board clocks backwards compatibly Stephen Boyd
@ 2015-10-27 1:20 ` Stephen Boyd
2015-10-27 23:01 ` [PATCH 1/2] clk: qcom: common: Add API to register board clocks backwards compatibly Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2015-10-27 1:20 UTC (permalink / raw)
To: Mike Turquette, Stephen Boyd
Cc: linux-kernel, linux-clk, linux-arm-msm, Georgi Djakov
Put the cxo and pxo clocks into the dt files as 'cxo_board' and
'pxo_board'. This provides a few benefits. It allows us to
specify the frequency of these clocks at the board level instead
of hard-coding them in the driver. It allows us to insert an RPM
clock in between the consumers of the crystals and the actual
clock if desired. And finally, it helps us transition the GCC
driver to use RPM clocks when the configuration is enabled.
Cc: Georgi Djakov <georgi.djakov@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
drivers/clk/qcom/gcc-msm8960.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/clk/qcom/gcc-msm8960.c b/drivers/clk/qcom/gcc-msm8960.c
index 66c18bc97857..6f11035bca93 100644
--- a/drivers/clk/qcom/gcc-msm8960.c
+++ b/drivers/clk/qcom/gcc-msm8960.c
@@ -3503,7 +3503,6 @@ MODULE_DEVICE_TABLE(of, gcc_msm8960_match_table);
static int gcc_msm8960_probe(struct platform_device *pdev)
{
- struct clk *clk;
struct device *dev = &pdev->dev;
const struct of_device_id *match;
struct platform_device *tsens;
@@ -3513,14 +3512,18 @@ static int gcc_msm8960_probe(struct platform_device *pdev)
if (!match)
return -EINVAL;
- /* Temporary until RPM clocks supported */
- clk = clk_register_fixed_rate(dev, "cxo", NULL, CLK_IS_ROOT, 19200000);
- if (IS_ERR(clk))
- return PTR_ERR(clk);
+ /*
+ * Backwards compatibility with old DTs. Register a pass-through
+ * factor 1/1 clock to translate cxo_board into cxo and pxo_board
+ * into pxo.
+ */
+ ret = qcom_cc_register_board_clk(dev, "cxo_board", "cxo", 19200000);
+ if (ret)
+ return ret;
- clk = clk_register_fixed_rate(dev, "pxo", NULL, CLK_IS_ROOT, 27000000);
- if (IS_ERR(clk))
- return PTR_ERR(clk);
+ ret = qcom_cc_register_board_clk(dev, "pxo_board", "pxo", 27000000);
+ if (ret)
+ return ret;
ret = qcom_cc_probe(pdev, match->data);
if (ret)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] clk: qcom: common: Add API to register board clocks backwards compatibly
2015-10-27 1:20 [PATCH 1/2] clk: qcom: common: Add API to register board clocks backwards compatibly Stephen Boyd
2015-10-27 1:20 ` [PATCH 2/2] clk: qcom: msm8960: Move cxo/pxo into dt files Stephen Boyd
@ 2015-10-27 23:01 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2015-10-27 23:01 UTC (permalink / raw)
To: Mike Turquette; +Cc: linux-kernel, linux-clk, linux-arm-msm, Georgi Djakov
On 10/26, Stephen Boyd wrote:
> We want to put the XO board clocks into the dt files. Add an API
> to do this generically. This also makes a place for us to handle
> the case where the RPM driver is enabled or disabled.
>
> Cc: Georgi Djakov <georgi.djakov@linaro.org>
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> ---
>
> I'm also thinking that maybe we should register the board clock if it
> isn't there in DT and then we'll either register the pass through or
> we'll skip it depending on if the RPM driver is enabled. That
> way the RPM driver doesn't need to know anything, just register the
> clock with parent as the board clock.
That seems like a better idea. v2 coming with that change and a
sleep_clk specific API, plus all the armv7 platforms converted.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-27 23:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-27 1:20 [PATCH 1/2] clk: qcom: common: Add API to register board clocks backwards compatibly Stephen Boyd
2015-10-27 1:20 ` [PATCH 2/2] clk: qcom: msm8960: Move cxo/pxo into dt files Stephen Boyd
2015-10-27 23:01 ` [PATCH 1/2] clk: qcom: common: Add API to register board clocks backwards compatibly Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).