@@ -375,6 +375,60 @@ static int tegra_gpio_irq_set_wake(struct irq_data *d, unsigned int enable)
375
375
}
376
376
#endif
377
377
378
+ #ifdef CONFIG_DEBUG_FS
379
+
380
+ #include <linux/debugfs.h>
381
+ #include <linux/seq_file.h>
382
+
383
+ static int dbg_gpio_show (struct seq_file * s , void * unused )
384
+ {
385
+ int i ;
386
+ int j ;
387
+
388
+ for (i = 0 ; i < tegra_gpio_bank_count ; i ++ ) {
389
+ for (j = 0 ; j < 4 ; j ++ ) {
390
+ int gpio = tegra_gpio_compose (i , j , 0 );
391
+ seq_printf (s ,
392
+ "%d:%d %02x %02x %02x %02x %02x %02x %06x\n" ,
393
+ i , j ,
394
+ tegra_gpio_readl (GPIO_CNF (gpio )),
395
+ tegra_gpio_readl (GPIO_OE (gpio )),
396
+ tegra_gpio_readl (GPIO_OUT (gpio )),
397
+ tegra_gpio_readl (GPIO_IN (gpio )),
398
+ tegra_gpio_readl (GPIO_INT_STA (gpio )),
399
+ tegra_gpio_readl (GPIO_INT_ENB (gpio )),
400
+ tegra_gpio_readl (GPIO_INT_LVL (gpio )));
401
+ }
402
+ }
403
+ return 0 ;
404
+ }
405
+
406
+ static int dbg_gpio_open (struct inode * inode , struct file * file )
407
+ {
408
+ return single_open (file , dbg_gpio_show , & inode -> i_private );
409
+ }
410
+
411
+ static const struct file_operations debug_fops = {
412
+ .open = dbg_gpio_open ,
413
+ .read = seq_read ,
414
+ .llseek = seq_lseek ,
415
+ .release = single_release ,
416
+ };
417
+
418
+ static void tegra_gpio_debuginit (void )
419
+ {
420
+ (void ) debugfs_create_file ("tegra_gpio" , S_IRUGO ,
421
+ NULL , NULL , & debug_fops );
422
+ }
423
+
424
+ #else
425
+
426
+ static inline void tegra_gpio_debuginit (void )
427
+ {
428
+ }
429
+
430
+ #endif
431
+
378
432
static struct irq_chip tegra_gpio_irq_chip = {
379
433
.name = "GPIO" ,
380
434
.irq_ack = tegra_gpio_irq_ack ,
@@ -519,6 +573,8 @@ static int tegra_gpio_probe(struct platform_device *pdev)
519
573
spin_lock_init (& bank -> lvl_lock [j ]);
520
574
}
521
575
576
+ tegra_gpio_debuginit ();
577
+
522
578
return 0 ;
523
579
}
524
580
@@ -536,52 +592,3 @@ static int __init tegra_gpio_init(void)
536
592
return platform_driver_register (& tegra_gpio_driver );
537
593
}
538
594
postcore_initcall (tegra_gpio_init );
539
-
540
- #ifdef CONFIG_DEBUG_FS
541
-
542
- #include <linux/debugfs.h>
543
- #include <linux/seq_file.h>
544
-
545
- static int dbg_gpio_show (struct seq_file * s , void * unused )
546
- {
547
- int i ;
548
- int j ;
549
-
550
- for (i = 0 ; i < tegra_gpio_bank_count ; i ++ ) {
551
- for (j = 0 ; j < 4 ; j ++ ) {
552
- int gpio = tegra_gpio_compose (i , j , 0 );
553
- seq_printf (s ,
554
- "%d:%d %02x %02x %02x %02x %02x %02x %06x\n" ,
555
- i , j ,
556
- tegra_gpio_readl (GPIO_CNF (gpio )),
557
- tegra_gpio_readl (GPIO_OE (gpio )),
558
- tegra_gpio_readl (GPIO_OUT (gpio )),
559
- tegra_gpio_readl (GPIO_IN (gpio )),
560
- tegra_gpio_readl (GPIO_INT_STA (gpio )),
561
- tegra_gpio_readl (GPIO_INT_ENB (gpio )),
562
- tegra_gpio_readl (GPIO_INT_LVL (gpio )));
563
- }
564
- }
565
- return 0 ;
566
- }
567
-
568
- static int dbg_gpio_open (struct inode * inode , struct file * file )
569
- {
570
- return single_open (file , dbg_gpio_show , & inode -> i_private );
571
- }
572
-
573
- static const struct file_operations debug_fops = {
574
- .open = dbg_gpio_open ,
575
- .read = seq_read ,
576
- .llseek = seq_lseek ,
577
- .release = single_release ,
578
- };
579
-
580
- static int __init tegra_gpio_debuginit (void )
581
- {
582
- (void ) debugfs_create_file ("tegra_gpio" , S_IRUGO ,
583
- NULL , NULL , & debug_fops );
584
- return 0 ;
585
- }
586
- late_initcall (tegra_gpio_debuginit );
587
- #endif
0 commit comments