Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b66545e7ae80b4b0eef3f7884ef9260455070be9
Commit:     b66545e7ae80b4b0eef3f7884ef9260455070be9
Parent:     9b73e76f3cf63379dcf45fcd4f112f5812418d0a
Author:     Andrew Victor <[EMAIL PROTECTED]>
AuthorDate: Fri Nov 23 16:09:10 2007 +0100
Committer:  Russell King <[EMAIL PROTECTED]>
CommitDate: Sat Jan 26 15:00:30 2008 +0000

    [ARM] 4602/3: AT91: debugfs interface to view GPIO pin state
    
    This patch adds a debug interface (if CONFIG_DEBUG_FS is selected) to
    display the basic configuration and current state of the GPIO pins on
    the Atmel AT91 processors.
    
    Signed-off-by: Andrew Victor <[EMAIL PROTECTED]>
    Signed-off-by: Russell King <[EMAIL PROTECTED]>
---
 arch/arm/mach-at91/gpio.c |   62 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index aa2d365..6aeddd6 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -13,6 +13,8 @@
 #include <linux/errno.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/module.h>
@@ -414,6 +416,66 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc 
*desc)
 
 /*--------------------------------------------------------------------------*/
 
+#ifdef CONFIG_DEBUG_FS
+
+static int at91_gpio_show(struct seq_file *s, void *unused)
+{
+       int bank, j;
+
+       /* print heading */
+       seq_printf(s, "Pin\t");
+       for (bank = 0; bank < gpio_banks; bank++) {
+               seq_printf(s, "PIO%c\t", 'A' + bank);
+       };
+       seq_printf(s, "\n\n");
+
+       /* print pin status */
+       for (j = 0; j < 32; j++) {
+               seq_printf(s, "%i:\t", j);
+
+               for (bank = 0; bank < gpio_banks; bank++) {
+                       unsigned        pin  = PIN_BASE + (32 * bank) + j;
+                       void __iomem    *pio = pin_to_controller(pin);
+                       unsigned        mask = pin_to_mask(pin);
+
+                       if (__raw_readl(pio + PIO_PSR) & mask)
+                               seq_printf(s, "GPIO:%s", __raw_readl(pio + 
PIO_PDSR) & mask ? "1" : "0");
+                       else
+                               seq_printf(s, "%s", __raw_readl(pio + PIO_ABSR) 
& mask ? "B" : "A");
+
+                       seq_printf(s, "\t");
+               }
+
+               seq_printf(s, "\n");
+       }
+
+       return 0;
+}
+
+static int at91_gpio_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, at91_gpio_show, NULL);
+}
+
+static const struct file_operations at91_gpio_operations = {
+       .open           = at91_gpio_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int __init at91_gpio_debugfs_init(void)
+{
+       /* /sys/kernel/debug/at91_gpio */
+       (void) debugfs_create_file("at91_gpio", S_IFREG | S_IRUGO, NULL, NULL, 
&at91_gpio_operations);
+       return 0;
+}
+postcore_initcall(at91_gpio_debugfs_init);
+
+#endif
+
+/*--------------------------------------------------------------------------*/
+
 /*
  * Called from the processor-specific init to enable GPIO interrupt support.
  */
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to