mbxdebugfs.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. struct dentry *sdram;
  11. struct dentry *misc;
  12. };
  13. static int open_file_generic(struct inode *inode, struct file *file)
  14. {
  15. file->private_data = inode->u.generic_ip;
  16. return 0;
  17. }
  18. static ssize_t write_file_dummy(struct file *file, const char __user *buf,
  19. size_t count, loff_t *ppos)
  20. {
  21. return count;
  22. }
  23. static ssize_t sysconf_read_file(struct file *file, char __user *userbuf,
  24. size_t count, loff_t *ppos)
  25. {
  26. char * s = big_buffer;
  27. s += sprintf(s, "SYSCFG = %08x\n", readl(SYSCFG));
  28. s += sprintf(s, "PFBASE = %08x\n", readl(PFBASE));
  29. s += sprintf(s, "PFCEIL = %08x\n", readl(PFCEIL));
  30. s += sprintf(s, "POLLFLAG = %08x\n", readl(POLLFLAG));
  31. s += sprintf(s, "SYSRST = %08x\n", readl(SYSRST));
  32. return simple_read_from_buffer(userbuf, count, ppos,
  33. big_buffer, s-big_buffer);
  34. }
  35. static ssize_t gsctl_read_file(struct file *file, char __user *userbuf,
  36. size_t count, loff_t *ppos)
  37. {
  38. char * s = big_buffer;
  39. s += sprintf(s, "GSCTRL = %08x\n", readl(GSCTRL));
  40. s += sprintf(s, "VSCTRL = %08x\n", readl(VSCTRL));
  41. s += sprintf(s, "GBBASE = %08x\n", readl(GBBASE));
  42. s += sprintf(s, "VBBASE = %08x\n", readl(VBBASE));
  43. s += sprintf(s, "GDRCTRL = %08x\n", readl(GDRCTRL));
  44. s += sprintf(s, "VCMSK = %08x\n", readl(VCMSK));
  45. s += sprintf(s, "GSCADR = %08x\n", readl(GSCADR));
  46. s += sprintf(s, "VSCADR = %08x\n", readl(VSCADR));
  47. s += sprintf(s, "VUBASE = %08x\n", readl(VUBASE));
  48. s += sprintf(s, "VVBASE = %08x\n", readl(VVBASE));
  49. s += sprintf(s, "GSADR = %08x\n", readl(GSADR));
  50. s += sprintf(s, "VSADR = %08x\n", readl(VSADR));
  51. s += sprintf(s, "HCCTRL = %08x\n", readl(HCCTRL));
  52. s += sprintf(s, "HCSIZE = %08x\n", readl(HCSIZE));
  53. s += sprintf(s, "HCPOS = %08x\n", readl(HCPOS));
  54. s += sprintf(s, "HCBADR = %08x\n", readl(HCBADR));
  55. s += sprintf(s, "HCCKMSK = %08x\n", readl(HCCKMSK));
  56. s += sprintf(s, "GPLUT = %08x\n", readl(GPLUT));
  57. return simple_read_from_buffer(userbuf, count, ppos,
  58. big_buffer, s-big_buffer);
  59. }
  60. static ssize_t display_read_file(struct file *file, char __user *userbuf,
  61. size_t count, loff_t *ppos)
  62. {
  63. char * s = big_buffer;
  64. s += sprintf(s, "DSCTRL = %08x\n", readl(DSCTRL));
  65. s += sprintf(s, "DHT01 = %08x\n", readl(DHT01));
  66. s += sprintf(s, "DHT02 = %08x\n", readl(DHT02));
  67. s += sprintf(s, "DHT03 = %08x\n", readl(DHT03));
  68. s += sprintf(s, "DVT01 = %08x\n", readl(DVT01));
  69. s += sprintf(s, "DVT02 = %08x\n", readl(DVT02));
  70. s += sprintf(s, "DVT03 = %08x\n", readl(DVT03));
  71. s += sprintf(s, "DBCOL = %08x\n", readl(DBCOL));
  72. s += sprintf(s, "BGCOLOR = %08x\n", readl(BGCOLOR));
  73. s += sprintf(s, "DINTRS = %08x\n", readl(DINTRS));
  74. s += sprintf(s, "DINTRE = %08x\n", readl(DINTRE));
  75. s += sprintf(s, "DINTRCNT = %08x\n", readl(DINTRCNT));
  76. s += sprintf(s, "DSIG = %08x\n", readl(DSIG));
  77. s += sprintf(s, "DMCTRL = %08x\n", readl(DMCTRL));
  78. s += sprintf(s, "CLIPCTRL = %08x\n", readl(CLIPCTRL));
  79. s += sprintf(s, "SPOCTRL = %08x\n", readl(SPOCTRL));
  80. s += sprintf(s, "SVCTRL = %08x\n", readl(SVCTRL));
  81. s += sprintf(s, "DLSTS = %08x\n", readl(DLSTS));
  82. s += sprintf(s, "DLLCTRL = %08x\n", readl(DLLCTRL));
  83. s += sprintf(s, "DVLNUM = %08x\n", readl(DVLNUM));
  84. s += sprintf(s, "DUCTRL = %08x\n", readl(DUCTRL));
  85. s += sprintf(s, "DVECTRL = %08x\n", readl(DVECTRL));
  86. s += sprintf(s, "DHDET = %08x\n", readl(DHDET));
  87. s += sprintf(s, "DVDET = %08x\n", readl(DVDET));
  88. s += sprintf(s, "DODMSK = %08x\n", readl(DODMSK));
  89. s += sprintf(s, "CSC01 = %08x\n", readl(CSC01));
  90. s += sprintf(s, "CSC02 = %08x\n", readl(CSC02));
  91. s += sprintf(s, "CSC03 = %08x\n", readl(CSC03));
  92. s += sprintf(s, "CSC04 = %08x\n", readl(CSC04));
  93. s += sprintf(s, "CSC05 = %08x\n", readl(CSC05));
  94. return simple_read_from_buffer(userbuf, count, ppos,
  95. big_buffer, s-big_buffer);
  96. }
  97. static ssize_t clock_read_file(struct file *file, char __user *userbuf,
  98. size_t count, loff_t *ppos)
  99. {
  100. char * s = big_buffer;
  101. s += sprintf(s, "SYSCLKSRC = %08x\n", readl(SYSCLKSRC));
  102. s += sprintf(s, "PIXCLKSRC = %08x\n", readl(PIXCLKSRC));
  103. s += sprintf(s, "CLKSLEEP = %08x\n", readl(CLKSLEEP));
  104. s += sprintf(s, "COREPLL = %08x\n", readl(COREPLL));
  105. s += sprintf(s, "DISPPLL = %08x\n", readl(DISPPLL));
  106. s += sprintf(s, "PLLSTAT = %08x\n", readl(PLLSTAT));
  107. s += sprintf(s, "VOVRCLK = %08x\n", readl(VOVRCLK));
  108. s += sprintf(s, "PIXCLK = %08x\n", readl(PIXCLK));
  109. s += sprintf(s, "MEMCLK = %08x\n", readl(MEMCLK));
  110. s += sprintf(s, "M24CLK = %08x\n", readl(M24CLK));
  111. s += sprintf(s, "MBXCLK = %08x\n", readl(MBXCLK));
  112. s += sprintf(s, "SDCLK = %08x\n", readl(SDCLK));
  113. s += sprintf(s, "PIXCLKDIV = %08x\n", readl(PIXCLKDIV));
  114. return simple_read_from_buffer(userbuf, count, ppos,
  115. big_buffer, s-big_buffer);
  116. }
  117. static ssize_t sdram_read_file(struct file *file, char __user *userbuf,
  118. size_t count, loff_t *ppos)
  119. {
  120. char * s = big_buffer;
  121. s += sprintf(s, "LMRST = %08x\n", readl(LMRST));
  122. s += sprintf(s, "LMCFG = %08x\n", readl(LMCFG));
  123. s += sprintf(s, "LMPWR = %08x\n", readl(LMPWR));
  124. s += sprintf(s, "LMPWRSTAT = %08x\n", readl(LMPWRSTAT));
  125. s += sprintf(s, "LMCEMR = %08x\n", readl(LMCEMR));
  126. s += sprintf(s, "LMTYPE = %08x\n", readl(LMTYPE));
  127. s += sprintf(s, "LMTIM = %08x\n", readl(LMTIM));
  128. s += sprintf(s, "LMREFRESH = %08x\n", readl(LMREFRESH));
  129. s += sprintf(s, "LMPROTMIN = %08x\n", readl(LMPROTMIN));
  130. s += sprintf(s, "LMPROTMAX = %08x\n", readl(LMPROTMAX));
  131. s += sprintf(s, "LMPROTCFG = %08x\n", readl(LMPROTCFG));
  132. s += sprintf(s, "LMPROTERR = %08x\n", readl(LMPROTERR));
  133. return simple_read_from_buffer(userbuf, count, ppos,
  134. big_buffer, s-big_buffer);
  135. }
  136. static ssize_t misc_read_file(struct file *file, char __user *userbuf,
  137. size_t count, loff_t *ppos)
  138. {
  139. char * s = big_buffer;
  140. s += sprintf(s, "LCD_CONFIG = %08x\n", readl(LCD_CONFIG));
  141. s += sprintf(s, "ODFBPWR = %08x\n", readl(ODFBPWR));
  142. s += sprintf(s, "ODFBSTAT = %08x\n", readl(ODFBSTAT));
  143. s += sprintf(s, "ID = %08x\n", readl(ID));
  144. return simple_read_from_buffer(userbuf, count, ppos,
  145. big_buffer, s-big_buffer);
  146. }
  147. static const struct file_operations sysconf_fops = {
  148. .read = sysconf_read_file,
  149. .write = write_file_dummy,
  150. .open = open_file_generic,
  151. };
  152. static const struct file_operations clock_fops = {
  153. .read = clock_read_file,
  154. .write = write_file_dummy,
  155. .open = open_file_generic,
  156. };
  157. static const struct file_operations display_fops = {
  158. .read = display_read_file,
  159. .write = write_file_dummy,
  160. .open = open_file_generic,
  161. };
  162. static const struct file_operations gsctl_fops = {
  163. .read = gsctl_read_file,
  164. .write = write_file_dummy,
  165. .open = open_file_generic,
  166. };
  167. static const struct file_operations sdram_fops = {
  168. .read = sdram_read_file,
  169. .write = write_file_dummy,
  170. .open = open_file_generic,
  171. };
  172. static const struct file_operations misc_fops = {
  173. .read = misc_read_file,
  174. .write = write_file_dummy,
  175. .open = open_file_generic,
  176. };
  177. static void __devinit mbxfb_debugfs_init(struct fb_info *fbi)
  178. {
  179. struct mbxfb_info *mfbi = fbi->par;
  180. struct mbxfb_debugfs_data *dbg;
  181. dbg = kzalloc(sizeof(struct mbxfb_debugfs_data), GFP_KERNEL);
  182. mfbi->debugfs_data = dbg;
  183. dbg->dir = debugfs_create_dir("mbxfb", NULL);
  184. dbg->sysconf = debugfs_create_file("sysconf", 0444, dbg->dir,
  185. fbi, &sysconf_fops);
  186. dbg->clock = debugfs_create_file("clock", 0444, dbg->dir,
  187. fbi, &clock_fops);
  188. dbg->display = debugfs_create_file("display", 0444, dbg->dir,
  189. fbi, &display_fops);
  190. dbg->gsctl = debugfs_create_file("gsctl", 0444, dbg->dir,
  191. fbi, &gsctl_fops);
  192. dbg->sdram = debugfs_create_file("sdram", 0444, dbg->dir,
  193. fbi, &sdram_fops);
  194. dbg->misc = debugfs_create_file("misc", 0444, dbg->dir,
  195. fbi, &misc_fops);
  196. }
  197. static void __devexit mbxfb_debugfs_remove(struct fb_info *fbi)
  198. {
  199. struct mbxfb_info *mfbi = fbi->par;
  200. struct mbxfb_debugfs_data *dbg = mfbi->debugfs_data;
  201. debugfs_remove(dbg->misc);
  202. debugfs_remove(dbg->sdram);
  203. debugfs_remove(dbg->gsctl);
  204. debugfs_remove(dbg->display);
  205. debugfs_remove(dbg->clock);
  206. debugfs_remove(dbg->sysconf);
  207. debugfs_remove(dbg->dir);
  208. }