1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * xhci-debugfs.c - xHCI debugfs interface
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright (C) 2017 Intel Corporation
6*4882a593Smuzhiyun *
7*4882a593Smuzhiyun * Author: Lu Baolu <baolu.lu@linux.intel.com>
8*4882a593Smuzhiyun */
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun #include <linux/slab.h>
11*4882a593Smuzhiyun #include <linux/uaccess.h>
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun #include "xhci.h"
14*4882a593Smuzhiyun #include "xhci-debugfs.h"
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun static const struct debugfs_reg32 xhci_cap_regs[] = {
17*4882a593Smuzhiyun dump_register(CAPLENGTH),
18*4882a593Smuzhiyun dump_register(HCSPARAMS1),
19*4882a593Smuzhiyun dump_register(HCSPARAMS2),
20*4882a593Smuzhiyun dump_register(HCSPARAMS3),
21*4882a593Smuzhiyun dump_register(HCCPARAMS1),
22*4882a593Smuzhiyun dump_register(DOORBELLOFF),
23*4882a593Smuzhiyun dump_register(RUNTIMEOFF),
24*4882a593Smuzhiyun dump_register(HCCPARAMS2),
25*4882a593Smuzhiyun };
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun static const struct debugfs_reg32 xhci_op_regs[] = {
28*4882a593Smuzhiyun dump_register(USBCMD),
29*4882a593Smuzhiyun dump_register(USBSTS),
30*4882a593Smuzhiyun dump_register(PAGESIZE),
31*4882a593Smuzhiyun dump_register(DNCTRL),
32*4882a593Smuzhiyun dump_register(CRCR),
33*4882a593Smuzhiyun dump_register(DCBAAP_LOW),
34*4882a593Smuzhiyun dump_register(DCBAAP_HIGH),
35*4882a593Smuzhiyun dump_register(CONFIG),
36*4882a593Smuzhiyun };
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun static const struct debugfs_reg32 xhci_runtime_regs[] = {
39*4882a593Smuzhiyun dump_register(MFINDEX),
40*4882a593Smuzhiyun dump_register(IR0_IMAN),
41*4882a593Smuzhiyun dump_register(IR0_IMOD),
42*4882a593Smuzhiyun dump_register(IR0_ERSTSZ),
43*4882a593Smuzhiyun dump_register(IR0_ERSTBA_LOW),
44*4882a593Smuzhiyun dump_register(IR0_ERSTBA_HIGH),
45*4882a593Smuzhiyun dump_register(IR0_ERDP_LOW),
46*4882a593Smuzhiyun dump_register(IR0_ERDP_HIGH),
47*4882a593Smuzhiyun };
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun static const struct debugfs_reg32 xhci_extcap_legsup[] = {
50*4882a593Smuzhiyun dump_register(EXTCAP_USBLEGSUP),
51*4882a593Smuzhiyun dump_register(EXTCAP_USBLEGCTLSTS),
52*4882a593Smuzhiyun };
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun static const struct debugfs_reg32 xhci_extcap_protocol[] = {
55*4882a593Smuzhiyun dump_register(EXTCAP_REVISION),
56*4882a593Smuzhiyun dump_register(EXTCAP_NAME),
57*4882a593Smuzhiyun dump_register(EXTCAP_PORTINFO),
58*4882a593Smuzhiyun dump_register(EXTCAP_PORTTYPE),
59*4882a593Smuzhiyun dump_register(EXTCAP_MANTISSA1),
60*4882a593Smuzhiyun dump_register(EXTCAP_MANTISSA2),
61*4882a593Smuzhiyun dump_register(EXTCAP_MANTISSA3),
62*4882a593Smuzhiyun dump_register(EXTCAP_MANTISSA4),
63*4882a593Smuzhiyun dump_register(EXTCAP_MANTISSA5),
64*4882a593Smuzhiyun dump_register(EXTCAP_MANTISSA6),
65*4882a593Smuzhiyun };
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun static const struct debugfs_reg32 xhci_extcap_dbc[] = {
68*4882a593Smuzhiyun dump_register(EXTCAP_DBC_CAPABILITY),
69*4882a593Smuzhiyun dump_register(EXTCAP_DBC_DOORBELL),
70*4882a593Smuzhiyun dump_register(EXTCAP_DBC_ERSTSIZE),
71*4882a593Smuzhiyun dump_register(EXTCAP_DBC_ERST_LOW),
72*4882a593Smuzhiyun dump_register(EXTCAP_DBC_ERST_HIGH),
73*4882a593Smuzhiyun dump_register(EXTCAP_DBC_ERDP_LOW),
74*4882a593Smuzhiyun dump_register(EXTCAP_DBC_ERDP_HIGH),
75*4882a593Smuzhiyun dump_register(EXTCAP_DBC_CONTROL),
76*4882a593Smuzhiyun dump_register(EXTCAP_DBC_STATUS),
77*4882a593Smuzhiyun dump_register(EXTCAP_DBC_PORTSC),
78*4882a593Smuzhiyun dump_register(EXTCAP_DBC_CONT_LOW),
79*4882a593Smuzhiyun dump_register(EXTCAP_DBC_CONT_HIGH),
80*4882a593Smuzhiyun dump_register(EXTCAP_DBC_DEVINFO1),
81*4882a593Smuzhiyun dump_register(EXTCAP_DBC_DEVINFO2),
82*4882a593Smuzhiyun };
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun static struct dentry *xhci_debugfs_root;
85*4882a593Smuzhiyun
xhci_debugfs_alloc_regset(struct xhci_hcd * xhci)86*4882a593Smuzhiyun static struct xhci_regset *xhci_debugfs_alloc_regset(struct xhci_hcd *xhci)
87*4882a593Smuzhiyun {
88*4882a593Smuzhiyun struct xhci_regset *regset;
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun regset = kzalloc(sizeof(*regset), GFP_KERNEL);
91*4882a593Smuzhiyun if (!regset)
92*4882a593Smuzhiyun return NULL;
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun /*
95*4882a593Smuzhiyun * The allocation and free of regset are executed in order.
96*4882a593Smuzhiyun * We needn't a lock here.
97*4882a593Smuzhiyun */
98*4882a593Smuzhiyun INIT_LIST_HEAD(®set->list);
99*4882a593Smuzhiyun list_add_tail(®set->list, &xhci->regset_list);
100*4882a593Smuzhiyun
101*4882a593Smuzhiyun return regset;
102*4882a593Smuzhiyun }
103*4882a593Smuzhiyun
xhci_debugfs_free_regset(struct xhci_regset * regset)104*4882a593Smuzhiyun static void xhci_debugfs_free_regset(struct xhci_regset *regset)
105*4882a593Smuzhiyun {
106*4882a593Smuzhiyun if (!regset)
107*4882a593Smuzhiyun return;
108*4882a593Smuzhiyun
109*4882a593Smuzhiyun list_del(®set->list);
110*4882a593Smuzhiyun kfree(regset);
111*4882a593Smuzhiyun }
112*4882a593Smuzhiyun
113*4882a593Smuzhiyun __printf(6, 7)
xhci_debugfs_regset(struct xhci_hcd * xhci,u32 base,const struct debugfs_reg32 * regs,size_t nregs,struct dentry * parent,const char * fmt,...)114*4882a593Smuzhiyun static void xhci_debugfs_regset(struct xhci_hcd *xhci, u32 base,
115*4882a593Smuzhiyun const struct debugfs_reg32 *regs,
116*4882a593Smuzhiyun size_t nregs, struct dentry *parent,
117*4882a593Smuzhiyun const char *fmt, ...)
118*4882a593Smuzhiyun {
119*4882a593Smuzhiyun struct xhci_regset *rgs;
120*4882a593Smuzhiyun va_list args;
121*4882a593Smuzhiyun struct debugfs_regset32 *regset;
122*4882a593Smuzhiyun struct usb_hcd *hcd = xhci_to_hcd(xhci);
123*4882a593Smuzhiyun
124*4882a593Smuzhiyun rgs = xhci_debugfs_alloc_regset(xhci);
125*4882a593Smuzhiyun if (!rgs)
126*4882a593Smuzhiyun return;
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun va_start(args, fmt);
129*4882a593Smuzhiyun vsnprintf(rgs->name, sizeof(rgs->name), fmt, args);
130*4882a593Smuzhiyun va_end(args);
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun regset = &rgs->regset;
133*4882a593Smuzhiyun regset->regs = regs;
134*4882a593Smuzhiyun regset->nregs = nregs;
135*4882a593Smuzhiyun regset->base = hcd->regs + base;
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun debugfs_create_regset32((const char *)rgs->name, 0444, parent, regset);
138*4882a593Smuzhiyun }
139*4882a593Smuzhiyun
xhci_debugfs_extcap_regset(struct xhci_hcd * xhci,int cap_id,const struct debugfs_reg32 * regs,size_t n,const char * cap_name)140*4882a593Smuzhiyun static void xhci_debugfs_extcap_regset(struct xhci_hcd *xhci, int cap_id,
141*4882a593Smuzhiyun const struct debugfs_reg32 *regs,
142*4882a593Smuzhiyun size_t n, const char *cap_name)
143*4882a593Smuzhiyun {
144*4882a593Smuzhiyun u32 offset;
145*4882a593Smuzhiyun int index = 0;
146*4882a593Smuzhiyun size_t psic, nregs = n;
147*4882a593Smuzhiyun void __iomem *base = &xhci->cap_regs->hc_capbase;
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun offset = xhci_find_next_ext_cap(base, 0, cap_id);
150*4882a593Smuzhiyun while (offset) {
151*4882a593Smuzhiyun if (cap_id == XHCI_EXT_CAPS_PROTOCOL) {
152*4882a593Smuzhiyun psic = XHCI_EXT_PORT_PSIC(readl(base + offset + 8));
153*4882a593Smuzhiyun nregs = min(4 + psic, n);
154*4882a593Smuzhiyun }
155*4882a593Smuzhiyun
156*4882a593Smuzhiyun xhci_debugfs_regset(xhci, offset, regs, nregs,
157*4882a593Smuzhiyun xhci->debugfs_root, "%s:%02d",
158*4882a593Smuzhiyun cap_name, index);
159*4882a593Smuzhiyun offset = xhci_find_next_ext_cap(base, offset, cap_id);
160*4882a593Smuzhiyun index++;
161*4882a593Smuzhiyun }
162*4882a593Smuzhiyun }
163*4882a593Smuzhiyun
xhci_ring_enqueue_show(struct seq_file * s,void * unused)164*4882a593Smuzhiyun static int xhci_ring_enqueue_show(struct seq_file *s, void *unused)
165*4882a593Smuzhiyun {
166*4882a593Smuzhiyun dma_addr_t dma;
167*4882a593Smuzhiyun struct xhci_ring *ring = *(struct xhci_ring **)s->private;
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun dma = xhci_trb_virt_to_dma(ring->enq_seg, ring->enqueue);
170*4882a593Smuzhiyun seq_printf(s, "%pad\n", &dma);
171*4882a593Smuzhiyun
172*4882a593Smuzhiyun return 0;
173*4882a593Smuzhiyun }
174*4882a593Smuzhiyun
xhci_ring_dequeue_show(struct seq_file * s,void * unused)175*4882a593Smuzhiyun static int xhci_ring_dequeue_show(struct seq_file *s, void *unused)
176*4882a593Smuzhiyun {
177*4882a593Smuzhiyun dma_addr_t dma;
178*4882a593Smuzhiyun struct xhci_ring *ring = *(struct xhci_ring **)s->private;
179*4882a593Smuzhiyun
180*4882a593Smuzhiyun dma = xhci_trb_virt_to_dma(ring->deq_seg, ring->dequeue);
181*4882a593Smuzhiyun seq_printf(s, "%pad\n", &dma);
182*4882a593Smuzhiyun
183*4882a593Smuzhiyun return 0;
184*4882a593Smuzhiyun }
185*4882a593Smuzhiyun
xhci_ring_cycle_show(struct seq_file * s,void * unused)186*4882a593Smuzhiyun static int xhci_ring_cycle_show(struct seq_file *s, void *unused)
187*4882a593Smuzhiyun {
188*4882a593Smuzhiyun struct xhci_ring *ring = *(struct xhci_ring **)s->private;
189*4882a593Smuzhiyun
190*4882a593Smuzhiyun seq_printf(s, "%d\n", ring->cycle_state);
191*4882a593Smuzhiyun
192*4882a593Smuzhiyun return 0;
193*4882a593Smuzhiyun }
194*4882a593Smuzhiyun
xhci_ring_dump_segment(struct seq_file * s,struct xhci_segment * seg)195*4882a593Smuzhiyun static void xhci_ring_dump_segment(struct seq_file *s,
196*4882a593Smuzhiyun struct xhci_segment *seg)
197*4882a593Smuzhiyun {
198*4882a593Smuzhiyun int i;
199*4882a593Smuzhiyun dma_addr_t dma;
200*4882a593Smuzhiyun union xhci_trb *trb;
201*4882a593Smuzhiyun char str[XHCI_MSG_MAX];
202*4882a593Smuzhiyun
203*4882a593Smuzhiyun for (i = 0; i < TRBS_PER_SEGMENT; i++) {
204*4882a593Smuzhiyun trb = &seg->trbs[i];
205*4882a593Smuzhiyun dma = seg->dma + i * sizeof(*trb);
206*4882a593Smuzhiyun seq_printf(s, "%pad: %s\n", &dma,
207*4882a593Smuzhiyun xhci_decode_trb(str, XHCI_MSG_MAX, le32_to_cpu(trb->generic.field[0]),
208*4882a593Smuzhiyun le32_to_cpu(trb->generic.field[1]),
209*4882a593Smuzhiyun le32_to_cpu(trb->generic.field[2]),
210*4882a593Smuzhiyun le32_to_cpu(trb->generic.field[3])));
211*4882a593Smuzhiyun }
212*4882a593Smuzhiyun }
213*4882a593Smuzhiyun
xhci_ring_trb_show(struct seq_file * s,void * unused)214*4882a593Smuzhiyun static int xhci_ring_trb_show(struct seq_file *s, void *unused)
215*4882a593Smuzhiyun {
216*4882a593Smuzhiyun int i;
217*4882a593Smuzhiyun struct xhci_ring *ring = *(struct xhci_ring **)s->private;
218*4882a593Smuzhiyun struct xhci_segment *seg = ring->first_seg;
219*4882a593Smuzhiyun
220*4882a593Smuzhiyun for (i = 0; i < ring->num_segs; i++) {
221*4882a593Smuzhiyun xhci_ring_dump_segment(s, seg);
222*4882a593Smuzhiyun seg = seg->next;
223*4882a593Smuzhiyun }
224*4882a593Smuzhiyun
225*4882a593Smuzhiyun return 0;
226*4882a593Smuzhiyun }
227*4882a593Smuzhiyun
228*4882a593Smuzhiyun static struct xhci_file_map ring_files[] = {
229*4882a593Smuzhiyun {"enqueue", xhci_ring_enqueue_show, },
230*4882a593Smuzhiyun {"dequeue", xhci_ring_dequeue_show, },
231*4882a593Smuzhiyun {"cycle", xhci_ring_cycle_show, },
232*4882a593Smuzhiyun {"trbs", xhci_ring_trb_show, },
233*4882a593Smuzhiyun };
234*4882a593Smuzhiyun
xhci_ring_open(struct inode * inode,struct file * file)235*4882a593Smuzhiyun static int xhci_ring_open(struct inode *inode, struct file *file)
236*4882a593Smuzhiyun {
237*4882a593Smuzhiyun int i;
238*4882a593Smuzhiyun struct xhci_file_map *f_map;
239*4882a593Smuzhiyun const char *file_name = file_dentry(file)->d_iname;
240*4882a593Smuzhiyun
241*4882a593Smuzhiyun for (i = 0; i < ARRAY_SIZE(ring_files); i++) {
242*4882a593Smuzhiyun f_map = &ring_files[i];
243*4882a593Smuzhiyun
244*4882a593Smuzhiyun if (strcmp(f_map->name, file_name) == 0)
245*4882a593Smuzhiyun break;
246*4882a593Smuzhiyun }
247*4882a593Smuzhiyun
248*4882a593Smuzhiyun return single_open(file, f_map->show, inode->i_private);
249*4882a593Smuzhiyun }
250*4882a593Smuzhiyun
251*4882a593Smuzhiyun static const struct file_operations xhci_ring_fops = {
252*4882a593Smuzhiyun .open = xhci_ring_open,
253*4882a593Smuzhiyun .read = seq_read,
254*4882a593Smuzhiyun .llseek = seq_lseek,
255*4882a593Smuzhiyun .release = single_release,
256*4882a593Smuzhiyun };
257*4882a593Smuzhiyun
xhci_slot_context_show(struct seq_file * s,void * unused)258*4882a593Smuzhiyun static int xhci_slot_context_show(struct seq_file *s, void *unused)
259*4882a593Smuzhiyun {
260*4882a593Smuzhiyun struct xhci_hcd *xhci;
261*4882a593Smuzhiyun struct xhci_slot_ctx *slot_ctx;
262*4882a593Smuzhiyun struct xhci_slot_priv *priv = s->private;
263*4882a593Smuzhiyun struct xhci_virt_device *dev = priv->dev;
264*4882a593Smuzhiyun char str[XHCI_MSG_MAX];
265*4882a593Smuzhiyun
266*4882a593Smuzhiyun xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
267*4882a593Smuzhiyun slot_ctx = xhci_get_slot_ctx(xhci, dev->out_ctx);
268*4882a593Smuzhiyun seq_printf(s, "%pad: %s\n", &dev->out_ctx->dma,
269*4882a593Smuzhiyun xhci_decode_slot_context(str,
270*4882a593Smuzhiyun le32_to_cpu(slot_ctx->dev_info),
271*4882a593Smuzhiyun le32_to_cpu(slot_ctx->dev_info2),
272*4882a593Smuzhiyun le32_to_cpu(slot_ctx->tt_info),
273*4882a593Smuzhiyun le32_to_cpu(slot_ctx->dev_state)));
274*4882a593Smuzhiyun
275*4882a593Smuzhiyun return 0;
276*4882a593Smuzhiyun }
277*4882a593Smuzhiyun
xhci_endpoint_context_show(struct seq_file * s,void * unused)278*4882a593Smuzhiyun static int xhci_endpoint_context_show(struct seq_file *s, void *unused)
279*4882a593Smuzhiyun {
280*4882a593Smuzhiyun int ep_index;
281*4882a593Smuzhiyun dma_addr_t dma;
282*4882a593Smuzhiyun struct xhci_hcd *xhci;
283*4882a593Smuzhiyun struct xhci_ep_ctx *ep_ctx;
284*4882a593Smuzhiyun struct xhci_slot_priv *priv = s->private;
285*4882a593Smuzhiyun struct xhci_virt_device *dev = priv->dev;
286*4882a593Smuzhiyun char str[XHCI_MSG_MAX];
287*4882a593Smuzhiyun
288*4882a593Smuzhiyun xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
289*4882a593Smuzhiyun
290*4882a593Smuzhiyun for (ep_index = 0; ep_index < 31; ep_index++) {
291*4882a593Smuzhiyun ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index);
292*4882a593Smuzhiyun dma = dev->out_ctx->dma + (ep_index + 1) * CTX_SIZE(xhci->hcc_params);
293*4882a593Smuzhiyun seq_printf(s, "%pad: %s\n", &dma,
294*4882a593Smuzhiyun xhci_decode_ep_context(str,
295*4882a593Smuzhiyun le32_to_cpu(ep_ctx->ep_info),
296*4882a593Smuzhiyun le32_to_cpu(ep_ctx->ep_info2),
297*4882a593Smuzhiyun le64_to_cpu(ep_ctx->deq),
298*4882a593Smuzhiyun le32_to_cpu(ep_ctx->tx_info)));
299*4882a593Smuzhiyun }
300*4882a593Smuzhiyun
301*4882a593Smuzhiyun return 0;
302*4882a593Smuzhiyun }
303*4882a593Smuzhiyun
xhci_device_name_show(struct seq_file * s,void * unused)304*4882a593Smuzhiyun static int xhci_device_name_show(struct seq_file *s, void *unused)
305*4882a593Smuzhiyun {
306*4882a593Smuzhiyun struct xhci_slot_priv *priv = s->private;
307*4882a593Smuzhiyun struct xhci_virt_device *dev = priv->dev;
308*4882a593Smuzhiyun
309*4882a593Smuzhiyun seq_printf(s, "%s\n", dev_name(&dev->udev->dev));
310*4882a593Smuzhiyun
311*4882a593Smuzhiyun return 0;
312*4882a593Smuzhiyun }
313*4882a593Smuzhiyun
314*4882a593Smuzhiyun static struct xhci_file_map context_files[] = {
315*4882a593Smuzhiyun {"name", xhci_device_name_show, },
316*4882a593Smuzhiyun {"slot-context", xhci_slot_context_show, },
317*4882a593Smuzhiyun {"ep-context", xhci_endpoint_context_show, },
318*4882a593Smuzhiyun };
319*4882a593Smuzhiyun
xhci_context_open(struct inode * inode,struct file * file)320*4882a593Smuzhiyun static int xhci_context_open(struct inode *inode, struct file *file)
321*4882a593Smuzhiyun {
322*4882a593Smuzhiyun int i;
323*4882a593Smuzhiyun struct xhci_file_map *f_map;
324*4882a593Smuzhiyun const char *file_name = file_dentry(file)->d_iname;
325*4882a593Smuzhiyun
326*4882a593Smuzhiyun for (i = 0; i < ARRAY_SIZE(context_files); i++) {
327*4882a593Smuzhiyun f_map = &context_files[i];
328*4882a593Smuzhiyun
329*4882a593Smuzhiyun if (strcmp(f_map->name, file_name) == 0)
330*4882a593Smuzhiyun break;
331*4882a593Smuzhiyun }
332*4882a593Smuzhiyun
333*4882a593Smuzhiyun return single_open(file, f_map->show, inode->i_private);
334*4882a593Smuzhiyun }
335*4882a593Smuzhiyun
336*4882a593Smuzhiyun static const struct file_operations xhci_context_fops = {
337*4882a593Smuzhiyun .open = xhci_context_open,
338*4882a593Smuzhiyun .read = seq_read,
339*4882a593Smuzhiyun .llseek = seq_lseek,
340*4882a593Smuzhiyun .release = single_release,
341*4882a593Smuzhiyun };
342*4882a593Smuzhiyun
343*4882a593Smuzhiyun
344*4882a593Smuzhiyun
xhci_portsc_show(struct seq_file * s,void * unused)345*4882a593Smuzhiyun static int xhci_portsc_show(struct seq_file *s, void *unused)
346*4882a593Smuzhiyun {
347*4882a593Smuzhiyun struct xhci_port *port = s->private;
348*4882a593Smuzhiyun u32 portsc;
349*4882a593Smuzhiyun char str[XHCI_MSG_MAX];
350*4882a593Smuzhiyun
351*4882a593Smuzhiyun portsc = readl(port->addr);
352*4882a593Smuzhiyun seq_printf(s, "%s\n", xhci_decode_portsc(str, portsc));
353*4882a593Smuzhiyun
354*4882a593Smuzhiyun return 0;
355*4882a593Smuzhiyun }
356*4882a593Smuzhiyun
xhci_port_open(struct inode * inode,struct file * file)357*4882a593Smuzhiyun static int xhci_port_open(struct inode *inode, struct file *file)
358*4882a593Smuzhiyun {
359*4882a593Smuzhiyun return single_open(file, xhci_portsc_show, inode->i_private);
360*4882a593Smuzhiyun }
361*4882a593Smuzhiyun
xhci_port_write(struct file * file,const char __user * ubuf,size_t count,loff_t * ppos)362*4882a593Smuzhiyun static ssize_t xhci_port_write(struct file *file, const char __user *ubuf,
363*4882a593Smuzhiyun size_t count, loff_t *ppos)
364*4882a593Smuzhiyun {
365*4882a593Smuzhiyun struct seq_file *s = file->private_data;
366*4882a593Smuzhiyun struct xhci_port *port = s->private;
367*4882a593Smuzhiyun struct xhci_hcd *xhci = hcd_to_xhci(port->rhub->hcd);
368*4882a593Smuzhiyun char buf[32];
369*4882a593Smuzhiyun u32 portsc;
370*4882a593Smuzhiyun unsigned long flags;
371*4882a593Smuzhiyun
372*4882a593Smuzhiyun if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
373*4882a593Smuzhiyun return -EFAULT;
374*4882a593Smuzhiyun
375*4882a593Smuzhiyun if (!strncmp(buf, "compliance", 10)) {
376*4882a593Smuzhiyun /* If CTC is clear, compliance is enabled by default */
377*4882a593Smuzhiyun if (!HCC2_CTC(xhci->hcc_params2))
378*4882a593Smuzhiyun return count;
379*4882a593Smuzhiyun spin_lock_irqsave(&xhci->lock, flags);
380*4882a593Smuzhiyun /* compliance mode can only be enabled on ports in RxDetect */
381*4882a593Smuzhiyun portsc = readl(port->addr);
382*4882a593Smuzhiyun if ((portsc & PORT_PLS_MASK) != XDEV_RXDETECT) {
383*4882a593Smuzhiyun spin_unlock_irqrestore(&xhci->lock, flags);
384*4882a593Smuzhiyun return -EPERM;
385*4882a593Smuzhiyun }
386*4882a593Smuzhiyun portsc = xhci_port_state_to_neutral(portsc);
387*4882a593Smuzhiyun portsc &= ~PORT_PLS_MASK;
388*4882a593Smuzhiyun portsc |= PORT_LINK_STROBE | XDEV_COMP_MODE;
389*4882a593Smuzhiyun writel(portsc, port->addr);
390*4882a593Smuzhiyun spin_unlock_irqrestore(&xhci->lock, flags);
391*4882a593Smuzhiyun } else {
392*4882a593Smuzhiyun return -EINVAL;
393*4882a593Smuzhiyun }
394*4882a593Smuzhiyun return count;
395*4882a593Smuzhiyun }
396*4882a593Smuzhiyun
397*4882a593Smuzhiyun static const struct file_operations port_fops = {
398*4882a593Smuzhiyun .open = xhci_port_open,
399*4882a593Smuzhiyun .write = xhci_port_write,
400*4882a593Smuzhiyun .read = seq_read,
401*4882a593Smuzhiyun .llseek = seq_lseek,
402*4882a593Smuzhiyun .release = single_release,
403*4882a593Smuzhiyun };
404*4882a593Smuzhiyun
xhci_debugfs_create_files(struct xhci_hcd * xhci,struct xhci_file_map * files,size_t nentries,void * data,struct dentry * parent,const struct file_operations * fops)405*4882a593Smuzhiyun static void xhci_debugfs_create_files(struct xhci_hcd *xhci,
406*4882a593Smuzhiyun struct xhci_file_map *files,
407*4882a593Smuzhiyun size_t nentries, void *data,
408*4882a593Smuzhiyun struct dentry *parent,
409*4882a593Smuzhiyun const struct file_operations *fops)
410*4882a593Smuzhiyun {
411*4882a593Smuzhiyun int i;
412*4882a593Smuzhiyun
413*4882a593Smuzhiyun for (i = 0; i < nentries; i++)
414*4882a593Smuzhiyun debugfs_create_file(files[i].name, 0444, parent, data, fops);
415*4882a593Smuzhiyun }
416*4882a593Smuzhiyun
xhci_debugfs_create_ring_dir(struct xhci_hcd * xhci,struct xhci_ring ** ring,const char * name,struct dentry * parent)417*4882a593Smuzhiyun static struct dentry *xhci_debugfs_create_ring_dir(struct xhci_hcd *xhci,
418*4882a593Smuzhiyun struct xhci_ring **ring,
419*4882a593Smuzhiyun const char *name,
420*4882a593Smuzhiyun struct dentry *parent)
421*4882a593Smuzhiyun {
422*4882a593Smuzhiyun struct dentry *dir;
423*4882a593Smuzhiyun
424*4882a593Smuzhiyun dir = debugfs_create_dir(name, parent);
425*4882a593Smuzhiyun xhci_debugfs_create_files(xhci, ring_files, ARRAY_SIZE(ring_files),
426*4882a593Smuzhiyun ring, dir, &xhci_ring_fops);
427*4882a593Smuzhiyun
428*4882a593Smuzhiyun return dir;
429*4882a593Smuzhiyun }
430*4882a593Smuzhiyun
xhci_debugfs_create_context_files(struct xhci_hcd * xhci,struct dentry * parent,int slot_id)431*4882a593Smuzhiyun static void xhci_debugfs_create_context_files(struct xhci_hcd *xhci,
432*4882a593Smuzhiyun struct dentry *parent,
433*4882a593Smuzhiyun int slot_id)
434*4882a593Smuzhiyun {
435*4882a593Smuzhiyun struct xhci_virt_device *dev = xhci->devs[slot_id];
436*4882a593Smuzhiyun
437*4882a593Smuzhiyun xhci_debugfs_create_files(xhci, context_files,
438*4882a593Smuzhiyun ARRAY_SIZE(context_files),
439*4882a593Smuzhiyun dev->debugfs_private,
440*4882a593Smuzhiyun parent, &xhci_context_fops);
441*4882a593Smuzhiyun }
442*4882a593Smuzhiyun
xhci_debugfs_create_endpoint(struct xhci_hcd * xhci,struct xhci_virt_device * dev,int ep_index)443*4882a593Smuzhiyun void xhci_debugfs_create_endpoint(struct xhci_hcd *xhci,
444*4882a593Smuzhiyun struct xhci_virt_device *dev,
445*4882a593Smuzhiyun int ep_index)
446*4882a593Smuzhiyun {
447*4882a593Smuzhiyun struct xhci_ep_priv *epriv;
448*4882a593Smuzhiyun struct xhci_slot_priv *spriv = dev->debugfs_private;
449*4882a593Smuzhiyun
450*4882a593Smuzhiyun if (!spriv)
451*4882a593Smuzhiyun return;
452*4882a593Smuzhiyun
453*4882a593Smuzhiyun if (spriv->eps[ep_index])
454*4882a593Smuzhiyun return;
455*4882a593Smuzhiyun
456*4882a593Smuzhiyun epriv = kzalloc(sizeof(*epriv), GFP_KERNEL);
457*4882a593Smuzhiyun if (!epriv)
458*4882a593Smuzhiyun return;
459*4882a593Smuzhiyun
460*4882a593Smuzhiyun epriv->show_ring = dev->eps[ep_index].ring;
461*4882a593Smuzhiyun
462*4882a593Smuzhiyun snprintf(epriv->name, sizeof(epriv->name), "ep%02d", ep_index);
463*4882a593Smuzhiyun epriv->root = xhci_debugfs_create_ring_dir(xhci,
464*4882a593Smuzhiyun &epriv->show_ring,
465*4882a593Smuzhiyun epriv->name,
466*4882a593Smuzhiyun spriv->root);
467*4882a593Smuzhiyun spriv->eps[ep_index] = epriv;
468*4882a593Smuzhiyun }
469*4882a593Smuzhiyun
xhci_debugfs_remove_endpoint(struct xhci_hcd * xhci,struct xhci_virt_device * dev,int ep_index)470*4882a593Smuzhiyun void xhci_debugfs_remove_endpoint(struct xhci_hcd *xhci,
471*4882a593Smuzhiyun struct xhci_virt_device *dev,
472*4882a593Smuzhiyun int ep_index)
473*4882a593Smuzhiyun {
474*4882a593Smuzhiyun struct xhci_ep_priv *epriv;
475*4882a593Smuzhiyun struct xhci_slot_priv *spriv = dev->debugfs_private;
476*4882a593Smuzhiyun
477*4882a593Smuzhiyun if (!spriv || !spriv->eps[ep_index])
478*4882a593Smuzhiyun return;
479*4882a593Smuzhiyun
480*4882a593Smuzhiyun epriv = spriv->eps[ep_index];
481*4882a593Smuzhiyun debugfs_remove_recursive(epriv->root);
482*4882a593Smuzhiyun spriv->eps[ep_index] = NULL;
483*4882a593Smuzhiyun kfree(epriv);
484*4882a593Smuzhiyun }
485*4882a593Smuzhiyun
xhci_stream_id_show(struct seq_file * s,void * unused)486*4882a593Smuzhiyun static int xhci_stream_id_show(struct seq_file *s, void *unused)
487*4882a593Smuzhiyun {
488*4882a593Smuzhiyun struct xhci_ep_priv *epriv = s->private;
489*4882a593Smuzhiyun
490*4882a593Smuzhiyun if (!epriv->stream_info)
491*4882a593Smuzhiyun return -EPERM;
492*4882a593Smuzhiyun
493*4882a593Smuzhiyun seq_printf(s, "Show stream ID %d trb ring, supported [1 - %d]\n",
494*4882a593Smuzhiyun epriv->stream_id, epriv->stream_info->num_streams - 1);
495*4882a593Smuzhiyun
496*4882a593Smuzhiyun return 0;
497*4882a593Smuzhiyun }
498*4882a593Smuzhiyun
xhci_stream_id_open(struct inode * inode,struct file * file)499*4882a593Smuzhiyun static int xhci_stream_id_open(struct inode *inode, struct file *file)
500*4882a593Smuzhiyun {
501*4882a593Smuzhiyun return single_open(file, xhci_stream_id_show, inode->i_private);
502*4882a593Smuzhiyun }
503*4882a593Smuzhiyun
xhci_stream_id_write(struct file * file,const char __user * ubuf,size_t count,loff_t * ppos)504*4882a593Smuzhiyun static ssize_t xhci_stream_id_write(struct file *file, const char __user *ubuf,
505*4882a593Smuzhiyun size_t count, loff_t *ppos)
506*4882a593Smuzhiyun {
507*4882a593Smuzhiyun struct seq_file *s = file->private_data;
508*4882a593Smuzhiyun struct xhci_ep_priv *epriv = s->private;
509*4882a593Smuzhiyun int ret;
510*4882a593Smuzhiyun u16 stream_id; /* MaxPStreams + 1 <= 16 */
511*4882a593Smuzhiyun
512*4882a593Smuzhiyun if (!epriv->stream_info)
513*4882a593Smuzhiyun return -EPERM;
514*4882a593Smuzhiyun
515*4882a593Smuzhiyun /* Decimal number */
516*4882a593Smuzhiyun ret = kstrtou16_from_user(ubuf, count, 10, &stream_id);
517*4882a593Smuzhiyun if (ret)
518*4882a593Smuzhiyun return ret;
519*4882a593Smuzhiyun
520*4882a593Smuzhiyun if (stream_id == 0 || stream_id >= epriv->stream_info->num_streams)
521*4882a593Smuzhiyun return -EINVAL;
522*4882a593Smuzhiyun
523*4882a593Smuzhiyun epriv->stream_id = stream_id;
524*4882a593Smuzhiyun epriv->show_ring = epriv->stream_info->stream_rings[stream_id];
525*4882a593Smuzhiyun
526*4882a593Smuzhiyun return count;
527*4882a593Smuzhiyun }
528*4882a593Smuzhiyun
529*4882a593Smuzhiyun static const struct file_operations stream_id_fops = {
530*4882a593Smuzhiyun .open = xhci_stream_id_open,
531*4882a593Smuzhiyun .write = xhci_stream_id_write,
532*4882a593Smuzhiyun .read = seq_read,
533*4882a593Smuzhiyun .llseek = seq_lseek,
534*4882a593Smuzhiyun .release = single_release,
535*4882a593Smuzhiyun };
536*4882a593Smuzhiyun
xhci_stream_context_array_show(struct seq_file * s,void * unused)537*4882a593Smuzhiyun static int xhci_stream_context_array_show(struct seq_file *s, void *unused)
538*4882a593Smuzhiyun {
539*4882a593Smuzhiyun struct xhci_ep_priv *epriv = s->private;
540*4882a593Smuzhiyun struct xhci_stream_ctx *stream_ctx;
541*4882a593Smuzhiyun dma_addr_t dma;
542*4882a593Smuzhiyun int id;
543*4882a593Smuzhiyun
544*4882a593Smuzhiyun if (!epriv->stream_info)
545*4882a593Smuzhiyun return -EPERM;
546*4882a593Smuzhiyun
547*4882a593Smuzhiyun seq_printf(s, "Allocated %d streams and %d stream context array entries\n",
548*4882a593Smuzhiyun epriv->stream_info->num_streams,
549*4882a593Smuzhiyun epriv->stream_info->num_stream_ctxs);
550*4882a593Smuzhiyun
551*4882a593Smuzhiyun for (id = 0; id < epriv->stream_info->num_stream_ctxs; id++) {
552*4882a593Smuzhiyun stream_ctx = epriv->stream_info->stream_ctx_array + id;
553*4882a593Smuzhiyun dma = epriv->stream_info->ctx_array_dma + id * 16;
554*4882a593Smuzhiyun if (id < epriv->stream_info->num_streams)
555*4882a593Smuzhiyun seq_printf(s, "%pad stream id %d deq %016llx\n", &dma,
556*4882a593Smuzhiyun id, le64_to_cpu(stream_ctx->stream_ring));
557*4882a593Smuzhiyun else
558*4882a593Smuzhiyun seq_printf(s, "%pad stream context entry not used deq %016llx\n",
559*4882a593Smuzhiyun &dma, le64_to_cpu(stream_ctx->stream_ring));
560*4882a593Smuzhiyun }
561*4882a593Smuzhiyun
562*4882a593Smuzhiyun return 0;
563*4882a593Smuzhiyun }
564*4882a593Smuzhiyun DEFINE_SHOW_ATTRIBUTE(xhci_stream_context_array);
565*4882a593Smuzhiyun
xhci_debugfs_create_stream_files(struct xhci_hcd * xhci,struct xhci_virt_device * dev,int ep_index)566*4882a593Smuzhiyun void xhci_debugfs_create_stream_files(struct xhci_hcd *xhci,
567*4882a593Smuzhiyun struct xhci_virt_device *dev,
568*4882a593Smuzhiyun int ep_index)
569*4882a593Smuzhiyun {
570*4882a593Smuzhiyun struct xhci_slot_priv *spriv = dev->debugfs_private;
571*4882a593Smuzhiyun struct xhci_ep_priv *epriv;
572*4882a593Smuzhiyun
573*4882a593Smuzhiyun if (!spriv || !spriv->eps[ep_index] ||
574*4882a593Smuzhiyun !dev->eps[ep_index].stream_info)
575*4882a593Smuzhiyun return;
576*4882a593Smuzhiyun
577*4882a593Smuzhiyun epriv = spriv->eps[ep_index];
578*4882a593Smuzhiyun epriv->stream_info = dev->eps[ep_index].stream_info;
579*4882a593Smuzhiyun
580*4882a593Smuzhiyun /* Show trb ring of stream ID 1 by default */
581*4882a593Smuzhiyun epriv->stream_id = 1;
582*4882a593Smuzhiyun epriv->show_ring = epriv->stream_info->stream_rings[1];
583*4882a593Smuzhiyun debugfs_create_file("stream_id", 0644,
584*4882a593Smuzhiyun epriv->root, epriv,
585*4882a593Smuzhiyun &stream_id_fops);
586*4882a593Smuzhiyun debugfs_create_file("stream_context_array", 0444,
587*4882a593Smuzhiyun epriv->root, epriv,
588*4882a593Smuzhiyun &xhci_stream_context_array_fops);
589*4882a593Smuzhiyun }
590*4882a593Smuzhiyun
xhci_debugfs_create_slot(struct xhci_hcd * xhci,int slot_id)591*4882a593Smuzhiyun void xhci_debugfs_create_slot(struct xhci_hcd *xhci, int slot_id)
592*4882a593Smuzhiyun {
593*4882a593Smuzhiyun struct xhci_slot_priv *priv;
594*4882a593Smuzhiyun struct xhci_virt_device *dev = xhci->devs[slot_id];
595*4882a593Smuzhiyun
596*4882a593Smuzhiyun priv = kzalloc(sizeof(*priv), GFP_KERNEL);
597*4882a593Smuzhiyun if (!priv)
598*4882a593Smuzhiyun return;
599*4882a593Smuzhiyun
600*4882a593Smuzhiyun snprintf(priv->name, sizeof(priv->name), "%02d", slot_id);
601*4882a593Smuzhiyun priv->root = debugfs_create_dir(priv->name, xhci->debugfs_slots);
602*4882a593Smuzhiyun priv->dev = dev;
603*4882a593Smuzhiyun dev->debugfs_private = priv;
604*4882a593Smuzhiyun
605*4882a593Smuzhiyun xhci_debugfs_create_ring_dir(xhci, &dev->eps[0].ring,
606*4882a593Smuzhiyun "ep00", priv->root);
607*4882a593Smuzhiyun
608*4882a593Smuzhiyun xhci_debugfs_create_context_files(xhci, priv->root, slot_id);
609*4882a593Smuzhiyun }
610*4882a593Smuzhiyun
xhci_debugfs_remove_slot(struct xhci_hcd * xhci,int slot_id)611*4882a593Smuzhiyun void xhci_debugfs_remove_slot(struct xhci_hcd *xhci, int slot_id)
612*4882a593Smuzhiyun {
613*4882a593Smuzhiyun int i;
614*4882a593Smuzhiyun struct xhci_slot_priv *priv;
615*4882a593Smuzhiyun struct xhci_virt_device *dev = xhci->devs[slot_id];
616*4882a593Smuzhiyun
617*4882a593Smuzhiyun if (!dev || !dev->debugfs_private)
618*4882a593Smuzhiyun return;
619*4882a593Smuzhiyun
620*4882a593Smuzhiyun priv = dev->debugfs_private;
621*4882a593Smuzhiyun
622*4882a593Smuzhiyun debugfs_remove_recursive(priv->root);
623*4882a593Smuzhiyun
624*4882a593Smuzhiyun for (i = 0; i < 31; i++)
625*4882a593Smuzhiyun kfree(priv->eps[i]);
626*4882a593Smuzhiyun
627*4882a593Smuzhiyun kfree(priv);
628*4882a593Smuzhiyun dev->debugfs_private = NULL;
629*4882a593Smuzhiyun }
630*4882a593Smuzhiyun
xhci_debugfs_create_ports(struct xhci_hcd * xhci,struct dentry * parent)631*4882a593Smuzhiyun static void xhci_debugfs_create_ports(struct xhci_hcd *xhci,
632*4882a593Smuzhiyun struct dentry *parent)
633*4882a593Smuzhiyun {
634*4882a593Smuzhiyun unsigned int num_ports;
635*4882a593Smuzhiyun char port_name[8];
636*4882a593Smuzhiyun struct xhci_port *port;
637*4882a593Smuzhiyun struct dentry *dir;
638*4882a593Smuzhiyun
639*4882a593Smuzhiyun num_ports = HCS_MAX_PORTS(xhci->hcs_params1);
640*4882a593Smuzhiyun
641*4882a593Smuzhiyun parent = debugfs_create_dir("ports", parent);
642*4882a593Smuzhiyun
643*4882a593Smuzhiyun while (num_ports--) {
644*4882a593Smuzhiyun scnprintf(port_name, sizeof(port_name), "port%02d",
645*4882a593Smuzhiyun num_ports + 1);
646*4882a593Smuzhiyun dir = debugfs_create_dir(port_name, parent);
647*4882a593Smuzhiyun port = &xhci->hw_ports[num_ports];
648*4882a593Smuzhiyun debugfs_create_file("portsc", 0644, dir, port, &port_fops);
649*4882a593Smuzhiyun }
650*4882a593Smuzhiyun }
651*4882a593Smuzhiyun
xhci_debugfs_init(struct xhci_hcd * xhci)652*4882a593Smuzhiyun void xhci_debugfs_init(struct xhci_hcd *xhci)
653*4882a593Smuzhiyun {
654*4882a593Smuzhiyun struct device *dev = xhci_to_hcd(xhci)->self.controller;
655*4882a593Smuzhiyun
656*4882a593Smuzhiyun xhci->debugfs_root = debugfs_create_dir(dev_name(dev),
657*4882a593Smuzhiyun xhci_debugfs_root);
658*4882a593Smuzhiyun
659*4882a593Smuzhiyun INIT_LIST_HEAD(&xhci->regset_list);
660*4882a593Smuzhiyun
661*4882a593Smuzhiyun xhci_debugfs_regset(xhci,
662*4882a593Smuzhiyun 0,
663*4882a593Smuzhiyun xhci_cap_regs, ARRAY_SIZE(xhci_cap_regs),
664*4882a593Smuzhiyun xhci->debugfs_root, "reg-cap");
665*4882a593Smuzhiyun
666*4882a593Smuzhiyun xhci_debugfs_regset(xhci,
667*4882a593Smuzhiyun HC_LENGTH(readl(&xhci->cap_regs->hc_capbase)),
668*4882a593Smuzhiyun xhci_op_regs, ARRAY_SIZE(xhci_op_regs),
669*4882a593Smuzhiyun xhci->debugfs_root, "reg-op");
670*4882a593Smuzhiyun
671*4882a593Smuzhiyun xhci_debugfs_regset(xhci,
672*4882a593Smuzhiyun readl(&xhci->cap_regs->run_regs_off) & RTSOFF_MASK,
673*4882a593Smuzhiyun xhci_runtime_regs, ARRAY_SIZE(xhci_runtime_regs),
674*4882a593Smuzhiyun xhci->debugfs_root, "reg-runtime");
675*4882a593Smuzhiyun
676*4882a593Smuzhiyun xhci_debugfs_extcap_regset(xhci, XHCI_EXT_CAPS_LEGACY,
677*4882a593Smuzhiyun xhci_extcap_legsup,
678*4882a593Smuzhiyun ARRAY_SIZE(xhci_extcap_legsup),
679*4882a593Smuzhiyun "reg-ext-legsup");
680*4882a593Smuzhiyun
681*4882a593Smuzhiyun xhci_debugfs_extcap_regset(xhci, XHCI_EXT_CAPS_PROTOCOL,
682*4882a593Smuzhiyun xhci_extcap_protocol,
683*4882a593Smuzhiyun ARRAY_SIZE(xhci_extcap_protocol),
684*4882a593Smuzhiyun "reg-ext-protocol");
685*4882a593Smuzhiyun
686*4882a593Smuzhiyun xhci_debugfs_extcap_regset(xhci, XHCI_EXT_CAPS_DEBUG,
687*4882a593Smuzhiyun xhci_extcap_dbc,
688*4882a593Smuzhiyun ARRAY_SIZE(xhci_extcap_dbc),
689*4882a593Smuzhiyun "reg-ext-dbc");
690*4882a593Smuzhiyun
691*4882a593Smuzhiyun xhci_debugfs_create_ring_dir(xhci, &xhci->cmd_ring,
692*4882a593Smuzhiyun "command-ring",
693*4882a593Smuzhiyun xhci->debugfs_root);
694*4882a593Smuzhiyun
695*4882a593Smuzhiyun xhci_debugfs_create_ring_dir(xhci, &xhci->event_ring,
696*4882a593Smuzhiyun "event-ring",
697*4882a593Smuzhiyun xhci->debugfs_root);
698*4882a593Smuzhiyun
699*4882a593Smuzhiyun xhci->debugfs_slots = debugfs_create_dir("devices", xhci->debugfs_root);
700*4882a593Smuzhiyun
701*4882a593Smuzhiyun xhci_debugfs_create_ports(xhci, xhci->debugfs_root);
702*4882a593Smuzhiyun }
703*4882a593Smuzhiyun
xhci_debugfs_exit(struct xhci_hcd * xhci)704*4882a593Smuzhiyun void xhci_debugfs_exit(struct xhci_hcd *xhci)
705*4882a593Smuzhiyun {
706*4882a593Smuzhiyun struct xhci_regset *rgs, *tmp;
707*4882a593Smuzhiyun
708*4882a593Smuzhiyun debugfs_remove_recursive(xhci->debugfs_root);
709*4882a593Smuzhiyun xhci->debugfs_root = NULL;
710*4882a593Smuzhiyun xhci->debugfs_slots = NULL;
711*4882a593Smuzhiyun
712*4882a593Smuzhiyun list_for_each_entry_safe(rgs, tmp, &xhci->regset_list, list)
713*4882a593Smuzhiyun xhci_debugfs_free_regset(rgs);
714*4882a593Smuzhiyun }
715*4882a593Smuzhiyun
xhci_debugfs_create_root(void)716*4882a593Smuzhiyun void __init xhci_debugfs_create_root(void)
717*4882a593Smuzhiyun {
718*4882a593Smuzhiyun xhci_debugfs_root = debugfs_create_dir("xhci", usb_debug_root);
719*4882a593Smuzhiyun }
720*4882a593Smuzhiyun
xhci_debugfs_remove_root(void)721*4882a593Smuzhiyun void __exit xhci_debugfs_remove_root(void)
722*4882a593Smuzhiyun {
723*4882a593Smuzhiyun debugfs_remove_recursive(xhci_debugfs_root);
724*4882a593Smuzhiyun xhci_debugfs_root = NULL;
725*4882a593Smuzhiyun }
726