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