Skip to content

Commit d680c76

Browse files
FrancescoVirlinzipmundt
authored andcommitted
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>
1 parent 47a7268 commit d680c76

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎arch/sh/include/asm/clock.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct clk_ops {
1515
void (*disable)(struct clk *clk);
1616
void (*recalc)(struct clk *clk);
1717
int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
18+
int (*set_parent)(struct clk *clk, struct clk *parent);
1819
long (*round_rate)(struct clk *clk, unsigned long rate);
1920
};
2021

‎arch/sh/kernel/cpu/clock.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,35 @@ void clk_recalc_rate(struct clk *clk)
239239
}
240240
EXPORT_SYMBOL_GPL(clk_recalc_rate);
241241

242+
int 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+
}
263+
EXPORT_SYMBOL_GPL(clk_set_parent);
264+
265+
struct clk *clk_get_parent(struct clk *clk)
266+
{
267+
return clk->parent;
268+
}
269+
EXPORT_SYMBOL_GPL(clk_get_parent);
270+
242271
long clk_round_rate(struct clk *clk, unsigned long rate)
243272
{
244273
if (likely(clk->ops && clk->ops->round_rate)) {

0 commit comments

Comments
 (0)