devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: linux-kernel@vger.kernel.org, devicetree-discuss@lists.ozlabs.org
Cc: Mike Turquette <mturquette@ti.com>,
	Sascha Hauer <kernel@pengutronix.de>,
	Rob Herring <rob.herring@calxeda.com>,
	Shawn Guo <shawn.guo@freescale.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	Russell King <linux@arm.linux.org.uk>
Subject: [RFC v2 7/9] arm/dt: Common plat-versatile support for icst and sp804 based system clocks
Date: Mon, 12 Dec 2011 15:02:07 -0700	[thread overview]
Message-ID: <1323727329-4989-7-git-send-email-grant.likely@secretlab.ca> (raw)
In-Reply-To: <1323727329-4989-1-git-send-email-grant.likely@secretlab.ca>

Signed-off-by: <grant.likely@secretlab.ca>
Cc: Russell King <linux@arm.linux.org.uk>
---
 arch/arm/plat-versatile/clock.c              |  130 ++++++++++++++++++++++++++
 arch/arm/plat-versatile/include/plat/clock.h |    3 +
 2 files changed, 133 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-versatile/clock.c b/arch/arm/plat-versatile/clock.c
index 98a9dd8..2b0682a 100644
--- a/arch/arm/plat-versatile/clock.c
+++ b/arch/arm/plat-versatile/clock.c
@@ -13,9 +13,15 @@
 #include <linux/errno.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_clk.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 
 #include <asm/hardware/icst.h>
+#include <asm/hardware/timer-sp.h>
+#include <asm/mach/time.h>
 
 #include <mach/clkdev.h>
 
@@ -93,3 +99,127 @@ const struct clk_ops icst_clk_default_ops = {
 	.setvco	= icst_clk_setvco,
 };
 EXPORT_SYMBOL(icst_clk_default_ops);
+
+#ifdef CONFIG_OF
+static struct icst_params __initdata icst307_default_params = {
+	.vco_max = ICST307_VCO_MAX,
+	.vco_min = ICST307_VCO_MIN,
+	.s2div = icst307_s2div,
+	.idx2s = icst307_idx2s,
+};
+
+static struct icst_params __initdata icst525_5v_default_params = {
+	.vco_max = ICST525_VCO_MAX_5V,
+	.vco_min = ICST525_VCO_MIN,
+	.s2div = icst525_s2div,
+	.idx2s = icst525_idx2s,
+};
+
+static struct icst_params __initdata icst525_3v_default_params = {
+	.vco_max = ICST525_VCO_MAX_3V,
+	.vco_min = ICST525_VCO_MIN,
+	.s2div = icst525_s2div,
+	.idx2s = icst525_idx2s,
+};
+
+struct icst_of_clk {
+	struct clk clk;
+	struct clk ref;
+	struct icst_params params;
+};
+
+static struct clk *icst_clk_src_get(struct of_phandle_args *args, void *data)
+{
+	struct icst_of_clk *icst = data;
+	return &icst->clk;
+}
+
+struct of_device_id versatile_dt_icst_match[] __initdata = {
+	{ .compatible="idt,ics307", .data=&icst307_default_params, },
+	{ .compatible="idt,ics525-5v", .data=&icst525_5v_default_params, },
+	{ .compatible="idt,ics525-3.3v", .data=&icst525_3v_default_params, },
+	{ /* sentinel */ }
+};
+
+void __init versatile_dt_icst_clk_setup(struct device_node *np)
+{
+	const struct of_device_id *match;
+	struct icst_of_clk *icst;
+	const struct icst_params *params;
+	u32 ref, vd_range[2], rd_range[2], vco_offset, lock_offset;
+	__iomem void * base;
+
+	/*
+	 * Only try to drive clocks that we know how to control.
+	 * ie. attached to an ARM Versatile block of system registers
+	 */
+	if (!of_device_is_compatible(np->parent, "arm,versatile-sys-regs"))
+		return;
+
+	match = of_match_node(versatile_dt_icst_match, np);
+	if (!match)
+		return;
+	params = match->data;
+
+	icst = kzalloc(sizeof(*icst), GFP_KERNEL);
+	if (!icst)
+		return;
+	icst->params = *params; /* Copy the default params */
+
+	base = of_iomap(np->parent, 0);
+	if (!base || of_property_read_u32(np, "idt,ref-clock-freq", &ref) ||
+	    of_property_read_u32(np, "arm,reg-vco-offset", &vco_offset) ||
+	    of_property_read_u32(np, "arm,reg-lock-offset", &lock_offset) ||
+	    of_property_read_u32_array(np, "idt,vco-div-range", vd_range, 2) ||
+	    of_property_read_u32_array(np, "idt,ref-div-range", rd_range, 2)) {
+		pr_err("ERROR: Unable to set up clock %s\n", np->full_name);
+		goto err_setup;
+	}
+
+	icst->params.ref = ref;
+	icst->params.vd_min = vd_range[0];
+	icst->params.vd_max = vd_range[1];
+	icst->params.rd_min = rd_range[0];
+	icst->params.rd_max = rd_range[1];
+	icst->clk.ops = &icst_clk_default_ops;
+	icst->clk.vcoreg = base + vco_offset;
+	icst->clk.lockreg = base + lock_offset;
+	icst->clk.params = &icst->params;
+
+	icst->ref.rate = ref;
+
+	if (of_clk_add_provider(np, icst_clk_src_get, icst))
+		goto err_setup;
+
+	return;
+
+ err_setup:
+	kfree(icst);
+}
+
+static struct of_device_id versatile_dt_clk_match_table[] __initdata = {
+	{ .compatible = "idt,ics307", .data = versatile_dt_icst_clk_setup, },
+	{ .compatible = "idt,ics525", .data = versatile_dt_icst_clk_setup, },
+	{ .compatible = "fixed-clock", .data = of_fixed_clk_setup, },
+	{}
+};
+
+/*
+ * Set up timer interrupt, and return the current time in seconds.
+ */
+static void __init versatile_dt_timer_init(void)
+{
+	struct device_node *np;
+
+	of_clk_init(versatile_dt_clk_match_table);
+
+	pr_debug("%s(): Looking for sp804 clocks\n", __func__);
+	for_each_compatible_node(np, NULL, "arm,sp804")
+		sp804_dt_setup(np);
+}
+
+struct sys_timer versatile_dt_timer = {
+	.init		= versatile_dt_timer_init,
+};
+
+#endif
diff --git a/arch/arm/plat-versatile/include/plat/clock.h b/arch/arm/plat-versatile/include/plat/clock.h
index 5749f79..ca81bfe 100644
--- a/arch/arm/plat-versatile/include/plat/clock.h
+++ b/arch/arm/plat-versatile/include/plat/clock.h
@@ -42,5 +42,8 @@ static inline void __clk_put(struct clk *clk)
 #define __clk_put(clk) do { } while (0)
 #endif
 
