From: Paul Walmsley <paul@pwsan.com>
To: linux-omap@vger.kernel.org
Cc: Paul Walmsley <paul@pwsan.com>
Subject: [PATCH 1/2] OMAP clock: add clk_round_rate_parent (with OMAP2/3 implementation)
Date: Wed, 25 Mar 2009 10:09:21 -0600 [thread overview]
Message-ID: <20090325160920.31866.22103.stgit@localhost.localdomain> (raw)
In-Reply-To: <20090325160759.31866.49722.stgit@localhost.localdomain>
This patch adds clk_round_rate_parent(), a means for internal clock
code to determine what a clock's rate would be if its parent changed.
This is needed by the pre-change clock notifier, which passes the
current clock rate and the desired clock rate to its callbacks.
An implementation is provided for the OMAP2/3 architecture
(omap2_clk_round_rate_parent)..
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
arch/arm/mach-omap2/clock.c | 30 ++++++++++++++++++++++++++++++
arch/arm/mach-omap2/clock.h | 1 +
arch/arm/mach-omap2/clock24xx.c | 1 +
arch/arm/mach-omap2/clock34xx.c | 1 +
arch/arm/plat-omap/include/mach/clock.h | 2 ++
5 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 41662fd..65391ba 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -871,6 +871,36 @@ struct clk *omap2_clk_get_parent(struct clk *clk)
return clk->parent;
}
+/**
+ * omap2_clk_round_rate_parent - return the rate for @clk if parent were changed
+ * @clk: struct clk that may change parents
+ * @new_parent: the struct clk that @clk may be reparented under
+ *
+ * Given a struct clk @clk and a new parent struct clk @new_parent,
+ * determine what @clk's rate would be after the reparent operation.
+ * Returns the new clock rate or -EINVAL upon error.
+ */
+long omap2_clk_round_rate_parent(struct clk *clk, struct clk *new_parent)
+{
+ u32 field_val, parent_div;
+ long rate;
+
+ if (!clk->clksel || !new_parent)
+ return -EINVAL;
+
+ parent_div = _omap2_clksel_get_src_field(new_parent, clk, &field_val);
+ if (!parent_div)
+ return -EINVAL;
+
+ /* CLKSEL clocks follow their parents' rates, divided by a divisor */
+ rate = new_parent->rate;
+ if (parent_div > 0)
+ rate /= parent_div;
+
+ return rate;
+}
+
+
/* DPLL rate rounding code */
/**
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index f4d489f..af350ed 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -41,6 +41,7 @@ int omap2_clk_register(struct clk *clk);
int omap2_clk_enable(struct clk *clk);
void omap2_clk_disable(struct clk *clk);
long omap2_clk_round_rate(struct clk *clk, unsigned long rate);
+long omap2_clk_round_rate_parent(struct clk *clk, struct clk *new_parent);
int omap2_clk_set_rate(struct clk *clk, unsigned long rate);
int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent);
int omap2_dpll_set_rate_tolerance(struct clk *clk, unsigned int tolerance);
diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
index 53864c0..3f75524 100644
--- a/arch/arm/mach-omap2/clock24xx.c
+++ b/arch/arm/mach-omap2/clock24xx.c
@@ -448,6 +448,7 @@ static struct clk_functions omap2_clk_functions = {
.clk_enable = omap2_clk_enable,
.clk_disable = omap2_clk_disable,
.clk_round_rate = omap2_clk_round_rate,
+ .clk_round_rate_parent = omap2_clk_round_rate_parent,
.clk_set_rate = omap2_clk_set_rate,
.clk_set_parent = omap2_clk_set_parent,
.clk_get_parent = omap2_clk_get_parent,
diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
index f7ac5c1..12ff39f 100644
--- a/arch/arm/mach-omap2/clock34xx.c
+++ b/arch/arm/mach-omap2/clock34xx.c
@@ -635,6 +635,7 @@ static struct clk_functions omap2_clk_functions = {
.clk_enable = omap2_clk_enable,
.clk_disable = omap2_clk_disable,
.clk_round_rate = omap2_clk_round_rate,
+ .clk_round_rate_parent = omap2_clk_round_rate_parent,
.clk_set_rate = omap2_clk_set_rate,
.clk_set_parent = omap2_clk_set_parent,
.clk_get_parent = omap2_clk_get_parent,
diff --git a/arch/arm/plat-omap/include/mach/clock.h b/arch/arm/plat-omap/include/mach/clock.h
index db57b71..89a2662 100644
--- a/arch/arm/plat-omap/include/mach/clock.h
+++ b/arch/arm/plat-omap/include/mach/clock.h
@@ -121,6 +121,8 @@ struct clk_functions {
int (*clk_enable)(struct clk *clk);
void (*clk_disable)(struct clk *clk);
long (*clk_round_rate)(struct clk *clk, unsigned long rate);
+ long (*clk_round_rate_parent)(struct clk *clk,
+ struct clk *parent);
int (*clk_set_rate)(struct clk *clk, unsigned long rate);
int (*clk_set_parent)(struct clk *clk, struct clk *parent);
struct clk * (*clk_get_parent)(struct clk *clk);
next prev parent reply other threads:[~2009-03-25 16:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-25 16:09 [PATCH 0/2] OMAP clock: implement clock rate/parent change notifiers Paul Walmsley
2009-03-25 16:09 ` Paul Walmsley [this message]
2009-03-25 16:09 ` [PATCH 2/2] OMAP2/3 " Paul Walmsley
2009-03-25 17:54 ` [PATCH 0/2] OMAP " Kevin Hilman
2011-08-14 7:39 ` Felipe Contreras
2011-12-08 19:26 ` Paul Walmsley
2011-12-08 19:56 ` Felipe Contreras
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=20090325160920.31866.22103.stgit@localhost.localdomain \
--to=paul@pwsan.com \
--cc=linux-omap@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.