aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/gpio.c
diff options
context:
space:
mode:
authorAndrew Victor <andrew@sanpeople.com>2007-11-23 10:09:10 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-01-26 10:00:30 -0500
commitb66545e7ae80b4b0eef3f7884ef9260455070be9 (patch)
tree3d766fb4377c2bb15d92019799e4ab643870f1be /arch/arm/mach-at91/gpio.c
parent9b73e76f3cf63379dcf45fcd4f112f5812418d0a (diff)
[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 <andrew@sanpeople.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-at91/gpio.c')
-rw-r--r--arch/arm/mach-at91/gpio.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index aa2d365c93fb..6aeddd68d8af 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -13,6 +13,8 @@
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/irq.h> 15#include <linux/irq.h>
16#include <linux/debugfs.h>
17#include <linux/seq_file.h>
16#include <linux/kernel.h> 18#include <linux/kernel.h>
17#include <linux/list.h> 19#include <linux/list.h>
18#include <linux/module.h> 20#include <linux/module.h>
@@ -414,6 +416,66 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
414 416
415/*--------------------------------------------------------------------------*/ 417/*--------------------------------------------------------------------------*/
416 418
419#ifdef CONFIG_DEBUG_FS
420
421static int at91_gpio_show(struct seq_file *s, void *unused)
422{
423 int bank, j;
424
425 /* print heading */
426 seq_printf(s, "Pin\t");
427 for (bank = 0; bank < gpio_banks; bank++) {
428 seq_printf(s, "PIO%c\t", 'A' + bank);
429 };
430 seq_printf(s, "\n\n");
431
432 /* print pin status */
433 for (j = 0; j < 32; j++) {
434 seq_printf(s, "%i:\t", j);
435
436 for (bank = 0; bank < gpio_banks; bank++) {
437 unsigned pin = PIN_BASE + (32 * bank) + j;
438 void __iomem *pio = pin_to_controller(pin);
439 unsigned mask = pin_to_mask(pin);
440
441 if (__raw_readl(pio + PIO_PSR) & mask)
442 seq_printf(s, "GPIO:%s", __raw_readl(pio + PIO_PDSR) & mask ? "1" : "0");
443 else
444 seq_printf(s, "%s", __raw_readl(pio + PIO_ABSR) & mask ? "B" : "A");
445
446 seq_printf(s, "\t");
447 }
448
449 seq_printf(s, "\n");
450 }
451
452 return 0;
453}
454
455static int at91_gpio_open(struct inode *inode, struct file *file)
456{
457 return single_open(file, at91_gpio_show, NULL);
458}
459
460static const struct file_operations at91_gpio_operations = {
461 .open = at91_gpio_open,
462 .read = seq_read,
463 .llseek = seq_lseek,
464 .release = single_release,
465};
466
467static int __init at91_gpio_debugfs_init(void)
468{
469 /* /sys/kernel/debug/at91_gpio */
470 (void) debugfs_create_file("at91_gpio", S_IFREG | S_IRUGO, NULL, NULL, &at91_gpio_operations);
471 return 0;
472}
473postcore_initcall(at91_gpio_debugfs_init);
474
475#endif
476
477/*--------------------------------------------------------------------------*/
478
417/* 479/*
418 * Called from the processor-specific init to enable GPIO interrupt support. 480 * Called from the processor-specific init to enable GPIO interrupt support.
419 */ 481 */