patch-2_6_7-vs1_9_1_12
[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        *regs = controller->regs;
135         u32                     temp;
136
137         temp = readl (&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 = readl (&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 = readl (&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                         readl (&regs->intrstatus), next, size);
170         ohci_dump_intr_mask (controller, "intrenable",
171                         readl (&regs->intrenable), next, size);
172         // intrdisable always same as intrenable
173
174         maybe_print_eds (controller, "ed_periodcurrent",
175                         readl (&regs->ed_periodcurrent), next, size);
176
177         maybe_print_eds (controller, "ed_controlhead",
178                         readl (&regs->ed_controlhead), next, size);
179         maybe_print_eds (controller, "ed_controlcurrent",
180                         readl (&regs->ed_controlcurrent), next, size);
181
182         maybe_print_eds (controller, "ed_bulkhead",
183                         readl (&regs->ed_bulkhead), next, size);
184         maybe_print_eds (controller, "ed_bulkcurrent",
185                         readl (&regs->ed_bulkcurrent), next, size);
186
187         maybe_print_eds (controller, "donehead",
188                         readl (&regs->donehead), next, size);
189 }
190
191 #define dbg_port_sw(hc,num,value,next,size) \
192         ohci_dbg_sw (hc, next, size, \
193                 "roothub.portstatus [%d] " \
194                 "0x%08x%s%s%s%s%s%s%s%s%s%s%s%s\n", \
195                 num, temp, \
196                 (temp & RH_PS_PRSC) ? " PRSC" : "", \
197                 (temp & RH_PS_OCIC) ? " OCIC" : "", \
198                 (temp & RH_PS_PSSC) ? " PSSC" : "", \
199                 (temp & RH_PS_PESC) ? " PESC" : "", \
200                 (temp & RH_PS_CSC) ? " CSC" : "", \
201                 \
202                 (temp & RH_PS_LSDA) ? " LSDA" : "", \
203                 (temp & RH_PS_PPS) ? " PPS" : "", \
204                 (temp & RH_PS_PRS) ? " PRS" : "", \
205                 (temp & RH_PS_POCI) ? " POCI" : "", \
206                 (temp & RH_PS_PSS) ? " PSS" : "", \
207                 \
208                 (temp & RH_PS_PES) ? " PES" : "", \
209                 (temp & RH_PS_CCS) ? " CCS" : "" \
210                 );
211
212
213 static void
214 ohci_dump_roothub (
215         struct ohci_hcd *controller,
216         int verbose,
217         char **next,
218         unsigned *size)
219 {
220         u32                     temp, ndp, i;
221
222         temp = roothub_a (controller);
223         if (temp == ~(u32)0)
224                 return;
225         ndp = (temp & RH_A_NDP);
226
227         if (verbose) {
228                 ohci_dbg_sw (controller, next, size,
229                         "roothub.a %08x POTPGT=%d%s%s%s%s%s NDP=%d\n", temp,
230                         ((temp & RH_A_POTPGT) >> 24) & 0xff,
231                         (temp & RH_A_NOCP) ? " NOCP" : "",
232                         (temp & RH_A_OCPM) ? " OCPM" : "",
233                         (temp & RH_A_DT) ? " DT" : "",
234                         (temp & RH_A_NPS) ? " NPS" : "",
235                         (temp & RH_A_PSM) ? " PSM" : "",
236                         ndp
237                         );
238                 temp = roothub_b (controller);
239                 ohci_dbg_sw (controller, next, size,
240                         "roothub.b %08x PPCM=%04x DR=%04x\n",
241                         temp,
242                         (temp & RH_B_PPCM) >> 16,
243                         (temp & RH_B_DR)
244                         );
245                 temp = roothub_status (controller);
246                 ohci_dbg_sw (controller, next, size,
247                         "roothub.status %08x%s%s%s%s%s%s\n",
248                         temp,
249                         (temp & RH_HS_CRWE) ? " CRWE" : "",
250                         (temp & RH_HS_OCIC) ? " OCIC" : "",
251                         (temp & RH_HS_LPSC) ? " LPSC" : "",
252                         (temp & RH_HS_DRWE) ? " DRWE" : "",
253                         (temp & RH_HS_OCI) ? " OCI" : "",
254                         (temp & RH_HS_LPS) ? " LPS" : ""
255                         );
256         }
257
258         for (i = 0; i < ndp; i++) {
259                 temp = roothub_portstatus (controller, i);
260                 dbg_port_sw (controller, i, temp, next, size);
261         }
262 }
263
264 static void ohci_dump (struct ohci_hcd *controller, int verbose)
265 {
266         ohci_dbg (controller, "OHCI controller state\n");
267
268         // dumps some of the state we know about
269         ohci_dump_status (controller, NULL, 0);
270         if (controller->hcca)
271                 ohci_dbg (controller,
272                         "hcca frame #%04x\n", OHCI_FRAME_NO(controller->hcca));
273         ohci_dump_roothub (controller, 1, NULL, 0);
274 }
275
276 static const char data0 [] = "DATA0";
277 static const char data1 [] = "DATA1";
278
279 static void ohci_dump_td (const struct ohci_hcd *ohci, const char *label,
280                 const struct td *td)
281 {
282         u32     tmp = le32_to_cpup (&td->hwINFO);
283
284         ohci_dbg (ohci, "%s td %p%s; urb %p index %d; hw next td %08x\n",
285                 label, td,
286                 (tmp & TD_DONE) ? " (DONE)" : "",
287                 td->urb, td->index,
288                 le32_to_cpup (&td->hwNextTD));
289         if ((tmp & TD_ISO) == 0) {
290                 const char      *toggle, *pid;
291                 u32     cbp, be;
292
293                 switch (tmp & TD_T) {
294                 case TD_T_DATA0: toggle = data0; break;
295                 case TD_T_DATA1: toggle = data1; break;
296                 case TD_T_TOGGLE: toggle = "(CARRY)"; break;
297                 default: toggle = "(?)"; break;
298                 }
299                 switch (tmp & TD_DP) {
300                 case TD_DP_SETUP: pid = "SETUP"; break;
301                 case TD_DP_IN: pid = "IN"; break;
302                 case TD_DP_OUT: pid = "OUT"; break;
303                 default: pid = "(bad pid)"; break;
304                 }
305                 ohci_dbg (ohci, "     info %08x CC=%x %s DI=%d %s %s\n", tmp,
306                         TD_CC_GET(tmp), /* EC, */ toggle,
307                         (tmp & TD_DI) >> 21, pid,
308                         (tmp & TD_R) ? "R" : "");
309                 cbp = le32_to_cpup (&td->hwCBP);
310                 be = le32_to_cpup (&td->hwBE);
311                 ohci_dbg (ohci, "     cbp %08x be %08x (len %d)\n", cbp, be,
312                         cbp ? (be + 1 - cbp) : 0);
313         } else {
314                 unsigned        i;
315                 ohci_dbg (ohci, "  info %08x CC=%x FC=%d DI=%d SF=%04x\n", tmp,
316                         TD_CC_GET(tmp),
317                         (tmp >> 24) & 0x07,
318                         (tmp & TD_DI) >> 21,
319                         tmp & 0x0000ffff);
320                 ohci_dbg (ohci, "  bp0 %08x be %08x\n",
321                         le32_to_cpup (&td->hwCBP) & ~0x0fff,
322                         le32_to_cpup (&td->hwBE));
323                 for (i = 0; i < MAXPSW; i++) {
324                         u16     psw = le16_to_cpup (&td->hwPSW [i]);
325                         int     cc = (psw >> 12) & 0x0f;
326                         ohci_dbg (ohci, "    psw [%d] = %2x, CC=%x %s=%d\n", i,
327                                 psw, cc,
328                                 (cc >= 0x0e) ? "OFFSET" : "SIZE",
329                                 psw & 0x0fff);
330                 }
331         }
332 }
333
334 /* caller MUST own hcd spinlock if verbose is set! */
335 static void __attribute__((unused))
336 ohci_dump_ed (const struct ohci_hcd *ohci, const char *label,
337                 const struct ed *ed, int verbose)
338 {
339         u32     tmp = ed->hwINFO;
340         char    *type = "";
341
342         ohci_dbg (ohci, "%s, ed %p state 0x%x type %s; next ed %08x\n",
343                 label,
344                 ed, ed->state, edstring (ed->type),
345                 le32_to_cpup (&ed->hwNextED));
346         switch (tmp & (ED_IN|ED_OUT)) {
347         case ED_OUT: type = "-OUT"; break;
348         case ED_IN: type = "-IN"; break;
349         /* else from TDs ... control */
350         }
351         ohci_dbg (ohci,
352                 "  info %08x MAX=%d%s%s%s%s EP=%d%s DEV=%d\n", le32_to_cpu (tmp),
353                 0x03ff & (le32_to_cpu (tmp) >> 16),
354                 (tmp & ED_DEQUEUE) ? " DQ" : "",
355                 (tmp & ED_ISO) ? " ISO" : "",
356                 (tmp & ED_SKIP) ? " SKIP" : "",
357                 (tmp & ED_LOWSPEED) ? " LOW" : "",
358                 0x000f & (le32_to_cpu (tmp) >> 7),
359                 type,
360                 0x007f & le32_to_cpu (tmp));
361         ohci_dbg (ohci, "  tds: head %08x %s%s tail %08x%s\n",
362                 tmp = le32_to_cpup (&ed->hwHeadP),
363                 (ed->hwHeadP & ED_C) ? data1 : data0,
364                 (ed->hwHeadP & ED_H) ? " HALT" : "",
365                 le32_to_cpup (&ed->hwTailP),
366                 verbose ? "" : " (not listing)");
367         if (verbose) {
368                 struct list_head        *tmp;
369
370                 /* use ed->td_list because HC concurrently modifies
371                  * hwNextTD as it accumulates ed_donelist.
372                  */
373                 list_for_each (tmp, &ed->td_list) {
374                         struct td               *td;
375                         td = list_entry (tmp, struct td, td_list);
376                         ohci_dump_td (ohci, "  ->", td);
377                 }
378         }
379 }
380
381 #else
382 static inline void ohci_dump (struct ohci_hcd *controller, int verbose) {}
383
384 #undef OHCI_VERBOSE_DEBUG
385
386 #endif /* DEBUG */
387
388 /*-------------------------------------------------------------------------*/
389
390 #ifdef STUB_DEBUG_FILES
391
392 static inline void create_debug_files (struct ohci_hcd *bus) { }
393 static inline void remove_debug_files (struct ohci_hcd *bus) { }
394
395 #else
396
397 static inline struct ohci_hcd *dev_to_ohci (struct device *dev)
398 {
399         struct usb_hcd  *hcd = dev_get_drvdata (dev);
400
401         return hcd_to_ohci (hcd);
402 }
403
404 static ssize_t
405 show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)
406 {
407         unsigned                temp, size = count;
408
409         if (!ed)
410                 return 0;
411
412         /* print first --> last */
413         while (ed->ed_prev)
414                 ed = ed->ed_prev;
415
416         /* dump a snapshot of the bulk or control schedule */
417         while (ed) {
418                 u32                     info = ed->hwINFO;
419                 u32                     scratch = cpu_to_le32p (&ed->hwINFO);
420                 struct list_head        *entry;
421                 struct td               *td;
422
423                 temp = scnprintf (buf, size,
424                         "ed/%p %cs dev%d ep%d%s max %d %08x%s%s %s",
425                         ed,
426                         (info & ED_LOWSPEED) ? 'l' : 'f',
427                         scratch & 0x7f,
428                         (scratch >> 7) & 0xf,
429                         (info & ED_IN) ? "in" : "out",
430                         0x03ff & (scratch >> 16),
431                         scratch,
432                         (info & ED_SKIP) ? " s" : "",
433                         (ed->hwHeadP & ED_H) ? " H" : "",
434                         (ed->hwHeadP & ED_C) ? data1 : data0);
435                 size -= temp;
436                 buf += temp;
437
438                 list_for_each (entry, &ed->td_list) {
439                         u32             cbp, be;
440
441                         td = list_entry (entry, struct td, td_list);
442                         scratch = cpu_to_le32p (&td->hwINFO);
443                         cbp = le32_to_cpup (&td->hwCBP);
444                         be = le32_to_cpup (&td->hwBE);
445                         temp = scnprintf (buf, size,
446                                         "\n\ttd %p %s %d cc=%x urb %p (%08x)",
447                                         td,
448                                         ({ char *pid;
449                                         switch (scratch & TD_DP) {
450                                         case TD_DP_SETUP: pid = "setup"; break;
451                                         case TD_DP_IN: pid = "in"; break;
452                                         case TD_DP_OUT: pid = "out"; break;
453                                         default: pid = "(?)"; break;
454                                          } pid;}),
455                                         cbp ? (be + 1 - cbp) : 0,
456                                         TD_CC_GET (scratch), td->urb, scratch);
457                         size -= temp;
458                         buf += temp;
459                 }
460
461                 temp = scnprintf (buf, size, "\n");
462                 size -= temp;
463                 buf += temp;
464
465                 ed = ed->ed_next;
466         }
467         return count - size;
468 }
469
470 static ssize_t
471 show_async (struct class_device *class_dev, char *buf)
472 {
473         struct usb_bus          *bus;
474         struct usb_hcd          *hcd;
475         struct ohci_hcd         *ohci;
476         size_t                  temp;
477         unsigned long           flags;
478
479         bus = to_usb_bus(class_dev);
480         hcd = bus->hcpriv;
481         ohci = hcd_to_ohci(hcd);
482
483         /* display control and bulk lists together, for simplicity */
484         spin_lock_irqsave (&ohci->lock, flags);
485         temp = show_list (ohci, buf, PAGE_SIZE, ohci->ed_controltail);
486         temp += show_list (ohci, buf + temp, PAGE_SIZE - temp, ohci->ed_bulktail);
487         spin_unlock_irqrestore (&ohci->lock, flags);
488
489         return temp;
490 }
491 static CLASS_DEVICE_ATTR (async, S_IRUGO, show_async, NULL);
492
493
494 #define DBG_SCHED_LIMIT 64
495
496 static ssize_t
497 show_periodic (struct class_device *class_dev, char *buf)
498 {
499         struct usb_bus          *bus;
500         struct usb_hcd          *hcd;
501         struct ohci_hcd         *ohci;
502         struct ed               **seen, *ed;
503         unsigned long           flags;
504         unsigned                temp, size, seen_count;
505         char                    *next;
506         unsigned                i;
507
508         if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC)))
509                 return 0;
510         seen_count = 0;
511
512         bus = to_usb_bus(class_dev);
513         hcd = bus->hcpriv;
514         ohci = hcd_to_ohci(hcd);
515         next = buf;
516         size = PAGE_SIZE;
517
518         temp = scnprintf (next, size, "size = %d\n", NUM_INTS);
519         size -= temp;
520         next += temp;
521
522         /* dump a snapshot of the periodic schedule (and load) */
523         spin_lock_irqsave (&ohci->lock, flags);
524         for (i = 0; i < NUM_INTS; i++) {
525                 if (!(ed = ohci->periodic [i]))
526                         continue;
527
528                 temp = scnprintf (next, size, "%2d [%3d]:", i, ohci->load [i]);
529                 size -= temp;
530                 next += temp;
531
532                 do {
533                         temp = scnprintf (next, size, " ed%d/%p",
534                                 ed->interval, ed);
535                         size -= temp;
536                         next += temp;
537                         for (temp = 0; temp < seen_count; temp++) {
538                                 if (seen [temp] == ed)
539                                         break;
540                         }
541
542                         /* show more info the first time around */
543                         if (temp == seen_count) {
544                                 u32     info = ed->hwINFO;
545                                 u32     scratch = cpu_to_le32p (&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                                         scratch & 0x7f,
558                                         (scratch >> 7) & 0xf,
559                                         (info & ED_IN) ? "in" : "out",
560                                         (info & ED_ISO) ? "iso" : "int",
561                                         qlen,
562                                         0x03ff & (scratch >> 16),
563                                         scratch,
564                                         (info & ED_SKIP) ? " K" : "",
565                                         (ed->hwHeadP & ED_H) ? " H" : "");
566                                 size -= temp;
567                                 next += temp;
568
569                                 if (seen_count < DBG_SCHED_LIMIT)
570                                         seen [seen_count++] = ed;
571
572                                 ed = ed->ed_next;
573
574                         } else {
575                                 /* we've seen it and what's after */
576                                 temp = 0;
577                                 ed = 0;
578                         }
579
580                 } while (ed);
581
582                 temp = scnprintf (next, size, "\n");
583                 size -= temp;
584                 next += temp;
585         }
586         spin_unlock_irqrestore (&ohci->lock, flags);
587         kfree (seen);
588
589         return PAGE_SIZE - size;
590 }
591 static CLASS_DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL);
592
593
594 #undef DBG_SCHED_LIMIT
595
596 static ssize_t
597 show_registers (struct class_device *class_dev, char *buf)
598 {
599         struct usb_bus          *bus;
600         struct usb_hcd          *hcd;
601         struct ohci_hcd         *ohci;
602         struct ohci_regs        *regs;
603         unsigned long           flags;
604         unsigned                temp, size;
605         char                    *next;
606         u32                     rdata;
607
608         bus = to_usb_bus(class_dev);
609         hcd = bus->hcpriv;
610         ohci = hcd_to_ohci(hcd);
611         regs = ohci->regs;
612         next = buf;
613         size = PAGE_SIZE;
614
615         spin_lock_irqsave (&ohci->lock, flags);
616
617         /* dump driver info, then registers in spec order */
618
619         ohci_dbg_sw (ohci, &next, &size,
620                 "bus %s, device %s\n"
621                 "%s version " DRIVER_VERSION "\n",
622                 hcd->self.controller->bus->name,
623                 hcd->self.controller->bus_id,
624                 hcd_name);
625
626         if (bus->controller->power.power_state) {
627                 size -= scnprintf (next, size,
628                         "SUSPENDED (no register access)\n");
629                 goto done;
630         }
631
632         ohci_dump_status(ohci, &next, &size);
633
634         /* hcca */
635         if (ohci->hcca)
636                 ohci_dbg_sw (ohci, &next, &size,
637                         "hcca frame 0x%04x\n", OHCI_FRAME_NO(ohci->hcca));
638
639         /* other registers mostly affect frame timings */
640         rdata = readl (&regs->fminterval);
641         temp = scnprintf (next, size,
642                         "fmintvl 0x%08x %sFSMPS=0x%04x FI=0x%04x\n",
643                         rdata, (rdata >> 31) ? " FIT" : "",
644                         (rdata >> 16) & 0xefff, rdata & 0xffff);
645         size -= temp;
646         next += temp;
647
648         rdata = readl (&regs->fmremaining);
649         temp = scnprintf (next, size, "fmremaining 0x%08x %sFR=0x%04x\n",
650                         rdata, (rdata >> 31) ? " FRT" : "",
651                         rdata & 0x3fff);
652         size -= temp;
653         next += temp;
654
655         rdata = readl (&regs->periodicstart);
656         temp = scnprintf (next, size, "periodicstart 0x%04x\n",
657                         rdata & 0x3fff);
658         size -= temp;
659         next += temp;
660
661         rdata = readl (&regs->lsthresh);
662         temp = scnprintf (next, size, "lsthresh 0x%04x\n",
663                         rdata & 0x3fff);
664         size -= temp;
665         next += temp;
666
667         /* roothub */
668         ohci_dump_roothub (ohci, 1, &next, &size);
669
670 done:
671         spin_unlock_irqrestore (&ohci->lock, flags);
672         return PAGE_SIZE - size;
673 }
674 static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
675
676
677 static inline void create_debug_files (struct ohci_hcd *bus)
678 {
679         class_device_create_file(&bus->hcd.self.class_dev, &class_device_attr_async);
680         class_device_create_file(&bus->hcd.self.class_dev, &class_device_attr_periodic);
681         class_device_create_file(&bus->hcd.self.class_dev, &class_device_attr_registers);
682         ohci_dbg (bus, "created debug files\n");
683 }
684
685 static inline void remove_debug_files (struct ohci_hcd *bus)
686 {
687         class_device_remove_file(&bus->hcd.self.class_dev, &class_device_attr_async);
688         class_device_remove_file(&bus->hcd.self.class_dev, &class_device_attr_periodic);
689         class_device_remove_file(&bus->hcd.self.class_dev, &class_device_attr_registers);
690 }
691
692 #endif
693
694 /*-------------------------------------------------------------------------*/
695