1 // SPDX-License-Identifier: GPL-2.0
3 * debugfs.c - DesignWare USB3 DRD Controller DebugFS file
5 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
7 * Authors: Felipe Balbi <balbi@ti.com>,
8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
11 #include <linux/kernel.h>
12 #include <linux/slab.h>
13 #include <linux/ptrace.h>
14 #include <linux/types.h>
15 #include <linux/spinlock.h>
16 #include <linux/debugfs.h>
17 #include <linux/seq_file.h>
18 #include <linux/delay.h>
19 #include <linux/uaccess.h>
21 #include <linux/usb/ch9.h>
28 #define dump_register(nm) \
30 .name = __stringify(nm), \
31 .offset = DWC3_ ##nm, \
34 #define dump_ep_register_set(n) \
36 .name = "DEPCMDPAR2("__stringify(n)")", \
37 .offset = DWC3_DEP_BASE(n) + \
41 .name = "DEPCMDPAR1("__stringify(n)")", \
42 .offset = DWC3_DEP_BASE(n) + \
46 .name = "DEPCMDPAR0("__stringify(n)")", \
47 .offset = DWC3_DEP_BASE(n) + \
51 .name = "DEPCMD("__stringify(n)")", \
52 .offset = DWC3_DEP_BASE(n) + \
57 static const struct debugfs_reg32 dwc3_regs
[] = {
58 dump_register(GSBUSCFG0
),
59 dump_register(GSBUSCFG1
),
60 dump_register(GTXTHRCFG
),
61 dump_register(GRXTHRCFG
),
63 dump_register(GEVTEN
),
65 dump_register(GUCTL1
),
66 dump_register(GSNPSID
),
70 dump_register(GBUSERRADDR0
),
71 dump_register(GBUSERRADDR1
),
72 dump_register(GPRTBIMAP0
),
73 dump_register(GPRTBIMAP1
),
74 dump_register(GHWPARAMS0
),
75 dump_register(GHWPARAMS1
),
76 dump_register(GHWPARAMS2
),
77 dump_register(GHWPARAMS3
),
78 dump_register(GHWPARAMS4
),
79 dump_register(GHWPARAMS5
),
80 dump_register(GHWPARAMS6
),
81 dump_register(GHWPARAMS7
),
82 dump_register(GDBGFIFOSPACE
),
83 dump_register(GDBGLTSSM
),
84 dump_register(GDBGBMU
),
85 dump_register(GDBGLSPMUX
),
86 dump_register(GDBGLSP
),
87 dump_register(GDBGEPINFO0
),
88 dump_register(GDBGEPINFO1
),
89 dump_register(GPRTBIMAP_HS0
),
90 dump_register(GPRTBIMAP_HS1
),
91 dump_register(GPRTBIMAP_FS0
),
92 dump_register(GPRTBIMAP_FS1
),
94 dump_register(GUSB2PHYCFG(0)),
95 dump_register(GUSB2PHYCFG(1)),
96 dump_register(GUSB2PHYCFG(2)),
97 dump_register(GUSB2PHYCFG(3)),
98 dump_register(GUSB2PHYCFG(4)),
99 dump_register(GUSB2PHYCFG(5)),
100 dump_register(GUSB2PHYCFG(6)),
101 dump_register(GUSB2PHYCFG(7)),
102 dump_register(GUSB2PHYCFG(8)),
103 dump_register(GUSB2PHYCFG(9)),
104 dump_register(GUSB2PHYCFG(10)),
105 dump_register(GUSB2PHYCFG(11)),
106 dump_register(GUSB2PHYCFG(12)),
107 dump_register(GUSB2PHYCFG(13)),
108 dump_register(GUSB2PHYCFG(14)),
109 dump_register(GUSB2PHYCFG(15)),
111 dump_register(GUSB2I2CCTL(0)),
112 dump_register(GUSB2I2CCTL(1)),
113 dump_register(GUSB2I2CCTL(2)),
114 dump_register(GUSB2I2CCTL(3)),
115 dump_register(GUSB2I2CCTL(4)),
116 dump_register(GUSB2I2CCTL(5)),
117 dump_register(GUSB2I2CCTL(6)),
118 dump_register(GUSB2I2CCTL(7)),
119 dump_register(GUSB2I2CCTL(8)),
120 dump_register(GUSB2I2CCTL(9)),
121 dump_register(GUSB2I2CCTL(10)),
122 dump_register(GUSB2I2CCTL(11)),
123 dump_register(GUSB2I2CCTL(12)),
124 dump_register(GUSB2I2CCTL(13)),
125 dump_register(GUSB2I2CCTL(14)),
126 dump_register(GUSB2I2CCTL(15)),
128 dump_register(GUSB2PHYACC(0)),
129 dump_register(GUSB2PHYACC(1)),
130 dump_register(GUSB2PHYACC(2)),
131 dump_register(GUSB2PHYACC(3)),
132 dump_register(GUSB2PHYACC(4)),
133 dump_register(GUSB2PHYACC(5)),
134 dump_register(GUSB2PHYACC(6)),
135 dump_register(GUSB2PHYACC(7)),
136 dump_register(GUSB2PHYACC(8)),
137 dump_register(GUSB2PHYACC(9)),
138 dump_register(GUSB2PHYACC(10)),
139 dump_register(GUSB2PHYACC(11)),
140 dump_register(GUSB2PHYACC(12)),
141 dump_register(GUSB2PHYACC(13)),
142 dump_register(GUSB2PHYACC(14)),
143 dump_register(GUSB2PHYACC(15)),
145 dump_register(GUSB3PIPECTL(0)),
146 dump_register(GUSB3PIPECTL(1)),
147 dump_register(GUSB3PIPECTL(2)),
148 dump_register(GUSB3PIPECTL(3)),
149 dump_register(GUSB3PIPECTL(4)),
150 dump_register(GUSB3PIPECTL(5)),
151 dump_register(GUSB3PIPECTL(6)),
152 dump_register(GUSB3PIPECTL(7)),
153 dump_register(GUSB3PIPECTL(8)),
154 dump_register(GUSB3PIPECTL(9)),
155 dump_register(GUSB3PIPECTL(10)),
156 dump_register(GUSB3PIPECTL(11)),
157 dump_register(GUSB3PIPECTL(12)),
158 dump_register(GUSB3PIPECTL(13)),
159 dump_register(GUSB3PIPECTL(14)),
160 dump_register(GUSB3PIPECTL(15)),
162 dump_register(GTXFIFOSIZ(0)),
163 dump_register(GTXFIFOSIZ(1)),
164 dump_register(GTXFIFOSIZ(2)),
165 dump_register(GTXFIFOSIZ(3)),
166 dump_register(GTXFIFOSIZ(4)),
167 dump_register(GTXFIFOSIZ(5)),
168 dump_register(GTXFIFOSIZ(6)),
169 dump_register(GTXFIFOSIZ(7)),
170 dump_register(GTXFIFOSIZ(8)),
171 dump_register(GTXFIFOSIZ(9)),
172 dump_register(GTXFIFOSIZ(10)),
173 dump_register(GTXFIFOSIZ(11)),
174 dump_register(GTXFIFOSIZ(12)),
175 dump_register(GTXFIFOSIZ(13)),
176 dump_register(GTXFIFOSIZ(14)),
177 dump_register(GTXFIFOSIZ(15)),
178 dump_register(GTXFIFOSIZ(16)),
179 dump_register(GTXFIFOSIZ(17)),
180 dump_register(GTXFIFOSIZ(18)),
181 dump_register(GTXFIFOSIZ(19)),
182 dump_register(GTXFIFOSIZ(20)),
183 dump_register(GTXFIFOSIZ(21)),
184 dump_register(GTXFIFOSIZ(22)),
185 dump_register(GTXFIFOSIZ(23)),
186 dump_register(GTXFIFOSIZ(24)),
187 dump_register(GTXFIFOSIZ(25)),
188 dump_register(GTXFIFOSIZ(26)),
189 dump_register(GTXFIFOSIZ(27)),
190 dump_register(GTXFIFOSIZ(28)),
191 dump_register(GTXFIFOSIZ(29)),
192 dump_register(GTXFIFOSIZ(30)),
193 dump_register(GTXFIFOSIZ(31)),
195 dump_register(GRXFIFOSIZ(0)),
196 dump_register(GRXFIFOSIZ(1)),
197 dump_register(GRXFIFOSIZ(2)),
198 dump_register(GRXFIFOSIZ(3)),
199 dump_register(GRXFIFOSIZ(4)),
200 dump_register(GRXFIFOSIZ(5)),
201 dump_register(GRXFIFOSIZ(6)),
202 dump_register(GRXFIFOSIZ(7)),
203 dump_register(GRXFIFOSIZ(8)),
204 dump_register(GRXFIFOSIZ(9)),
205 dump_register(GRXFIFOSIZ(10)),
206 dump_register(GRXFIFOSIZ(11)),
207 dump_register(GRXFIFOSIZ(12)),
208 dump_register(GRXFIFOSIZ(13)),
209 dump_register(GRXFIFOSIZ(14)),
210 dump_register(GRXFIFOSIZ(15)),
211 dump_register(GRXFIFOSIZ(16)),
212 dump_register(GRXFIFOSIZ(17)),
213 dump_register(GRXFIFOSIZ(18)),
214 dump_register(GRXFIFOSIZ(19)),
215 dump_register(GRXFIFOSIZ(20)),
216 dump_register(GRXFIFOSIZ(21)),
217 dump_register(GRXFIFOSIZ(22)),
218 dump_register(GRXFIFOSIZ(23)),
219 dump_register(GRXFIFOSIZ(24)),
220 dump_register(GRXFIFOSIZ(25)),
221 dump_register(GRXFIFOSIZ(26)),
222 dump_register(GRXFIFOSIZ(27)),
223 dump_register(GRXFIFOSIZ(28)),
224 dump_register(GRXFIFOSIZ(29)),
225 dump_register(GRXFIFOSIZ(30)),
226 dump_register(GRXFIFOSIZ(31)),
228 dump_register(GEVNTADRLO(0)),
229 dump_register(GEVNTADRHI(0)),
230 dump_register(GEVNTSIZ(0)),
231 dump_register(GEVNTCOUNT(0)),
233 dump_register(GHWPARAMS8
),
236 dump_register(DEVTEN
),
238 dump_register(DGCMDPAR
),
239 dump_register(DGCMD
),
240 dump_register(DALEPENA
),
242 dump_ep_register_set(0),
243 dump_ep_register_set(1),
244 dump_ep_register_set(2),
245 dump_ep_register_set(3),
246 dump_ep_register_set(4),
247 dump_ep_register_set(5),
248 dump_ep_register_set(6),
249 dump_ep_register_set(7),
250 dump_ep_register_set(8),
251 dump_ep_register_set(9),
252 dump_ep_register_set(10),
253 dump_ep_register_set(11),
254 dump_ep_register_set(12),
255 dump_ep_register_set(13),
256 dump_ep_register_set(14),
257 dump_ep_register_set(15),
258 dump_ep_register_set(16),
259 dump_ep_register_set(17),
260 dump_ep_register_set(18),
261 dump_ep_register_set(19),
262 dump_ep_register_set(20),
263 dump_ep_register_set(21),
264 dump_ep_register_set(22),
265 dump_ep_register_set(23),
266 dump_ep_register_set(24),
267 dump_ep_register_set(25),
268 dump_ep_register_set(26),
269 dump_ep_register_set(27),
270 dump_ep_register_set(28),
271 dump_ep_register_set(29),
272 dump_ep_register_set(30),
273 dump_ep_register_set(31),
278 dump_register(OEVTEN
),
282 static int dwc3_mode_show(struct seq_file
*s
, void *unused
)
284 struct dwc3
*dwc
= s
->private;
288 spin_lock_irqsave(&dwc
->lock
, flags
);
289 reg
= dwc3_readl(dwc
->regs
, DWC3_GCTL
);
290 spin_unlock_irqrestore(&dwc
->lock
, flags
);
292 switch (DWC3_GCTL_PRTCAP(reg
)) {
293 case DWC3_GCTL_PRTCAP_HOST
:
294 seq_printf(s
, "host\n");
296 case DWC3_GCTL_PRTCAP_DEVICE
:
297 seq_printf(s
, "device\n");
299 case DWC3_GCTL_PRTCAP_OTG
:
300 seq_printf(s
, "otg\n");
303 seq_printf(s
, "UNKNOWN %08x\n", DWC3_GCTL_PRTCAP(reg
));
309 static int dwc3_mode_open(struct inode
*inode
, struct file
*file
)
311 return single_open(file
, dwc3_mode_show
, inode
->i_private
);
314 static ssize_t
dwc3_mode_write(struct file
*file
,
315 const char __user
*ubuf
, size_t count
, loff_t
*ppos
)
317 struct seq_file
*s
= file
->private_data
;
318 struct dwc3
*dwc
= s
->private;
322 if (copy_from_user(&buf
, ubuf
, min_t(size_t, sizeof(buf
) - 1, count
)))
325 if (!strncmp(buf
, "host", 4))
326 mode
= DWC3_GCTL_PRTCAP_HOST
;
328 if (!strncmp(buf
, "device", 6))
329 mode
= DWC3_GCTL_PRTCAP_DEVICE
;
331 if (!strncmp(buf
, "otg", 3))
332 mode
= DWC3_GCTL_PRTCAP_OTG
;
334 dwc3_set_mode(dwc
, mode
);
339 static const struct file_operations dwc3_mode_fops
= {
340 .open
= dwc3_mode_open
,
341 .write
= dwc3_mode_write
,
344 .release
= single_release
,
347 static int dwc3_testmode_show(struct seq_file
*s
, void *unused
)
349 struct dwc3
*dwc
= s
->private;
353 spin_lock_irqsave(&dwc
->lock
, flags
);
354 reg
= dwc3_readl(dwc
->regs
, DWC3_DCTL
);
355 reg
&= DWC3_DCTL_TSTCTRL_MASK
;
357 spin_unlock_irqrestore(&dwc
->lock
, flags
);
361 seq_printf(s
, "no test\n");
364 seq_printf(s
, "test_j\n");
367 seq_printf(s
, "test_k\n");
370 seq_printf(s
, "test_se0_nak\n");
373 seq_printf(s
, "test_packet\n");
376 seq_printf(s
, "test_force_enable\n");
379 seq_printf(s
, "UNKNOWN %d\n", reg
);
385 static int dwc3_testmode_open(struct inode
*inode
, struct file
*file
)
387 return single_open(file
, dwc3_testmode_show
, inode
->i_private
);
390 static ssize_t
dwc3_testmode_write(struct file
*file
,
391 const char __user
*ubuf
, size_t count
, loff_t
*ppos
)
393 struct seq_file
*s
= file
->private_data
;
394 struct dwc3
*dwc
= s
->private;
399 if (copy_from_user(&buf
, ubuf
, min_t(size_t, sizeof(buf
) - 1, count
)))
402 if (!strncmp(buf
, "test_j", 6))
404 else if (!strncmp(buf
, "test_k", 6))
406 else if (!strncmp(buf
, "test_se0_nak", 12))
407 testmode
= TEST_SE0_NAK
;
408 else if (!strncmp(buf
, "test_packet", 11))
409 testmode
= TEST_PACKET
;
410 else if (!strncmp(buf
, "test_force_enable", 17))
411 testmode
= TEST_FORCE_EN
;
415 spin_lock_irqsave(&dwc
->lock
, flags
);
416 dwc3_gadget_set_test_mode(dwc
, testmode
);
417 spin_unlock_irqrestore(&dwc
->lock
, flags
);
422 static const struct file_operations dwc3_testmode_fops
= {
423 .open
= dwc3_testmode_open
,
424 .write
= dwc3_testmode_write
,
427 .release
= single_release
,
430 static int dwc3_link_state_show(struct seq_file
*s
, void *unused
)
432 struct dwc3
*dwc
= s
->private;
434 enum dwc3_link_state state
;
437 spin_lock_irqsave(&dwc
->lock
, flags
);
438 reg
= dwc3_readl(dwc
->regs
, DWC3_DSTS
);
439 state
= DWC3_DSTS_USBLNKST(reg
);
440 spin_unlock_irqrestore(&dwc
->lock
, flags
);
442 seq_printf(s
, "%s\n", dwc3_gadget_link_string(state
));
447 static int dwc3_link_state_open(struct inode
*inode
, struct file
*file
)
449 return single_open(file
, dwc3_link_state_show
, inode
->i_private
);
452 static ssize_t
dwc3_link_state_write(struct file
*file
,
453 const char __user
*ubuf
, size_t count
, loff_t
*ppos
)
455 struct seq_file
*s
= file
->private_data
;
456 struct dwc3
*dwc
= s
->private;
458 enum dwc3_link_state state
= 0;
461 if (copy_from_user(&buf
, ubuf
, min_t(size_t, sizeof(buf
) - 1, count
)))
464 if (!strncmp(buf
, "SS.Disabled", 11))
465 state
= DWC3_LINK_STATE_SS_DIS
;
466 else if (!strncmp(buf
, "Rx.Detect", 9))
467 state
= DWC3_LINK_STATE_RX_DET
;
468 else if (!strncmp(buf
, "SS.Inactive", 11))
469 state
= DWC3_LINK_STATE_SS_INACT
;
470 else if (!strncmp(buf
, "Recovery", 8))
471 state
= DWC3_LINK_STATE_RECOV
;
472 else if (!strncmp(buf
, "Compliance", 10))
473 state
= DWC3_LINK_STATE_CMPLY
;
474 else if (!strncmp(buf
, "Loopback", 8))
475 state
= DWC3_LINK_STATE_LPBK
;
479 spin_lock_irqsave(&dwc
->lock
, flags
);
480 dwc3_gadget_set_link_state(dwc
, state
);
481 spin_unlock_irqrestore(&dwc
->lock
, flags
);
486 static const struct file_operations dwc3_link_state_fops
= {
487 .open
= dwc3_link_state_open
,
488 .write
= dwc3_link_state_write
,
491 .release
= single_release
,
494 struct dwc3_ep_file_map
{
496 const struct file_operations
*const fops
;
499 static int dwc3_tx_fifo_queue_show(struct seq_file
*s
, void *unused
)
501 struct dwc3_ep
*dep
= s
->private;
502 struct dwc3
*dwc
= dep
->dwc
;
506 spin_lock_irqsave(&dwc
->lock
, flags
);
507 val
= dwc3_core_fifo_space(dep
, DWC3_TXFIFOQ
);
508 seq_printf(s
, "%u\n", val
);
509 spin_unlock_irqrestore(&dwc
->lock
, flags
);
514 static int dwc3_rx_fifo_queue_show(struct seq_file
*s
, void *unused
)
516 struct dwc3_ep
*dep
= s
->private;
517 struct dwc3
*dwc
= dep
->dwc
;
521 spin_lock_irqsave(&dwc
->lock
, flags
);
522 val
= dwc3_core_fifo_space(dep
, DWC3_RXFIFOQ
);
523 seq_printf(s
, "%u\n", val
);
524 spin_unlock_irqrestore(&dwc
->lock
, flags
);
529 static int dwc3_tx_request_queue_show(struct seq_file
*s
, void *unused
)
531 struct dwc3_ep
*dep
= s
->private;
532 struct dwc3
*dwc
= dep
->dwc
;
536 spin_lock_irqsave(&dwc
->lock
, flags
);
537 val
= dwc3_core_fifo_space(dep
, DWC3_TXREQQ
);
538 seq_printf(s
, "%u\n", val
);
539 spin_unlock_irqrestore(&dwc
->lock
, flags
);
544 static int dwc3_rx_request_queue_show(struct seq_file
*s
, void *unused
)
546 struct dwc3_ep
*dep
= s
->private;
547 struct dwc3
*dwc
= dep
->dwc
;
551 spin_lock_irqsave(&dwc
->lock
, flags
);
552 val
= dwc3_core_fifo_space(dep
, DWC3_RXREQQ
);
553 seq_printf(s
, "%u\n", val
);
554 spin_unlock_irqrestore(&dwc
->lock
, flags
);
559 static int dwc3_rx_info_queue_show(struct seq_file
*s
, void *unused
)
561 struct dwc3_ep
*dep
= s
->private;
562 struct dwc3
*dwc
= dep
->dwc
;
566 spin_lock_irqsave(&dwc
->lock
, flags
);
567 val
= dwc3_core_fifo_space(dep
, DWC3_RXINFOQ
);
568 seq_printf(s
, "%u\n", val
);
569 spin_unlock_irqrestore(&dwc
->lock
, flags
);
574 static int dwc3_descriptor_fetch_queue_show(struct seq_file
*s
, void *unused
)
576 struct dwc3_ep
*dep
= s
->private;
577 struct dwc3
*dwc
= dep
->dwc
;
581 spin_lock_irqsave(&dwc
->lock
, flags
);
582 val
= dwc3_core_fifo_space(dep
, DWC3_DESCFETCHQ
);
583 seq_printf(s
, "%u\n", val
);
584 spin_unlock_irqrestore(&dwc
->lock
, flags
);
589 static int dwc3_event_queue_show(struct seq_file
*s
, void *unused
)
591 struct dwc3_ep
*dep
= s
->private;
592 struct dwc3
*dwc
= dep
->dwc
;
596 spin_lock_irqsave(&dwc
->lock
, flags
);
597 val
= dwc3_core_fifo_space(dep
, DWC3_EVENTQ
);
598 seq_printf(s
, "%u\n", val
);
599 spin_unlock_irqrestore(&dwc
->lock
, flags
);
604 static int dwc3_transfer_type_show(struct seq_file
*s
, void *unused
)
606 struct dwc3_ep
*dep
= s
->private;
607 struct dwc3
*dwc
= dep
->dwc
;
610 spin_lock_irqsave(&dwc
->lock
, flags
);
611 if (!(dep
->flags
& DWC3_EP_ENABLED
) ||
612 !dep
->endpoint
.desc
) {
613 seq_printf(s
, "--\n");
617 switch (usb_endpoint_type(dep
->endpoint
.desc
)) {
618 case USB_ENDPOINT_XFER_CONTROL
:
619 seq_printf(s
, "control\n");
621 case USB_ENDPOINT_XFER_ISOC
:
622 seq_printf(s
, "isochronous\n");
624 case USB_ENDPOINT_XFER_BULK
:
625 seq_printf(s
, "bulk\n");
627 case USB_ENDPOINT_XFER_INT
:
628 seq_printf(s
, "interrupt\n");
631 seq_printf(s
, "--\n");
635 spin_unlock_irqrestore(&dwc
->lock
, flags
);
640 static int dwc3_trb_ring_show(struct seq_file
*s
, void *unused
)
642 struct dwc3_ep
*dep
= s
->private;
643 struct dwc3
*dwc
= dep
->dwc
;
647 spin_lock_irqsave(&dwc
->lock
, flags
);
648 if (dep
->number
<= 1) {
649 seq_printf(s
, "--\n");
653 seq_printf(s
, "buffer_addr,size,type,ioc,isp_imi,csp,chn,lst,hwo\n");
655 for (i
= 0; i
< DWC3_TRB_NUM
; i
++) {
656 struct dwc3_trb
*trb
= &dep
->trb_pool
[i
];
657 unsigned int type
= DWC3_TRBCTL_TYPE(trb
->ctrl
);
659 seq_printf(s
, "%08x%08x,%d,%s,%d,%d,%d,%d,%d,%d %c%c\n",
660 trb
->bph
, trb
->bpl
, trb
->size
,
661 dwc3_trb_type_string(type
),
662 !!(trb
->ctrl
& DWC3_TRB_CTRL_IOC
),
663 !!(trb
->ctrl
& DWC3_TRB_CTRL_ISP_IMI
),
664 !!(trb
->ctrl
& DWC3_TRB_CTRL_CSP
),
665 !!(trb
->ctrl
& DWC3_TRB_CTRL_CHN
),
666 !!(trb
->ctrl
& DWC3_TRB_CTRL_LST
),
667 !!(trb
->ctrl
& DWC3_TRB_CTRL_HWO
),
668 dep
->trb_enqueue
== i
? 'E' : ' ',
669 dep
->trb_dequeue
== i
? 'D' : ' ');
673 spin_unlock_irqrestore(&dwc
->lock
, flags
);
678 DEFINE_SHOW_ATTRIBUTE(dwc3_tx_fifo_queue
);
679 DEFINE_SHOW_ATTRIBUTE(dwc3_rx_fifo_queue
);
680 DEFINE_SHOW_ATTRIBUTE(dwc3_tx_request_queue
);
681 DEFINE_SHOW_ATTRIBUTE(dwc3_rx_request_queue
);
682 DEFINE_SHOW_ATTRIBUTE(dwc3_rx_info_queue
);
683 DEFINE_SHOW_ATTRIBUTE(dwc3_descriptor_fetch_queue
);
684 DEFINE_SHOW_ATTRIBUTE(dwc3_event_queue
);
685 DEFINE_SHOW_ATTRIBUTE(dwc3_transfer_type
);
686 DEFINE_SHOW_ATTRIBUTE(dwc3_trb_ring
);
688 static const struct dwc3_ep_file_map dwc3_ep_file_map
[] = {
689 { "tx_fifo_queue", &dwc3_tx_fifo_queue_fops
, },
690 { "rx_fifo_queue", &dwc3_rx_fifo_queue_fops
, },
691 { "tx_request_queue", &dwc3_tx_request_queue_fops
, },
692 { "rx_request_queue", &dwc3_rx_request_queue_fops
, },
693 { "rx_info_queue", &dwc3_rx_info_queue_fops
, },
694 { "descriptor_fetch_queue", &dwc3_descriptor_fetch_queue_fops
, },
695 { "event_queue", &dwc3_event_queue_fops
, },
696 { "transfer_type", &dwc3_transfer_type_fops
, },
697 { "trb_ring", &dwc3_trb_ring_fops
, },
700 static void dwc3_debugfs_create_endpoint_files(struct dwc3_ep
*dep
,
701 struct dentry
*parent
)
705 for (i
= 0; i
< ARRAY_SIZE(dwc3_ep_file_map
); i
++) {
706 const struct file_operations
*fops
= dwc3_ep_file_map
[i
].fops
;
707 const char *name
= dwc3_ep_file_map
[i
].name
;
709 debugfs_create_file(name
, S_IRUGO
, parent
, dep
, fops
);
713 static void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep
*dep
,
714 struct dentry
*parent
)
718 dir
= debugfs_create_dir(dep
->name
, parent
);
719 dwc3_debugfs_create_endpoint_files(dep
, dir
);
722 static void dwc3_debugfs_create_endpoint_dirs(struct dwc3
*dwc
,
723 struct dentry
*parent
)
727 for (i
= 0; i
< dwc
->num_eps
; i
++) {
728 struct dwc3_ep
*dep
= dwc
->eps
[i
];
733 dwc3_debugfs_create_endpoint_dir(dep
, parent
);
737 void dwc3_debugfs_init(struct dwc3
*dwc
)
741 dwc
->regset
= kzalloc(sizeof(*dwc
->regset
), GFP_KERNEL
);
745 dwc
->regset
->regs
= dwc3_regs
;
746 dwc
->regset
->nregs
= ARRAY_SIZE(dwc3_regs
);
747 dwc
->regset
->base
= dwc
->regs
- DWC3_GLOBALS_REGS_START
;
749 root
= debugfs_create_dir(dev_name(dwc
->dev
), NULL
);
752 debugfs_create_regset32("regdump", S_IRUGO
, root
, dwc
->regset
);
754 if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE
)) {
755 debugfs_create_file("mode", S_IRUGO
| S_IWUSR
, root
, dwc
,
759 if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE
) ||
760 IS_ENABLED(CONFIG_USB_DWC3_GADGET
)) {
761 debugfs_create_file("testmode", S_IRUGO
| S_IWUSR
, root
, dwc
,
762 &dwc3_testmode_fops
);
763 debugfs_create_file("link_state", S_IRUGO
| S_IWUSR
, root
, dwc
,
764 &dwc3_link_state_fops
);
765 dwc3_debugfs_create_endpoint_dirs(dwc
, root
);
769 void dwc3_debugfs_exit(struct dwc3
*dwc
)
771 debugfs_remove_recursive(dwc
->root
);