fhci-dbg.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Freescale QUICC Engine USB Host Controller Driver
  3. *
  4. * Copyright (c) Freescale Semicondutor, Inc. 2006.
  5. * Shlomi Gridish <gridish@freescale.com>
  6. * Jerry Huang <Chang-Ming.Huang@freescale.com>
  7. * Copyright (c) Logic Product Development, Inc. 2007
  8. * Peter Barada <peterb@logicpd.com>
  9. * Copyright (c) MontaVista Software, Inc. 2008.
  10. * Anton Vorontsov <avorontsov@ru.mvista.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/errno.h>
  19. #include <linux/debugfs.h>
  20. #include <linux/seq_file.h>
  21. #include <linux/usb.h>
  22. #include <linux/usb/hcd.h>
  23. #include "fhci.h"
  24. void fhci_dbg_isr(struct fhci_hcd *fhci, int usb_er)
  25. {
  26. int i;
  27. if (usb_er == -1) {
  28. fhci->usb_irq_stat[12]++;
  29. return;
  30. }
  31. for (i = 0; i < 12; ++i) {
  32. if (usb_er & (1 << i))
  33. fhci->usb_irq_stat[i]++;
  34. }
  35. }
  36. static int fhci_dfs_regs_show(struct seq_file *s, void *v)
  37. {
  38. struct fhci_hcd *fhci = s->private;
  39. struct qe_usb_ctlr __iomem *regs = fhci->regs;
  40. seq_printf(s,
  41. "mode: 0x%x\n" "addr: 0x%x\n"
  42. "command: 0x%x\n" "ep0: 0x%x\n"
  43. "event: 0x%x\n" "mask: 0x%x\n"
  44. "status: 0x%x\n" "SOF timer: %d\n"
  45. "frame number: %d\n"
  46. "lines status: 0x%x\n",
  47. in_8(&regs->usb_usmod), in_8(&regs->usb_usadr),
  48. in_8(&regs->usb_uscom), in_be16(&regs->usb_usep[0]),
  49. in_be16(&regs->usb_usber), in_be16(&regs->usb_usbmr),
  50. in_8(&regs->usb_usbs), in_be16(&regs->usb_ussft),
  51. in_be16(&regs->usb_usfrn),
  52. fhci_ioports_check_bus_state(fhci));
  53. return 0;
  54. }
  55. static int fhci_dfs_irq_stat_show(struct seq_file *s, void *v)
  56. {
  57. struct fhci_hcd *fhci = s->private;
  58. int *usb_irq_stat = fhci->usb_irq_stat;
  59. seq_printf(s,
  60. "RXB: %d\n" "TXB: %d\n" "BSY: %d\n"
  61. "SOF: %d\n" "TXE0: %d\n" "TXE1: %d\n"
  62. "TXE2: %d\n" "TXE3: %d\n" "IDLE: %d\n"
  63. "RESET: %d\n" "SFT: %d\n" "MSF: %d\n"
  64. "IDLE_ONLY: %d\n",
  65. usb_irq_stat[0], usb_irq_stat[1], usb_irq_stat[2],
  66. usb_irq_stat[3], usb_irq_stat[4], usb_irq_stat[5],
  67. usb_irq_stat[6], usb_irq_stat[7], usb_irq_stat[8],
  68. usb_irq_stat[9], usb_irq_stat[10], usb_irq_stat[11],
  69. usb_irq_stat[12]);
  70. return 0;
  71. }
  72. static int fhci_dfs_regs_open(struct inode *inode, struct file *file)
  73. {
  74. return single_open(file, fhci_dfs_regs_show, inode->i_private);
  75. }
  76. static int fhci_dfs_irq_stat_open(struct inode *inode, struct file *file)
  77. {
  78. return single_open(file, fhci_dfs_irq_stat_show, inode->i_private);
  79. }
  80. static const struct file_operations fhci_dfs_regs_fops = {
  81. .open = fhci_dfs_regs_open,
  82. .read = seq_read,
  83. .llseek = seq_lseek,
  84. .release = single_release,
  85. };
  86. static const struct file_operations fhci_dfs_irq_stat_fops = {
  87. .open = fhci_dfs_irq_stat_open,
  88. .read = seq_read,
  89. .llseek = seq_lseek,
  90. .release = single_release,
  91. };
  92. void fhci_dfs_create(struct fhci_hcd *fhci)
  93. {
  94. struct device *dev = fhci_to_hcd(fhci)->self.controller;
  95. fhci->dfs_root = debugfs_create_dir(dev_name(dev), usb_debug_root);
  96. if (!fhci->dfs_root) {
  97. WARN_ON(1);
  98. return;
  99. }
  100. fhci->dfs_regs = debugfs_create_file("regs", S_IFREG | S_IRUGO,
  101. fhci->dfs_root, fhci, &fhci_dfs_regs_fops);
  102. fhci->dfs_irq_stat = debugfs_create_file("irq_stat",
  103. S_IFREG | S_IRUGO, fhci->dfs_root, fhci,
  104. &fhci_dfs_irq_stat_fops);
  105. WARN_ON(!fhci->dfs_regs || !fhci->dfs_irq_stat);
  106. }
  107. void fhci_dfs_destroy(struct fhci_hcd *fhci)
  108. {
  109. if (!fhci->dfs_root)
  110. return;
  111. debugfs_remove(fhci->dfs_irq_stat);
  112. debugfs_remove(fhci->dfs_regs);
  113. debugfs_remove(fhci->dfs_root);
  114. }