14 #define edstring(ed_type) ({ char *temp; \
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; \
21 #define pipestring(pipe) edstring(usb_pipetype(pipe))
29 unsigned int pipe= urb->pipe;
31 if (!urb->dev || !urb->dev->bus) {
36 #ifndef OHCI_VERBOSE_DEBUG
42 usb_pipedevice (pipe),
43 usb_pipeendpoint (pipe),
44 usb_pipeout (pipe)?
"out" :
"in",
48 urb->transfer_buffer_length,
51 #ifdef OHCI_VERBOSE_DEBUG
55 if (usb_pipecontrol (pipe)) {
57 for (i = 0; i < 8 ; i++)
58 printk (
" %02x", ((
__u8 *) urb->setup_packet) [i]);
61 if (urb->transfer_buffer_length > 0 && urb->transfer_buffer) {
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?
"...":
"", status);
75 #define ohci_dbg_sw(ohci, next, size, format, arg...) \
79 s_len = scnprintf (*next, *size, format, ## arg ); \
80 *size -= s_len; *next += s_len; \
82 ohci_dbg(ohci,format, ## arg ); \
86 #define ohci_dbg_nosw(ohci, next, size, format, arg...) \
89 s_len = scnprintf(*next, *size, format, ## arg); \
90 *size -= s_len; *next += s_len; \
94 static void ohci_dump_intr_mask (
101 ohci_dbg_sw (ohci, next, size,
"%s 0x%08x%s%s%s%s%s%s%s%s%s\n",
116 static void maybe_print_eds (
124 ohci_dbg_sw (ohci, next, size,
"%s %08x\n", label, value);
127 static char *hcfs2string (
int state)
138 static const char *rh_state_string(
struct ohci_hcd *ohci)
159 ohci_dbg_sw (controller, next, size,
160 "OHCI %d.%d, %s legacy support registers, rh state %s\n",
161 0x03 & (temp >> 4), (temp & 0x0f),
162 (temp & 0x0100) ?
"with" :
"NO",
163 rh_state_string(controller));
166 ohci_dbg_sw (controller, next, size,
167 "control 0x%03x%s%s%s HCFS=%s%s%s%s%s CBSR=%d\n",
181 ohci_dbg_sw (controller, next, size,
182 "cmdstatus 0x%05x SOC=%d%s%s%s%s\n", temp,
190 ohci_dump_intr_mask (controller,
"intrstatus",
193 ohci_dump_intr_mask (controller,
"intrenable",
198 maybe_print_eds (controller,
"ed_periodcurrent",
202 maybe_print_eds (controller,
"ed_controlhead",
205 maybe_print_eds (controller,
"ed_controlcurrent",
209 maybe_print_eds (controller,
"ed_bulkhead",
212 maybe_print_eds (controller,
"ed_bulkcurrent",
216 maybe_print_eds (controller,
"donehead",
220 #define dbg_port_sw(hc,num,value,next,size) \
221 ohci_dbg_sw (hc, next, size, \
222 "roothub.portstatus [%d] " \
223 "0x%08x%s%s%s%s%s%s%s%s%s%s%s%s\n", \
225 (temp & RH_PS_PRSC) ? " PRSC" : "", \
226 (temp & RH_PS_OCIC) ? " OCIC" : "", \
227 (temp & RH_PS_PSSC) ? " PSSC" : "", \
228 (temp & RH_PS_PESC) ? " PESC" : "", \
229 (temp & RH_PS_CSC) ? " CSC" : "", \
231 (temp & RH_PS_LSDA) ? " LSDA" : "", \
232 (temp & RH_PS_PPS) ? " PPS" : "", \
233 (temp & RH_PS_PRS) ? " PRS" : "", \
234 (temp & RH_PS_POCI) ? " POCI" : "", \
235 (temp & RH_PS_PSS) ? " PSS" : "", \
237 (temp & RH_PS_PES) ? " PES" : "", \
238 (temp & RH_PS_CCS) ? " CCS" : "" \
251 temp = roothub_a (controller);
256 ohci_dbg_sw (controller, next, size,
257 "roothub.a %08x POTPGT=%d%s%s%s%s%s NDP=%d(%d)\n", temp,
266 temp = roothub_b (controller);
267 ohci_dbg_sw (controller, next, size,
268 "roothub.b %08x PPCM=%04x DR=%04x\n",
273 temp = roothub_status (controller);
274 ohci_dbg_sw (controller, next, size,
275 "roothub.status %08x%s%s%s%s%s%s\n",
286 for (i = 0; i < controller->
num_ports; i++) {
287 temp = roothub_portstatus (controller, i);
288 dbg_port_sw (controller, i, temp, next, size);
292 static void ohci_dump (
struct ohci_hcd *controller,
int verbose)
294 ohci_dbg (controller,
"OHCI controller state\n");
297 ohci_dump_status (controller,
NULL,
NULL);
298 if (controller->
hcca)
300 "hcca frame #%04x\n", ohci_frame_no(controller));
301 ohci_dump_roothub (controller, 1,
NULL,
NULL);
304 static const char data0 [] =
"DATA0";
305 static const char data1 [] =
"DATA1";
307 static void ohci_dump_td (
const struct ohci_hcd *ohci,
const char *label,
312 ohci_dbg (ohci,
"%s td %p%s; urb %p index %d; hw next td %08x\n",
314 (tmp &
TD_DONE) ?
" (DONE)" :
"",
316 hc32_to_cpup (ohci, &td->
hwNextTD));
317 if ((tmp &
TD_ISO) == 0) {
321 switch (tmp &
TD_T) {
325 default: toggle =
"(?)";
break;
327 switch (tmp &
TD_DP) {
331 default: pid =
"(bad pid)";
break;
333 ohci_dbg (ohci,
" info %08x CC=%x %s DI=%d %s %s\n", tmp,
335 (tmp &
TD_DI) >> 21, pid,
336 (tmp &
TD_R) ?
"R" :
"");
337 cbp = hc32_to_cpup (ohci, &td->
hwCBP);
338 be = hc32_to_cpup (ohci, &td->
hwBE);
339 ohci_dbg (ohci,
" cbp %08x be %08x (len %d)\n", cbp, be,
340 cbp ? (be + 1 - cbp) : 0);
343 ohci_dbg (ohci,
" info %08x CC=%x FC=%d DI=%d SF=%04x\n", tmp,
348 ohci_dbg (ohci,
" bp0 %08x be %08x\n",
349 hc32_to_cpup (ohci, &td->
hwCBP) & ~0x0fff,
350 hc32_to_cpup (ohci, &td->
hwBE));
351 for (i = 0; i <
MAXPSW; i++) {
352 u16 psw = ohci_hwPSW (ohci, td, i);
353 int cc = (psw >> 12) & 0x0f;
354 ohci_dbg (ohci,
" psw [%d] = %2x, CC=%x %s=%d\n", i,
356 (cc >= 0x0e) ?
"OFFSET" :
"SIZE",
364 ohci_dump_ed (
const struct ohci_hcd *ohci,
const char *label,
365 const struct ed *
ed,
int verbose)
370 ohci_dbg (ohci,
"%s, ed %p state 0x%x type %s; next ed %08x\n",
373 hc32_to_cpup (ohci, &ed->
hwNextED));
375 case ED_OUT: type =
"-OUT";
break;
376 case ED_IN: type =
"-IN";
break;
380 " info %08x MAX=%d%s%s%s%s EP=%d%s DEV=%d\n", tmp,
381 0x03ff & (tmp >> 16),
383 (tmp &
ED_ISO) ?
" ISO" :
"",
384 (tmp &
ED_SKIP) ?
" SKIP" :
"",
389 tmp = hc32_to_cpup (ohci, &ed->
hwHeadP);
390 ohci_dbg (ohci,
" tds: head %08x %s%s tail %08x%s\n",
392 (tmp &
ED_C) ? data1 : data0,
393 (tmp &
ED_H) ?
" HALT" :
"",
394 hc32_to_cpup (ohci, &ed->
hwTailP),
395 verbose ?
"" :
" (not listing)");
405 ohci_dump_td (ohci,
" ->", td);
411 static inline void ohci_dump (
struct ohci_hcd *controller,
int verbose) {}
413 #undef OHCI_VERBOSE_DEBUG
419 #ifdef STUB_DEBUG_FILES
426 static int debug_async_open(
struct inode *,
struct file *);
427 static int debug_periodic_open(
struct inode *,
struct file *);
428 static int debug_registers_open(
struct inode *,
struct file *);
429 static int debug_async_open(
struct inode *,
struct file *);
431 static int debug_close(
struct inode *,
struct file *);
435 .open = debug_async_open,
437 .release = debug_close,
442 .open = debug_periodic_open,
444 .release = debug_close,
449 .open = debug_registers_open,
451 .release = debug_close,
455 static struct dentry *ohci_debug_root;
485 "ed/%p %cs dev%d ep%d%s max %d %08x%s%s %s",
487 (info & ED_LOWSPEED) ?
'l' :
'f',
490 (info &
ED_IN) ?
"in" :
"out",
491 0x03ff & (info >> 16),
493 (info & ED_SKIP) ?
" s" :
"",
494 (headp & ED_H) ?
" H" :
"",
495 (headp & ED_C) ? data1 : data0);
503 info = hc32_to_cpup (ohci, &td->
hwINFO);
504 cbp = hc32_to_cpup (ohci, &td->
hwCBP);
505 be = hc32_to_cpup (ohci, &td->
hwBE);
507 "\n\ttd %p %s %d cc=%x urb %p (%08x)",
510 switch (info & TD_DP) {
514 default: pid =
"(?)";
break;
516 cbp ? (be + 1 - cbp) : 0,
542 temp += show_list(ohci, buf->
page + temp, buf->
count - temp,
544 spin_unlock_irqrestore (&ohci->
lock, flags);
549 #define DBG_SCHED_LIMIT 64
554 struct ed **seen, *
ed;
578 temp =
scnprintf (next, size,
"%2d [%3d]:", i, ohci->
load [i]);
583 temp =
scnprintf (next, size,
" ed%d/%p",
587 for (temp = 0; temp < seen_count; temp++) {
588 if (seen [temp] == ed)
593 if (temp == seen_count) {
603 " (%cs dev%d ep%d%s-%s qlen %u"
605 (info & ED_LOWSPEED) ?
'l' :
'f',
608 (info &
ED_IN) ?
"in" :
"out",
609 (info & ED_ISO) ?
"iso" :
"int",
611 0x03ff & (info >> 16),
613 (info & ED_SKIP) ?
" K" :
"",
621 seen [seen_count++] =
ed;
637 spin_unlock_irqrestore (&ohci->
lock, flags);
642 #undef DBG_SCHED_LIMIT
655 hcd = ohci_to_hcd(ohci);
664 ohci_dbg_nosw(ohci, &next, &size,
665 "bus %s, device %s\n"
668 hcd->self.controller->bus->name,
669 dev_name(hcd->self.controller),
673 if (!HCD_HW_ACCESSIBLE(hcd)) {
675 "SUSPENDED (no register access)\n");
679 ohci_dump_status(ohci, &next, &size);
683 ohci_dbg_nosw(ohci, &next, &size,
684 "hcca frame 0x%04x\n", ohci_frame_no(ohci));
689 "fmintvl 0x%08x %sFSMPS=0x%04x FI=0x%04x\n",
690 rdata, (rdata >> 31) ?
"FIT " :
"",
691 (rdata >> 16) & 0xefff, rdata & 0xffff);
696 temp =
scnprintf (next, size,
"fmremaining 0x%08x %sFR=0x%04x\n",
697 rdata, (rdata >> 31) ?
"FRT " :
"",
703 temp =
scnprintf (next, size,
"periodicstart 0x%04x\n",
709 temp =
scnprintf (next, size,
"lsthresh 0x%04x\n",
714 temp =
scnprintf (next, size,
"hub poll timer %s\n",
715 HCD_POLL_RH(ohci_to_hcd(ohci)) ?
"ON" :
"off");
720 ohci_dump_roothub (ohci, 1, &next, &size);
723 spin_unlock_irqrestore (&ohci->
lock, flags);
768 size_t len, loff_t *
offset)
774 if (buf->
count == 0) {
775 ret = fill_buffer(buf);
791 static int debug_close(
struct inode *
inode,
struct file *file)
803 static int debug_async_open(
struct inode *inode,
struct file *file)
810 static int debug_periodic_open(
struct inode *inode,
struct file *file)
813 fill_periodic_buffer);
818 static int debug_registers_open(
struct inode *inode,
struct file *file)
821 fill_registers_buffer);
827 struct usb_bus *
bus = &ohci_to_hcd(ohci)->self;
830 if (!ohci->debug_dir)
834 ohci->debug_dir, ohci,
836 if (!ohci->debug_async)
840 ohci->debug_dir, ohci,
841 &debug_periodic_fops);
842 if (!ohci->debug_periodic)
846 ohci->debug_dir, ohci,
847 &debug_registers_fops);
848 if (!ohci->debug_registers)
849 goto registers_error;
851 ohci_dbg (ohci,
"created debug files\n");
861 ohci->debug_periodic =
NULL;
862 ohci->debug_async =
NULL;
863 ohci->debug_dir =
NULL;