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