2 * UHCI-specific debugging code. Invaluable when something
3 * goes wrong, but don't get in my face.
5 * (C) Copyright 1999 Linus Torvalds
8 #include <linux/kernel.h>
13 void show_td(struct uhci_td
* td
)
17 printk("%08x ", td
->link
);
18 printk("%se%d %s%s%s%s%s%s%s%s%s%sLength=%x ",
19 ((td
->status
>> 29) & 1) ? "SPD " : "",
20 ((td
->status
>> 27) & 3),
21 ((td
->status
>> 26) & 1) ? "LS " : "",
22 ((td
->status
>> 25) & 1) ? "IOS " : "",
23 ((td
->status
>> 24) & 1) ? "IOC " : "",
24 ((td
->status
>> 23) & 1) ? "Active " : "",
25 ((td
->status
>> 22) & 1) ? "Stalled " : "",
26 ((td
->status
>> 21) & 1) ? "DataBufErr " : "",
27 ((td
->status
>> 20) & 1) ? "Babble " : "",
28 ((td
->status
>> 19) & 1) ? "NAK " : "",
29 ((td
->status
>> 18) & 1) ? "CRC/Timeo " : "",
30 ((td
->status
>> 17) & 1) ? "BitStuff " : "",
32 switch (td
->info
& 0xff) {
46 printk("MaxLen=%x %sEndPt=%x Dev=%x, PID=%x(%s) ",
48 ((td
->info
>> 19) & 1) ? "DT " : "",
49 (td
->info
>> 15) & 15,
50 (td
->info
>> 8) & 127,
53 printk("(buf=%08x)\n", td
->buffer
);
56 static void show_sc(int port
, unsigned short status
)
58 printk(" stat%d = %04x %s%s%s%s%s%s%s%s\n",
61 (status
& (1 << 12)) ? " PortSuspend" : "",
62 (status
& (1 << 9)) ? " PortReset" : "",
63 (status
& (1 << 8)) ? " LowSpeed" : "",
64 (status
& 0x40) ? " ResumeDetect" : "",
65 (status
& 0x08) ? " EnableChange" : "",
66 (status
& 0x04) ? " PortEnabled" : "",
67 (status
& 0x02) ? " ConnectChange" : "",
68 (status
& 0x01) ? " PortConnected" : "");
71 void show_status(struct uhci
*uhci
)
73 unsigned int io_addr
= uhci
->io_addr
;
74 unsigned short usbcmd
, usbstat
, usbint
, usbfrnum
;
75 unsigned int flbaseadd
;
77 unsigned short portsc1
, portsc2
;
79 usbcmd
= inw(io_addr
+ 0);
80 usbstat
= inw(io_addr
+ 2);
81 usbint
= inw(io_addr
+ 4);
82 usbfrnum
= inw(io_addr
+ 6);
83 flbaseadd
= inl(io_addr
+ 8);
84 sof
= inb(io_addr
+ 12);
85 portsc1
= inw(io_addr
+ 16);
86 portsc2
= inw(io_addr
+ 18);
88 printk(" usbcmd = %04x %s%s%s%s%s%s%s%s\n",
90 (usbcmd
& 0x80) ? " Maxp64" : " Maxp32",
91 (usbcmd
& 0x40) ? " CF" : "",
92 (usbcmd
& 0x20) ? " SWDBG" : "",
93 (usbcmd
& 0x10) ? " FGR" : "",
94 (usbcmd
& 0x08) ? " EGSM" : "",
95 (usbcmd
& 0x04) ? " GRESET" : "",
96 (usbcmd
& 0x02) ? " HCRESET" : "",
97 (usbcmd
& 0x01) ? " RS" : "");
99 printk(" usbstat = %04x %s%s%s%s%s%s\n",
101 (usbstat
& 0x20) ? " HCHalted" : "",
102 (usbstat
& 0x10) ? " HostControllerProcessError" : "",
103 (usbstat
& 0x08) ? " HostSystemError" : "",
104 (usbstat
& 0x04) ? " ResumeDetect" : "",
105 (usbstat
& 0x02) ? " USBError" : "",
106 (usbstat
& 0x01) ? " USBINT" : "");
108 printk(" usbint = %04x\n", usbint
);
109 printk(" usbfrnum = (%d)%03x\n", (usbfrnum
>> 10) & 1, 0xfff & (4*(unsigned int)usbfrnum
));
110 printk(" flbaseadd = %08x\n", flbaseadd
);
111 printk(" sof = %02x\n", sof
);
116 #define uhci_link_to_qh(x) ((struct uhci_qh *) uhci_link_to_td(x))
118 struct uhci_td
* uhci_link_to_td(unsigned int link
)
123 return bus_to_virt(link
& ~15);
126 void show_queue(struct uhci_qh
*qh
)
132 printk(" link = %p, element = %p\n", qh
->link
, qh
->element
);
135 printk(" td 0 = NULL\n");
139 for(td
= uhci_link_to_td(qh
->element
); td
;
140 td
= uhci_link_to_td(td
->link
)) {
141 printk(" td %d = %p\n", i
++, td
);
147 int is_skeleton_qh(struct uhci
*uhci
, struct uhci_qh
*qh
)
150 struct uhci_device
* root_hub
=usb_to_uhci(uhci
->bus
->root_hub
);
151 for (j
= 0; j
< UHCI_MAXQH
; j
++)
152 if (qh
== root_hub
->qh
+ j
)
158 static const char *qh_names
[] = {"isochronous", "interrupt2", "interrupt4",
159 "interrupt8", "interrupt16", "interrupt32",
160 "interrupt64", "interrupt128", "interrupt256",
161 "control", "bulk0", "bulk1", "bulk2", "bulk3",
164 void show_queues(struct uhci
*uhci
)
168 struct uhci_device
* root_hub
=usb_to_uhci(uhci
->bus
->root_hub
);
170 for (i
= 0; i
< UHCI_MAXQH
; ++i
) {
171 printk(" %s:\n", qh_names
[i
]);
173 printk(" qh #%d, %p\n", i
, virt_to_bus(root_hub
->qh
+ i
));
174 show_queue(uhci
->root_hub
->qh
+ i
);
177 qh
= uhci_link_to_qh(root_hub
->qh
[i
].link
);
178 for (; qh
; qh
= uhci_link_to_qh(qh
->link
)) {
179 if (is_skeleton_qh(uhci
, qh
))