Merge to kernel-2.6.20-1.2949.fc6.vs2.2.0.1
[linux-2.6.git] / arch / arm / plat-omap / clock.c
index 7f45c7c..f1179ad 100644 (file)
@@ -100,6 +100,7 @@ void clk_disable(struct clk *clk)
                return;
 
        spin_lock_irqsave(&clockfw_lock, flags);
+       BUG_ON(clk->usecount == 0);
        if (arch_clock->clk_disable)
                arch_clock->clk_disable(clk);
        spin_unlock_irqrestore(&clockfw_lock, flags);
@@ -322,6 +323,31 @@ EXPORT_SYMBOL(clk_allow_idle);
 
 /*-------------------------------------------------------------------------*/
 
+#ifdef CONFIG_OMAP_RESET_CLOCKS
+/*
+ * Disable any unused clocks left on by the bootloader
+ */
+static int __init clk_disable_unused(void)
+{
+       struct clk *ck;
+       unsigned long flags;
+
+       list_for_each_entry(ck, &clocks, node) {
+               if (ck->usecount > 0 || (ck->flags & ALWAYS_ENABLED) ||
+                       ck->enable_reg == 0)
+                       continue;
+
+               spin_lock_irqsave(&clockfw_lock, flags);
+               if (arch_clock->clk_disable_unused)
+                       arch_clock->clk_disable_unused(ck);
+               spin_unlock_irqrestore(&clockfw_lock, flags);
+       }
+
+       return 0;
+}
+late_initcall(clk_disable_unused);
+#endif
+
 int __init clk_init(struct clk_functions * custom_clocks)
 {
        if (!custom_clocks) {