]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/plat-omap/clock.c
ARM: OMAP: CLKFW: Remove procfs entry for debugging clock framework
[linux-2.6-omap-h63xx.git] / arch / arm / plat-omap / clock.c
index cbcc8fe30efadcd75606361792c8a02d82ffa4a5..714dbbf169674dc7e8a08283e4d33421d10661e9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  linux/arch/arm/plat-omap/clock.c
  *
- *  Copyright (C) 2004 - 2005 Nokia corporation
+ *  Copyright (C) 2004 - 2008 Nokia corporation
  *  Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
  *
  *  Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com>
@@ -21,6 +21,7 @@
 #include <linux/clk.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/debugfs.h>
 
 #include <asm/io.h>
 #include <asm/semaphore.h>
@@ -33,41 +34,6 @@ static DEFINE_SPINLOCK(clockfw_lock);
 
 static struct clk_functions *arch_clock;
 
-#ifdef CONFIG_PM_DEBUG
-
-static void print_parents(struct clk *clk)
-{
-       struct clk *p;
-       int printed = 0;
-
-       list_for_each_entry(p, &clocks, node) {
-               if (p->parent == clk && p->usecount) {
-                       if (!clk->usecount && !printed) {
-                               printk("MISMATCH: %s\n", clk->name);
-                               printed = 1;
-                       }
-                       printk("\t%-15s\n", p->name);
-               }
-       }
-}
-
-void clk_print_usecounts(void)
-{
-       unsigned long flags;
-       struct clk *p;
-
-       spin_lock_irqsave(&clockfw_lock, flags);
-       list_for_each_entry(p, &clocks, node) {
-               if (p->usecount)
-                       printk("%-15s: %d\n", p->name, p->usecount);
-               print_parents(p);
-
-       }
-       spin_unlock_irqrestore(&clockfw_lock, flags);
-}
-
-#endif
-
 /*-------------------------------------------------------------------------
  * Standard clock functions defined in include/linux/clk.h
  *-------------------------------------------------------------------------*/
@@ -135,9 +101,17 @@ void clk_disable(struct clk *clk)
                return;
 
        spin_lock_irqsave(&clockfw_lock, flags);
-       BUG_ON(clk->usecount == 0);
+       if (clk->usecount == 0) {
+               printk(KERN_ERR "Trying disable clock %s with 0 usecount\n",
+                      clk->name);
+               WARN_ON(1);
+               goto out;
+       }
+
        if (arch_clock->clk_disable)
                arch_clock->clk_disable(clk);
+
+out:
        spin_unlock_irqrestore(&clockfw_lock, flags);
 }
 EXPORT_SYMBOL(clk_disable);
@@ -304,6 +278,23 @@ void propagate_rate(struct clk * tclk)
        }
 }
 
+/**
+ * recalculate_root_clocks - recalculate and propagate all root clocks
+ *
+ * Recalculates all root clocks (clocks with no parent), which if the
+ * clock's .recalc is set correctly, should also propagate their rates.
+ * Called at init.
+ */
+void recalculate_root_clocks(void)
+{
+       struct clk *clkp;
+
+       list_for_each_entry(clkp, &clocks, node) {
+               if (unlikely(!clkp->parent) && likely((u32)clkp->recalc))
+                       clkp->recalc(clkp);
+       }
+}
+
 int clk_register(struct clk *clk)
 {
        if (clk == NULL || IS_ERR(clk))
@@ -358,6 +349,30 @@ void clk_allow_idle(struct clk *clk)
 }
 EXPORT_SYMBOL(clk_allow_idle);
 
+void clk_enable_init_clocks(void)
+{
+       struct clk *clkp;
+
+       list_for_each_entry(clkp, &clocks, node) {
+               if (clkp->flags & ENABLE_ON_INIT)
+                       clk_enable(clkp);
+       }
+}
+EXPORT_SYMBOL(clk_enable_init_clocks);
+
+#ifdef CONFIG_CPU_FREQ
+void clk_init_cpufreq_table(struct cpufreq_frequency_table **table)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&clockfw_lock, flags);
+       if (arch_clock->clk_init_cpufreq_table)
+               arch_clock->clk_init_cpufreq_table(table);
+       spin_unlock_irqrestore(&clockfw_lock, flags);
+}
+EXPORT_SYMBOL(clk_init_cpufreq_table);
+#endif
+
 /*-------------------------------------------------------------------------*/
 
 #ifdef CONFIG_OMAP_RESET_CLOCKS
