aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/gpio.c
diff options
context:
space:
mode:
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 */