33
33
#include <linux/uaccess.h>
34
34
#include <linux/jiffies.h>
35
35
#include <linux/miscdevice.h>
36
+ #include <linux/debugfs.h>
36
37
37
38
/* ----------------------------
38
39
* driver parameters
44
45
#define READ_BUF_SIZE 128U /* read buffer length in words */
45
46
#define WRITE_BUF_SIZE 128U /* write buffer length in words */
46
47
48
+ #define AXIS_FIFO_DEBUG_REG_NAME_MAX_LEN 4
49
+
47
50
/* ----------------------------
48
51
* IP register offsets
49
52
* ----------------------------
@@ -137,6 +140,13 @@ struct axis_fifo {
137
140
138
141
struct device * dt_device ; /* device created from the device tree */
139
142
struct miscdevice miscdev ;
143
+
144
+ struct dentry * debugfs_dir ;
145
+ };
146
+
147
+ struct axis_fifo_debug_reg {
148
+ const char * const name ;
149
+ unsigned int offset ;
140
150
};
141
151
142
152
/* ----------------------------
@@ -537,6 +547,37 @@ static const struct file_operations fops = {
537
547
.write = axis_fifo_write
538
548
};
539
549
550
+ static int axis_fifo_debugfs_regs_show (struct seq_file * m , void * p )
551
+ {
552
+ static const struct axis_fifo_debug_reg regs [] = {
553
+ {"isr" , XLLF_ISR_OFFSET },
554
+ {"ier" , XLLF_IER_OFFSET },
555
+ {"tdfv" , XLLF_TDFV_OFFSET },
556
+ {"rdfo" , XLLF_RDFO_OFFSET },
557
+ { /* Sentinel */ },
558
+ };
559
+ const struct axis_fifo_debug_reg * reg ;
560
+ struct axis_fifo * fifo = m -> private ;
561
+
562
+ for (reg = regs ; reg -> name ; ++ reg ) {
563
+ u32 val = ioread32 (fifo -> base_addr + reg -> offset );
564
+
565
+ seq_printf (m , "%*s: 0x%08x\n" , AXIS_FIFO_DEBUG_REG_NAME_MAX_LEN ,
566
+ reg -> name , val );
567
+ }
568
+
569
+ return 0 ;
570
+ }
571
+ DEFINE_SHOW_ATTRIBUTE (axis_fifo_debugfs_regs );
572
+
573
+ static void axis_fifo_debugfs_init (struct axis_fifo * fifo )
574
+ {
575
+ fifo -> debugfs_dir = debugfs_create_dir (dev_name (fifo -> dt_device ), NULL );
576
+
577
+ debugfs_create_file ("regs" , 0444 , fifo -> debugfs_dir , fifo ,
578
+ & axis_fifo_debugfs_regs_fops );
579
+ }
580
+
540
581
/* read named property from the device tree */
541
582
static int get_dts_property (struct axis_fifo * fifo ,
542
583
char * name , unsigned int * var )
@@ -708,6 +749,8 @@ static int axis_fifo_probe(struct platform_device *pdev)
708
749
if (rc < 0 )
709
750
goto err_initial ;
710
751
752
+ axis_fifo_debugfs_init (fifo );
753
+
711
754
return 0 ;
712
755
713
756
err_initial :
@@ -720,6 +763,7 @@ static void axis_fifo_remove(struct platform_device *pdev)
720
763
struct device * dev = & pdev -> dev ;
721
764
struct axis_fifo * fifo = dev_get_drvdata (dev );
722
765
766
+ debugfs_remove (fifo -> debugfs_dir );
723
767
misc_deregister (& fifo -> miscdev );
724
768
dev_set_drvdata (dev , NULL );
725
769
}
0 commit comments