@@ -397,64 +412,93 @@ int __init clk_init(struct clk_functions * custom_clocks)
        return 0;
 }
 
-#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_PROC_FS)
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
-
-static void *omap_ck_start(struct seq_file *m, loff_t *pos)
-{
-       return *pos < 1 ? (void *)1 : NULL;
-}
+#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
+/*
+ *     debugfs support to trace clock tree hierarchy and attributes
+ */
+static struct dentry *clk_debugfs_root;
 
-static void *omap_ck_next(struct seq_file *m, void *v, loff_t *pos)
+static int clk_debugfs_register_one(struct clk *c)
 {
-       ++*pos;
-       return NULL;
-}
+       int err;
+       struct dentry *d, *child;
+       struct clk *pa = c->parent;
+       char s[255];
+       char *p = s;
+
+       p += sprintf(p, "%s", c->name);
+       if (c->id != 0)
+               sprintf(p, ":%d", c->id);
+       d = debugfs_create_dir(s, pa ? pa->dent : clk_debugfs_root);
+       if (IS_ERR(d))
+               return PTR_ERR(d);
+       c->dent = d;
+
+       d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usecount);
+       if (IS_ERR(d)) {
+               err = PTR_ERR(d);
+               goto err_out;
+       }
+       d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate);
+       if (IS_ERR(d)) {
+               err = PTR_ERR(d);
+               goto err_out;
+       }
+       d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags);
+       if (IS_ERR(d)) {
+               err = PTR_ERR(d);
+               goto err_out;
+       }
+       return 0;
 
-static void omap_ck_stop(struct seq_file *m, void *v)
-{
+err_out:
+       d = c->dent;
+       list_for_each_entry(child, &d->d_subdirs, d_u.d_child)
+               debugfs_remove(child);
+       debugfs_remove(c->dent);
+       return err;
 }
 
-int omap_ck_show(struct seq_file *m, void *v)
+static int clk_debugfs_register(struct clk *c)
 {
-       struct clk *cp;
+       int err;
+       struct clk *pa = c->parent;
 
-       list_for_each_entry(cp, &clocks, node)
-               seq_printf(m,"%s %ld %d\n", cp->name, cp->rate, cp->usecount);
+       if (pa && !pa->dent) {
+               err = clk_debugfs_register(pa);
+               if (err)
+                       return err;
+       }
 
+       if (!c->dent) {
+               err = clk_debugfs_register_one(c);
+               if (err)
+                       return err;
+       }
        return 0;
 }
 
-static struct seq_operations omap_ck_op = {
-       .start =        omap_ck_start,
-       .next =         omap_ck_next,
-       .stop =         omap_ck_stop,
-       .show =         omap_ck_show
-};
-
-static int omap_ck_open(struct inode *inode, struct file *file)
+static int __init clk_debugfs_init(void)
 {
-       return seq_open(file, &omap_ck_op);
-}
-
-static struct file_operations proc_omap_ck_operations = {
-       .open           = omap_ck_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = seq_release,
-};
-
-int __init omap_ck_init(void)
-{
-    struct proc_dir_entry *entry;
-
-       entry = create_proc_entry("omap_clocks", 0, NULL);
-       if (entry)
-               entry->proc_fops = &proc_omap_ck_operations;
+       struct clk *c;
+       struct dentry *d;
+       int err;
+
+       d = debugfs_create_dir("clock", NULL);
+       if (IS_ERR(d))
+               return PTR_ERR(d);
+       clk_debugfs_root = d;
+
+       list_for_each_entry(c, &clocks, node) {
+               err = clk_debugfs_register(c);
+               if (err)
+                       goto err_out;
+       }
        return 0;
-
+err_out:
+       debugfs_remove(clk_debugfs_root); /* REVISIT: Cleanup correctly */
+       return err;
 }
-__initcall(omap_ck_init);
-#endif
+late_initcall(clk_debugfs_init);
 
+#endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */