mbxdebugfs.c 8.2 KB

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