aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/sh/include/asm/clock.h1
-rw-r--r--arch/sh/kernel/cpu/clock.c20
2 files changed, 21 insertions, 0 deletions
diff --git a/arch/sh/include/asm/clock.h b/arch/sh/include/asm/clock.h
index 5de72eef9724..fdb915608dbc 100644
--- a/arch/sh/include/asm/clock.h
+++ b/arch/sh/include/asm/clock.h
@@ -48,6 +48,7 @@ int clk_init(void);
48unsigned long followparent_recalc(struct clk *); 48unsigned long followparent_recalc(struct clk *);
49void recalculate_root_clocks(void); 49void recalculate_root_clocks(void);
50void propagate_rate(struct clk *); 50void propagate_rate(struct clk *);
51int clk_reparent(struct clk *child, struct clk *parent);
51void clk_recalc_rate(struct clk *); 52void clk_recalc_rate(struct clk *);
52int clk_register(struct clk *); 53int clk_register(struct clk *);
53void clk_unregister(struct clk *); 54void clk_unregister(struct clk *);
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index e027fe5898d6..e3d1de8a46fd 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -81,6 +81,19 @@ unsigned long followparent_recalc(struct clk *clk)
81 return clk->parent->rate; 81 return clk->parent->rate;
82} 82}
83 83
84int clk_reparent(struct clk *child, struct clk *parent)
85{
86 list_del_init(&child->sibling);
87 if (parent)
88 list_add(&child->sibling, &parent->children);
89 child->parent = parent;
90
91 /* now do the debugfs renaming to reattach the child
92 to the proper parent */
93
94 return 0;
95}
96
84/* Propagate rate to children */ 97/* Propagate rate to children */
85void propagate_rate(struct clk *tclk) 98void propagate_rate(struct clk *tclk)
86{ 99{
@@ -288,12 +301,19 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
288 301
289 if (!parent || !clk) 302 if (!parent || !clk)
290 return ret; 303 return ret;
304 if (clk->parent == parent)
305 return 0;
291 306
292 spin_lock_irqsave(&clock_lock, flags); 307 spin_lock_irqsave(&clock_lock, flags);
293 if (clk->usecount == 0) { 308 if (clk->usecount == 0) {
294 if (clk->ops->set_parent) 309 if (clk->ops->set_parent)
295 ret = clk->ops->set_parent(clk, parent); 310 ret = clk->ops->set_parent(clk, parent);
311 else
312 ret = clk_reparent(clk, parent);
313
296 if (ret == 0) { 314 if (ret == 0) {
315 pr_debug("clock: set parent of %s to %s (new rate %ld)\n",
316 clk->name, clk->parent->name, clk->rate);
297 if (clk->ops->recalc) 317 if (clk->ops->recalc)
298 clk->rate = clk->ops->recalc(clk); 318 clk->rate = clk->ops->recalc(clk);
299 propagate_rate(clk); 319 propagate_rate(clk);