]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
sh: clkfwk: add clk_set_parent/clk_get_parent
authorFrancesco VIRLINZI <francesco.virlinzi@st.com>
Wed, 11 Mar 2009 07:40:54 +0000 (07:40 +0000)
committerPaul Mundt <lethal@linux-sh.org>
Wed, 11 Mar 2009 08:18:46 +0000 (17:18 +0900)
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>
arch/sh/include/asm/clock.h
arch/sh/kernel/cpu/clock.c

index f9c88583d90aba3395c2a520ed05662056231269..2f6c9627bc1f81c6dcbc041ee003b47010ae8f21 100644 (file)
@@ -15,6 +15,7 @@ struct clk_ops {
        void (*disable)(struct clk *clk);
        void (*recalc)(struct clk *clk);
        int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
+       int (*set_parent)(struct clk *clk, struct clk *parent);
        long (*round_rate)(struct clk *clk, unsigned long rate);
 };
 
index 7b17137536d622c3909e7ee8f6cac6ac78bb56c3..332a1798547c9d92ed4ea7631effb1cfb81b26d0 100644 (file)
@@ -239,6 +239,35 @@ void clk_recalc_rate(struct clk *clk)
 }
 EXPORT_SYMBOL_GPL(clk_recalc_rate);
 
+int clk_set_parent(struct clk *clk, struct clk *parent)
+{
+       int ret = -EINVAL;
+       struct clk *old;
+
+       if (!parent || !clk)
+               return ret;
+
+       old = clk->parent;
+       if (likely(clk->ops && clk->ops->set_parent)) {
+               unsigned long flags;
+               spin_lock_irqsave(&clock_lock, flags);
+               ret = clk->ops->set_parent(clk, parent);
+               spin_unlock_irqrestore(&clock_lock, flags);
+               clk->parent = (ret ? old : parent);
+       }
+
+       if (unlikely(clk->flags & CLK_RATE_PROPAGATES))
+               propagate_rate(clk);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(clk_set_parent);
+
+struct clk *clk_get_parent(struct clk *clk)
+{
+       return clk->parent;
+}
+EXPORT_SYMBOL_GPL(clk_get_parent);
+
 long clk_round_rate(struct clk *clk, unsigned long rate)
 {
        if (likely(clk->ops && clk->ops->round_rate)) {