Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: jeremy.kerr@canonical.com (Jeremy Kerr)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] clk: Generic support for fixed-rate clocks
Date: Wed, 05 Jan 2011 11:51:02 +0800	[thread overview]
Message-ID: <1294199462.348743.574566157747.2.gpush@pororo> (raw)
In-Reply-To: <1294199462.347935.472473715866.0.gpush@pororo>

Since most platforms will need a fixed-rate clock, add one. This will
also serve as a basic example of an implementation of struct clk.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 include/linux/clk.h |   16 ++++++++++++++++
 kernel/clk.c        |   14 ++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/include/linux/clk.h b/include/linux/clk.h
index 95c49b1..6cef9fe 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -164,6 +164,22 @@ static inline void clk_common_init(struct clk *clk)
 		mutex_init(&clk->lock.mutex);
 }
 
+/* Simple fixed-rate clock */
+struct clk_fixed {
+	struct clk	clk;
+	unsigned long	rate;
+};
+
+extern struct clk_ops clk_fixed_ops;
+
+#define INIT_CLK_FIXED(name, r) { \
+	.clk = INIT_CLK(name.clk, clk_fixed_ops), \
+	.rate = (r) \
+}
+
+#define DEFINE_CLK_FIXED(name, r) \
+	struct clk_fixed name = INIT_CLK_FIXED(name, r)
+
 #else /* !CONFIG_USE_COMMON_STRUCT_CLK */
 
 /*
diff --git a/kernel/clk.c b/kernel/clk.c
index 8de8fe3..6c38cc0 100644
--- a/kernel/clk.c
+++ b/kernel/clk.c
@@ -100,3 +100,17 @@ struct clk *clk_get_parent(struct clk *clk)
 	return ERR_PTR(-ENOSYS);
 }
 EXPORT_SYMBOL_GPL(clk_get_parent);
+
+/* clk_fixed support */
+
+#define to_clk_fixed(clk) (container_of(clk, struct clk_fixed, clk))
+
+static unsigned long clk_fixed_get_rate(struct clk *clk)
+{
+	return to_clk_fixed(clk)->rate;
+}
+
+struct clk_ops clk_fixed_ops = {
+	.get_rate = clk_fixed_get_rate,
+};
+EXPORT_SYMBOL_GPL(clk_fixed_ops);

  reply	other threads:[~2011-01-05  3:51 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-05  3:51 [PATCH 0/2] Common struct clk implementation, v10 Jeremy Kerr
2011-01-05  3:51 ` Jeremy Kerr [this message]
2011-01-05  3:51 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2011-01-06 16:07   ` Richard Cochran
2011-01-06 20:11     ` Uwe Kleine-König
2011-01-07  0:10       ` Jeremy Kerr
2011-01-07  0:32         ` Russell King - ARM Linux
2011-01-07  9:40           ` Uwe Kleine-König
2011-01-08 13:15   ` Sascha Hauer
2011-01-10  2:43     ` Jeremy Kerr
2011-01-10 10:41       ` Sascha Hauer
2011-01-10 11:00         ` Russell King - ARM Linux
2011-01-11  0:54           ` Jeremy Kerr
2011-01-16  7:26             ` Grant Likely
2011-01-16 20:41               ` Ryan Mallon
2011-01-16 21:07                 ` Uwe Kleine-König
2011-01-16 21:39                   ` Ryan Mallon
2011-01-11 10:16   ` Sascha Hauer
2011-01-11 10:27     ` Jeremy Kerr
2011-01-11 11:22       ` Sascha Hauer
2011-01-18  8:44         ` Paul Mundt
2011-01-18  9:21           ` Sascha Hauer
2011-01-18  9:23             ` Paul Mundt
2011-01-18 12:21   ` Russell King - ARM Linux
2011-01-05  3:55 ` [PATCH 0/2] Common struct clk implementation, v10 Jeremy Kerr
2011-01-07  1:33 ` Ben Dooks
2011-01-07  9:49   ` Uwe Kleine-König
  -- strict thread matches above, loose matches on Subject: below --
2011-03-03  6:40 [PATCH 0/2] Common struct clk implementation, v14 Jeremy Kerr
2011-03-03  6:40 ` [PATCH 2/2] clk: Generic support for fixed-rate clocks Jeremy Kerr
2011-02-21  2:50 [PATCH 0/2] Common struct clk implementation, v13 Jeremy Kerr
2011-02-21  2:50 ` [PATCH 2/2] clk: Generic support for fixed-rate clocks Jeremy Kerr
2011-02-21 19:51   ` Ryan Mallon
2011-02-21 23:29     ` Jeremy Kerr
2011-01-05  3:18 [PATCH 0/2] Common struct clk implementation, v10 Jeremy Kerr
2011-01-05  3:18 ` [PATCH 2/2] clk: Generic support for fixed-rate clocks Jeremy Kerr
2010-12-08  2:08 [PATCH 0/2] Common struct clk implementation, v8 Jeremy Kerr
2010-12-08  2:08 ` [PATCH 2/2] clk: Generic support for fixed-rate clocks Jeremy Kerr
2010-12-13 12:14   ` Sascha Hauer
2010-12-13 12:35     ` Jeremy Kerr
2010-12-13 12:42       ` Sascha Hauer
2010-12-08  2:05 [PATCH 1/2] Add a common struct clk Jeremy Kerr
2010-12-08  2:05 ` [PATCH 2/2] clk: Generic support for fixed-rate clocks Jeremy Kerr
2010-07-12  2:37 [PATCH 0/2] Common struct clk implementation, v6 Jeremy Kerr
2010-07-12  2:37 ` [PATCH 2/2] clk: Generic support for fixed-rate clocks Jeremy Kerr
2010-06-21  5:35 [PATCH 0/2] Common struct clk implementation, v5 Jeremy Kerr
2010-06-21  5:35 ` [PATCH 2/2] clk: Generic support for fixed-rate clocks Jeremy Kerr
2010-06-21 20:43   ` Ryan Mallon
2010-06-22  1:05     ` Jeremy Kerr

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=1294199462.348743.574566157747.2.gpush@pororo \
    --to=jeremy.kerr@canonical.com \
    --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