aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh
diff options
context:
space:
mode:
authorFrancesco VIRLINZI <francesco.virlinzi@st.com>2009-03-11 03:40:54 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-03-11 04:18:46 -0400
commitd680c76eccd9222031ee30dcee5fdedba2467610 (patch)
treecfde726fe9c9193c07c768cb2144cb1eb4f1f1f8 /arch/sh
parent47a72688fae7298e1ad5fdc9bff7e04b6a549620 (diff)
sh: clkfwk: add clk_set_parent/clk_get_parent
This patch adds the clk_set_parent/clk_get_parent routines to the sh clock framework. Signed-off-by: Francesco Virlinzi <francesco.virlinzi@st.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r--arch/sh/include/asm/clock.h1
-rw-r--r--arch/sh/kernel/cpu/clock.c29
2 files changed, 30 insertions, 0 deletions
diff --git a/arch/sh/include/asm/clock.h b/arch/sh/include/asm/clock.h
index f9c88583d90a..2f6c9627bc1f 100644
--- a/arch/sh/include/asm/clock.h
+++ b/arch/sh/include/asm/clock.h
@@ -15,6 +15,7 @@ struct clk_ops {
15 void (*disable)(struct clk *clk); 15 void (*disable)(struct clk *clk);
16 void (*recalc)(struct clk *clk); 16 void (*recalc)(struct clk *clk);
17 int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id); 17 int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
18 int (*set_parent)(struct clk *clk, struct clk *parent);
18 long (*round_rate)(struct clk *clk, unsigned long rate); 19 long (*round_rate)(struct clk *clk, unsigned long rate);
19}; 20};
20 21
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 7b17137536d6..332a1798547c 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -239,6 +239,35 @@ void clk_recalc_rate(struct clk *clk)
239} 239}
240EXPORT_SYMBOL_GPL(clk_recalc_rate); 240EXPORT_SYMBOL_GPL(clk_recalc_rate);
241 241
242int clk_set_parent(struct clk *clk, struct clk *parent)
243{
244 int ret = -EINVAL;
245 struct clk *old;
246
247 if (!parent || !clk)
248 return ret;
249
250 old = clk->parent;
251 if (likely(clk->ops && clk->ops->set_parent)) {
252 unsigned long flags;
253 spin_lock_irqsave(&clock_lock, flags);
254 ret = clk->ops->set_parent(clk, parent);
255 spin_unlock_irqrestore(&clock_lock, flags);
256 clk->parent = (ret ? old : parent);
257 }
258
259 if (unlikely(clk->flags & CLK_RATE_PROPAGATES))
260 propagate_rate(clk);
261 return ret;
262}
263EXPORT_SYMBOL_GPL(clk_set_parent);
264
265struct clk *clk_get_parent(struct clk *clk)
266{
267 return clk->parent;
268}
269EXPORT_SYMBOL_GPL(clk_get_parent);
270
242long clk_round_rate(struct clk *clk, unsigned long rate) 271long clk_round_rate(struct clk *clk, unsigned long rate)
243{ 272{
244 if (likely(clk->ops && clk->ops->round_rate)) { 273 if (likely(clk->ops && clk->ops->round_rate)) {