fhci-dbg.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Freescale QUICC Engine USB Host Controller Driver
  4. *
  5. * Copyright (c) Freescale Semicondutor, Inc. 2006.
  6. * Shlomi Gridish <gridish@freescale.com>
  7. * Jerry Huang <Chang-Ming.Huang@freescale.com>
  8. * Copyright (c) Logic Product Development, Inc. 2007
  9. * Peter Barada <peterb@logicpd.com>
  10. * Copyright (c) MontaVista Software, Inc. 2008.
  11. * Anton Vorontsov <avorontsov@ru.mvista.com>
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/errno.h>
  15. #include <linux/debugfs.h>
  16. #include <linux/seq_file.h>
  17. #include <linux/usb.h>
  18. #include <linux/usb/hcd.h>
  19. #include "fhci.h"
  20. void fhci_dbg_isr(struct fhci_hcd *fhci, int usb_er)
  21. {
  22. int i;
  23. if (usb_er == -1) {
  24. fhci->usb_irq_stat[12]++;
  25. return;
  26. }
  27. for (i = 0; i < 12; ++i) {
  28. if (usb_er & (1 << i))
  29. fhci->usb_irq_stat[i]++;
  30. }
  31. }
  32. static int fhci_dfs_regs_show(struct seq_file *s, void *v)
  33. {
  34. struct fhci_hcd *fhci = s->private;
  35. struct qe_usb_ctlr __iomem *regs = fhci->regs;
  36. seq_printf(s,
  37. "mode: 0x%x\n" "addr: 0x%x\n"
  38. "command: 0x%x\n" "ep0: 0x%x\n"
  39. "event: 0x%x\n" "mask: 0x%x\n"
  40. "status: 0x%x\n" "SOF timer: %d\n"
  41. "frame number: %d\n"
  42. "lines status: 0x%x\n",
  43. in_8(&regs->usb_usmod), in_8(&regs->usb_usadr),
  44. in_8(&regs->usb_uscom), in_be16(&regs->usb_usep[0]),
  45. in_be16(&regs->usb_usber), in_be16(&regs->usb_usbmr),
  46. in_8(&regs->usb_usbs), in_be16(&regs->usb_ussft),
  47. in_be16(&regs->usb_usfrn),
  48. fhci_ioports_check_bus_state(fhci));
  49. return 0;
  50. }
  51. DEFINE_SHOW_ATTRIBUTE(fhci_dfs_regs);
  52. static int fhci_dfs_irq_stat_show(struct seq_file *s, void *v)
  53. {
  54. struct fhci_hcd *fhci = s->private;
  55. int *usb_irq_stat = fhci->usb_irq_stat;
  56. seq_printf(s,
  57. "RXB: %d\n" "TXB: %d\n" "BSY: %d\n"
  58. "SOF: %d\n" "TXE0: %d\n" "TXE1: %d\n"
  59. "TXE2: %d\n" "TXE3: %d\n" "IDLE: %d\n"
  60. "RESET: %d\n" "SFT: %d\n" "MSF: %d\n"
  61. "IDLE_ONLY: %d\n",
  62. usb_irq_stat[0], usb_irq_stat[1], usb_irq_stat[2],
  63. usb_irq_stat[3], usb_irq_stat[4], usb_irq_stat[5],
  64. usb_irq_stat[6], usb_irq_stat[7], usb_irq_stat[8],
  65. usb_irq_stat[9], usb_irq_stat[10], usb_irq_stat[11],
  66. usb_irq_stat[12]);
  67. return 0;
  68. }
  69. DEFINE_SHOW_ATTRIBUTE(fhci_dfs_irq_stat);
  70. void fhci_dfs_create(struct fhci_hcd *fhci)
  71. {
  72. struct device *dev = fhci_to_hcd(fhci)->self.controller;
  73. fhci->dfs_root = debugfs_create_dir(dev_name(dev), usb_debug_root);
  74. debugfs_create_file("regs", S_IFREG | S_IRUGO, fhci->dfs_root, fhci,
  75. &fhci_dfs_regs_fops);
  76. debugfs_create_file("irq_stat", S_IFREG | S_IRUGO, fhci->dfs_root, fhci,
  77. &fhci_dfs_irq_stat_fops);
  78. }
  79. void fhci_dfs_destroy(struct fhci_hcd *fhci)
  80. {
  81. debugfs_remove_recursive(fhci->dfs_root);
  82. }