fix USB driver to compile with ADMH_VERBOSE_DEBUG defined
[lede.git] / target / linux / adm5120 / files / drivers / usb / host / adm5120-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 static inline char *ed_typestring(int ed_type)
13 {
14         switch (ed_type) {
15         case PIPE_CONTROL:
16                 return "ctrl";
17         case PIPE_BULK:
18                 return "bulk";
19         case PIPE_INTERRUPT:
20                 return "intr";
21         case PIPE_ISOCHRONOUS:
22                 return "isoc";
23         }
24         return "(bad ed_type)";
25 }
26
27 static inline char *ed_statestring(int state)
28 {
29         switch (state) {
30         case ED_IDLE:
31                 return "IDLE";
32         case ED_UNLINK:
33                 return "UNLINK";
34         case ED_OPER:
35                 return "OPER";
36         }
37         return "?STATE";
38 }
39
40 static inline char *pipestring(int pipe)
41 {
42         return ed_typestring(usb_pipetype(pipe));
43 }
44
45 static inline char *td_pidstring(u32 info)
46 {
47         switch (info & TD_DP) {
48         case TD_DP_SETUP:
49                 return "SETUP";
50         case TD_DP_IN:
51                 return "IN";
52         case TD_DP_OUT:
53                 return "OUT";
54         }
55         return "?PID";
56 }
57
58 static inline char *td_togglestring(u32 info)
59 {
60         switch (info & TD_T) {
61         case TD_T_DATA0:
62                 return "DATA0";
63         case TD_T_DATA1:
64                 return "DATA1";
65         case TD_T_CARRY:
66                 return "CARRY";
67         }
68         return "?TOGGLE";
69 }
70
71 /*-------------------------------------------------------------------------*/
72
73 #ifdef DEBUG
74
75 /* debug| print the main components of an URB
76  * small: 0) header + data packets 1) just header
77  */
78 static void __attribute__((unused))
79 urb_print(struct admhcd *ahcd, struct urb *urb, char *str, int small)
80 {
81         unsigned int pipe = urb->pipe;
82
83         if (!urb->dev || !urb->dev->bus) {
84                 admhc_dbg(ahcd, "%s URB: no dev", str);
85                 return;
86         }
87
88 #ifndef ADMHC_VERBOSE_DEBUG
89         if (urb->status != 0)
90 #endif
91         admhc_dbg(ahcd, "URB-%s %p dev=%d ep=%d%s-%s flags=%x len=%d/%d "
92                         "stat=%d\n",
93                         str,
94                         urb,
95                         usb_pipedevice (pipe),
96                         usb_pipeendpoint (pipe),
97                         usb_pipeout(pipe)? "out" : "in",
98                         pipestring(pipe),
99                         urb->transfer_flags,
100                         urb->actual_length,
101                         urb->transfer_buffer_length,
102                         urb->status);
103
104 #ifdef  ADMHC_VERBOSE_DEBUG
105         if (!small) {
106                 int i, len;
107
108                 if (usb_pipecontrol(pipe)) {
109                         admhc_dbg(ahcd, "setup(8):");
110                         for (i = 0; i < 8 ; i++)
111                                 printk (" %02x", ((__u8 *) urb->setup_packet) [i]);
112                         printk ("\n");
113                 }
114                 if (urb->transfer_buffer_length > 0 && urb->transfer_buffer) {
115                         admhc_dbg(ahcd, "data(%d/%d):",
116                                 urb->actual_length,
117                                 urb->transfer_buffer_length);
118                         len = usb_pipeout(pipe)?
119                                                 urb->transfer_buffer_length: urb->actual_length;
120                         for (i = 0; i < 16 && i < len; i++)
121                                 printk(" %02x", ((__u8 *)urb->transfer_buffer)[i]);
122                         printk("%s stat:%d\n", i < len? "...": "", urb->status);
123                 }
124         }
125 #endif /* ADMHC_VERBOSE_DEBUG */
126 }
127
128 #define admhc_dbg_sw(ahcd, next, size, format, arg...) \
129         do { \
130         if (next) { \
131                 unsigned s_len; \
132                 s_len = scnprintf(*next, *size, format, ## arg ); \
133                 *size -= s_len; *next += s_len; \
134         } else \
135                 admhc_dbg(ahcd,format, ## arg ); \
136         } while (0);
137
138
139 static void admhc_dump_intr_mask(struct admhcd *ahcd, char *label, u32 mask,
140                 char **next, unsigned *size)
141 {
142         admhc_dbg_sw(ahcd, next, size, "%s 0x%08x%s%s%s%s%s%s%s%s%s%s%s%s\n",
143                 label,
144                 mask,
145                 (mask & ADMHC_INTR_INTA) ? " INTA" : "",
146                 (mask & ADMHC_INTR_FATI) ? " FATI" : "",
147                 (mask & ADMHC_INTR_SWI) ? " SWI" : "",
148                 (mask & ADMHC_INTR_TDC) ? " TDC" : "",
149                 (mask & ADMHC_INTR_FNO) ? " FNO" : "",
150                 (mask & ADMHC_INTR_SO) ? " SO" : "",
151                 (mask & ADMHC_INTR_INSM) ? " INSM" : "",
152                 (mask & ADMHC_INTR_BABI) ? " BABI" : "",
153                 (mask & ADMHC_INTR_7) ? " !7!" : "",
154                 (mask & ADMHC_INTR_6) ? " !6!" : "",
155                 (mask & ADMHC_INTR_RESI) ? " RESI" : "",
156                 (mask & ADMHC_INTR_SOFI) ? " SOFI" : ""
157                 );
158 }
159
160 static void maybe_print_eds(struct admhcd *ahcd, char *label, u32 value,
161                 char **next, unsigned *size)
162 {
163         if (value)
164                 admhc_dbg_sw(ahcd, next, size, "%s %08x\n", label, value);
165 }
166
167 static char *buss2string (int state)
168 {
169         switch (state) {
170         case ADMHC_BUSS_RESET:
171                 return "reset";
172         case ADMHC_BUSS_RESUME:
173                 return "resume";
174         case ADMHC_BUSS_OPER:
175                 return "operational";
176         case ADMHC_BUSS_SUSPEND:
177                 return "suspend";
178         }
179         return "?state";
180 }
181
182 static void
183 admhc_dump_status(struct admhcd *ahcd, char **next, unsigned *size)
184 {
185         struct admhcd_regs __iomem *regs = ahcd->regs;
186         u32                     temp;
187
188         temp = admhc_readl(ahcd, &regs->gencontrol);
189         admhc_dbg_sw(ahcd, next, size,
190                 "gencontrol 0x%08x%s%s%s%s\n",
191                 temp,
192                 (temp & ADMHC_CTRL_UHFE) ? " UHFE" : "",
193                 (temp & ADMHC_CTRL_SIR) ? " SIR" : "",
194                 (temp & ADMHC_CTRL_DMAA) ? " DMAA" : "",
195                 (temp & ADMHC_CTRL_SR) ? " SR" : ""
196                 );
197
198         temp = admhc_readl(ahcd, &regs->host_control);
199         admhc_dbg_sw(ahcd, next, size,
200                 "host_control 0x%08x BUSS=%s%s\n",
201                 temp,
202                 buss2string(temp & ADMHC_HC_BUSS),
203                 (temp & ADMHC_HC_DMAE) ? " DMAE" : ""
204                 );
205
206         admhc_dump_intr_mask(ahcd, "int_status",
207                         admhc_readl(ahcd, &regs->int_status),
208                         next, size);
209         admhc_dump_intr_mask(ahcd, "int_enable",
210                         admhc_readl(ahcd, &regs->int_enable),
211                         next, size);
212
213         maybe_print_eds(ahcd, "hosthead",
214                         admhc_readl(ahcd, &regs->hosthead), next, size);
215 }
216
217 #define dbg_port_sw(hc,num,value,next,size) \
218         admhc_dbg_sw(hc, next, size, \
219                 "portstatus [%d] " \
220                 "0x%08x%s%s%s%s%s%s%s%s%s%s%s%s\n", \
221                 num, temp, \
222                 (temp & ADMHC_PS_PRSC) ? " PRSC" : "", \
223                 (temp & ADMHC_PS_OCIC) ? " OCIC" : "", \
224                 (temp & ADMHC_PS_PSSC) ? " PSSC" : "", \
225                 (temp & ADMHC_PS_PESC) ? " PESC" : "", \
226                 (temp & ADMHC_PS_CSC) ? " CSC" : "", \
227                 \
228                 (temp & ADMHC_PS_LSDA) ? " LSDA" : "", \
229                 (temp & ADMHC_PS_PPS) ? " PPS" : "", \
230                 (temp & ADMHC_PS_PRS) ? " PRS" : "", \
231                 (temp & ADMHC_PS_POCI) ? " POCI" : "", \
232                 (temp & ADMHC_PS_PSS) ? " PSS" : "", \
233                 \
234                 (temp & ADMHC_PS_PES) ? " PES" : "", \
235                 (temp & ADMHC_PS_CCS) ? " CCS" : "" \
236                 );
237
238
239 static void
240 admhc_dump_roothub(
241         struct admhcd *ahcd,
242         int verbose,
243         char **next,
244         unsigned *size)
245 {
246         u32                     temp, i;
247
248         temp = admhc_read_rhdesc(ahcd);
249         if (temp == ~(u32)0)
250                 return;
251
252         if (verbose) {
253                 admhc_dbg_sw(ahcd, next, size,
254                         "rhdesc %08x%s%s%s%s%s%s PPCM=%02x%s%s%s%s NUMP=%d(%d)\n",
255                         temp,
256                         (temp & ADMHC_RH_CRWE) ? " CRWE" : "",
257                         (temp & ADMHC_RH_OCIC) ? " OCIC" : "",
258                         (temp & ADMHC_RH_LPSC) ? " LPSC" : "",
259                         (temp & ADMHC_RH_LPSC) ? " DRWE" : "",
260                         (temp & ADMHC_RH_LPSC) ? " OCI" : "",
261                         (temp & ADMHC_RH_LPSC) ? " LPS" : "",
262                         ((temp & ADMHC_RH_PPCM) >> 16),
263                         (temp & ADMHC_RH_NOCP) ? " NOCP" : "",
264                         (temp & ADMHC_RH_OCPM) ? " OCPM" : "",
265                         (temp & ADMHC_RH_NPS) ? " NPS" : "",
266                         (temp & ADMHC_RH_PSM) ? " PSM" : "",
267                         (temp & ADMHC_RH_NUMP), ahcd->num_ports
268                         );
269         }
270
271         for (i = 0; i < ahcd->num_ports; i++) {
272                 temp = admhc_read_portstatus(ahcd, i);
273                 dbg_port_sw(ahcd, i, temp, next, size);
274         }
275 }
276
277 static void admhc_dump(struct admhcd *ahcd, int verbose)
278 {
279         admhc_dbg(ahcd, "ADMHC ahcd state\n");
280
281         /* dumps some of the state we know about */
282         admhc_dump_status(ahcd, NULL, NULL);
283         admhc_dbg(ahcd,"current frame #%04x\n",
284                 admhc_frame_no(ahcd));
285
286         admhc_dump_roothub(ahcd, verbose, NULL, NULL);
287 }
288
289 static const char data0[] = "DATA0";
290 static const char data1[] = "DATA1";
291
292 static void admhc_dump_td(const struct admhcd *ahcd, const char *label,
293                 const struct td *td)
294 {
295         u32     tmp;
296
297         admhc_dbg(ahcd, "%s td %p; urb %p index %d; hwNextTD %08x\n",
298                 label, td,
299                 td->urb, td->index,
300                 hc32_to_cpup(ahcd, &td->hwNextTD));
301
302         tmp = hc32_to_cpup(ahcd, &td->hwINFO);
303         admhc_dbg(ahcd, "     status %08x%s CC=%x EC=%d %s %s ISI=%x FN=%x\n",
304                 tmp,
305                 (tmp & TD_OWN) ? " OWN" : "",
306                 TD_CC_GET(tmp),
307                 TD_EC_GET(tmp),
308                 td_togglestring(tmp),
309                 td_pidstring(tmp),
310                 TD_ISI_GET(tmp),
311                 TD_FN_GET(tmp));
312
313         tmp = hc32_to_cpup(ahcd, &td->hwCBL);
314         admhc_dbg(ahcd, "     dbp %08x; cbl %08x; LEN=%d%s\n",
315                 hc32_to_cpup(ahcd, &td->hwDBP),
316                 tmp,
317                 TD_BL_GET(tmp),
318                 (tmp & TD_IE) ? " IE" : "");
319 }
320
321 /* caller MUST own hcd spinlock if verbose is set! */
322 static void __attribute__((unused))
323 admhc_dump_ed(const struct admhcd *ahcd, const char *label,
324                 const struct ed *ed, int verbose)
325 {
326         u32 tmp = hc32_to_cpu(ahcd, ed->hwINFO);
327
328         admhc_dbg(ahcd, "%s ed %p %s type %s; next ed %08x\n",
329                 label,
330                 ed, ed_statestring(ed->state), ed_typestring(ed->type),
331                 hc32_to_cpup(ahcd, &ed->hwNextED));
332
333         admhc_dbg(ahcd, "  info %08x MAX=%d%s%s%s%s EP=%d DEV=%d\n", tmp,
334                 ED_MPS_GET(tmp),
335                 (tmp & ED_ISO) ? " ISO" : "",
336                 (tmp & ED_SKIP) ? " SKIP" : "",
337                 (tmp & ED_SPEED_FULL) ? " FULL" : " LOW",
338                 (tmp & ED_INT) ? " INT" : "",
339                 ED_EN_GET(tmp),
340                 ED_FA_GET(tmp));
341
342         tmp = hc32_to_cpup(ahcd, &ed->hwHeadP);
343         admhc_dbg(ahcd, "  tds: head %08x tail %08x %s%s%s\n",
344                 tmp & TD_MASK,
345                 hc32_to_cpup (ahcd, &ed->hwTailP),
346                 (tmp & ED_C) ? data1 : data0,
347                 (tmp & ED_H) ? " HALT" : "",
348                 verbose ? " td list follows" : " (not listing)");
349
350         if (verbose) {
351                 struct list_head        *tmp;
352
353                 /* use ed->td_list because HC concurrently modifies
354                  * hwNextTD as it accumulates ed_donelist.
355                  */
356                 list_for_each(tmp, &ed->td_list) {
357                         struct td               *td;
358                         td = list_entry(tmp, struct td, td_list);
359                         admhc_dump_td (ahcd, "  ->", td);
360                 }
361         }
362 }
363
364 #else /* ifdef DEBUG */
365
366 static inline void urb_print(struct admhcd *ahcd, struct urb * urb, char * str,
367         int small) {}
368 static inline void admhc_dump_ed(const struct admhcd *ahcd, const char *label,
369         const struct ed *ed, int verbose) {}
370 static inline void admhc_dump_td(const struct admhcd *ahcd, const char *label,
371         const struct td *td) {}
372 static inline void admhc_dump(struct admhcd *ahcd, int verbose) {}
373
374 #undef ADMHC_VERBOSE_DEBUG
375
376 #endif /* DEBUG */
377
378 /*-------------------------------------------------------------------------*/
379
380 #ifdef STUB_DEBUG_FILES
381
382 static inline void create_debug_files(struct admhcd *bus) { }
383 static inline void remove_debug_files(struct admhcd *bus) { }
384
385 #else
386
387 static ssize_t
388 show_list(struct admhcd *ahcd, char *buf, size_t count, struct ed *ed)
389 {
390         unsigned                temp, size = count;
391
392         if (!ed)
393                 return 0;
394
395         /* dump a snapshot of the bulk or control schedule */
396         while (ed) {
397                 u32 info = hc32_to_cpu(ahcd, ed->hwINFO);
398                 u32 headp = hc32_to_cpu(ahcd, ed->hwHeadP);
399                 u32 tailp = hc32_to_cpu(ahcd, ed->hwTailP);
400                 struct list_head *entry;
401                 struct td       *td;
402
403                 temp = scnprintf(buf, size,
404                         "ed/%p %s %s %cs dev%d ep%d %s%smax %d %08x%s%s %s"
405                         " h:%08x t:%08x",
406                         ed,
407                         ed_statestring(ed->state),
408                         ed_typestring (ed->type),
409                         (info & ED_SPEED_FULL) ? 'f' : 'l',
410                         info & ED_FA_MASK,
411                         (info >> ED_EN_SHIFT) & ED_EN_MASK,
412                         (info & ED_INT) ? "INT " : "",
413                         (info & ED_ISO) ? "ISO " : "",
414                         (info >> ED_MPS_SHIFT) & ED_MPS_MASK ,
415                         info,
416                         (info & ED_SKIP) ? " S" : "",
417                         (headp & ED_H) ? " H" : "",
418                         (headp & ED_C) ? data1 : data0,
419                         headp & ED_MASK,tailp);
420                 size -= temp;
421                 buf += temp;
422
423                 list_for_each(entry, &ed->td_list) {
424                         u32             dbp, cbl;
425
426                         td = list_entry(entry, struct td, td_list);
427                         info = hc32_to_cpup (ahcd, &td->hwINFO);
428                         dbp = hc32_to_cpup (ahcd, &td->hwDBP);
429                         cbl = hc32_to_cpup (ahcd, &td->hwCBL);
430
431                         temp = scnprintf(buf, size,
432                                 "\n\ttd/%p %s %d %s%scc=%x urb %p (%08x,%08x)",
433                                 td,
434                                 td_pidstring(info),
435                                 TD_BL_GET(cbl),
436                                 (info & TD_OWN) ? "" : "DONE ",
437                                 (cbl & TD_IE) ? "IE " : "",
438                                 TD_CC_GET (info), td->urb, info, cbl);
439                         size -= temp;
440                         buf += temp;
441                 }
442
443                 temp = scnprintf(buf, size, "\n");
444                 size -= temp;
445                 buf += temp;
446
447                 ed = ed->ed_next;
448         }
449         return count - size;
450 }
451
452 static ssize_t
453 show_async(struct class_device *class_dev, char *buf)
454 {
455         struct usb_bus          *bus;
456         struct usb_hcd          *hcd;
457         struct admhcd           *ahcd;
458         size_t                  temp;
459         unsigned long           flags;
460
461         bus = class_get_devdata(class_dev);
462         hcd = bus_to_hcd(bus);
463         ahcd = hcd_to_admhcd(hcd);
464
465         /* display control and bulk lists together, for simplicity */
466         spin_lock_irqsave(&ahcd->lock, flags);
467         temp = show_list(ahcd, buf, PAGE_SIZE, ahcd->ed_head);
468         spin_unlock_irqrestore(&ahcd->lock, flags);
469
470         return temp;
471 }
472 static CLASS_DEVICE_ATTR(async, S_IRUGO, show_async, NULL);
473
474
475 #define DBG_SCHED_LIMIT 64
476
477 static ssize_t
478 show_periodic(struct class_device *class_dev, char *buf)
479 {
480         struct usb_bus          *bus;
481         struct usb_hcd          *hcd;
482         struct admhcd           *ahcd;
483         struct ed               **seen, *ed;
484         unsigned long           flags;
485         unsigned                temp, size, seen_count;
486         char                    *next;
487         unsigned                i;
488
489         if (!(seen = kmalloc(DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC)))
490                 return 0;
491         seen_count = 0;
492
493         bus = class_get_devdata(class_dev);
494         hcd = bus_to_hcd(bus);
495         ahcd = hcd_to_admhcd(hcd);
496         next = buf;
497         size = PAGE_SIZE;
498
499         temp = scnprintf(next, size, "size = %d\n", NUM_INTS);
500         size -= temp;
501         next += temp;
502
503         /* dump a snapshot of the periodic schedule (and load) */
504         spin_lock_irqsave(&ahcd->lock, flags);
505         for (i = 0; i < NUM_INTS; i++) {
506                 if (!(ed = ahcd->periodic [i]))
507                         continue;
508
509                 temp = scnprintf(next, size, "%2d [%3d]:", i, ahcd->load [i]);
510                 size -= temp;
511                 next += temp;
512
513                 do {
514                         temp = scnprintf(next, size, " ed%d/%p",
515                                 ed->interval, ed);
516                         size -= temp;
517                         next += temp;
518                         for (temp = 0; temp < seen_count; temp++) {
519                                 if (seen [temp] == ed)
520                                         break;
521                         }
522
523                         /* show more info the first time around */
524                         if (temp == seen_count) {
525                                 u32     info = hc32_to_cpu (ahcd, ed->hwINFO);
526                                 struct list_head        *entry;
527                                 unsigned                qlen = 0;
528
529                                 /* qlen measured here in TDs, not urbs */
530                                 list_for_each (entry, &ed->td_list)
531                                         qlen++;
532                                 temp = scnprintf(next, size,
533                                         " (%cs dev%d ep%d%s qlen %u"
534                                         " max %d %08x%s%s)",
535                                         (info & ED_SPEED_FULL) ? 'f' : 'l',
536                                         ED_FA_GET(info),
537                                         ED_EN_GET(info),
538                                         (info & ED_ISO) ? "iso" : "int",
539                                         qlen,
540                                         ED_MPS_GET(info),
541                                         info,
542                                         (info & ED_SKIP) ? " K" : "",
543                                         (ed->hwHeadP &
544                                                 cpu_to_hc32(ahcd, ED_H)) ?
545                                                         " H" : "");
546                                 size -= temp;
547                                 next += temp;
548
549                                 if (seen_count < DBG_SCHED_LIMIT)
550                                         seen [seen_count++] = ed;
551
552                                 ed = ed->ed_next;
553
554                         } else {
555                                 /* we've seen it and what's after */
556                                 temp = 0;
557                                 ed = NULL;
558                         }
559
560                 } while (ed);
561
562                 temp = scnprintf(next, size, "\n");
563                 size -= temp;
564                 next += temp;
565         }
566         spin_unlock_irqrestore(&ahcd->lock, flags);
567         kfree (seen);
568
569         return PAGE_SIZE - size;
570 }
571 static CLASS_DEVICE_ATTR(periodic, S_IRUGO, show_periodic, NULL);
572
573
574 #undef DBG_SCHED_LIMIT
575
576 static ssize_t
577 show_registers(struct class_device *class_dev, char *buf)
578 {
579         struct usb_bus          *bus;
580         struct usb_hcd          *hcd;
581         struct admhcd           *ahcd;
582         struct admhcd_regs __iomem *regs;
583         unsigned long           flags;
584         unsigned                temp, size;
585         char                    *next;
586         u32                     rdata;
587
588         bus = class_get_devdata(class_dev);
589         hcd = bus_to_hcd(bus);
590         ahcd = hcd_to_admhcd(hcd);
591         regs = ahcd->regs;
592         next = buf;
593         size = PAGE_SIZE;
594
595         spin_lock_irqsave(&ahcd->lock, flags);
596
597         /* dump driver info, then registers in spec order */
598
599         admhc_dbg_sw(ahcd, &next, &size,
600                 "bus %s, device %s\n"
601                 "%s\n"
602                 "%s version " DRIVER_VERSION "\n",
603                 hcd->self.controller->bus->name,
604                 hcd->self.controller->bus_id,
605                 hcd->product_desc,
606                 hcd_name);
607
608         if (bus->controller->power.power_state.event) {
609                 size -= scnprintf(next, size,
610                         "SUSPENDED (no register access)\n");
611                 goto done;
612         }
613
614         admhc_dump_status(ahcd, &next, &size);
615
616         /* other registers mostly affect frame timings */
617         rdata = admhc_readl(ahcd, &regs->fminterval);
618         temp = scnprintf(next, size,
619                         "fmintvl 0x%08x %sFSLDP=0x%04x FI=0x%04x\n",
620                         rdata, (rdata & ADMHC_SFI_FIT) ? "FIT " : "",
621                         (rdata >> ADMHC_SFI_FSLDP_SHIFT) & ADMHC_SFI_FSLDP_MASK,
622                         rdata  & ADMHC_SFI_FI_MASK);
623         size -= temp;
624         next += temp;
625
626         rdata = admhc_readl(ahcd, &regs->fmnumber);
627         temp = scnprintf(next, size, "fmnumber 0x%08x %sFR=0x%04x FN=%04x\n",
628                         rdata, (rdata & ADMHC_SFN_FRT) ? "FRT " : "",
629                         (rdata >> ADMHC_SFN_FR_SHIFT) & ADMHC_SFN_FR_MASK,
630                         rdata  & ADMHC_SFN_FN_MASK);
631         size -= temp;
632         next += temp;
633
634         /* TODO: use predefined bitmask */
635         rdata = admhc_readl(ahcd, &regs->lsthresh);
636         temp = scnprintf(next, size, "lsthresh 0x%04x\n",
637                         rdata & 0x3fff);
638         size -= temp;
639         next += temp;
640
641         temp = scnprintf(next, size, "hub poll timer: %s\n",
642                         admhcd_to_hcd(ahcd)->poll_rh ? "ON" : "OFF");
643         size -= temp;
644         next += temp;
645
646         /* roothub */
647         admhc_dump_roothub(ahcd, 1, &next, &size);
648
649 done:
650         spin_unlock_irqrestore(&ahcd->lock, flags);
651         return PAGE_SIZE - size;
652 }
653 static CLASS_DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL);
654
655
656 static inline void create_debug_files (struct admhcd *ahcd)
657 {
658         struct class_device *cldev = admhcd_to_hcd(ahcd)->self.class_dev;
659         int retval;
660
661         retval = class_device_create_file(cldev, &class_device_attr_async);
662         retval = class_device_create_file(cldev, &class_device_attr_periodic);
663         retval = class_device_create_file(cldev, &class_device_attr_registers);
664         admhc_dbg(ahcd, "created debug files\n");
665 }
666
667 static inline void remove_debug_files (struct admhcd *ahcd)
668 {
669         struct class_device *cldev = admhcd_to_hcd(ahcd)->self.class_dev;
670
671         class_device_remove_file(cldev, &class_device_attr_async);
672         class_device_remove_file(cldev, &class_device_attr_periodic);
673         class_device_remove_file(cldev, &class_device_attr_registers);
674 }
675
676 #endif
677
678 /*-------------------------------------------------------------------------*/
679