vserver 1.9.5.x5
[linux-2.6.git] / drivers / usb / host / ohci-dbg.c
1 /*
2  * OHCI HCD (Host Controller Driver) for USB.
3  *
4  * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5  * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6  *
7  * This file is licenced under the GPL.
8  */
9
10 /*-------------------------------------------------------------------------*/
11
12 #ifdef DEBUG
13
14 #define edstring(ed_type) ({ char *temp; \
15         switch (ed_type) { \
16         case PIPE_CONTROL:      temp = "ctrl"; break; \
17         case PIPE_BULK:         temp = "bulk"; break; \
18         case PIPE_INTERRUPT:    temp = "intr"; break; \
19         default:                temp = "isoc"; break; \
20         }; temp;})
21 #define pipestring(pipe) edstring(usb_pipetype(pipe))
22
23 /* debug| print the main components of an URB
24  * small: 0) header + data packets 1) just header
25  */
26 static void __attribute__((unused))
27 urb_print (struct urb * urb, char * str, int small)
28 {
29         unsigned int pipe= urb->pipe;
30
31         if (!urb->dev || !urb->dev->bus) {
32                 dbg("%s URB: no dev", str);
33                 return;
34         }
35
36 #ifndef OHCI_VERBOSE_DEBUG
37         if (urb->status != 0)
38 #endif
39         dbg("%s %p dev=%d ep=%d%s-%s flags=%x len=%d/%d stat=%d",
40                     str,
41                     urb,
42                     usb_pipedevice (pipe),
43                     usb_pipeendpoint (pipe),
44                     usb_pipeout (pipe)? "out" : "in",
45                     pipestring (pipe),
46                     urb->transfer_flags,
47                     urb->actual_length,
48                     urb->transfer_buffer_length,
49                     urb->status);
50
51 #ifdef  OHCI_VERBOSE_DEBUG
52         if (!small) {
53                 int i, len;
54
55                 if (usb_pipecontrol (pipe)) {
56                         printk (KERN_DEBUG __FILE__ ": setup(8):");
57                         for (i = 0; i < 8 ; i++)
58                                 printk (" %02x", ((__u8 *) urb->setup_packet) [i]);
59                         printk ("\n");
60                 }
61                 if (urb->transfer_buffer_length > 0 && urb->transfer_buffer) {
62                         printk (KERN_DEBUG __FILE__ ": data(%d/%d):",
63                                 urb->actual_length,
64                                 urb->transfer_buffer_length);
65                         len = usb_pipeout (pipe)?
66                                                 urb->transfer_buffer_length: urb->actual_length;
67                         for (i = 0; i < 16 && i < len; i++)
68                                 printk (" %02x", ((__u8 *) urb->transfer_buffer) [i]);
69                         printk ("%s stat:%d\n", i < len? "...": "", urb->status);
70                 }
71         }
72 #endif
73 }
74
75 #define ohci_dbg_sw(ohci, next, size, format, arg...) \
76         do { \
77         if (next) { \
78                 unsigned s_len; \
79                 s_len = scnprintf (*next, *size, format, ## arg ); \
80                 *size -= s_len; *next += s_len; \
81         } else \
82                 ohci_dbg(ohci,format, ## arg ); \
83         } while (0);
84
85
86 static void ohci_dump_intr_mask (
87         struct ohci_hcd *ohci,
88         char *label,
89         u32 mask,
90         char **next,
91         unsigned *size)
92 {
93         ohci_dbg_sw (ohci, next, size, "%s 0x%08x%s%s%s%s%s%s%s%s%s\n",
94                 label,
95                 mask,
96                 (mask & OHCI_INTR_MIE) ? " MIE" : "",
97                 (mask & OHCI_INTR_OC) ? " OC" : "",
98                 (mask & OHCI_INTR_RHSC) ? " RHSC" : "",
99                 (mask & OHCI_INTR_FNO) ? " FNO" : "",
100                 (mask & OHCI_INTR_UE) ? " UE" : "",
101                 (mask & OHCI_INTR_RD) ? " RD" : "",
102                 (mask & OHCI_INTR_SF) ? " SF" : "",
103                 (mask & OHCI_INTR_WDH) ? " WDH" : "",
104                 (mask & OHCI_INTR_SO) ? " SO" : ""
105                 );
106 }
107
108 static void maybe_print_eds (
109         struct ohci_hcd *ohci,
110         char *label,
111         u32 value,
112         char **next,
113         unsigned *size)
114 {
115         if (value)
116                 ohci_dbg_sw (ohci, next, size, "%s %08x\n", label, value);
117 }
118
119 static char *hcfs2string (int state)
120 {
121         switch (state) {
122                 case OHCI_USB_RESET:    return "reset";
123                 case OHCI_USB_RESUME:   return "resume";
124                 case OHCI_USB_OPER:     return "operational";
125                 case OHCI_USB_SUSPEND:  return "suspend";
126         }
127         return "?";
128 }
129
130 // dump control and status registers
131 static void
132 ohci_dump_status (struct ohci_hcd *controller, char **next, unsigned *size)
133 {
134         struct ohci_regs __iomem *regs = controller->regs;
135         u32                     temp;
136
137         temp = ohci_readl (controller, &regs->revision) & 0xff;
138         ohci_dbg_sw (controller, next, size,
139                 "OHCI %d.%d, %s legacy support registers\n",
140                 0x03 & (temp >> 4), (temp & 0x0f),
141                 (temp & 0x10) ? "with" : "NO");
142
143         temp = ohci_readl (controller, &regs->control);
144         ohci_dbg_sw (controller, next, size,
145                 "control 0x%03x%s%s%s HCFS=%s%s%s%s%s CBSR=%d\n",
146                 temp,
147                 (temp & OHCI_CTRL_RWE) ? " RWE" : "",
148                 (temp & OHCI_CTRL_RWC) ? " RWC" : "",
149                 (temp & OHCI_CTRL_IR) ? " IR" : "",
150                 hcfs2string (temp & OHCI_CTRL_HCFS),
151                 (temp & OHCI_CTRL_BLE) ? " BLE" : "",
152                 (temp & OHCI_CTRL_CLE) ? " CLE" : "",
153                 (temp & OHCI_CTRL_IE) ? " IE" : "",
154                 (temp & OHCI_CTRL_PLE) ? " PLE" : "",
155                 temp & OHCI_CTRL_CBSR
156                 );
157
158         temp = ohci_readl (controller, &regs->cmdstatus);
159         ohci_dbg_sw (controller, next, size,
160                 "cmdstatus 0x%05x SOC=%d%s%s%s%s\n", temp,
161                 (temp & OHCI_SOC) >> 16,
162                 (temp & OHCI_OCR) ? " OCR" : "",
163                 (temp & OHCI_BLF) ? " BLF" : "",
164                 (temp & OHCI_CLF) ? " CLF" : "",
165                 (temp & OHCI_HCR) ? " HCR" : ""
166                 );
167
168         ohci_dump_intr_mask (controller, "intrstatus",
169                         ohci_readl (controller, &regs->intrstatus),
170                         next, size);
171         ohci_dump_intr_mask (controller, "intrenable",
172                         ohci_readl (controller, &regs->intrenable),
173                         next, size);
174         // intrdisable always same as intrenable
175
176         maybe_print_eds (controller, "ed_periodcurrent",
177                         ohci_readl (controller, &regs->ed_periodcurrent),
178                         next, size);
179
180         maybe_print_eds (controller, "ed_controlhead",
181                         ohci_readl (controller, &regs->ed_controlhead),
182                         next, size);
183         maybe_print_eds (controller, "ed_controlcurrent",
184                         ohci_readl (controller, &regs->ed_controlcurrent),
185                         next, size);
186
187         maybe_print_eds (controller, "ed_bulkhead",
188                         ohci_readl (controller, &regs->ed_bulkhead),
189                         next, size);
190         maybe_print_eds (controller, "ed_bulkcurrent",
191                         ohci_readl (controller, &regs->ed_bulkcurrent),
192                         next, size);
193
194         maybe_print_eds (controller, "donehead",
195                         ohci_readl (controller, &regs->donehead), next, size);
196 }
197
198 #define dbg_port_sw(hc,num,value,next,size) \
199         ohci_dbg_sw (hc, next, size, \
200                 "roothub.portstatus [%d] " \
201                 "0x%08x%s%s%s%s%s%s%s%s%s%s%s%s\n", \
202                 num, temp, \
203                 (temp & RH_PS_PRSC) ? " PRSC" : "", \
204                 (temp & RH_PS_OCIC) ? " OCIC" : "", \
205                 (temp & RH_PS_PSSC) ? " PSSC" : "", \
206                 (temp & RH_PS_PESC) ? " PESC" : "", \
207                 (temp & RH_PS_CSC) ? " CSC" : "", \
208                 \
209                 (temp & RH_PS_LSDA) ? " LSDA" : "", \
210                 (temp & RH_PS_PPS) ? " PPS" : "", \
211                 (temp & RH_PS_PRS) ? " PRS" : "", \
212                 (temp & RH_PS_POCI) ? " POCI" : "", \
213                 (temp & RH_PS_PSS) ? " PSS" : "", \
214                 \
215                 (temp & RH_PS_PES) ? " PES" : "", \
216                 (temp & RH_PS_CCS) ? " CCS" : "" \
217                 );
218
219
220 static void
221 ohci_dump_roothub (
222         struct ohci_hcd *controller,
223         int verbose,
224         char **next,
225         unsigned *size)
226 {
227         u32                     temp, ndp, i;
228
229         temp = roothub_a (controller);
230         if (temp == ~(u32)0)
231                 return;
232         ndp = (temp & RH_A_NDP);
233
234         if (verbose) {
235                 ohci_dbg_sw (controller, next, size,
236                         "roothub.a %08x POTPGT=%d%s%s%s%s%s NDP=%d\n", temp,
237                         ((temp & RH_A_POTPGT) >> 24) & 0xff,
238                         (temp & RH_A_NOCP) ? " NOCP" : "",
239                         (temp & RH_A_OCPM) ? " OCPM" : "",
240                         (temp & RH_A_DT) ? " DT" : "",
241                         (temp & RH_A_NPS) ? " NPS" : "",
242                         (temp & RH_A_PSM) ? " PSM" : "",
243                         ndp
244                         );
245                 temp = roothub_b (controller);
246                 ohci_dbg_sw (controller, next, size,
247                         "roothub.b %08x PPCM=%04x DR=%04x\n",
248                         temp,
249                         (temp & RH_B_PPCM) >> 16,
250                         (temp & RH_B_DR)
251                         );
252                 temp = roothub_status (controller);
253                 ohci_dbg_sw (controller, next, size,
254                         "roothub.status %08x%s%s%s%s%s%s\n",
255                         temp,
256                         (temp & RH_HS_CRWE) ? " CRWE" : "",
257                         (temp & RH_HS_OCIC) ? " OCIC" : "",
258                         (temp & RH_HS_LPSC) ? " LPSC" : "",
259                         (temp & RH_HS_DRWE) ? " DRWE" : "",
260                         (temp & RH_HS_OCI) ? " OCI" : "",
261                         (temp & RH_HS_LPS) ? " LPS" : ""
262                         );
263         }
264
265         for (i = 0; i < ndp; i++) {
266                 temp = roothub_portstatus (controller, i);
267                 dbg_port_sw (controller, i, temp, next, size);
268         }
269 }
270
271 static void ohci_dump (struct ohci_hcd *controller, int verbose)
272 {
273         ohci_dbg (controller, "OHCI controller state\n");
274
275         // dumps some of the state we know about
276         ohci_dump_status (controller, NULL, NULL);
277         if (controller->hcca)
278                 ohci_dbg (controller,
279                         "hcca frame #%04x\n", ohci_frame_no(controller));
280         ohci_dump_roothub (controller, 1, NULL, NULL);
281 }
282
283 static const char data0 [] = "DATA0";
284 static const char data1 [] = "DATA1";
285
286 static void ohci_dump_td (const struct ohci_hcd *ohci, const char *label,
287                 const struct td *td)
288 {
289         u32     tmp = hc32_to_cpup (ohci, &td->hwINFO);
290
291         ohci_dbg (ohci, "%s td %p%s; urb %p index %d; hw next td %08x\n",
292                 label, td,
293                 (tmp & TD_DONE) ? " (DONE)" : "",
294                 td->urb, td->index,
295                 hc32_to_cpup (ohci, &td->hwNextTD));
296         if ((tmp & TD_ISO) == 0) {
297                 const char      *toggle, *pid;
298                 u32     cbp, be;
299
300                 switch (tmp & TD_T) {
301                 case TD_T_DATA0: toggle = data0; break;
302                 case TD_T_DATA1: toggle = data1; break;
303                 case TD_T_TOGGLE: toggle = "(CARRY)"; break;
304                 default: toggle = "(?)"; break;
305                 }
306                 switch (tmp & TD_DP) {
307                 case TD_DP_SETUP: pid = "SETUP"; break;
308                 case TD_DP_IN: pid = "IN"; break;
309                 case TD_DP_OUT: pid = "OUT"; break;
310                 default: pid = "(bad pid)"; break;
311                 }
312                 ohci_dbg (ohci, "     info %08x CC=%x %s DI=%d %s %s\n", tmp,
313                         TD_CC_GET(tmp), /* EC, */ toggle,
314                         (tmp & TD_DI) >> 21, pid,
315                         (tmp & TD_R) ? "R" : "");
316                 cbp = hc32_to_cpup (ohci, &td->hwCBP);
317                 be = hc32_to_cpup (ohci, &td->hwBE);
318                 ohci_dbg (ohci, "     cbp %08x be %08x (len %d)\n", cbp, be,
319                         cbp ? (be + 1 - cbp) : 0);
320         } else {
321                 unsigned        i;
322                 ohci_dbg (ohci, "  info %08x CC=%x FC=%d DI=%d SF=%04x\n", tmp,
323                         TD_CC_GET(tmp),
324                         (tmp >> 24) & 0x07,
325                         (tmp & TD_DI) >> 21,
326                         tmp & 0x0000ffff);
327                 ohci_dbg (ohci, "  bp0 %08x be %08x\n",
328                         hc32_to_cpup (ohci, &td->hwCBP) & ~0x0fff,
329                         hc32_to_cpup (ohci, &td->hwBE));
330                 for (i = 0; i < MAXPSW; i++) {
331                         u16     psw = hc16_to_cpup (ohci, &td->hwPSW [i]);
332                         int     cc = (psw >> 12) & 0x0f;
333                         ohci_dbg (ohci, "    psw [%d] = %2x, CC=%x %s=%d\n", i,
334                                 psw, cc,
335                                 (cc >= 0x0e) ? "OFFSET" : "SIZE",
336                                 psw & 0x0fff);
337                 }
338         }
339 }
340
341 /* caller MUST own hcd spinlock if verbose is set! */
342 static void __attribute__((unused))
343 ohci_dump_ed (const struct ohci_hcd *ohci, const char *label,
344                 const struct ed *ed, int verbose)
345 {
346         u32     tmp = hc32_to_cpu (ohci, ed->hwINFO);
347         char    *type = "";
348
349         ohci_dbg (ohci, "%s, ed %p state 0x%x type %s; next ed %08x\n",
350                 label,
351                 ed, ed->state, edstring (ed->type),
352                 hc32_to_cpup (ohci, &ed->hwNextED));
353         switch (tmp & (ED_IN|ED_OUT)) {
354         case ED_OUT: type = "-OUT"; break;
355         case ED_IN: type = "-IN"; break;
356         /* else from TDs ... control */
357         }
358         ohci_dbg (ohci,
359                 "  info %08x MAX=%d%s%s%s%s EP=%d%s DEV=%d\n", tmp,
360                 0x03ff & (tmp >> 16),
361                 (tmp & ED_DEQUEUE) ? " DQ" : "",
362                 (tmp & ED_ISO) ? " ISO" : "",
363                 (tmp & ED_SKIP) ? " SKIP" : "",
364                 (tmp & ED_LOWSPEED) ? " LOW" : "",
365                 0x000f & (tmp >> 7),
366                 type,
367                 0x007f & tmp);
368         tmp = hc32_to_cpup (ohci, &ed->hwHeadP);
369         ohci_dbg (ohci, "  tds: head %08x %s%s tail %08x%s\n",
370                 tmp,
371                 (tmp & ED_C) ? data1 : data0,
372                 (tmp & ED_H) ? " HALT" : "",
373                 hc32_to_cpup (ohci, &ed->hwTailP),
374                 verbose ? "" : " (not listing)");
375         if (verbose) {
376                 struct list_head        *tmp;
377
378                 /* use ed->td_list because HC concurrently modifies
379                  * hwNextTD as it accumulates ed_donelist.
380                  */
381                 list_for_each (tmp, &ed->td_list) {
382                         struct td               *td;
383                         td = list_entry (tmp, struct td, td_list);
384                         ohci_dump_td (ohci, "  ->", td);
385                 }
386         }
387 }
388
389 #else
390 static inline void ohci_dump (struct ohci_hcd *controller, int verbose) {}
391
392 #undef OHCI_VERBOSE_DEBUG
393
394 #endif /* DEBUG */
395
396 /*-------------------------------------------------------------------------*/
397
398 #ifdef STUB_DEBUG_FILES
399
400 static inline void create_debug_files (struct ohci_hcd *bus) { }
401 static inline void remove_debug_files (struct ohci_hcd *bus) { }
402
403 #else
404
405 static ssize_t
406 show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)
407 {
408         unsigned                temp, size = count;
409
410         if (!ed)
411                 return 0;
412
413         /* print first --> last */
414         while (ed->ed_prev)
415                 ed = ed->ed_prev;
416
417         /* dump a snapshot of the bulk or control schedule */
418         while (ed) {
419                 u32             info = hc32_to_cpu (ohci, ed->hwINFO);
420                 u32             headp = hc32_to_cpu (ohci, ed->hwHeadP);
421                 struct list_head *entry;
422                 struct td       *td;
423
424                 temp = scnprintf (buf, size,
425                         "ed/%p %cs dev%d ep%d%s max %d %08x%s%s %s",
426                         ed,
427                         (info & ED_LOWSPEED) ? 'l' : 'f',
428                         info & 0x7f,
429                         (info >> 7) & 0xf,
430                         (info & ED_IN) ? "in" : "out",
431                         0x03ff & (info >> 16),
432                         info,
433                         (info & ED_SKIP) ? " s" : "",
434                         (headp & ED_H) ? " H" : "",
435                         (headp & ED_C) ? data1 : data0);
436                 size -= temp;
437                 buf += temp;
438
439                 list_for_each (entry, &ed->td_list) {
440                         u32             cbp, be;
441
442                         td = list_entry (entry, struct td, td_list);
443                         info = hc32_to_cpup (ohci, &td->hwINFO);
444                         cbp = hc32_to_cpup (ohci, &td->hwCBP);
445                         be = hc32_to_cpup (ohci, &td->hwBE);
446                         temp = scnprintf (buf, size,
447                                         "\n\ttd %p %s %d cc=%x urb %p (%08x)",
448                                         td,
449                                         ({ char *pid;
450                                         switch (info & TD_DP) {
451                                         case TD_DP_SETUP: pid = "setup"; break;
452                                         case TD_DP_IN: pid = "in"; break;
453                                         case TD_DP_OUT: pid = "out"; break;
454                                         default: pid = "(?)"; break;
455                                          } pid;}),
456                                         cbp ? (be + 1 - cbp) : 0,
457                                         TD_CC_GET (info), td->urb, info);
458                         size -= temp;
459                         buf += temp;
460                 }
461
462                 temp = scnprintf (buf, size, "\n");
463                 size -= temp;
464                 buf += temp;
465
466                 ed = ed->ed_next;
467         }
468         return count - size;
469 }
470
471 static ssize_t
472 show_async (struct class_device *class_dev, char *buf)
473 {
474         struct usb_bus          *bus;
475         struct usb_hcd          *hcd;
476         struct ohci_hcd         *ohci;
477         size_t                  temp;
478         unsigned long           flags;
479
480         bus = to_usb_bus(class_dev);
481         hcd = bus->hcpriv;
482         ohci = hcd_to_ohci(hcd);
483
484         /* display control and bulk lists together, for simplicity */
485         spin_lock_irqsave (&ohci->lock, flags);
486         temp = show_list (ohci, buf, PAGE_SIZE, ohci->ed_controltail);
487         temp += show_list (ohci, buf + temp, PAGE_SIZE - temp, ohci->ed_bulktail);
488         spin_unlock_irqrestore (&ohci->lock, flags);
489
490         return temp;
491 }
492 static CLASS_DEVICE_ATTR (async, S_IRUGO, show_async, NULL);
493
494
495 #define DBG_SCHED_LIMIT 64
496
497 static ssize_t
498 show_periodic (struct class_device *class_dev, char *buf)
499 {
500         struct usb_bus          *bus;
501         struct usb_hcd          *hcd;
502         struct ohci_hcd         *ohci;
503         struct ed               **seen, *ed;
504         unsigned long           flags;
505         unsigned                temp, size, seen_count;
506         char                    *next;
507         unsigned                i;
508
509         if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC)))
510                 return 0;
511         seen_count = 0;
512
513         bus = to_usb_bus(class_dev);
514         hcd = bus->hcpriv;
515         ohci = hcd_to_ohci(hcd);
516         next = buf;
517         size = PAGE_SIZE;
518
519         temp = scnprintf (next, size, "size = %d\n", NUM_INTS);
520         size -= temp;
521         next += temp;
522
523         /* dump a snapshot of the periodic schedule (and load) */
524         spin_lock_irqsave (&ohci->lock, flags);
525         for (i = 0; i < NUM_INTS; i++) {
526                 if (!(ed = ohci->periodic [i]))
527                         continue;
528
529                 temp = scnprintf (next, size, "%2d [%3d]:", i, ohci->load [i]);
530                 size -= temp;
531                 next += temp;
532
533                 do {
534                         temp = scnprintf (next, size, " ed%d/%p",
535                                 ed->interval, ed);
536                         size -= temp;
537                         next += temp;
538                         for (temp = 0; temp < seen_count; temp++) {
539                                 if (seen [temp] == ed)
540                                         break;
541                         }
542
543                         /* show more info the first time around */
544                         if (temp == seen_count) {
545                                 u32     info = hc32_to_cpu (ohci, ed->hwINFO);
546                                 struct list_head        *entry;
547                                 unsigned                qlen = 0;
548
549                                 /* qlen measured here in TDs, not urbs */
550                                 list_for_each (entry, &ed->td_list)
551                                         qlen++;
552
553                                 temp = scnprintf (next, size,
554                                         " (%cs dev%d ep%d%s-%s qlen %u"
555                                         " max %d %08x%s%s)",
556                                         (info & ED_LOWSPEED) ? 'l' : 'f',
557                                         info & 0x7f,
558                                         (info >> 7) & 0xf,
559                                         (info & ED_IN) ? "in" : "out",
560                                         (info & ED_ISO) ? "iso" : "int",
561                                         qlen,
562                                         0x03ff & (info >> 16),
563                                         info,
564                                         (info & ED_SKIP) ? " K" : "",
565                                         (ed->hwHeadP &
566                                                 cpu_to_hc32(ohci, ED_H)) ?
567                                                         " H" : "");
568                                 size -= temp;
569                                 next += temp;
570
571                                 if (seen_count < DBG_SCHED_LIMIT)
572                                         seen [seen_count++] = ed;
573
574                                 ed = ed->ed_next;
575
576                         } else {
577                                 /* we've seen it and what's after */
578                                 temp = 0;
579                                 ed = NULL;
580                         }
581
582                 } while (ed);
583
584                 temp = scnprintf (next, size, "\n");
585                 size -= temp;
586                 next += temp;
587         }
588         spin_unlock_irqrestore (&ohci->lock, flags);
589         kfree (seen);
590
591         return PAGE_SIZE - size;
592 }
593 static CLASS_DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL);
594
595
596 #undef DBG_SCHED_LIMIT
597
598 static ssize_t
599 show_registers (struct class_device *class_dev, char *buf)
600 {
601         struct usb_bus          *bus;
602         struct usb_hcd          *hcd;
603         struct ohci_hcd         *ohci;
604         struct ohci_regs __iomem *regs;
605         unsigned long           flags;
606         unsigned                temp, size;
607         char                    *next;
608         u32                     rdata;
609
610         bus = to_usb_bus(class_dev);
611         hcd = bus->hcpriv;
612         ohci = hcd_to_ohci(hcd);
613         regs = ohci->regs;
614         next = buf;
615         size = PAGE_SIZE;
616
617         spin_lock_irqsave (&ohci->lock, flags);
618
619         /* dump driver info, then registers in spec order */
620
621         ohci_dbg_sw (ohci, &next, &size,
622                 "bus %s, device %s\n"
623                 "%s version " DRIVER_VERSION "\n",
624                 hcd->self.controller->bus->name,
625                 hcd->self.controller->bus_id,
626                 hcd_name);
627
628         if (bus->controller->power.power_state) {
629                 size -= scnprintf (next, size,
630                         "SUSPENDED (no register access)\n");
631                 goto done;
632         }
633
634         ohci_dump_status(ohci, &next, &size);
635
636         /* hcca */
637         if (ohci->hcca)
638                 ohci_dbg_sw (ohci, &next, &size,
639                         "hcca frame 0x%04x\n", ohci_frame_no(ohci));
640
641         /* other registers mostly affect frame timings */
642         rdata = ohci_readl (ohci, &regs->fminterval);
643         temp = scnprintf (next, size,
644                         "fmintvl 0x%08x %sFSMPS=0x%04x FI=0x%04x\n",
645                         rdata, (rdata >> 31) ? "FIT " : "",
646                         (rdata >> 16) & 0xefff, rdata & 0xffff);
647         size -= temp;
648         next += temp;
649
650         rdata = ohci_readl (ohci, &regs->fmremaining);
651         temp = scnprintf (next, size, "fmremaining 0x%08x %sFR=0x%04x\n",
652                         rdata, (rdata >> 31) ? "FRT " : "",
653                         rdata & 0x3fff);
654         size -= temp;
655         next += temp;
656
657         rdata = ohci_readl (ohci, &regs->periodicstart);
658         temp = scnprintf (next, size, "periodicstart 0x%04x\n",
659                         rdata & 0x3fff);
660         size -= temp;
661         next += temp;
662
663         rdata = ohci_readl (ohci, &regs->lsthresh);
664         temp = scnprintf (next, size, "lsthresh 0x%04x\n",
665                         rdata & 0x3fff);
666         size -= temp;
667         next += temp;
668
669         /* roothub */
670         ohci_dump_roothub (ohci, 1, &next, &size);
671
672 done:
673         spin_unlock_irqrestore (&ohci->lock, flags);
674         return PAGE_SIZE - size;
675 }
676 static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
677
678
679 static inline void create_debug_files (struct ohci_hcd *ohci)
680 {
681         struct class_device *cldev = &ohci_to_hcd(ohci)->self.class_dev;
682
683         class_device_create_file(cldev, &class_device_attr_async);
684         class_device_create_file(cldev, &class_device_attr_periodic);
685         class_device_create_file(cldev, &class_device_attr_registers);
686         ohci_dbg (ohci, "created debug files\n");
687 }
688
689 static inline void remove_debug_files (struct ohci_hcd *ohci)
690 {
691         struct class_device *cldev = &ohci_to_hcd(ohci)->self.class_dev;
692
693         class_device_remove_file(cldev, &class_device_attr_async);
694         class_device_remove_file(cldev, &class_device_attr_periodic);
695         class_device_remove_file(cldev, &class_device_attr_registers);
696 }
697
698 #endif
699
700 /*-------------------------------------------------------------------------*/
701