ARM: tegra: la: Add debugfs to latency allowance.
Jon Mayo [Thu, 21 Jul 2011 01:49:00 +0000 (18:49 -0700)]
add /sys/kernel/debug/tegra_latency/la_info to print programmed latency
allowance settings.

Original-Change-Id: I65a7a04c42f8ac27aaf2c1c953d695bc0bba0c77
Reviewed-on: http://git-master/r/42285
Reviewed-by: Jonathan Mayo <jmayo@nvidia.com>
Tested-by: Jonathan Mayo <jmayo@nvidia.com>
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>

Rebase-Id: R540ef9a4ed274eae52800edcd6ad590e16b67e09

arch/arm/mach-tegra/latency_allowance.c

index b96ddd7..4c2de2a 100644 (file)
@@ -17,6 +17,8 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
 #include <linux/err.h>
 #include <linux/spinlock_types.h>
 #include <linux/spinlock.h>
@@ -95,6 +97,8 @@
                printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__); \
        }
 
+static struct dentry *latency_debug_dir;
+
 struct la_client_info {
        unsigned int fifo_size_in_atoms;
        unsigned int expiration_in_ns;  /* worst case expiration value */
@@ -478,6 +482,48 @@ void tegra_disable_latency_scaling(enum tegra_la_id id)
        spin_unlock(&safety_lock);
 }
 
+static int la_regs_show(struct seq_file *s, void *unused)
+{
+       unsigned i;
+       unsigned long la;
+
+       /* iterate the list, but don't print MAX_ID */
+       for (i = 0; i < ARRAY_SIZE(la_info) - 1; i++) {
+               la = (readl(la_info[i].reg_addr) & la_info[i].mask)
+                       >> la_info[i].shift;
+               seq_printf(s, "%-16s: %4u\n", la_info[i].name, la);
+       }
+
+        return 0;
+}
+
+static int dbg_la_regs_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, la_regs_show, inode->i_private);
+}
+
+static const struct file_operations regs_fops = {
+       .open           = dbg_la_regs_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int __init tegra_latency_allowance_debugfs_init(void)
+{
+       if (latency_debug_dir)
+               return 0;
+
+       latency_debug_dir = debugfs_create_dir("tegra_latency", NULL);
+
+       debugfs_create_file("la_info", S_IRUGO, latency_debug_dir, NULL,
+               &regs_fops);
+
+       return 0;
+}
+
+late_initcall(tegra_latency_allowance_debugfs_init);
+
 static int __init tegra_latency_allowance_init(void)
 {
        la_scaling_enable_count = 0;