1 // SPDX-License-Identifier: GPL-2.0
3 * debugfs.c - Designware USB2 DRD controller debugfs
5 * Copyright (C) 2015 Intel Corporation
6 * Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
9 #include <linux/spinlock.h>
10 #include <linux/debugfs.h>
11 #include <linux/seq_file.h>
12 #include <linux/uaccess.h>
17 #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
18 IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
20 * testmode_write - debugfs: change usb test mode
21 * @seq: The seq file to write to.
22 * @v: Unused parameter.
24 * This debugfs entry modify the current usb test mode.
26 static ssize_t
testmode_write(struct file
*file
, const char __user
*ubuf
, size_t
29 struct seq_file
*s
= file
->private_data
;
30 struct dwc2_hsotg
*hsotg
= s
->private;
35 if (copy_from_user(&buf
, ubuf
, min_t(size_t, sizeof(buf
) - 1, count
)))
38 if (!strncmp(buf
, "test_j", 6))
40 else if (!strncmp(buf
, "test_k", 6))
42 else if (!strncmp(buf
, "test_se0_nak", 12))
43 testmode
= TEST_SE0_NAK
;
44 else if (!strncmp(buf
, "test_packet", 11))
45 testmode
= TEST_PACKET
;
46 else if (!strncmp(buf
, "test_force_enable", 17))
47 testmode
= TEST_FORCE_EN
;
51 spin_lock_irqsave(&hsotg
->lock
, flags
);
52 dwc2_hsotg_set_test_mode(hsotg
, testmode
);
53 spin_unlock_irqrestore(&hsotg
->lock
, flags
);
58 * testmode_show - debugfs: show usb test mode state
59 * @seq: The seq file to write to.
60 * @v: Unused parameter.
62 * This debugfs entry shows which usb test mode is currently enabled.
64 static int testmode_show(struct seq_file
*s
, void *unused
)
66 struct dwc2_hsotg
*hsotg
= s
->private;
70 spin_lock_irqsave(&hsotg
->lock
, flags
);
71 dctl
= dwc2_readl(hsotg
->regs
+ DCTL
);
72 dctl
&= DCTL_TSTCTL_MASK
;
73 dctl
>>= DCTL_TSTCTL_SHIFT
;
74 spin_unlock_irqrestore(&hsotg
->lock
, flags
);
78 seq_puts(s
, "no test\n");
81 seq_puts(s
, "test_j\n");
84 seq_puts(s
, "test_k\n");
87 seq_puts(s
, "test_se0_nak\n");
90 seq_puts(s
, "test_packet\n");
93 seq_puts(s
, "test_force_enable\n");
96 seq_printf(s
, "UNKNOWN %d\n", dctl
);
102 static int testmode_open(struct inode
*inode
, struct file
*file
)
104 return single_open(file
, testmode_show
, inode
->i_private
);
107 static const struct file_operations testmode_fops
= {
108 .owner
= THIS_MODULE
,
109 .open
= testmode_open
,
110 .write
= testmode_write
,
113 .release
= single_release
,
117 * state_show - debugfs: show overall driver and device state.
118 * @seq: The seq file to write to.
119 * @v: Unused parameter.
121 * This debugfs entry shows the overall state of the hardware and
122 * some general information about each of the endpoints available
125 static int state_show(struct seq_file
*seq
, void *v
)
127 struct dwc2_hsotg
*hsotg
= seq
->private;
128 void __iomem
*regs
= hsotg
->regs
;
131 seq_printf(seq
, "DCFG=0x%08x, DCTL=0x%08x, DSTS=0x%08x\n",
132 dwc2_readl(regs
+ DCFG
),
133 dwc2_readl(regs
+ DCTL
),
134 dwc2_readl(regs
+ DSTS
));
136 seq_printf(seq
, "DIEPMSK=0x%08x, DOEPMASK=0x%08x\n",
137 dwc2_readl(regs
+ DIEPMSK
), dwc2_readl(regs
+ DOEPMSK
));
139 seq_printf(seq
, "GINTMSK=0x%08x, GINTSTS=0x%08x\n",
140 dwc2_readl(regs
+ GINTMSK
),
141 dwc2_readl(regs
+ GINTSTS
));
143 seq_printf(seq
, "DAINTMSK=0x%08x, DAINT=0x%08x\n",
144 dwc2_readl(regs
+ DAINTMSK
),
145 dwc2_readl(regs
+ DAINT
));
147 seq_printf(seq
, "GNPTXSTS=0x%08x, GRXSTSR=%08x\n",
148 dwc2_readl(regs
+ GNPTXSTS
),
149 dwc2_readl(regs
+ GRXSTSR
));
151 seq_puts(seq
, "\nEndpoint status:\n");
153 for (idx
= 0; idx
< hsotg
->num_of_eps
; idx
++) {
156 in
= dwc2_readl(regs
+ DIEPCTL(idx
));
157 out
= dwc2_readl(regs
+ DOEPCTL(idx
));
159 seq_printf(seq
, "ep%d: DIEPCTL=0x%08x, DOEPCTL=0x%08x",
162 in
= dwc2_readl(regs
+ DIEPTSIZ(idx
));
163 out
= dwc2_readl(regs
+ DOEPTSIZ(idx
));
165 seq_printf(seq
, ", DIEPTSIZ=0x%08x, DOEPTSIZ=0x%08x",
174 static int state_open(struct inode
*inode
, struct file
*file
)
176 return single_open(file
, state_show
, inode
->i_private
);
179 static const struct file_operations state_fops
= {
180 .owner
= THIS_MODULE
,
184 .release
= single_release
,
188 * fifo_show - debugfs: show the fifo information
189 * @seq: The seq_file to write data to.
190 * @v: Unused parameter.
192 * Show the FIFO information for the overall fifo and all the
193 * periodic transmission FIFOs.
195 static int fifo_show(struct seq_file
*seq
, void *v
)
197 struct dwc2_hsotg
*hsotg
= seq
->private;
198 void __iomem
*regs
= hsotg
->regs
;
202 seq_puts(seq
, "Non-periodic FIFOs:\n");
203 seq_printf(seq
, "RXFIFO: Size %d\n", dwc2_readl(regs
+ GRXFSIZ
));
205 val
= dwc2_readl(regs
+ GNPTXFSIZ
);
206 seq_printf(seq
, "NPTXFIFO: Size %d, Start 0x%08x\n",
207 val
>> FIFOSIZE_DEPTH_SHIFT
,
208 val
& FIFOSIZE_STARTADDR_MASK
);
210 seq_puts(seq
, "\nPeriodic TXFIFOs:\n");
212 for (idx
= 1; idx
< hsotg
->num_of_eps
; idx
++) {
213 val
= dwc2_readl(regs
+ DPTXFSIZN(idx
));
215 seq_printf(seq
, "\tDPTXFIFO%2d: Size %d, Start 0x%08x\n", idx
,
216 val
>> FIFOSIZE_DEPTH_SHIFT
,
217 val
& FIFOSIZE_STARTADDR_MASK
);
223 static int fifo_open(struct inode
*inode
, struct file
*file
)
225 return single_open(file
, fifo_show
, inode
->i_private
);
228 static const struct file_operations fifo_fops
= {
229 .owner
= THIS_MODULE
,
233 .release
= single_release
,
236 static const char *decode_direction(int is_in
)
238 return is_in
? "in" : "out";
242 * ep_show - debugfs: show the state of an endpoint.
243 * @seq: The seq_file to write data to.
244 * @v: Unused parameter.
246 * This debugfs entry shows the state of the given endpoint (one is
247 * registered for each available).
249 static int ep_show(struct seq_file
*seq
, void *v
)
251 struct dwc2_hsotg_ep
*ep
= seq
->private;
252 struct dwc2_hsotg
*hsotg
= ep
->parent
;
253 struct dwc2_hsotg_req
*req
;
254 void __iomem
*regs
= hsotg
->regs
;
255 int index
= ep
->index
;
259 seq_printf(seq
, "Endpoint index %d, named %s, dir %s:\n",
260 ep
->index
, ep
->ep
.name
, decode_direction(ep
->dir_in
));
262 /* first show the register state */
264 seq_printf(seq
, "\tDIEPCTL=0x%08x, DOEPCTL=0x%08x\n",
265 dwc2_readl(regs
+ DIEPCTL(index
)),
266 dwc2_readl(regs
+ DOEPCTL(index
)));
268 seq_printf(seq
, "\tDIEPDMA=0x%08x, DOEPDMA=0x%08x\n",
269 dwc2_readl(regs
+ DIEPDMA(index
)),
270 dwc2_readl(regs
+ DOEPDMA(index
)));
272 seq_printf(seq
, "\tDIEPINT=0x%08x, DOEPINT=0x%08x\n",
273 dwc2_readl(regs
+ DIEPINT(index
)),
274 dwc2_readl(regs
+ DOEPINT(index
)));
276 seq_printf(seq
, "\tDIEPTSIZ=0x%08x, DOEPTSIZ=0x%08x\n",
277 dwc2_readl(regs
+ DIEPTSIZ(index
)),
278 dwc2_readl(regs
+ DOEPTSIZ(index
)));
281 seq_printf(seq
, "mps %d\n", ep
->ep
.maxpacket
);
282 seq_printf(seq
, "total_data=%ld\n", ep
->total_data
);
284 seq_printf(seq
, "request list (%p,%p):\n",
285 ep
->queue
.next
, ep
->queue
.prev
);
287 spin_lock_irqsave(&hsotg
->lock
, flags
);
289 list_for_each_entry(req
, &ep
->queue
, queue
) {
290 if (--show_limit
< 0) {
291 seq_puts(seq
, "not showing more requests...\n");
295 seq_printf(seq
, "%c req %p: %d bytes @%p, ",
296 req
== ep
->req
? '*' : ' ',
297 req
, req
->req
.length
, req
->req
.buf
);
298 seq_printf(seq
, "%d done, res %d\n",
299 req
->req
.actual
, req
->req
.status
);
302 spin_unlock_irqrestore(&hsotg
->lock
, flags
);
307 static int ep_open(struct inode
*inode
, struct file
*file
)
309 return single_open(file
, ep_show
, inode
->i_private
);
312 static const struct file_operations ep_fops
= {
313 .owner
= THIS_MODULE
,
317 .release
= single_release
,
321 * dwc2_hsotg_create_debug - create debugfs directory and files
322 * @hsotg: The driver state
324 * Create the debugfs files to allow the user to get information
325 * about the state of the system. The directory name is created
326 * with the same name as the device itself, in case we end up
327 * with multiple blocks in future systems.
329 static void dwc2_hsotg_create_debug(struct dwc2_hsotg
*hsotg
)
335 root
= hsotg
->debug_root
;
337 /* create general state file */
339 file
= debugfs_create_file("state", 0444, root
, hsotg
, &state_fops
);
341 dev_err(hsotg
->dev
, "%s: failed to create state\n", __func__
);
343 file
= debugfs_create_file("testmode", 0644, root
, hsotg
,
346 dev_err(hsotg
->dev
, "%s: failed to create testmode\n",
349 file
= debugfs_create_file("fifo", 0444, root
, hsotg
, &fifo_fops
);
351 dev_err(hsotg
->dev
, "%s: failed to create fifo\n", __func__
);
353 /* Create one file for each out endpoint */
354 for (epidx
= 0; epidx
< hsotg
->num_of_eps
; epidx
++) {
355 struct dwc2_hsotg_ep
*ep
;
357 ep
= hsotg
->eps_out
[epidx
];
359 file
= debugfs_create_file(ep
->name
, 0444,
362 dev_err(hsotg
->dev
, "failed to create %s debug file\n",
366 /* Create one file for each in endpoint. EP0 is handled with out eps */
367 for (epidx
= 1; epidx
< hsotg
->num_of_eps
; epidx
++) {
368 struct dwc2_hsotg_ep
*ep
;
370 ep
= hsotg
->eps_in
[epidx
];
372 file
= debugfs_create_file(ep
->name
, 0444,
375 dev_err(hsotg
->dev
, "failed to create %s debug file\n",
381 static inline void dwc2_hsotg_create_debug(struct dwc2_hsotg
*hsotg
) {}
384 /* dwc2_hsotg_delete_debug is removed as cleanup in done in dwc2_debugfs_exit */
386 #define dump_register(nm) \
392 static const struct debugfs_reg32 dwc2_regs
[] = {
394 * Accessing registers like this can trigger mode mismatch interrupt.
395 * However, according to dwc2 databook, the register access, in this
396 * case, is completed on the processor bus but is ignored by the core
397 * and does not affect its operation.
399 dump_register(GOTGCTL
),
400 dump_register(GOTGINT
),
401 dump_register(GAHBCFG
),
402 dump_register(GUSBCFG
),
403 dump_register(GRSTCTL
),
404 dump_register(GINTSTS
),
405 dump_register(GINTMSK
),
406 dump_register(GRXSTSR
),
407 dump_register(GRXSTSP
),
408 dump_register(GRXFSIZ
),
409 dump_register(GNPTXFSIZ
),
410 dump_register(GNPTXSTS
),
411 dump_register(GI2CCTL
),
412 dump_register(GPVNDCTL
),
413 dump_register(GGPIO
),
415 dump_register(GSNPSID
),
416 dump_register(GHWCFG1
),
417 dump_register(GHWCFG2
),
418 dump_register(GHWCFG3
),
419 dump_register(GHWCFG4
),
420 dump_register(GLPMCFG
),
421 dump_register(GPWRDN
),
422 dump_register(GDFIFOCFG
),
423 dump_register(ADPCTL
),
424 dump_register(HPTXFSIZ
),
425 dump_register(DPTXFSIZN(1)),
426 dump_register(DPTXFSIZN(2)),
427 dump_register(DPTXFSIZN(3)),
428 dump_register(DPTXFSIZN(4)),
429 dump_register(DPTXFSIZN(5)),
430 dump_register(DPTXFSIZN(6)),
431 dump_register(DPTXFSIZN(7)),
432 dump_register(DPTXFSIZN(8)),
433 dump_register(DPTXFSIZN(9)),
434 dump_register(DPTXFSIZN(10)),
435 dump_register(DPTXFSIZN(11)),
436 dump_register(DPTXFSIZN(12)),
437 dump_register(DPTXFSIZN(13)),
438 dump_register(DPTXFSIZN(14)),
439 dump_register(DPTXFSIZN(15)),
443 dump_register(DIEPMSK
),
444 dump_register(DOEPMSK
),
445 dump_register(DAINT
),
446 dump_register(DAINTMSK
),
447 dump_register(DTKNQR1
),
448 dump_register(DTKNQR2
),
449 dump_register(DTKNQR3
),
450 dump_register(DTKNQR4
),
451 dump_register(DVBUSDIS
),
452 dump_register(DVBUSPULSE
),
453 dump_register(DIEPCTL(0)),
454 dump_register(DIEPCTL(1)),
455 dump_register(DIEPCTL(2)),
456 dump_register(DIEPCTL(3)),
457 dump_register(DIEPCTL(4)),
458 dump_register(DIEPCTL(5)),
459 dump_register(DIEPCTL(6)),
460 dump_register(DIEPCTL(7)),
461 dump_register(DIEPCTL(8)),
462 dump_register(DIEPCTL(9)),
463 dump_register(DIEPCTL(10)),
464 dump_register(DIEPCTL(11)),
465 dump_register(DIEPCTL(12)),
466 dump_register(DIEPCTL(13)),
467 dump_register(DIEPCTL(14)),
468 dump_register(DIEPCTL(15)),
469 dump_register(DOEPCTL(0)),
470 dump_register(DOEPCTL(1)),
471 dump_register(DOEPCTL(2)),
472 dump_register(DOEPCTL(3)),
473 dump_register(DOEPCTL(4)),
474 dump_register(DOEPCTL(5)),
475 dump_register(DOEPCTL(6)),
476 dump_register(DOEPCTL(7)),
477 dump_register(DOEPCTL(8)),
478 dump_register(DOEPCTL(9)),
479 dump_register(DOEPCTL(10)),
480 dump_register(DOEPCTL(11)),
481 dump_register(DOEPCTL(12)),
482 dump_register(DOEPCTL(13)),
483 dump_register(DOEPCTL(14)),
484 dump_register(DOEPCTL(15)),
485 dump_register(DIEPINT(0)),
486 dump_register(DIEPINT(1)),
487 dump_register(DIEPINT(2)),
488 dump_register(DIEPINT(3)),
489 dump_register(DIEPINT(4)),
490 dump_register(DIEPINT(5)),
491 dump_register(DIEPINT(6)),
492 dump_register(DIEPINT(7)),
493 dump_register(DIEPINT(8)),
494 dump_register(DIEPINT(9)),
495 dump_register(DIEPINT(10)),
496 dump_register(DIEPINT(11)),
497 dump_register(DIEPINT(12)),
498 dump_register(DIEPINT(13)),
499 dump_register(DIEPINT(14)),
500 dump_register(DIEPINT(15)),
501 dump_register(DOEPINT(0)),
502 dump_register(DOEPINT(1)),
503 dump_register(DOEPINT(2)),
504 dump_register(DOEPINT(3)),
505 dump_register(DOEPINT(4)),
506 dump_register(DOEPINT(5)),
507 dump_register(DOEPINT(6)),
508 dump_register(DOEPINT(7)),
509 dump_register(DOEPINT(8)),
510 dump_register(DOEPINT(9)),
511 dump_register(DOEPINT(10)),
512 dump_register(DOEPINT(11)),
513 dump_register(DOEPINT(12)),
514 dump_register(DOEPINT(13)),
515 dump_register(DOEPINT(14)),
516 dump_register(DOEPINT(15)),
517 dump_register(DIEPTSIZ(0)),
518 dump_register(DIEPTSIZ(1)),
519 dump_register(DIEPTSIZ(2)),
520 dump_register(DIEPTSIZ(3)),
521 dump_register(DIEPTSIZ(4)),
522 dump_register(DIEPTSIZ(5)),
523 dump_register(DIEPTSIZ(6)),
524 dump_register(DIEPTSIZ(7)),
525 dump_register(DIEPTSIZ(8)),
526 dump_register(DIEPTSIZ(9)),
527 dump_register(DIEPTSIZ(10)),
528 dump_register(DIEPTSIZ(11)),
529 dump_register(DIEPTSIZ(12)),
530 dump_register(DIEPTSIZ(13)),
531 dump_register(DIEPTSIZ(14)),
532 dump_register(DIEPTSIZ(15)),
533 dump_register(DOEPTSIZ(0)),
534 dump_register(DOEPTSIZ(1)),
535 dump_register(DOEPTSIZ(2)),
536 dump_register(DOEPTSIZ(3)),
537 dump_register(DOEPTSIZ(4)),
538 dump_register(DOEPTSIZ(5)),
539 dump_register(DOEPTSIZ(6)),
540 dump_register(DOEPTSIZ(7)),
541 dump_register(DOEPTSIZ(8)),
542 dump_register(DOEPTSIZ(9)),
543 dump_register(DOEPTSIZ(10)),
544 dump_register(DOEPTSIZ(11)),
545 dump_register(DOEPTSIZ(12)),
546 dump_register(DOEPTSIZ(13)),
547 dump_register(DOEPTSIZ(14)),
548 dump_register(DOEPTSIZ(15)),
549 dump_register(DIEPDMA(0)),
550 dump_register(DIEPDMA(1)),
551 dump_register(DIEPDMA(2)),
552 dump_register(DIEPDMA(3)),
553 dump_register(DIEPDMA(4)),
554 dump_register(DIEPDMA(5)),
555 dump_register(DIEPDMA(6)),
556 dump_register(DIEPDMA(7)),
557 dump_register(DIEPDMA(8)),
558 dump_register(DIEPDMA(9)),
559 dump_register(DIEPDMA(10)),
560 dump_register(DIEPDMA(11)),
561 dump_register(DIEPDMA(12)),
562 dump_register(DIEPDMA(13)),
563 dump_register(DIEPDMA(14)),
564 dump_register(DIEPDMA(15)),
565 dump_register(DOEPDMA(0)),
566 dump_register(DOEPDMA(1)),
567 dump_register(DOEPDMA(2)),
568 dump_register(DOEPDMA(3)),
569 dump_register(DOEPDMA(4)),
570 dump_register(DOEPDMA(5)),
571 dump_register(DOEPDMA(6)),
572 dump_register(DOEPDMA(7)),
573 dump_register(DOEPDMA(8)),
574 dump_register(DOEPDMA(9)),
575 dump_register(DOEPDMA(10)),
576 dump_register(DOEPDMA(11)),
577 dump_register(DOEPDMA(12)),
578 dump_register(DOEPDMA(13)),
579 dump_register(DOEPDMA(14)),
580 dump_register(DOEPDMA(15)),
581 dump_register(DTXFSTS(0)),
582 dump_register(DTXFSTS(1)),
583 dump_register(DTXFSTS(2)),
584 dump_register(DTXFSTS(3)),
585 dump_register(DTXFSTS(4)),
586 dump_register(DTXFSTS(5)),
587 dump_register(DTXFSTS(6)),
588 dump_register(DTXFSTS(7)),
589 dump_register(DTXFSTS(8)),
590 dump_register(DTXFSTS(9)),
591 dump_register(DTXFSTS(10)),
592 dump_register(DTXFSTS(11)),
593 dump_register(DTXFSTS(12)),
594 dump_register(DTXFSTS(13)),
595 dump_register(DTXFSTS(14)),
596 dump_register(DTXFSTS(15)),
597 dump_register(PCGCTL
),
600 dump_register(HFNUM
),
601 dump_register(HPTXSTS
),
602 dump_register(HAINT
),
603 dump_register(HAINTMSK
),
604 dump_register(HFLBADDR
),
605 dump_register(HPRT0
),
606 dump_register(HCCHAR(0)),
607 dump_register(HCCHAR(1)),
608 dump_register(HCCHAR(2)),
609 dump_register(HCCHAR(3)),
610 dump_register(HCCHAR(4)),
611 dump_register(HCCHAR(5)),
612 dump_register(HCCHAR(6)),
613 dump_register(HCCHAR(7)),
614 dump_register(HCCHAR(8)),
615 dump_register(HCCHAR(9)),
616 dump_register(HCCHAR(10)),
617 dump_register(HCCHAR(11)),
618 dump_register(HCCHAR(12)),
619 dump_register(HCCHAR(13)),
620 dump_register(HCCHAR(14)),
621 dump_register(HCCHAR(15)),
622 dump_register(HCSPLT(0)),
623 dump_register(HCSPLT(1)),
624 dump_register(HCSPLT(2)),
625 dump_register(HCSPLT(3)),
626 dump_register(HCSPLT(4)),
627 dump_register(HCSPLT(5)),
628 dump_register(HCSPLT(6)),
629 dump_register(HCSPLT(7)),
630 dump_register(HCSPLT(8)),
631 dump_register(HCSPLT(9)),
632 dump_register(HCSPLT(10)),
633 dump_register(HCSPLT(11)),
634 dump_register(HCSPLT(12)),
635 dump_register(HCSPLT(13)),
636 dump_register(HCSPLT(14)),
637 dump_register(HCSPLT(15)),
638 dump_register(HCINT(0)),
639 dump_register(HCINT(1)),
640 dump_register(HCINT(2)),
641 dump_register(HCINT(3)),
642 dump_register(HCINT(4)),
643 dump_register(HCINT(5)),
644 dump_register(HCINT(6)),
645 dump_register(HCINT(7)),
646 dump_register(HCINT(8)),
647 dump_register(HCINT(9)),
648 dump_register(HCINT(10)),
649 dump_register(HCINT(11)),
650 dump_register(HCINT(12)),
651 dump_register(HCINT(13)),
652 dump_register(HCINT(14)),
653 dump_register(HCINT(15)),
654 dump_register(HCINTMSK(0)),
655 dump_register(HCINTMSK(1)),
656 dump_register(HCINTMSK(2)),
657 dump_register(HCINTMSK(3)),
658 dump_register(HCINTMSK(4)),
659 dump_register(HCINTMSK(5)),
660 dump_register(HCINTMSK(6)),
661 dump_register(HCINTMSK(7)),
662 dump_register(HCINTMSK(8)),
663 dump_register(HCINTMSK(9)),
664 dump_register(HCINTMSK(10)),
665 dump_register(HCINTMSK(11)),
666 dump_register(HCINTMSK(12)),
667 dump_register(HCINTMSK(13)),
668 dump_register(HCINTMSK(14)),
669 dump_register(HCINTMSK(15)),
670 dump_register(HCTSIZ(0)),
671 dump_register(HCTSIZ(1)),
672 dump_register(HCTSIZ(2)),
673 dump_register(HCTSIZ(3)),
674 dump_register(HCTSIZ(4)),
675 dump_register(HCTSIZ(5)),
676 dump_register(HCTSIZ(6)),
677 dump_register(HCTSIZ(7)),
678 dump_register(HCTSIZ(8)),
679 dump_register(HCTSIZ(9)),
680 dump_register(HCTSIZ(10)),
681 dump_register(HCTSIZ(11)),
682 dump_register(HCTSIZ(12)),
683 dump_register(HCTSIZ(13)),
684 dump_register(HCTSIZ(14)),
685 dump_register(HCTSIZ(15)),
686 dump_register(HCDMA(0)),
687 dump_register(HCDMA(1)),
688 dump_register(HCDMA(2)),
689 dump_register(HCDMA(3)),
690 dump_register(HCDMA(4)),
691 dump_register(HCDMA(5)),
692 dump_register(HCDMA(6)),
693 dump_register(HCDMA(7)),
694 dump_register(HCDMA(8)),
695 dump_register(HCDMA(9)),
696 dump_register(HCDMA(10)),
697 dump_register(HCDMA(11)),
698 dump_register(HCDMA(12)),
699 dump_register(HCDMA(13)),
700 dump_register(HCDMA(14)),
701 dump_register(HCDMA(15)),
702 dump_register(HCDMAB(0)),
703 dump_register(HCDMAB(1)),
704 dump_register(HCDMAB(2)),
705 dump_register(HCDMAB(3)),
706 dump_register(HCDMAB(4)),
707 dump_register(HCDMAB(5)),
708 dump_register(HCDMAB(6)),
709 dump_register(HCDMAB(7)),
710 dump_register(HCDMAB(8)),
711 dump_register(HCDMAB(9)),
712 dump_register(HCDMAB(10)),
713 dump_register(HCDMAB(11)),
714 dump_register(HCDMAB(12)),
715 dump_register(HCDMAB(13)),
716 dump_register(HCDMAB(14)),
717 dump_register(HCDMAB(15)),
720 #define print_param(_seq, _ptr, _param) \
721 seq_printf((_seq), "%-30s: %d\n", #_param, (_ptr)->_param)
723 #define print_param_hex(_seq, _ptr, _param) \
724 seq_printf((_seq), "%-30s: 0x%x\n", #_param, (_ptr)->_param)
726 static int params_show(struct seq_file
*seq
, void *v
)
728 struct dwc2_hsotg
*hsotg
= seq
->private;
729 struct dwc2_core_params
*p
= &hsotg
->params
;
732 print_param(seq
, p
, otg_cap
);
733 print_param(seq
, p
, dma_desc_enable
);
734 print_param(seq
, p
, dma_desc_fs_enable
);
735 print_param(seq
, p
, speed
);
736 print_param(seq
, p
, enable_dynamic_fifo
);
737 print_param(seq
, p
, en_multiple_tx_fifo
);
738 print_param(seq
, p
, host_rx_fifo_size
);
739 print_param(seq
, p
, host_nperio_tx_fifo_size
);
740 print_param(seq
, p
, host_perio_tx_fifo_size
);
741 print_param(seq
, p
, max_transfer_size
);
742 print_param(seq
, p
, max_packet_count
);
743 print_param(seq
, p
, host_channels
);
744 print_param(seq
, p
, phy_type
);
745 print_param(seq
, p
, phy_utmi_width
);
746 print_param(seq
, p
, phy_ulpi_ddr
);
747 print_param(seq
, p
, phy_ulpi_ext_vbus
);
748 print_param(seq
, p
, i2c_enable
);
749 print_param(seq
, p
, ulpi_fs_ls
);
750 print_param(seq
, p
, host_support_fs_ls_low_power
);
751 print_param(seq
, p
, host_ls_low_power_phy_clk
);
752 print_param(seq
, p
, ts_dline
);
753 print_param(seq
, p
, reload_ctl
);
754 print_param_hex(seq
, p
, ahbcfg
);
755 print_param(seq
, p
, uframe_sched
);
756 print_param(seq
, p
, external_id_pin_ctl
);
757 print_param(seq
, p
, hibernation
);
758 print_param(seq
, p
, host_dma
);
759 print_param(seq
, p
, g_dma
);
760 print_param(seq
, p
, g_dma_desc
);
761 print_param(seq
, p
, g_rx_fifo_size
);
762 print_param(seq
, p
, g_np_tx_fifo_size
);
764 for (i
= 0; i
< MAX_EPS_CHANNELS
; i
++) {
767 snprintf(str
, 32, "g_tx_fifo_size[%d]", i
);
768 seq_printf(seq
, "%-30s: %d\n", str
, p
->g_tx_fifo_size
[i
]);
774 static int params_open(struct inode
*inode
, struct file
*file
)
776 return single_open(file
, params_show
, inode
->i_private
);
779 static const struct file_operations params_fops
= {
780 .owner
= THIS_MODULE
,
784 .release
= single_release
,
787 static int hw_params_show(struct seq_file
*seq
, void *v
)
789 struct dwc2_hsotg
*hsotg
= seq
->private;
790 struct dwc2_hw_params
*hw
= &hsotg
->hw_params
;
792 print_param(seq
, hw
, op_mode
);
793 print_param(seq
, hw
, arch
);
794 print_param(seq
, hw
, dma_desc_enable
);
795 print_param(seq
, hw
, enable_dynamic_fifo
);
796 print_param(seq
, hw
, en_multiple_tx_fifo
);
797 print_param(seq
, hw
, rx_fifo_size
);
798 print_param(seq
, hw
, host_nperio_tx_fifo_size
);
799 print_param(seq
, hw
, dev_nperio_tx_fifo_size
);
800 print_param(seq
, hw
, host_perio_tx_fifo_size
);
801 print_param(seq
, hw
, nperio_tx_q_depth
);
802 print_param(seq
, hw
, host_perio_tx_q_depth
);
803 print_param(seq
, hw
, dev_token_q_depth
);
804 print_param(seq
, hw
, max_transfer_size
);
805 print_param(seq
, hw
, max_packet_count
);
806 print_param(seq
, hw
, host_channels
);
807 print_param(seq
, hw
, hs_phy_type
);
808 print_param(seq
, hw
, fs_phy_type
);
809 print_param(seq
, hw
, i2c_enable
);
810 print_param(seq
, hw
, num_dev_ep
);
811 print_param(seq
, hw
, num_dev_perio_in_ep
);
812 print_param(seq
, hw
, total_fifo_size
);
813 print_param(seq
, hw
, power_optimized
);
814 print_param(seq
, hw
, utmi_phy_data_width
);
815 print_param_hex(seq
, hw
, snpsid
);
816 print_param_hex(seq
, hw
, dev_ep_dirs
);
821 static int hw_params_open(struct inode
*inode
, struct file
*file
)
823 return single_open(file
, hw_params_show
, inode
->i_private
);
826 static const struct file_operations hw_params_fops
= {
827 .owner
= THIS_MODULE
,
828 .open
= hw_params_open
,
831 .release
= single_release
,
834 static int dr_mode_show(struct seq_file
*seq
, void *v
)
836 struct dwc2_hsotg
*hsotg
= seq
->private;
837 const char *dr_mode
= "";
839 device_property_read_string(hsotg
->dev
, "dr_mode", &dr_mode
);
840 seq_printf(seq
, "%s\n", dr_mode
);
844 static int dr_mode_open(struct inode
*inode
, struct file
*file
)
846 return single_open(file
, dr_mode_show
, inode
->i_private
);
849 static const struct file_operations dr_mode_fops
= {
850 .owner
= THIS_MODULE
,
851 .open
= dr_mode_open
,
854 .release
= single_release
,
857 int dwc2_debugfs_init(struct dwc2_hsotg
*hsotg
)
862 hsotg
->debug_root
= debugfs_create_dir(dev_name(hsotg
->dev
), NULL
);
863 if (!hsotg
->debug_root
) {
868 file
= debugfs_create_file("params", 0444,
870 hsotg
, ¶ms_fops
);
872 dev_err(hsotg
->dev
, "%s: failed to create params\n", __func__
);
874 file
= debugfs_create_file("hw_params", 0444,
876 hsotg
, &hw_params_fops
);
878 dev_err(hsotg
->dev
, "%s: failed to create hw_params\n",
881 file
= debugfs_create_file("dr_mode", 0444,
883 hsotg
, &dr_mode_fops
);
885 dev_err(hsotg
->dev
, "%s: failed to create dr_mode\n", __func__
);
887 /* Add gadget debugfs nodes */
888 dwc2_hsotg_create_debug(hsotg
);
890 hsotg
->regset
= devm_kzalloc(hsotg
->dev
, sizeof(*hsotg
->regset
),
892 if (!hsotg
->regset
) {
897 hsotg
->regset
->regs
= dwc2_regs
;
898 hsotg
->regset
->nregs
= ARRAY_SIZE(dwc2_regs
);
899 hsotg
->regset
->base
= hsotg
->regs
;
901 file
= debugfs_create_regset32("regdump", 0444, hsotg
->debug_root
,
910 debugfs_remove_recursive(hsotg
->debug_root
);
915 void dwc2_debugfs_exit(struct dwc2_hsotg
*hsotg
)
917 debugfs_remove_recursive(hsotg
->debug_root
);
918 hsotg
->debug_root
= NULL
;