mbxdebugfs.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #include <linux/debugfs.h>
  2. #define BIG_BUFFER_SIZE (1024)
  3. static char big_buffer[BIG_BUFFER_SIZE];
  4. struct mbxfb_debugfs_data {
  5. struct dentry *dir;
  6. struct dentry *sysconf;
  7. struct dentry *clock;
  8. struct dentry *display;
  9. struct dentry *gsctl;
  10. };
  11. static int open_file_generic(struct inode *inode, struct file *file)
  12. {
  13. file->private_data = inode->u.generic_ip;
  14. return 0;
  15. }
  16. static ssize_t write_file_dummy(struct file *file, const char __user *buf,
  17. size_t count, loff_t *ppos)
  18. {
  19. return count;
  20. }
  21. static ssize_t sysconf_read_file(struct file *file, char __user *userbuf,
  22. size_t count, loff_t *ppos)
  23. {
  24. char * s = big_buffer;
  25. s += sprintf(s, "SYSCFG = %08lx\n", SYSCFG);
  26. s += sprintf(s, "PFBASE = %08lx\n", PFBASE);
  27. s += sprintf(s, "PFCEIL = %08lx\n", PFCEIL);
  28. s += sprintf(s, "POLLFLAG = %08lx\n", POLLFLAG);
  29. s += sprintf(s, "SYSRST = %08lx\n", SYSRST);
  30. return simple_read_from_buffer(userbuf, count, ppos,
  31. big_buffer, s-big_buffer);
  32. }
  33. static ssize_t gsctl_read_file(struct file *file, char __user *userbuf,
  34. size_t count, loff_t *ppos)
  35. {
  36. char * s = big_buffer;
  37. s += sprintf(s, "GSCTRL = %08lx\n", GSCTRL);
  38. s += sprintf(s, "VSCTRL = %08lx\n", VSCTRL);
  39. s += sprintf(s, "GBBASE = %08lx\n", GBBASE);
  40. s += sprintf(s, "VBBASE = %08lx\n", VBBASE);
  41. s += sprintf(s, "GDRCTRL = %08lx\n", GDRCTRL);
  42. s += sprintf(s, "VCMSK = %08lx\n", VCMSK);
  43. s += sprintf(s, "GSCADR = %08lx\n", GSCADR);
  44. s += sprintf(s, "VSCADR = %08lx\n", VSCADR);
  45. s += sprintf(s, "VUBASE = %08lx\n", VUBASE);
  46. s += sprintf(s, "VVBASE = %08lx\n", VVBASE);
  47. s += sprintf(s, "GSADR = %08lx\n", GSADR);
  48. s += sprintf(s, "VSADR = %08lx\n", VSADR);
  49. s += sprintf(s, "HCCTRL = %08lx\n", HCCTRL);
  50. s += sprintf(s, "HCSIZE = %08lx\n", HCSIZE);
  51. s += sprintf(s, "HCPOS = %08lx\n", HCPOS);
  52. s += sprintf(s, "HCBADR = %08lx\n", HCBADR);
  53. s += sprintf(s, "HCCKMSK = %08lx\n", HCCKMSK);
  54. s += sprintf(s, "GPLUT = %08lx\n", GPLUT);
  55. return simple_read_from_buffer(userbuf, count, ppos,
  56. big_buffer, s-big_buffer);
  57. }
  58. static ssize_t display_read_file(struct file *file, char __user *userbuf,
  59. size_t count, loff_t *ppos)
  60. {
  61. char * s = big_buffer;
  62. s += sprintf(s, "DSCTRL = %08lx\n", DSCTRL);
  63. s += sprintf(s, "DHT01 = %08lx\n", DHT01);
  64. s += sprintf(s, "DHT02 = %08lx\n", DHT02);
  65. s += sprintf(s, "DHT03 = %08lx\n", DHT03);
  66. s += sprintf(s, "DVT01 = %08lx\n", DVT01);
  67. s += sprintf(s, "DVT02 = %08lx\n", DVT02);
  68. s += sprintf(s, "DVT03 = %08lx\n", DVT03);
  69. s += sprintf(s, "DBCOL = %08lx\n", DBCOL);
  70. s += sprintf(s, "BGCOLOR = %08lx\n", BGCOLOR);
  71. s += sprintf(s, "DINTRS = %08lx\n", DINTRS);
  72. s += sprintf(s, "DINTRE = %08lx\n", DINTRE);
  73. s += sprintf(s, "DINTRCNT = %08lx\n", DINTRCNT);
  74. s += sprintf(s, "DSIG = %08lx\n", DSIG);
  75. s += sprintf(s, "DMCTRL = %08lx\n", DMCTRL);
  76. s += sprintf(s, "CLIPCTRL = %08lx\n", CLIPCTRL);
  77. s += sprintf(s, "SPOCTRL = %08lx\n", SPOCTRL);
  78. s += sprintf(s, "SVCTRL = %08lx\n", SVCTRL);
  79. s += sprintf(s, "DLSTS = %08lx\n", DLSTS);
  80. s += sprintf(s, "DLLCTRL = %08lx\n", DLLCTRL);
  81. s += sprintf(s, "DVLNUM = %08lx\n", DVLNUM);
  82. s += sprintf(s, "DUCTRL = %08lx\n", DUCTRL);
  83. s += sprintf(s, "DVECTRL = %08lx\n", DVECTRL);
  84. s += sprintf(s, "DHDET = %08lx\n", DHDET);
  85. s += sprintf(s, "DVDET = %08lx\n", DVDET);
  86. s += sprintf(s, "DODMSK = %08lx\n", DODMSK);
  87. s += sprintf(s, "CSC01 = %08lx\n", CSC01);
  88. s += sprintf(s, "CSC02 = %08lx\n", CSC02);
  89. s += sprintf(s, "CSC03 = %08lx\n", CSC03);
  90. s += sprintf(s, "CSC04 = %08lx\n", CSC04);
  91. s += sprintf(s, "CSC05 = %08lx\n", CSC05);
  92. return simple_read_from_buffer(userbuf, count, ppos,
  93. big_buffer, s-big_buffer);
  94. }
  95. static ssize_t clock_read_file(struct file *file, char __user *userbuf,
  96. size_t count, loff_t *ppos)
  97. {
  98. char * s = big_buffer;
  99. s += sprintf(s, "SYSCLKSRC = %08lx\n", SYSCLKSRC);
  100. s += sprintf(s, "PIXCLKSRC = %08lx\n", PIXCLKSRC);
  101. s += sprintf(s, "CLKSLEEP = %08lx\n", CLKSLEEP);
  102. s += sprintf(s, "COREPLL = %08lx\n", COREPLL);
  103. s += sprintf(s, "DISPPLL = %08lx\n", DISPPLL);
  104. s += sprintf(s, "PLLSTAT = %08lx\n", PLLSTAT);
  105. s += sprintf(s, "VOVRCLK = %08lx\n", VOVRCLK);
  106. s += sprintf(s, "PIXCLK = %08lx\n", PIXCLK);
  107. s += sprintf(s, "MEMCLK = %08lx\n", MEMCLK);
  108. s += sprintf(s, "M24CLK = %08lx\n", M24CLK);
  109. s += sprintf(s, "MBXCLK = %08lx\n", MBXCLK);
  110. s += sprintf(s, "SDCLK = %08lx\n", SDCLK);
  111. s += sprintf(s, "PIXCLKDIV = %08lx\n", PIXCLKDIV);
  112. return simple_read_from_buffer(userbuf, count, ppos,
  113. big_buffer, s-big_buffer);
  114. }
  115. static struct file_operations sysconf_fops = {
  116. .read = sysconf_read_file,
  117. .write = write_file_dummy,
  118. .open = open_file_generic,
  119. };
  120. static struct file_operations clock_fops = {
  121. .read = clock_read_file,
  122. .write = write_file_dummy,
  123. .open = open_file_generic,
  124. };
  125. static struct file_operations display_fops = {
  126. .read = display_read_file,
  127. .write = write_file_dummy,
  128. .open = open_file_generic,
  129. };
  130. static struct file_operations gsctl_fops = {
  131. .read = gsctl_read_file,
  132. .write = write_file_dummy,
  133. .open = open_file_generic,
  134. };
  135. static void __devinit mbxfb_debugfs_init(struct fb_info *fbi)
  136. {
  137. struct mbxfb_info *mfbi = fbi->par;
  138. struct mbxfb_debugfs_data *dbg;
  139. dbg = kzalloc(sizeof(struct mbxfb_debugfs_data), GFP_KERNEL);
  140. mfbi->debugfs_data = dbg;
  141. dbg->dir = debugfs_create_dir("mbxfb", NULL);
  142. dbg->sysconf = debugfs_create_file("sysconf", 0444, dbg->dir,
  143. fbi, &sysconf_fops);
  144. dbg->clock = debugfs_create_file("clock", 0444, dbg->dir,
  145. fbi, &clock_fops);
  146. dbg->display = debugfs_create_file("display", 0444, dbg->dir,
  147. fbi, &display_fops);
  148. dbg->gsctl = debugfs_create_file("gsctl", 0444, dbg->dir,
  149. fbi, &gsctl_fops);
  150. }
  151. static void __devexit mbxfb_debugfs_remove(struct fb_info *fbi)
  152. {
  153. struct mbxfb_info *mfbi = fbi->par;
  154. struct mbxfb_debugfs_data *dbg = mfbi->debugfs_data;
  155. debugfs_remove(dbg->gsctl);
  156. debugfs_remove(dbg->display);
  157. debugfs_remove(dbg->clock);
  158. debugfs_remove(dbg->sysconf);
  159. debugfs_remove(dbg->dir);
  160. }