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: [RFC,PATCH 2/2] clk: Generic support for fixed-rate clocks
Date: Wed, 02 Jun 2010 19:56:44 +0800	[thread overview]
Message-ID: <1275479804.138392.188759209099.2.gpush@pororo> (raw)
In-Reply-To: <1275479804.137633.565764505843.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 |   13 +++++++++++++
 kernel/Makefile     |    1 +
 kernel/clk.c        |   25 +++++++++++++++++++++++++
 3 files changed, 39 insertions(+)

diff --git a/include/linux/clk.h b/include/linux/clk.h
index f70137a..009ca73 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -112,6 +112,19 @@ static inline struct clk *clk_get_parent(struct clk *clk)
 	return ERR_PTR(-ENOSYS);
 }
 
+/* Simple fixed-rate clock */
+struct clk_fixed {
+	struct clk	clk;
+	unsigned long	rate;
+};
+
+extern struct clk_operations clk_fixed_operations;
+
+#define DEFINE_CLK_FIXED(r) { \
+	.clk = DEFINE_CLK(clk_fixed_operations), \
+	.rate = (r) \
+}
+
 #else /* !CONFIG_USE_COMMON_STRUCT_CLK */
 
 /*
diff --git a/kernel/Makefile b/kernel/Makefile
index 057472f..1ae15aa 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -105,6 +105,7 @@ obj-$(CONFIG_PERF_EVENTS) += perf_event.o
 obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
 obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o
 obj-$(CONFIG_PADATA) += padata.o
+obj-$(CONFIG_USE_COMMON_STRUCT_CLK) += clk.o
 
 ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y)
 # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
diff --git a/kernel/clk.c b/kernel/clk.c
new file mode 100644
index 0000000..353736c
--- /dev/null
+++ b/kernel/clk.c
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2010 Canonical Ltd <jeremy.kerr@canonical.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Standard functionality for the common clock API.
+ */
+
+#include <linux/module.h>
+#include <linux/clk.h>
+
+#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_operations clk_fixed_operations = {
+	.get_rate = clk_fixed_get_rate,
+};
+
+EXPORT_SYMBOL_GPL(clk_fixed_operations);

  parent reply	other threads:[~2010-06-02 11:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-02 11:56 [RFC,PATCH 0/2] Common struct clk implementation, v3 Jeremy Kerr
2010-06-02 11:56 ` [RFC,PATCH 1/2] Add a common struct clk Jeremy Kerr
2010-06-02 12:03   ` Ben Dooks
2010-06-03  3:21     ` Jeremy Kerr
2010-06-03  8:13       ` Ben Dooks
2010-06-03 10:24         ` Jeremy Kerr
2010-06-03 11:05           ` Russell King - ARM Linux
2010-06-04  0:06             ` Ben Dooks
2010-06-04  1:43               ` Jeremy Kerr
2010-06-04  1:40             ` Jeremy Kerr
2010-06-03 21:09         ` Ryan Mallon
2010-06-03 23:45           ` Ben Dooks
2010-06-02 11:56 ` Jeremy Kerr [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-06-04  7:30 [RFC,PATCH 0/2] Common struct clk implementation, v4 Jeremy Kerr
2010-06-04  7:30 ` [RFC,PATCH 2/2] clk: Generic support for fixed-rate clocks 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=1275479804.138392.188759209099.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