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 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 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 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 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 if (!fhci->dfs_root) { 87236dd4d1SAnton Vorontsov WARN_ON(1); 88236dd4d1SAnton Vorontsov return; 89236dd4d1SAnton Vorontsov } 90236dd4d1SAnton Vorontsov 91236dd4d1SAnton Vorontsov fhci->dfs_regs = debugfs_create_file("regs", S_IFREG | S_IRUGO, 92236dd4d1SAnton Vorontsov fhci->dfs_root, fhci, &fhci_dfs_regs_fops); 93236dd4d1SAnton Vorontsov 94236dd4d1SAnton Vorontsov fhci->dfs_irq_stat = debugfs_create_file("irq_stat", 95236dd4d1SAnton Vorontsov S_IFREG | S_IRUGO, fhci->dfs_root, fhci, 96236dd4d1SAnton Vorontsov &fhci_dfs_irq_stat_fops); 97236dd4d1SAnton Vorontsov 98236dd4d1SAnton Vorontsov WARN_ON(!fhci->dfs_regs || !fhci->dfs_irq_stat); 99236dd4d1SAnton Vorontsov } 100236dd4d1SAnton Vorontsov 101236dd4d1SAnton Vorontsov void fhci_dfs_destroy(struct fhci_hcd *fhci) 102236dd4d1SAnton Vorontsov { 103236dd4d1SAnton Vorontsov if (!fhci->dfs_root) 104236dd4d1SAnton Vorontsov return; 105236dd4d1SAnton Vorontsov 106236dd4d1SAnton Vorontsov debugfs_remove(fhci->dfs_irq_stat); 107236dd4d1SAnton Vorontsov debugfs_remove(fhci->dfs_regs); 108236dd4d1SAnton Vorontsov debugfs_remove(fhci->dfs_root); 109236dd4d1SAnton Vorontsov } 110