net: ipmr: adjust mroute.h style and drop extern
[linux/fpc-iii.git] / drivers / usb / dwc2 / debugfs.c
blob55d91f24f94ab3aefd21c74626d7244fdccd7947
1 /**
2 * debugfs.c - Designware USB2 DRD controller debugfs
4 * Copyright (C) 2015 Intel Corporation
5 * Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 of
9 * the License as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #include <linux/spinlock.h>
18 #include <linux/debugfs.h>
19 #include <linux/seq_file.h>
20 #include <linux/uaccess.h>
22 #include "core.h"
23 #include "debug.h"
25 #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
26 IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
27 /**
28 * testmode_write - debugfs: change usb test mode
29 * @seq: The seq file to write to.
30 * @v: Unused parameter.
32 * This debugfs entry modify the current usb test mode.
34 static ssize_t testmode_write(struct file *file, const char __user *ubuf, size_t
35 count, loff_t *ppos)
37 struct seq_file *s = file->private_data;
38 struct dwc2_hsotg *hsotg = s->private;
39 unsigned long flags;
40 u32 testmode = 0;
41 char buf[32];
43 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
44 return -EFAULT;
46 if (!strncmp(buf, "test_j", 6))
47 testmode = TEST_J;
48 else if (!strncmp(buf, "test_k", 6))
49 testmode = TEST_K;
50 else if (!strncmp(buf, "test_se0_nak", 12))
51 testmode = TEST_SE0_NAK;
52 else if (!strncmp(buf, "test_packet", 11))
53 testmode = TEST_PACKET;
54 else if (!strncmp(buf, "test_force_enable", 17))
55 testmode = TEST_FORCE_EN;
56 else
57 testmode = 0;
59 spin_lock_irqsave(&hsotg->lock, flags);
60 dwc2_hsotg_set_test_mode(hsotg, testmode);
61 spin_unlock_irqrestore(&hsotg->lock, flags);
62 return count;
65 /**
66 * testmode_show - debugfs: show usb test mode state
67 * @seq: The seq file to write to.
68 * @v: Unused parameter.
70 * This debugfs entry shows which usb test mode is currently enabled.
72 static int testmode_show(struct seq_file *s, void *unused)
74 struct dwc2_hsotg *hsotg = s->private;
75 unsigned long flags;
76 int dctl;
78 spin_lock_irqsave(&hsotg->lock, flags);
79 dctl = dwc2_readl(hsotg->regs + DCTL);
80 dctl &= DCTL_TSTCTL_MASK;
81 dctl >>= DCTL_TSTCTL_SHIFT;
82 spin_unlock_irqrestore(&hsotg->lock, flags);
84 switch (dctl) {
85 case 0:
86 seq_puts(s, "no test\n");
87 break;
88 case TEST_J:
89 seq_puts(s, "test_j\n");
90 break;
91 case TEST_K:
92 seq_puts(s, "test_k\n");
93 break;
94 case TEST_SE0_NAK:
95 seq_puts(s, "test_se0_nak\n");
96 break;
97 case TEST_PACKET:
98 seq_puts(s, "test_packet\n");
99 break;
100 case TEST_FORCE_EN:
101 seq_puts(s, "test_force_enable\n");
102 break;
103 default:
104 seq_printf(s, "UNKNOWN %d\n", dctl);
107 return 0;
110 static int testmode_open(struct inode *inode, struct file *file)
112 return single_open(file, testmode_show, inode->i_private);
115 static const struct file_operations testmode_fops = {
116 .owner = THIS_MODULE,
117 .open = testmode_open,
118 .write = testmode_write,
119 .read = seq_read,
120 .llseek = seq_lseek,
121 .release = single_release,
125 * state_show - debugfs: show overall driver and device state.
126 * @seq: The seq file to write to.
127 * @v: Unused parameter.
129 * This debugfs entry shows the overall state of the hardware and
130 * some general information about each of the endpoints available
131 * to the system.
133 static int state_show(struct seq_file *seq, void *v)
135 struct dwc2_hsotg *hsotg = seq->private;
136 void __iomem *regs = hsotg->regs;
137 int idx;
139 seq_printf(seq, "DCFG=0x%08x, DCTL=0x%08x, DSTS=0x%08x\n",
140 dwc2_readl(regs + DCFG),
141 dwc2_readl(regs + DCTL),
142 dwc2_readl(regs + DSTS));
144 seq_printf(seq, "DIEPMSK=0x%08x, DOEPMASK=0x%08x\n",
145 dwc2_readl(regs + DIEPMSK), dwc2_readl(regs + DOEPMSK));
147 seq_printf(seq, "GINTMSK=0x%08x, GINTSTS=0x%08x\n",
148 dwc2_readl(regs + GINTMSK),
149 dwc2_readl(regs + GINTSTS));
151 seq_printf(seq, "DAINTMSK=0x%08x, DAINT=0x%08x\n",
152 dwc2_readl(regs + DAINTMSK),
153 dwc2_readl(regs + DAINT));
155 seq_printf(seq, "GNPTXSTS=0x%08x, GRXSTSR=%08x\n",
156 dwc2_readl(regs + GNPTXSTS),
157 dwc2_readl(regs + GRXSTSR));
159 seq_puts(seq, "\nEndpoint status:\n");
161 for (idx = 0; idx < hsotg->num_of_eps; idx++) {
162 u32 in, out;
164 in = dwc2_readl(regs + DIEPCTL(idx));
165 out = dwc2_readl(regs + DOEPCTL(idx));
167 seq_printf(seq, "ep%d: DIEPCTL=0x%08x, DOEPCTL=0x%08x",
168 idx, in, out);
170 in = dwc2_readl(regs + DIEPTSIZ(idx));
171 out = dwc2_readl(regs + DOEPTSIZ(idx));
173 seq_printf(seq, ", DIEPTSIZ=0x%08x, DOEPTSIZ=0x%08x",
174 in, out);
176 seq_puts(seq, "\n");
179 return 0;
182 static int state_open(struct inode *inode, struct file *file)
184 return single_open(file, state_show, inode->i_private);
187 static const struct file_operations state_fops = {
188 .owner = THIS_MODULE,
189 .open = state_open,
190 .read = seq_read,
191 .llseek = seq_lseek,
192 .release = single_release,
196 * fifo_show - debugfs: show the fifo information
197 * @seq: The seq_file to write data to.
198 * @v: Unused parameter.
200 * Show the FIFO information for the overall fifo and all the
201 * periodic transmission FIFOs.
203 static int fifo_show(struct seq_file *seq, void *v)
205 struct dwc2_hsotg *hsotg = seq->private;
206 void __iomem *regs = hsotg->regs;
207 u32 val;
208 int idx;
210 seq_puts(seq, "Non-periodic FIFOs:\n");
211 seq_printf(seq, "RXFIFO: Size %d\n", dwc2_readl(regs + GRXFSIZ));
213 val = dwc2_readl(regs + GNPTXFSIZ);
214 seq_printf(seq, "NPTXFIFO: Size %d, Start 0x%08x\n",
215 val >> FIFOSIZE_DEPTH_SHIFT,
216 val & FIFOSIZE_DEPTH_MASK);
218 seq_puts(seq, "\nPeriodic TXFIFOs:\n");
220 for (idx = 1; idx < hsotg->num_of_eps; idx++) {
221 val = dwc2_readl(regs + DPTXFSIZN(idx));
223 seq_printf(seq, "\tDPTXFIFO%2d: Size %d, Start 0x%08x\n", idx,
224 val >> FIFOSIZE_DEPTH_SHIFT,
225 val & FIFOSIZE_STARTADDR_MASK);
228 return 0;
231 static int fifo_open(struct inode *inode, struct file *file)
233 return single_open(file, fifo_show, inode->i_private);
236 static const struct file_operations fifo_fops = {
237 .owner = THIS_MODULE,
238 .open = fifo_open,
239 .read = seq_read,
240 .llseek = seq_lseek,
241 .release = single_release,
244 static const char *decode_direction(int is_in)
246 return is_in ? "in" : "out";
250 * ep_show - debugfs: show the state of an endpoint.
251 * @seq: The seq_file to write data to.
252 * @v: Unused parameter.
254 * This debugfs entry shows the state of the given endpoint (one is
255 * registered for each available).
257 static int ep_show(struct seq_file *seq, void *v)
259 struct dwc2_hsotg_ep *ep = seq->private;
260 struct dwc2_hsotg *hsotg = ep->parent;
261 struct dwc2_hsotg_req *req;
262 void __iomem *regs = hsotg->regs;
263 int index = ep->index;
264 int show_limit = 15;
265 unsigned long flags;
267 seq_printf(seq, "Endpoint index %d, named %s, dir %s:\n",
268 ep->index, ep->ep.name, decode_direction(ep->dir_in));
270 /* first show the register state */
272 seq_printf(seq, "\tDIEPCTL=0x%08x, DOEPCTL=0x%08x\n",
273 dwc2_readl(regs + DIEPCTL(index)),
274 dwc2_readl(regs + DOEPCTL(index)));
276 seq_printf(seq, "\tDIEPDMA=0x%08x, DOEPDMA=0x%08x\n",
277 dwc2_readl(regs + DIEPDMA(index)),
278 dwc2_readl(regs + DOEPDMA(index)));
280 seq_printf(seq, "\tDIEPINT=0x%08x, DOEPINT=0x%08x\n",
281 dwc2_readl(regs + DIEPINT(index)),
282 dwc2_readl(regs + DOEPINT(index)));
284 seq_printf(seq, "\tDIEPTSIZ=0x%08x, DOEPTSIZ=0x%08x\n",
285 dwc2_readl(regs + DIEPTSIZ(index)),
286 dwc2_readl(regs + DOEPTSIZ(index)));
288 seq_puts(seq, "\n");
289 seq_printf(seq, "mps %d\n", ep->ep.maxpacket);
290 seq_printf(seq, "total_data=%ld\n", ep->total_data);
292 seq_printf(seq, "request list (%p,%p):\n",
293 ep->queue.next, ep->queue.prev);
295 spin_lock_irqsave(&hsotg->lock, flags);
297 list_for_each_entry(req, &ep->queue, queue) {
298 if (--show_limit < 0) {
299 seq_puts(seq, "not showing more requests...\n");
300 break;
303 seq_printf(seq, "%c req %p: %d bytes @%p, ",
304 req == ep->req ? '*' : ' ',
305 req, req->req.length, req->req.buf);
306 seq_printf(seq, "%d done, res %d\n",
307 req->req.actual, req->req.status);
310 spin_unlock_irqrestore(&hsotg->lock, flags);
312 return 0;
315 static int ep_open(struct inode *inode, struct file *file)
317 return single_open(file, ep_show, inode->i_private);
320 static const struct file_operations ep_fops = {
321 .owner = THIS_MODULE,
322 .open = ep_open,
323 .read = seq_read,
324 .llseek = seq_lseek,
325 .release = single_release,
329 * dwc2_hsotg_create_debug - create debugfs directory and files
330 * @hsotg: The driver state
332 * Create the debugfs files to allow the user to get information
333 * about the state of the system. The directory name is created
334 * with the same name as the device itself, in case we end up
335 * with multiple blocks in future systems.
337 static void dwc2_hsotg_create_debug(struct dwc2_hsotg *hsotg)
339 struct dentry *root;
340 struct dentry *file;
341 unsigned epidx;
343 root = hsotg->debug_root;
345 /* create general state file */
347 file = debugfs_create_file("state", S_IRUGO, root, hsotg, &state_fops);
348 if (IS_ERR(file))
349 dev_err(hsotg->dev, "%s: failed to create state\n", __func__);
351 file = debugfs_create_file("testmode", S_IRUGO | S_IWUSR, root, hsotg,
352 &testmode_fops);
353 if (IS_ERR(file))
354 dev_err(hsotg->dev, "%s: failed to create testmode\n",
355 __func__);
357 file = debugfs_create_file("fifo", S_IRUGO, root, hsotg, &fifo_fops);
358 if (IS_ERR(file))
359 dev_err(hsotg->dev, "%s: failed to create fifo\n", __func__);
361 /* Create one file for each out endpoint */
362 for (epidx = 0; epidx < hsotg->num_of_eps; epidx++) {
363 struct dwc2_hsotg_ep *ep;
365 ep = hsotg->eps_out[epidx];
366 if (ep) {
367 file = debugfs_create_file(ep->name, S_IRUGO,
368 root, ep, &ep_fops);
369 if (IS_ERR(file))
370 dev_err(hsotg->dev, "failed to create %s debug file\n",
371 ep->name);
374 /* Create one file for each in endpoint. EP0 is handled with out eps */
375 for (epidx = 1; epidx < hsotg->num_of_eps; epidx++) {
376 struct dwc2_hsotg_ep *ep;
378 ep = hsotg->eps_in[epidx];
379 if (ep) {
380 file = debugfs_create_file(ep->name, S_IRUGO,
381 root, ep, &ep_fops);
382 if (IS_ERR(file))
383 dev_err(hsotg->dev, "failed to create %s debug file\n",
384 ep->name);
388 #else
389 static inline void dwc2_hsotg_create_debug(struct dwc2_hsotg *hsotg) {}
390 #endif
392 /* dwc2_hsotg_delete_debug is removed as cleanup in done in dwc2_debugfs_exit */
394 #define dump_register(nm) \
396 .name = #nm, \
397 .offset = nm, \
400 static const struct debugfs_reg32 dwc2_regs[] = {
402 * Accessing registers like this can trigger mode mismatch interrupt.
403 * However, according to dwc2 databook, the register access, in this
404 * case, is completed on the processor bus but is ignored by the core
405 * and does not affect its operation.
407 dump_register(GOTGCTL),
408 dump_register(GOTGINT),
409 dump_register(GAHBCFG),
410 dump_register(GUSBCFG),
411 dump_register(GRSTCTL),
412 dump_register(GINTSTS),
413 dump_register(GINTMSK),
414 dump_register(GRXSTSR),
415 dump_register(GRXSTSP),
416 dump_register(GRXFSIZ),
417 dump_register(GNPTXFSIZ),
418 dump_register(GNPTXSTS),
419 dump_register(GI2CCTL),
420 dump_register(GPVNDCTL),
421 dump_register(GGPIO),
422 dump_register(GUID),
423 dump_register(GSNPSID),
424 dump_register(GHWCFG1),
425 dump_register(GHWCFG2),
426 dump_register(GHWCFG3),
427 dump_register(GHWCFG4),
428 dump_register(GLPMCFG),
429 dump_register(GPWRDN),
430 dump_register(GDFIFOCFG),
431 dump_register(ADPCTL),
432 dump_register(HPTXFSIZ),
433 dump_register(DPTXFSIZN(1)),
434 dump_register(DPTXFSIZN(2)),
435 dump_register(DPTXFSIZN(3)),
436 dump_register(DPTXFSIZN(4)),
437 dump_register(DPTXFSIZN(5)),
438 dump_register(DPTXFSIZN(6)),
439 dump_register(DPTXFSIZN(7)),
440 dump_register(DPTXFSIZN(8)),
441 dump_register(DPTXFSIZN(9)),
442 dump_register(DPTXFSIZN(10)),
443 dump_register(DPTXFSIZN(11)),
444 dump_register(DPTXFSIZN(12)),
445 dump_register(DPTXFSIZN(13)),
446 dump_register(DPTXFSIZN(14)),
447 dump_register(DPTXFSIZN(15)),
448 dump_register(DCFG),
449 dump_register(DCTL),
450 dump_register(DSTS),
451 dump_register(DIEPMSK),
452 dump_register(DOEPMSK),
453 dump_register(DAINT),
454 dump_register(DAINTMSK),
455 dump_register(DTKNQR1),
456 dump_register(DTKNQR2),
457 dump_register(DTKNQR3),
458 dump_register(DTKNQR4),
459 dump_register(DVBUSDIS),
460 dump_register(DVBUSPULSE),
461 dump_register(DIEPCTL(0)),
462 dump_register(DIEPCTL(1)),
463 dump_register(DIEPCTL(2)),
464 dump_register(DIEPCTL(3)),
465 dump_register(DIEPCTL(4)),
466 dump_register(DIEPCTL(5)),
467 dump_register(DIEPCTL(6)),
468 dump_register(DIEPCTL(7)),
469 dump_register(DIEPCTL(8)),
470 dump_register(DIEPCTL(9)),
471 dump_register(DIEPCTL(10)),
472 dump_register(DIEPCTL(11)),
473 dump_register(DIEPCTL(12)),
474 dump_register(DIEPCTL(13)),
475 dump_register(DIEPCTL(14)),
476 dump_register(DIEPCTL(15)),
477 dump_register(DOEPCTL(0)),
478 dump_register(DOEPCTL(1)),
479 dump_register(DOEPCTL(2)),
480 dump_register(DOEPCTL(3)),
481 dump_register(DOEPCTL(4)),
482 dump_register(DOEPCTL(5)),
483 dump_register(DOEPCTL(6)),
484 dump_register(DOEPCTL(7)),
485 dump_register(DOEPCTL(8)),
486 dump_register(DOEPCTL(9)),
487 dump_register(DOEPCTL(10)),
488 dump_register(DOEPCTL(11)),
489 dump_register(DOEPCTL(12)),
490 dump_register(DOEPCTL(13)),
491 dump_register(DOEPCTL(14)),
492 dump_register(DOEPCTL(15)),
493 dump_register(DIEPINT(0)),
494 dump_register(DIEPINT(1)),
495 dump_register(DIEPINT(2)),
496 dump_register(DIEPINT(3)),
497 dump_register(DIEPINT(4)),
498 dump_register(DIEPINT(5)),
499 dump_register(DIEPINT(6)),
500 dump_register(DIEPINT(7)),
501 dump_register(DIEPINT(8)),
502 dump_register(DIEPINT(9)),
503 dump_register(DIEPINT(10)),
504 dump_register(DIEPINT(11)),
505 dump_register(DIEPINT(12)),
506 dump_register(DIEPINT(13)),
507 dump_register(DIEPINT(14)),
508 dump_register(DIEPINT(15)),
509 dump_register(DOEPINT(0)),
510 dump_register(DOEPINT(1)),
511 dump_register(DOEPINT(2)),
512 dump_register(DOEPINT(3)),
513 dump_register(DOEPINT(4)),
514 dump_register(DOEPINT(5)),
515 dump_register(DOEPINT(6)),
516 dump_register(DOEPINT(7)),
517 dump_register(DOEPINT(8)),
518 dump_register(DOEPINT(9)),
519 dump_register(DOEPINT(10)),
520 dump_register(DOEPINT(11)),
521 dump_register(DOEPINT(12)),
522 dump_register(DOEPINT(13)),
523 dump_register(DOEPINT(14)),
524 dump_register(DOEPINT(15)),
525 dump_register(DIEPTSIZ(0)),
526 dump_register(DIEPTSIZ(1)),
527 dump_register(DIEPTSIZ(2)),
528 dump_register(DIEPTSIZ(3)),
529 dump_register(DIEPTSIZ(4)),
530 dump_register(DIEPTSIZ(5)),
531 dump_register(DIEPTSIZ(6)),
532 dump_register(DIEPTSIZ(7)),
533 dump_register(DIEPTSIZ(8)),
534 dump_register(DIEPTSIZ(9)),
535 dump_register(DIEPTSIZ(10)),
536 dump_register(DIEPTSIZ(11)),
537 dump_register(DIEPTSIZ(12)),
538 dump_register(DIEPTSIZ(13)),
539 dump_register(DIEPTSIZ(14)),
540 dump_register(DIEPTSIZ(15)),
541 dump_register(DOEPTSIZ(0)),
542 dump_register(DOEPTSIZ(1)),
543 dump_register(DOEPTSIZ(2)),
544 dump_register(DOEPTSIZ(3)),
545 dump_register(DOEPTSIZ(4)),
546 dump_register(DOEPTSIZ(5)),
547 dump_register(DOEPTSIZ(6)),
548 dump_register(DOEPTSIZ(7)),
549 dump_register(DOEPTSIZ(8)),
550 dump_register(DOEPTSIZ(9)),
551 dump_register(DOEPTSIZ(10)),
552 dump_register(DOEPTSIZ(11)),
553 dump_register(DOEPTSIZ(12)),
554 dump_register(DOEPTSIZ(13)),
555 dump_register(DOEPTSIZ(14)),
556 dump_register(DOEPTSIZ(15)),
557 dump_register(DIEPDMA(0)),
558 dump_register(DIEPDMA(1)),
559 dump_register(DIEPDMA(2)),
560 dump_register(DIEPDMA(3)),
561 dump_register(DIEPDMA(4)),
562 dump_register(DIEPDMA(5)),
563 dump_register(DIEPDMA(6)),
564 dump_register(DIEPDMA(7)),
565 dump_register(DIEPDMA(8)),
566 dump_register(DIEPDMA(9)),
567 dump_register(DIEPDMA(10)),
568 dump_register(DIEPDMA(11)),
569 dump_register(DIEPDMA(12)),
570 dump_register(DIEPDMA(13)),
571 dump_register(DIEPDMA(14)),
572 dump_register(DIEPDMA(15)),
573 dump_register(DOEPDMA(0)),
574 dump_register(DOEPDMA(1)),
575 dump_register(DOEPDMA(2)),
576 dump_register(DOEPDMA(3)),
577 dump_register(DOEPDMA(4)),
578 dump_register(DOEPDMA(5)),
579 dump_register(DOEPDMA(6)),
580 dump_register(DOEPDMA(7)),
581 dump_register(DOEPDMA(8)),
582 dump_register(DOEPDMA(9)),
583 dump_register(DOEPDMA(10)),
584 dump_register(DOEPDMA(11)),
585 dump_register(DOEPDMA(12)),
586 dump_register(DOEPDMA(13)),
587 dump_register(DOEPDMA(14)),
588 dump_register(DOEPDMA(15)),
589 dump_register(DTXFSTS(0)),
590 dump_register(DTXFSTS(1)),
591 dump_register(DTXFSTS(2)),
592 dump_register(DTXFSTS(3)),
593 dump_register(DTXFSTS(4)),
594 dump_register(DTXFSTS(5)),
595 dump_register(DTXFSTS(6)),
596 dump_register(DTXFSTS(7)),
597 dump_register(DTXFSTS(8)),
598 dump_register(DTXFSTS(9)),
599 dump_register(DTXFSTS(10)),
600 dump_register(DTXFSTS(11)),
601 dump_register(DTXFSTS(12)),
602 dump_register(DTXFSTS(13)),
603 dump_register(DTXFSTS(14)),
604 dump_register(DTXFSTS(15)),
605 dump_register(PCGCTL),
606 dump_register(HCFG),
607 dump_register(HFIR),
608 dump_register(HFNUM),
609 dump_register(HPTXSTS),
610 dump_register(HAINT),
611 dump_register(HAINTMSK),
612 dump_register(HFLBADDR),
613 dump_register(HPRT0),
614 dump_register(HCCHAR(0)),
615 dump_register(HCCHAR(1)),
616 dump_register(HCCHAR(2)),
617 dump_register(HCCHAR(3)),
618 dump_register(HCCHAR(4)),
619 dump_register(HCCHAR(5)),
620 dump_register(HCCHAR(6)),
621 dump_register(HCCHAR(7)),
622 dump_register(HCCHAR(8)),
623 dump_register(HCCHAR(9)),
624 dump_register(HCCHAR(10)),
625 dump_register(HCCHAR(11)),
626 dump_register(HCCHAR(12)),
627 dump_register(HCCHAR(13)),
628 dump_register(HCCHAR(14)),
629 dump_register(HCCHAR(15)),
630 dump_register(HCSPLT(0)),
631 dump_register(HCSPLT(1)),
632 dump_register(HCSPLT(2)),
633 dump_register(HCSPLT(3)),
634 dump_register(HCSPLT(4)),
635 dump_register(HCSPLT(5)),
636 dump_register(HCSPLT(6)),
637 dump_register(HCSPLT(7)),
638 dump_register(HCSPLT(8)),
639 dump_register(HCSPLT(9)),
640 dump_register(HCSPLT(10)),
641 dump_register(HCSPLT(11)),
642 dump_register(HCSPLT(12)),
643 dump_register(HCSPLT(13)),
644 dump_register(HCSPLT(14)),
645 dump_register(HCSPLT(15)),
646 dump_register(HCINT(0)),
647 dump_register(HCINT(1)),
648 dump_register(HCINT(2)),
649 dump_register(HCINT(3)),
650 dump_register(HCINT(4)),
651 dump_register(HCINT(5)),
652 dump_register(HCINT(6)),
653 dump_register(HCINT(7)),
654 dump_register(HCINT(8)),
655 dump_register(HCINT(9)),
656 dump_register(HCINT(10)),
657 dump_register(HCINT(11)),
658 dump_register(HCINT(12)),
659 dump_register(HCINT(13)),
660 dump_register(HCINT(14)),
661 dump_register(HCINT(15)),
662 dump_register(HCINTMSK(0)),
663 dump_register(HCINTMSK(1)),
664 dump_register(HCINTMSK(2)),
665 dump_register(HCINTMSK(3)),
666 dump_register(HCINTMSK(4)),
667 dump_register(HCINTMSK(5)),
668 dump_register(HCINTMSK(6)),
669 dump_register(HCINTMSK(7)),
670 dump_register(HCINTMSK(8)),
671 dump_register(HCINTMSK(9)),
672 dump_register(HCINTMSK(10)),
673 dump_register(HCINTMSK(11)),
674 dump_register(HCINTMSK(12)),
675 dump_register(HCINTMSK(13)),
676 dump_register(HCINTMSK(14)),
677 dump_register(HCINTMSK(15)),
678 dump_register(HCTSIZ(0)),
679 dump_register(HCTSIZ(1)),
680 dump_register(HCTSIZ(2)),
681 dump_register(HCTSIZ(3)),
682 dump_register(HCTSIZ(4)),
683 dump_register(HCTSIZ(5)),
684 dump_register(HCTSIZ(6)),
685 dump_register(HCTSIZ(7)),
686 dump_register(HCTSIZ(8)),
687 dump_register(HCTSIZ(9)),
688 dump_register(HCTSIZ(10)),
689 dump_register(HCTSIZ(11)),
690 dump_register(HCTSIZ(12)),
691 dump_register(HCTSIZ(13)),
692 dump_register(HCTSIZ(14)),
693 dump_register(HCTSIZ(15)),
694 dump_register(HCDMA(0)),
695 dump_register(HCDMA(1)),
696 dump_register(HCDMA(2)),
697 dump_register(HCDMA(3)),
698 dump_register(HCDMA(4)),
699 dump_register(HCDMA(5)),
700 dump_register(HCDMA(6)),
701 dump_register(HCDMA(7)),
702 dump_register(HCDMA(8)),
703 dump_register(HCDMA(9)),
704 dump_register(HCDMA(10)),
705 dump_register(HCDMA(11)),
706 dump_register(HCDMA(12)),
707 dump_register(HCDMA(13)),
708 dump_register(HCDMA(14)),
709 dump_register(HCDMA(15)),
710 dump_register(HCDMAB(0)),
711 dump_register(HCDMAB(1)),
712 dump_register(HCDMAB(2)),
713 dump_register(HCDMAB(3)),
714 dump_register(HCDMAB(4)),
715 dump_register(HCDMAB(5)),
716 dump_register(HCDMAB(6)),
717 dump_register(HCDMAB(7)),
718 dump_register(HCDMAB(8)),
719 dump_register(HCDMAB(9)),
720 dump_register(HCDMAB(10)),
721 dump_register(HCDMAB(11)),
722 dump_register(HCDMAB(12)),
723 dump_register(HCDMAB(13)),
724 dump_register(HCDMAB(14)),
725 dump_register(HCDMAB(15)),
728 int dwc2_debugfs_init(struct dwc2_hsotg *hsotg)
730 int ret;
731 struct dentry *file;
733 hsotg->debug_root = debugfs_create_dir(dev_name(hsotg->dev), NULL);
734 if (!hsotg->debug_root) {
735 ret = -ENOMEM;
736 goto err0;
739 /* Add gadget debugfs nodes */
740 dwc2_hsotg_create_debug(hsotg);
742 hsotg->regset = devm_kzalloc(hsotg->dev, sizeof(*hsotg->regset),
743 GFP_KERNEL);
744 if (!hsotg->regset) {
745 ret = -ENOMEM;
746 goto err1;
749 hsotg->regset->regs = dwc2_regs;
750 hsotg->regset->nregs = ARRAY_SIZE(dwc2_regs);
751 hsotg->regset->base = hsotg->regs;
753 file = debugfs_create_regset32("regdump", S_IRUGO, hsotg->debug_root,
754 hsotg->regset);
755 if (!file) {
756 ret = -ENOMEM;
757 goto err1;
760 return 0;
761 err1:
762 debugfs_remove_recursive(hsotg->debug_root);
763 err0:
764 return ret;
767 void dwc2_debugfs_exit(struct dwc2_hsotg *hsotg)
769 debugfs_remove_recursive(hsotg->debug_root);
770 hsotg->debug_root = NULL;