aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/sh
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/sh')
-rw-r--r--drivers/sh/clk/core.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c
index d6702e57d428..dc8d022c07a1 100644
--- a/drivers/sh/clk/core.c
+++ b/drivers/sh/clk/core.c
@@ -34,6 +34,9 @@ static LIST_HEAD(clock_list);
34static DEFINE_SPINLOCK(clock_lock); 34static DEFINE_SPINLOCK(clock_lock);
35static DEFINE_MUTEX(clock_list_sem); 35static DEFINE_MUTEX(clock_list_sem);
36 36
37/* clock disable operations are not passed on to hardware during boot */
38static int allow_disable;
39
37void clk_rate_table_build(struct clk *clk, 40void clk_rate_table_build(struct clk *clk,
38 struct cpufreq_frequency_table *freq_table, 41 struct cpufreq_frequency_table *freq_table,
39 int nr_freqs, 42 int nr_freqs,
@@ -228,7 +231,7 @@ static void __clk_disable(struct clk *clk)
228 return; 231 return;
229 232
230 if (!(--clk->usecount)) { 233 if (!(--clk->usecount)) {
231 if (likely(clk->ops && clk->ops->disable)) 234 if (likely(allow_disable && clk->ops && clk->ops->disable))
232 clk->ops->disable(clk); 235 clk->ops->disable(clk);
233 if (likely(clk->parent)) 236 if (likely(clk->parent))
234 __clk_disable(clk->parent); 237 __clk_disable(clk->parent);
@@ -393,7 +396,7 @@ int clk_register(struct clk *clk)
393{ 396{
394 int ret; 397 int ret;
395 398
396 if (clk == NULL || IS_ERR(clk)) 399 if (IS_ERR_OR_NULL(clk))
397 return -EINVAL; 400 return -EINVAL;
398 401
399 /* 402 /*
@@ -744,3 +747,25 @@ err_out:
744 return err; 747 return err;
745} 748}
746late_initcall(clk_debugfs_init); 749late_initcall(clk_debugfs_init);
750
751static int __init clk_late_init(void)
752{
753 unsigned long flags;
754 struct clk *clk;
755
756 /* disable all clocks with zero use count */
757 mutex_lock(&clock_list_sem);
758 spin_lock_irqsave(&clock_lock, flags);
759
760 list_for_each_entry(clk, &clock_list, node)
761 if (!clk->usecount && clk->ops && clk->ops->disable)
762 clk->ops->disable(clk);
763
764 /* from now on allow clock disable operations */
765 allow_disable = 1;
766
767 spin_unlock_irqrestore(&clock_lock, flags);
768 mutex_unlock(&clock_list_sem);
769 return 0;
770}
771late_initcall(clk_late_init);