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