c8sectpfe-debugfs.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. /*
  2. * c8sectpfe-debugfs.c - C8SECTPFE STi DVB driver
  3. *
  4. * Copyright (c) STMicroelectronics 2015
  5. *
  6. * Author: Peter Griffin <peter.griffin@linaro.org>
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 of
  10. * the License as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #include <linux/debugfs.h>
  18. #include <linux/device.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/io.h>
  21. #include <linux/kernel.h>
  22. #include <linux/seq_file.h>
  23. #include <linux/slab.h>
  24. #include <linux/types.h>
  25. #include "c8sectpfe-debugfs.h"
  26. #define dump_register(nm ...) \
  27. { \
  28. .name = #nm, \
  29. .offset = nm, \
  30. }
  31. static const struct debugfs_reg32 fei_sys_regs[] = {
  32. dump_register(SYS_INPUT_ERR_STATUS),
  33. dump_register(SYS_OTHER_ERR_STATUS),
  34. dump_register(SYS_INPUT_ERR_MASK),
  35. dump_register(SYS_DMA_ROUTE),
  36. dump_register(SYS_INPUT_CLKEN),
  37. dump_register(IBENABLE_MASK),
  38. dump_register(SYS_OTHER_CLKEN),
  39. dump_register(SYS_CFG_NUM_IB),
  40. dump_register(SYS_CFG_NUM_MIB),
  41. dump_register(SYS_CFG_NUM_SWTS),
  42. dump_register(SYS_CFG_NUM_TSOUT),
  43. dump_register(SYS_CFG_NUM_CCSC),
  44. dump_register(SYS_CFG_NUM_RAM),
  45. dump_register(SYS_CFG_NUM_TP),
  46. dump_register(C8SECTPFE_IB_IP_FMT_CFG(0)),
  47. dump_register(C8SECTPFE_IB_TAGBYTES_CFG(0)),
  48. dump_register(C8SECTPFE_IB_PID_SET(0)),
  49. dump_register(C8SECTPFE_IB_PKT_LEN(0)),
  50. dump_register(C8SECTPFE_IB_BUFF_STRT(0)),
  51. dump_register(C8SECTPFE_IB_BUFF_END(0)),
  52. dump_register(C8SECTPFE_IB_READ_PNT(0)),
  53. dump_register(C8SECTPFE_IB_WRT_PNT(0)),
  54. dump_register(C8SECTPFE_IB_PRI_THRLD(0)),
  55. dump_register(C8SECTPFE_IB_STAT(0)),
  56. dump_register(C8SECTPFE_IB_MASK(0)),
  57. dump_register(C8SECTPFE_IB_SYS(0)),
  58. dump_register(C8SECTPFE_IB_IP_FMT_CFG(1)),
  59. dump_register(C8SECTPFE_IB_TAGBYTES_CFG(1)),
  60. dump_register(C8SECTPFE_IB_PID_SET(1)),
  61. dump_register(C8SECTPFE_IB_PKT_LEN(1)),
  62. dump_register(C8SECTPFE_IB_BUFF_STRT(1)),
  63. dump_register(C8SECTPFE_IB_BUFF_END(1)),
  64. dump_register(C8SECTPFE_IB_READ_PNT(1)),
  65. dump_register(C8SECTPFE_IB_WRT_PNT(1)),
  66. dump_register(C8SECTPFE_IB_PRI_THRLD(1)),
  67. dump_register(C8SECTPFE_IB_STAT(1)),
  68. dump_register(C8SECTPFE_IB_MASK(1)),
  69. dump_register(C8SECTPFE_IB_SYS(1)),
  70. dump_register(C8SECTPFE_IB_IP_FMT_CFG(2)),
  71. dump_register(C8SECTPFE_IB_TAGBYTES_CFG(2)),
  72. dump_register(C8SECTPFE_IB_PID_SET(2)),
  73. dump_register(C8SECTPFE_IB_PKT_LEN(2)),
  74. dump_register(C8SECTPFE_IB_BUFF_STRT(2)),
  75. dump_register(C8SECTPFE_IB_BUFF_END(2)),
  76. dump_register(C8SECTPFE_IB_READ_PNT(2)),
  77. dump_register(C8SECTPFE_IB_WRT_PNT(2)),
  78. dump_register(C8SECTPFE_IB_PRI_THRLD(2)),
  79. dump_register(C8SECTPFE_IB_STAT(2)),
  80. dump_register(C8SECTPFE_IB_MASK(2)),
  81. dump_register(C8SECTPFE_IB_SYS(2)),
  82. dump_register(C8SECTPFE_IB_IP_FMT_CFG(3)),
  83. dump_register(C8SECTPFE_IB_TAGBYTES_CFG(3)),
  84. dump_register(C8SECTPFE_IB_PID_SET(3)),
  85. dump_register(C8SECTPFE_IB_PKT_LEN(3)),
  86. dump_register(C8SECTPFE_IB_BUFF_STRT(3)),
  87. dump_register(C8SECTPFE_IB_BUFF_END(3)),
  88. dump_register(C8SECTPFE_IB_READ_PNT(3)),
  89. dump_register(C8SECTPFE_IB_WRT_PNT(3)),
  90. dump_register(C8SECTPFE_IB_PRI_THRLD(3)),
  91. dump_register(C8SECTPFE_IB_STAT(3)),
  92. dump_register(C8SECTPFE_IB_MASK(3)),
  93. dump_register(C8SECTPFE_IB_SYS(3)),
  94. dump_register(C8SECTPFE_IB_IP_FMT_CFG(4)),
  95. dump_register(C8SECTPFE_IB_TAGBYTES_CFG(4)),
  96. dump_register(C8SECTPFE_IB_PID_SET(4)),
  97. dump_register(C8SECTPFE_IB_PKT_LEN(4)),
  98. dump_register(C8SECTPFE_IB_BUFF_STRT(4)),
  99. dump_register(C8SECTPFE_IB_BUFF_END(4)),
  100. dump_register(C8SECTPFE_IB_READ_PNT(4)),
  101. dump_register(C8SECTPFE_IB_WRT_PNT(4)),
  102. dump_register(C8SECTPFE_IB_PRI_THRLD(4)),
  103. dump_register(C8SECTPFE_IB_STAT(4)),
  104. dump_register(C8SECTPFE_IB_MASK(4)),
  105. dump_register(C8SECTPFE_IB_SYS(4)),
  106. dump_register(C8SECTPFE_IB_IP_FMT_CFG(5)),
  107. dump_register(C8SECTPFE_IB_TAGBYTES_CFG(5)),
  108. dump_register(C8SECTPFE_IB_PID_SET(5)),
  109. dump_register(C8SECTPFE_IB_PKT_LEN(5)),
  110. dump_register(C8SECTPFE_IB_BUFF_STRT(5)),
  111. dump_register(C8SECTPFE_IB_BUFF_END(5)),
  112. dump_register(C8SECTPFE_IB_READ_PNT(5)),
  113. dump_register(C8SECTPFE_IB_WRT_PNT(5)),
  114. dump_register(C8SECTPFE_IB_PRI_THRLD(5)),
  115. dump_register(C8SECTPFE_IB_STAT(5)),
  116. dump_register(C8SECTPFE_IB_MASK(5)),
  117. dump_register(C8SECTPFE_IB_SYS(5)),
  118. dump_register(C8SECTPFE_IB_IP_FMT_CFG(6)),
  119. dump_register(C8SECTPFE_IB_TAGBYTES_CFG(6)),
  120. dump_register(C8SECTPFE_IB_PID_SET(6)),
  121. dump_register(C8SECTPFE_IB_PKT_LEN(6)),
  122. dump_register(C8SECTPFE_IB_BUFF_STRT(6)),
  123. dump_register(C8SECTPFE_IB_BUFF_END(6)),
  124. dump_register(C8SECTPFE_IB_READ_PNT(6)),
  125. dump_register(C8SECTPFE_IB_WRT_PNT(6)),
  126. dump_register(C8SECTPFE_IB_PRI_THRLD(6)),
  127. dump_register(C8SECTPFE_IB_STAT(6)),
  128. dump_register(C8SECTPFE_IB_MASK(6)),
  129. dump_register(C8SECTPFE_IB_SYS(6)),
  130. dump_register(DMA_CPU_ID),
  131. dump_register(DMA_CPU_VCR),
  132. dump_register(DMA_CPU_RUN),
  133. dump_register(DMA_CPU_PC),
  134. dump_register(DMA_PER_TPn_DREQ_MASK),
  135. dump_register(DMA_PER_TPn_DACK_SET),
  136. dump_register(DMA_PER_TPn_DREQ),
  137. dump_register(DMA_PER_TPn_DACK),
  138. dump_register(DMA_PER_DREQ_MODE),
  139. dump_register(DMA_PER_STBUS_SYNC),
  140. dump_register(DMA_PER_STBUS_ACCESS),
  141. dump_register(DMA_PER_STBUS_ADDRESS),
  142. dump_register(DMA_PER_IDLE_INT),
  143. dump_register(DMA_PER_PRIORITY),
  144. dump_register(DMA_PER_MAX_OPCODE),
  145. dump_register(DMA_PER_MAX_CHUNK),
  146. dump_register(DMA_PER_PAGE_SIZE),
  147. dump_register(DMA_PER_MBOX_STATUS),
  148. dump_register(DMA_PER_MBOX_SET),
  149. dump_register(DMA_PER_MBOX_CLEAR),
  150. dump_register(DMA_PER_MBOX_MASK),
  151. dump_register(DMA_PER_INJECT_PKT_SRC),
  152. dump_register(DMA_PER_INJECT_PKT_DEST),
  153. dump_register(DMA_PER_INJECT_PKT_ADDR),
  154. dump_register(DMA_PER_INJECT_PKT),
  155. dump_register(DMA_PER_PAT_PTR_INIT),
  156. dump_register(DMA_PER_PAT_PTR),
  157. dump_register(DMA_PER_SLEEP_MASK),
  158. dump_register(DMA_PER_SLEEP_COUNTER),
  159. dump_register(DMA_FIRMWARE_VERSION),
  160. dump_register(DMA_PTRREC_BASE),
  161. dump_register(DMA_PTRREC_INPUT_OFFSET),
  162. dump_register(DMA_ERRREC_BASE),
  163. dump_register(DMA_ERROR_RECORD(0)),
  164. dump_register(DMA_ERROR_RECORD(1)),
  165. dump_register(DMA_ERROR_RECORD(2)),
  166. dump_register(DMA_ERROR_RECORD(3)),
  167. dump_register(DMA_ERROR_RECORD(4)),
  168. dump_register(DMA_ERROR_RECORD(5)),
  169. dump_register(DMA_ERROR_RECORD(6)),
  170. dump_register(DMA_ERROR_RECORD(7)),
  171. dump_register(DMA_ERROR_RECORD(8)),
  172. dump_register(DMA_ERROR_RECORD(9)),
  173. dump_register(DMA_ERROR_RECORD(10)),
  174. dump_register(DMA_ERROR_RECORD(11)),
  175. dump_register(DMA_ERROR_RECORD(12)),
  176. dump_register(DMA_ERROR_RECORD(13)),
  177. dump_register(DMA_ERROR_RECORD(14)),
  178. dump_register(DMA_ERROR_RECORD(15)),
  179. dump_register(DMA_ERROR_RECORD(16)),
  180. dump_register(DMA_ERROR_RECORD(17)),
  181. dump_register(DMA_ERROR_RECORD(18)),
  182. dump_register(DMA_ERROR_RECORD(19)),
  183. dump_register(DMA_ERROR_RECORD(20)),
  184. dump_register(DMA_ERROR_RECORD(21)),
  185. dump_register(DMA_ERROR_RECORD(22)),
  186. dump_register(DMA_IDLE_REQ),
  187. dump_register(DMA_FIRMWARE_CONFIG),
  188. dump_register(PIDF_BASE(0)),
  189. dump_register(PIDF_BASE(1)),
  190. dump_register(PIDF_BASE(2)),
  191. dump_register(PIDF_BASE(3)),
  192. dump_register(PIDF_BASE(4)),
  193. dump_register(PIDF_BASE(5)),
  194. dump_register(PIDF_BASE(6)),
  195. dump_register(PIDF_BASE(7)),
  196. dump_register(PIDF_BASE(8)),
  197. dump_register(PIDF_BASE(9)),
  198. dump_register(PIDF_BASE(10)),
  199. dump_register(PIDF_BASE(11)),
  200. dump_register(PIDF_BASE(12)),
  201. dump_register(PIDF_BASE(13)),
  202. dump_register(PIDF_BASE(14)),
  203. dump_register(PIDF_BASE(15)),
  204. dump_register(PIDF_BASE(16)),
  205. dump_register(PIDF_BASE(17)),
  206. dump_register(PIDF_BASE(18)),
  207. dump_register(PIDF_BASE(19)),
  208. dump_register(PIDF_BASE(20)),
  209. dump_register(PIDF_BASE(21)),
  210. dump_register(PIDF_BASE(22)),
  211. dump_register(PIDF_LEAK_ENABLE),
  212. dump_register(PIDF_LEAK_STATUS),
  213. dump_register(PIDF_LEAK_COUNT_RESET),
  214. dump_register(PIDF_LEAK_COUNTER),
  215. };
  216. void c8sectpfe_debugfs_init(struct c8sectpfei *fei)
  217. {
  218. struct dentry *root;
  219. struct dentry *file;
  220. root = debugfs_create_dir("c8sectpfe", NULL);
  221. if (!root)
  222. goto err;
  223. fei->root = root;
  224. fei->regset = devm_kzalloc(fei->dev, sizeof(*fei->regset), GFP_KERNEL);
  225. if (!fei->regset)
  226. goto err;
  227. fei->regset->regs = fei_sys_regs;
  228. fei->regset->nregs = ARRAY_SIZE(fei_sys_regs);
  229. fei->regset->base = fei->io;
  230. file = debugfs_create_regset32("registers", S_IRUGO, root,
  231. fei->regset);
  232. if (!file) {
  233. dev_err(fei->dev,
  234. "%s not able to create 'registers' debugfs\n"
  235. , __func__);
  236. goto err;
  237. }
  238. return;
  239. err:
  240. debugfs_remove_recursive(root);
  241. }
  242. void c8sectpfe_debugfs_exit(struct c8sectpfei *fei)
  243. {
  244. debugfs_remove_recursive(fei->root);
  245. fei->root = NULL;
  246. }