15fd54aceSGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0+
2236dd4d1SAnton Vorontsov /*
3236dd4d1SAnton Vorontsov * Freescale QUICC Engine USB Host Controller Driver
4236dd4d1SAnton Vorontsov *
5236dd4d1SAnton Vorontsov * Copyright (c) Freescale Semicondutor, Inc. 2006.
6236dd4d1SAnton Vorontsov * Shlomi Gridish <gridish@freescale.com>
7236dd4d1SAnton Vorontsov * Jerry Huang <Chang-Ming.Huang@freescale.com>
8236dd4d1SAnton Vorontsov * Copyright (c) Logic Product Development, Inc. 2007
9236dd4d1SAnton Vorontsov * Peter Barada <peterb@logicpd.com>
10236dd4d1SAnton Vorontsov * Copyright (c) MontaVista Software, Inc. 2008.
11236dd4d1SAnton Vorontsov * Anton Vorontsov <avorontsov@ru.mvista.com>
12236dd4d1SAnton Vorontsov */
13236dd4d1SAnton Vorontsov
14236dd4d1SAnton Vorontsov #include <linux/kernel.h>
15236dd4d1SAnton Vorontsov #include <linux/errno.h>
16236dd4d1SAnton Vorontsov #include <linux/debugfs.h>
17236dd4d1SAnton Vorontsov #include <linux/seq_file.h>
18236dd4d1SAnton Vorontsov #include <linux/usb.h>
1927729aadSEric Lescouet #include <linux/usb/hcd.h>
20236dd4d1SAnton Vorontsov #include "fhci.h"
21236dd4d1SAnton Vorontsov
fhci_dbg_isr(struct fhci_hcd * fhci,int usb_er)22236dd4d1SAnton Vorontsov void fhci_dbg_isr(struct fhci_hcd *fhci, int usb_er)
23236dd4d1SAnton Vorontsov {
24236dd4d1SAnton Vorontsov int i;
25236dd4d1SAnton Vorontsov
26236dd4d1SAnton Vorontsov if (usb_er == -1) {
27236dd4d1SAnton Vorontsov fhci->usb_irq_stat[12]++;
28236dd4d1SAnton Vorontsov return;
29236dd4d1SAnton Vorontsov }
30236dd4d1SAnton Vorontsov
31236dd4d1SAnton Vorontsov for (i = 0; i < 12; ++i) {
32236dd4d1SAnton Vorontsov if (usb_er & (1 << i))
33236dd4d1SAnton Vorontsov fhci->usb_irq_stat[i]++;
34236dd4d1SAnton Vorontsov }
35236dd4d1SAnton Vorontsov }
36236dd4d1SAnton Vorontsov
fhci_dfs_regs_show(struct seq_file * s,void * v)37236dd4d1SAnton Vorontsov static int fhci_dfs_regs_show(struct seq_file *s, void *v)
38236dd4d1SAnton Vorontsov {
39236dd4d1SAnton Vorontsov struct fhci_hcd *fhci = s->private;
40cf61fdb9SGuilherme Maciel Ferreira struct qe_usb_ctlr __iomem *regs = fhci->regs;
41236dd4d1SAnton Vorontsov
42236dd4d1SAnton Vorontsov seq_printf(s,
43236dd4d1SAnton Vorontsov "mode: 0x%x\n" "addr: 0x%x\n"
44236dd4d1SAnton Vorontsov "command: 0x%x\n" "ep0: 0x%x\n"
45236dd4d1SAnton Vorontsov "event: 0x%x\n" "mask: 0x%x\n"
46236dd4d1SAnton Vorontsov "status: 0x%x\n" "SOF timer: %d\n"
47236dd4d1SAnton Vorontsov "frame number: %d\n"
48236dd4d1SAnton Vorontsov "lines status: 0x%x\n",
49cf61fdb9SGuilherme Maciel Ferreira in_8(®s->usb_usmod), in_8(®s->usb_usadr),
50cf61fdb9SGuilherme Maciel Ferreira in_8(®s->usb_uscom), in_be16(®s->usb_usep[0]),
51cf61fdb9SGuilherme Maciel Ferreira in_be16(®s->usb_usber), in_be16(®s->usb_usbmr),
52cf61fdb9SGuilherme Maciel Ferreira in_8(®s->usb_usbs), in_be16(®s->usb_ussft),
53cf61fdb9SGuilherme Maciel Ferreira in_be16(®s->usb_usfrn),
54236dd4d1SAnton Vorontsov fhci_ioports_check_bus_state(fhci));
55236dd4d1SAnton Vorontsov
56236dd4d1SAnton Vorontsov return 0;
57236dd4d1SAnton Vorontsov }
58513f6750SAndy Shevchenko DEFINE_SHOW_ATTRIBUTE(fhci_dfs_regs);
59236dd4d1SAnton Vorontsov
fhci_dfs_irq_stat_show(struct seq_file * s,void * v)60236dd4d1SAnton Vorontsov static int fhci_dfs_irq_stat_show(struct seq_file *s, void *v)
61236dd4d1SAnton Vorontsov {
62236dd4d1SAnton Vorontsov struct fhci_hcd *fhci = s->private;
63236dd4d1SAnton Vorontsov int *usb_irq_stat = fhci->usb_irq_stat;
64236dd4d1SAnton Vorontsov
65236dd4d1SAnton Vorontsov seq_printf(s,
66236dd4d1SAnton Vorontsov "RXB: %d\n" "TXB: %d\n" "BSY: %d\n"
67236dd4d1SAnton Vorontsov "SOF: %d\n" "TXE0: %d\n" "TXE1: %d\n"
68236dd4d1SAnton Vorontsov "TXE2: %d\n" "TXE3: %d\n" "IDLE: %d\n"
69236dd4d1SAnton Vorontsov "RESET: %d\n" "SFT: %d\n" "MSF: %d\n"
70236dd4d1SAnton Vorontsov "IDLE_ONLY: %d\n",
71236dd4d1SAnton Vorontsov usb_irq_stat[0], usb_irq_stat[1], usb_irq_stat[2],
72236dd4d1SAnton Vorontsov usb_irq_stat[3], usb_irq_stat[4], usb_irq_stat[5],
73236dd4d1SAnton Vorontsov usb_irq_stat[6], usb_irq_stat[7], usb_irq_stat[8],
74236dd4d1SAnton Vorontsov usb_irq_stat[9], usb_irq_stat[10], usb_irq_stat[11],
75236dd4d1SAnton Vorontsov usb_irq_stat[12]);
76236dd4d1SAnton Vorontsov
77236dd4d1SAnton Vorontsov return 0;
78236dd4d1SAnton Vorontsov }
79513f6750SAndy Shevchenko DEFINE_SHOW_ATTRIBUTE(fhci_dfs_irq_stat);
80236dd4d1SAnton Vorontsov
fhci_dfs_create(struct fhci_hcd * fhci)81236dd4d1SAnton Vorontsov void fhci_dfs_create(struct fhci_hcd *fhci)
82236dd4d1SAnton Vorontsov {
83236dd4d1SAnton Vorontsov struct device *dev = fhci_to_hcd(fhci)->self.controller;
84236dd4d1SAnton Vorontsov
8566536ab3SGreg Kroah-Hartman fhci->dfs_root = debugfs_create_dir(dev_name(dev), usb_debug_root);
86236dd4d1SAnton Vorontsov
87*2ee12724SGreg Kroah-Hartman debugfs_create_file("regs", S_IFREG | S_IRUGO, fhci->dfs_root, fhci,
88*2ee12724SGreg Kroah-Hartman &fhci_dfs_regs_fops);
89*2ee12724SGreg Kroah-Hartman debugfs_create_file("irq_stat", S_IFREG | S_IRUGO, fhci->dfs_root, fhci,
90236dd4d1SAnton Vorontsov &fhci_dfs_irq_stat_fops);
91236dd4d1SAnton Vorontsov }
92236dd4d1SAnton Vorontsov
fhci_dfs_destroy(struct fhci_hcd * fhci)93236dd4d1SAnton Vorontsov void fhci_dfs_destroy(struct fhci_hcd *fhci)
94236dd4d1SAnton Vorontsov {
95*2ee12724SGreg Kroah-Hartman debugfs_remove_recursive(fhci->dfs_root);
96236dd4d1SAnton Vorontsov }
97