+#ifdef CONFIG_OF
+extern struct sys_timer versatile_dt_timer;
+#endif
 
 #endif
-- 
1.7.5.4

  parent reply	other threads:[~2011-12-12 22:02 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-12 22:02 [RFC v2 1/9] arm/versatile*: merge all versatile struct clk definitions Grant Likely
     [not found] ` <1323727329-4989-1-git-send-email-grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
2011-12-12 22:02   ` [RFC v2 2/9] arm/versatile*: Consolidate clk_ops and setvco implementations Grant Likely
2011-12-12 22:02   ` [RFC v2 3/9] of: Add of_property_match_string() to find index into a string list Grant Likely
2011-12-12 22:02   ` [RFC v2 4/9] of: add clock providers Grant Likely
     [not found]     ` <1323727329-4989-4-git-send-email-grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
2011-12-12 23:29       ` Jamie Iles
2011-12-13 17:54         ` Grant Likely
2011-12-13 18:01           ` Rob Herring
2011-12-13 18:03             ` Grant Likely
2011-12-15 13:51           ` Shawn Guo
     [not found]             ` <20111215135129.GA2831-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2011-12-15 14:23               ` Rob Herring
2011-12-15 15:13                 ` Shawn Guo
     [not found]                   ` <20111215151335.GB2831-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2011-12-15 17:37                     ` Grant Likely
2012-01-10 21:33       ` Jamie Iles
2012-01-12  4:46         ` Grant Likely
2012-01-12 10:07           ` Jamie Iles
2012-01-12 18:44             ` Turquette, Mike
2012-01-12 19:16               ` Grant Likely
     [not found]           ` <CACxGe6vqb8AZcZb5WMvfmLsUZH7=SEtBrJCSfsFmDYpKX42MzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-13 12:47             ` Shawn Guo
2012-01-14  4:30               ` Turquette, Mike
2012-01-14  5:40                 ` Shawn Guo
2012-01-13 13:50       ` Shawn Guo
     [not found]         ` <20120113135036.GC17029-rvtDTF3kK1ictlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2012-01-13 14:05           ` Rob Herring
     [not found]             ` <4F103A21.1050403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-13 14:38               ` Shawn Guo
2012-01-17 20:44     ` Stephen Warren
2012-01-17 22:47       ` Grant Likely
2012-01-17 23:37         ` Turquette, Mike
     [not found]           ` <CAJOA=zMgGsZKGQ-EfSnXDY_WoFrzG6XPZtuxANFKqdL8CAaYrw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-17 23:49             ` Grant Likely
2012-01-18  0:05             ` Stephen Warren
2011-12-12 22:02   ` [RFC v2 6/9] arm/dt: add devicetree support to sp804 timer support Grant Likely
2011-12-12 23:54     ` Rob Herring
     [not found]       ` <4EE69446.2060009-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-13  0:29         ` Grant Likely
2011-12-12 22:02   ` [RFC v2 9/9] arm/highbank: Use clock binding common support code Grant Likely
2011-12-12 22:02 ` [RFC v2 5/9] dt/clock: Add handling for fixed clocks and a clock node setup iterator Grant Likely
     [not found]   ` <1323727329-4989-5-git-send-email-grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
2011-12-15 15:19     ` Shawn Guo
2011-12-12 22:02 ` Grant Likely [this message]
     [not found]   ` <1323727329-4989-7-git-send-email-grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
2012-01-17 21:05     ` [RFC v2 7/9] arm/dt: Common plat-versatile support for icst and sp804 based system clocks Stephen Warren
2012-01-17 22:02       ` Rob Herring
2012-01-17 22:59       ` Grant Likely
2011-12-12 22:02 ` [RFC v2 8/9] dt/arm: versatile add clock parsing Grant Likely

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=1323727329-4989-7-git-send-email-grant.likely@secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mturquette@ti.com \
    --cc=rob.herring@calxeda.com \
    --cc=shawn.guo@freescale.com \
    /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).