linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mturquette@linaro.org (Mike Turquette)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/3] clk: sunxi: Unify oscillator clock
Date: Wed, 10 Apr 2013 15:02:57 -0700	[thread overview]
Message-ID: <1365631378-16103-4-git-send-email-mturquette@linaro.org> (raw)
In-Reply-To: <1365631378-16103-1-git-send-email-mturquette@linaro.org>

From: Emilio L?pez <emilio@elopez.com.ar>

This commit uses the new fixed-rate support on the composite clock to
unify osc24M_fixed and osc24M clocks, so it matches the actual hardware.

Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
[mturquette at linaro.org: replace clk_register_gatable_osc with a call to
clk_register_composite]
---
Emilio,

I haven't been able to test these changes at run-time.  Can you see if
they are valid for solving your issue on sunxi?

 drivers/clk/sunxi/clk-sunxi.c |   33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 0bb0eb4..8492ad1 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -33,16 +33,36 @@ static DEFINE_SPINLOCK(clk_lock);
 static void __init sunxi_osc_clk_setup(struct device_node *node)
 {
 	struct clk *clk;
+	struct clk_fixed_rate *fixed;
+	struct clk_gate *gate;
 	const char *clk_name = node->name;
-	const char *parent;
-	void *reg;
+	u32 rate;
 
-	reg = of_iomap(node, 0);
+	/* allocate fixed-rate and gate clock structs */
+	fixed = kzalloc(sizeof(struct clk_fixed_rate), GFP_KERNEL);
+	if (!fixed)
+		return;
+	gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL);
+	if (!gate) {
+		kfree(fixed);
+		return;
+	}
 
-	parent = of_clk_get_parent_name(node, 0);
+	if (of_property_read_u32(node, "clock-frequency", &rate))
+		return;
+
+	/* set up gate and fixed rate properties */
+	gate->reg = of_iomap(node, 0);
+	gate->bit_idx = SUNXI_OSC24M_GATE;
+	gate->lock = &clk_lock;
+	fixed->fixed_rate = rate;
 
-	clk = clk_register_gate(NULL, clk_name, parent, 0, reg,
-				SUNXI_OSC24M_GATE, 0, &clk_lock);
+	clk = clk_register_composite(NULL, clk_name,
+			NULL, 0,
+			NULL, NULL,
+			&fixed->hw, &clk_fixed_rate_ops,
+			&gate->hw, &clk_gate_ops,
+			CLK_IS_ROOT);
 
 	if (clk) {
 		of_clk_add_provider(node, of_clk_src_simple_get, clk);
@@ -380,7 +400,6 @@ static void __init sunxi_gates_clk_setup(struct device_node *node,
 
 /* Matches for of_clk_init */
 static const __initconst struct of_device_id clk_match[] = {
-	{.compatible = "fixed-clock", .data = of_fixed_clk_setup,},
 	{.compatible = "allwinner,sun4i-osc-clk", .data = sunxi_osc_clk_setup,},
 	{}
 };
-- 
1.7.10.4

  parent reply	other threads:[~2013-04-10 22:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-09 13:48 [PATCH 0/3] sunxi: unify main oscillator and its gate Emilio López
2013-04-09 13:48 ` [PATCH 1/3] clk: composite: Add fixed-rate support Emilio López
2013-04-09 15:41   ` Gregory CLEMENT
2013-04-09 16:04     ` Emilio López
2013-04-10 22:02   ` [PATCH 0/3] fixed-rate and fixed-factor clocks in composite clock Mike Turquette
2013-04-10 22:02     ` [PATCH 1/3] clk: composite: rename 'div' references to 'rate' Mike Turquette
2013-04-11 11:40       ` Prashant Gaikwad
2013-04-11 17:56         ` Mike Turquette
2013-04-10 22:02     ` [PATCH 2/3] clk: composite: allow fixed rates & fixed dividers Mike Turquette
2013-04-11 11:47       ` Prashant Gaikwad
2013-04-11 17:56         ` Mike Turquette
2013-04-10 22:02     ` Mike Turquette [this message]
2013-04-11  0:07       ` [PATCH v2 3/3] clk: sunxi: Unify oscillator clock Emilio López
2013-04-12 18:40         ` Mike Turquette
2013-04-11 18:31     ` [PATCH v2 1/2] clk: composite: rename 'div' references to 'rate' Mike Turquette
2013-04-11 18:31       ` [PATCH v2 2/2] clk: composite: allow fixed rates & fixed dividers Mike Turquette
2013-04-09 13:48 ` [PATCH 2/3] clk: sunxi: Unify oscillator clock Emilio López
2013-04-09 13:48 ` [PATCH 3/3] ARM: sunxi: unify osc24M_fixed and osc24M Emilio López
2013-04-15  8:45   ` Maxime Ripard
2013-04-09 14:56 ` [PATCH 0/3] sunxi: unify main oscillator and its gate Gregory CLEMENT
2013-04-09 15:04   ` Emilio López

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1365631378-16103-4-git-send-email-mturquette@linaro.org \
    --to=mturquette@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).