-/*-------------------------------------------------------------------------*/
-
-#ifdef CONFIG_USB_GADGET_DEBUG_FILES
-
-#include <linux/seq_file.h>
-
-static const char debug_filename[] = "driver/udc";
-
-#define FOURBITS "%s%s%s%s"
-#define EIGHTBITS FOURBITS FOURBITS
-
-static void proc_ep_show(struct seq_file *s, struct at91_ep *ep)
-{
- static char *types[] = {
- "control", "out-iso", "out-bulk", "out-int",
- "BOGUS", "in-iso", "in-bulk", "in-int"};
-
- u32 csr;
- struct at91_request *req;
- unsigned long flags;
- struct at91_udc *udc = ep->udc;
-
- spin_lock_irqsave(&udc->lock, flags);
-
- csr = __raw_readl(ep->creg);
-
- /* NOTE: not collecting per-endpoint irq statistics... */
-
- seq_printf(s, "\n");
- seq_printf(s, "%s, maxpacket %d %s%s %s%s\n",
- ep->ep.name, ep->ep.maxpacket,
- ep->is_in ? "in" : "out",
- ep->is_iso ? " iso" : "",
- ep->is_pingpong
- ? (ep->fifo_bank ? "pong" : "ping")
- : "",
- ep->stopped ? " stopped" : "");
- seq_printf(s, "csr %08x rxbytes=%d %s %s %s" EIGHTBITS "\n",
- csr,
- (csr & 0x07ff0000) >> 16,
- (csr & (1 << 15)) ? "enabled" : "disabled",
- (csr & (1 << 11)) ? "DATA1" : "DATA0",
- types[(csr & 0x700) >> 8],
-
- /* iff type is control then print current direction */
- (!(csr & 0x700))
- ? ((csr & (1 << 7)) ? " IN" : " OUT")
- : "",
- (csr & (1 << 6)) ? " rxdatabk1" : "",
- (csr & (1 << 5)) ? " forcestall" : "",
- (csr & (1 << 4)) ? " txpktrdy" : "",
-
- (csr & (1 << 3)) ? " stallsent" : "",
- (csr & (1 << 2)) ? " rxsetup" : "",
- (csr & (1 << 1)) ? " rxdatabk0" : "",
- (csr & (1 << 0)) ? " txcomp" : "");
- if (list_empty (&ep->queue))
- seq_printf(s, "\t(queue empty)\n");
-
- else list_for_each_entry (req, &ep->queue, queue) {
- unsigned length = req->req.actual;
-
- seq_printf(s, "\treq %p len %d/%d buf %p\n",
- &req->req, length,
- req->req.length, req->req.buf);
- }
- spin_unlock_irqrestore(&udc->lock, flags);
-}
-
-static void proc_irq_show(struct seq_file *s, const char *label, u32 mask)
-{
- int i;
-
- seq_printf(s, "%s %04x:%s%s" FOURBITS, label, mask,
- (mask & (1 << 13)) ? " wakeup" : "",
- (mask & (1 << 12)) ? " endbusres" : "",
-
- (mask & (1 << 11)) ? " sofint" : "",
- (mask & (1 << 10)) ? " extrsm" : "",
- (mask & (1 << 9)) ? " rxrsm" : "",
- (mask & (1 << 8)) ? " rxsusp" : "");
- for (i = 0; i < 8; i++) {
- if (mask & (1 << i))
- seq_printf(s, " ep%d", i);
- }
- seq_printf(s, "\n");
-}
-
-static int proc_udc_show(struct seq_file *s, void *unused)
-{
- struct at91_udc *udc = s->private;
- struct at91_ep *ep;
- u32 tmp;
-
- seq_printf(s, "%s: version %s\n", driver_name, DRIVER_VERSION);
-
- seq_printf(s, "vbus %s, pullup %s, %s powered%s, gadget %s\n\n",
- udc->vbus ? "present" : "off",
- udc->enabled
- ? (udc->vbus ? "active" : "enabled")
- : "disabled",
- udc->gadget.is_selfpowered ? "self" : "VBUS",
- udc->suspended ? ", suspended" : "",
- udc->driver ? udc->driver->driver.name : "(none)");
-
- /* don't access registers when interface isn't clocked */
- if (!udc->clocked) {
- seq_printf(s, "(not clocked)\n");
- return 0;
- }
-
- tmp = at91_udp_read(udc, AT91_UDP_FRM_NUM);
- seq_printf(s, "frame %05x:%s%s frame=%d\n", tmp,
- (tmp & AT91_UDP_FRM_OK) ? " ok" : "",
- (tmp & AT91_UDP_FRM_ERR) ? " err" : "",
- (tmp & AT91_UDP_NUM));
-
- tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT);
- seq_printf(s, "glbstate %02x:%s" FOURBITS "\n", tmp,
- (tmp & AT91_UDP_RMWUPE) ? " rmwupe" : "",
- (tmp & AT91_UDP_RSMINPR) ? " rsminpr" : "",
- (tmp & AT91_UDP_ESR) ? " esr" : "",
- (tmp & AT91_UDP_CONFG) ? " confg" : "",
- (tmp & AT91_UDP_FADDEN) ? " fadden" : "");
-
- tmp = at91_udp_read(udc, AT91_UDP_FADDR);
- seq_printf(s, "faddr %03x:%s fadd=%d\n", tmp,
- (tmp & AT91_UDP_FEN) ? " fen" : "",
- (tmp & AT91_UDP_FADD));
-
- proc_irq_show(s, "imr ", at91_udp_read(udc, AT91_UDP_IMR));
- proc_irq_show(s, "isr ", at91_udp_read(udc, AT91_UDP_ISR));
-
- if (udc->enabled && udc->vbus) {
- proc_ep_show(s, &udc->ep[0]);
- list_for_each_entry (ep, &udc->gadget.ep_list, ep.ep_list) {
- if (ep->ep.desc)
- proc_ep_show(s, ep);
- }
- }
- return 0;
-}
-
-static int proc_udc_open(struct inode *inode, struct file *file)
-{
- return single_open(file, proc_udc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations proc_ops = {
- .owner = THIS_MODULE,
- .open = proc_udc_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static void create_debug_file(struct at91_udc *udc)
-{
- udc->pde = proc_create_data(debug_filename, 0, NULL, &proc_ops, udc);
-}
-
-static void remove_debug_file(struct at91_udc *udc)
-{
- if (udc->pde)
- remove_proc_entry(debug_filename, NULL);
-}
-
-#else
-
-static inline void create_debug_file(struct at91_udc *udc) {}
-static inline void remove_debug_file(struct at91_udc *udc) {}
-
-#endif
-