mbxdebugfs.c 8.1 KB

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