Merge remote branch 'tegra/linux-tegra-2.6.36' into android-tegra-2.6.36
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-tegra / irq.c
index ced7007c0610f4276af252b430fd4240579be34f..458f9c8e85cbada0c07914b1a0f20faf79cc9354 100644 (file)
 
 #include <linux/kernel.h>
 #include <linux/delay.h>
+#include <linux/debugfs.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/io.h>
+#include <linux/seq_file.h>
 
 #include <asm/hardware/gic.h>
 
@@ -46,6 +48,8 @@ static u32 tegra_lp0_wake_enb;
 static u32 tegra_lp0_wake_level;
 static u32 tegra_lp0_wake_level_any;
 
+static unsigned int tegra_wake_irq_count[32];
+
 /* ensures that sufficient time is passed for a register write to
  * serialize into the 32KHz domain */
 static void pmc_32kwritel(u32 val, unsigned long offs)
@@ -165,6 +169,8 @@ static void tegra_irq_handle_wake(void)
                pr_info("Resume caused by WAKE%d, %s\n", wake,
                        desc->action->name);
 
+               tegra_wake_irq_count[wake]++;
+
                generic_handle_irq(irq);
        }
 }
@@ -202,9 +208,21 @@ static int tegra_set_type(unsigned int irq, unsigned int flow_type)
        return 0;
 }
 
+static void tegra_ack(unsigned int irq)
+{
+       tegra_legacy_force_irq_clr(irq);
+       gic_ack_irq(irq);
+}
+
+static int tegra_retrigger(unsigned int irq)
+{
+       tegra_legacy_force_irq_set(irq);
+       return 1;
+}
+
 static struct irq_chip tegra_irq = {
        .name           = "PPI",
-       .ack            = gic_ack_irq,
+       .ack            = tegra_ack,
        .mask           = tegra_mask,
        .unmask         = tegra_unmask,
        .set_wake       = tegra_set_wake,
@@ -212,6 +230,7 @@ static struct irq_chip tegra_irq = {
 #ifdef CONFIG_SMP
        .set_affinity   = gic_set_cpu,
 #endif
+       .retrigger      = tegra_retrigger,
 };
 
 void __init tegra_init_irq(void)
@@ -242,3 +261,63 @@ void tegra_irq_resume(void)
        tegra_legacy_irq_resume();
        tegra_irq_handle_wake();
 }
+
+#ifdef CONFIG_DEBUG_FS
+static int tegra_wake_irq_debug_show(struct seq_file *s, void *data)
+{
+       int wake;
+       int irq;
+       struct irq_desc *desc;
+       const char *irq_name;
+
+       seq_printf(s, "wake  irq  count  name\n");
+       seq_printf(s, "----------------------\n");
+       for (wake = 0; wake < 32; wake++) {
+               irq = tegra_wake_to_irq(wake);
+               if (irq < 0)
+                       continue;
+
+               desc = irq_to_desc(irq);
+               if (tegra_wake_irq_count[wake] == 0 && desc->action == NULL)
+                       continue;
+
+               if (!(desc->status & IRQ_WAKEUP))
+                       continue;
+
+               irq_name = (desc->action && desc->action->name) ?
+                       desc->action->name : "???";
+
+               seq_printf(s, "%4d  %3d  %5d  %s\n",
+                       wake, irq, tegra_wake_irq_count[wake], irq_name);
+       }
+       return 0;
+}
+
+static int tegra_wake_irq_debug_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, tegra_wake_irq_debug_show, NULL);
+}
+
+static const struct file_operations tegra_wake_irq_debug_fops = {
+       .open           = tegra_wake_irq_debug_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int __init tegra_irq_debug_init(void)
+{
+       struct dentry *d;
+
+       d = debugfs_create_file("wake_irq", 0755, NULL, NULL,
+               &tegra_wake_irq_debug_fops);
+       if (!d) {
+               pr_info("Failed to create suspend_mode debug file\n");
+               return -ENOMEM;
+       }
+
+       return 0;
+}
+
+late_initcall(tegra_irq_debug_init);
+#endif