Import 2.3.9pre5
[davej-history.git] / drivers / usb / ohci-debug.c
blob56b9fff0afdc8b79244c55260ef2ab1b096a296e
1 /*
2 * OHCI debugging code. It's gross.
4 * (C) Copyright 1999 Gregory P. Smith
5 */
7 #include <linux/kernel.h>
8 #include <asm/io.h>
10 #include "ohci.h"
12 void show_ohci_status(struct ohci *ohci)
14 struct ohci_regs regs;
15 int i;
17 regs.revision = readl(&ohci->regs->revision);
18 regs.control = readl(&ohci->regs->control);
19 regs.cmdstatus = readl(&ohci->regs->cmdstatus);
20 regs.intrstatus = readl(&ohci->regs->intrstatus);
21 regs.intrenable = readl(&ohci->regs->intrenable);
22 regs.hcca = readl(&ohci->regs->hcca);
23 regs.ed_periodcurrent = readl(&ohci->regs->ed_periodcurrent);
24 regs.ed_controlhead = readl(&ohci->regs->ed_controlhead);
25 regs.ed_controlcurrent = readl(&ohci->regs->ed_controlcurrent);
26 regs.ed_bulkhead = readl(&ohci->regs->ed_bulkhead);
27 regs.ed_bulkcurrent = readl(&ohci->regs->ed_bulkcurrent);
28 regs.current_donehead = readl(&ohci->regs->current_donehead);
29 regs.fminterval = readl(&ohci->regs->fminterval);
30 regs.fmremaining = readl(&ohci->regs->fmremaining);
31 regs.fmnumber = readl(&ohci->regs->fmnumber);
32 regs.periodicstart = readl(&ohci->regs->periodicstart);
33 regs.lsthresh = readl(&ohci->regs->lsthresh);
34 regs.roothub.a = readl(&ohci->regs->roothub.a);
35 regs.roothub.b = readl(&ohci->regs->roothub.b);
36 regs.roothub.status = readl(&ohci->regs->roothub.status);
37 for (i=0; i<MAX_ROOT_PORTS; ++i)
38 regs.roothub.portstatus[i] = readl(&ohci->regs->roothub.portstatus[i]);
40 printk(KERN_DEBUG " ohci revision = %x\n", regs.revision);
41 printk(KERN_DEBUG " ohci control = %x\n", regs.control);
42 printk(KERN_DEBUG " ohci cmdstatus = %x\n", regs.cmdstatus);
43 printk(KERN_DEBUG " ohci intrstatus = %x\n", regs.intrstatus);
44 printk(KERN_DEBUG " ohci intrenable = %x\n", regs.intrenable);
46 printk(KERN_DEBUG " ohci hcca = %x\n", regs.hcca);
47 printk(KERN_DEBUG " ohci ed_pdcur = %x\n", regs.ed_periodcurrent);
48 printk(KERN_DEBUG " ohci ed_ctrlhead = %x\n", regs.ed_controlhead);
49 printk(KERN_DEBUG " ohci ed_ctrlcur = %x\n", regs.ed_controlcurrent);
50 printk(KERN_DEBUG " ohci ed_bulkhead = %x\n", regs.ed_bulkhead);
51 printk(KERN_DEBUG " ohci ed_bulkcur = %x\n", regs.ed_bulkcurrent);
52 printk(KERN_DEBUG " ohci curdonehead = %x\n", regs.current_donehead);
54 printk(KERN_DEBUG " ohci fminterval = %x\n", regs.fminterval);
55 printk(KERN_DEBUG " ohci fmremaining = %x\n", regs.fmremaining);
56 printk(KERN_DEBUG " ohci fmnumber = %x\n", regs.fmnumber);
57 printk(KERN_DEBUG " ohci pdstart = %x\n", regs.periodicstart);
58 printk(KERN_DEBUG " ohci lsthresh = %x\n", regs.lsthresh);
60 printk(KERN_DEBUG " ohci roothub.a = %x\n", regs.roothub.a);
61 printk(KERN_DEBUG " ohci roothub.b = %x\n", regs.roothub.b);
62 printk(KERN_DEBUG " ohci root status = %x\n", regs.roothub.status);
63 printk(KERN_DEBUG " roothub.port0 = %x\n", regs.roothub.portstatus[0]);
64 printk(KERN_DEBUG " roothub.port1 = %x\n", regs.roothub.portstatus[1]);
65 } /* show_ohci_status() */
68 void show_ohci_ed(struct ohci_ed *ed)
70 int stat = le32_to_cpup(&ed->status);
71 int skip = (stat & OHCI_ED_SKIP);
72 int mps = (stat & OHCI_ED_MPS) >> 16;
73 int isoc = (stat & OHCI_ED_F_ISOC);
74 int low_speed = (stat & OHCI_ED_S_LOW);
75 int dir = (stat & OHCI_ED_D);
76 int endnum = (stat & OHCI_ED_EN) >> 7;
77 int funcaddr = (stat & OHCI_ED_FA);
78 int halted = (le32_to_cpup(&ed->_head_td) & 1);
79 int toggle = (le32_to_cpup(&ed->_head_td) & 2) >> 1;
81 printk(KERN_DEBUG " ohci ED:\n");
82 printk(KERN_DEBUG " status = 0x%x\n", stat);
83 printk(KERN_DEBUG " %sMPS %d%s%s%s%s tc%d e%d fa%d%s\n",
84 skip ? "Skip " : "",
85 mps,
86 isoc ? " Isoc." : "",
87 low_speed ? " LowSpd" : "",
88 (dir == OHCI_ED_D_IN) ? " Input" :
89 (dir == OHCI_ED_D_OUT) ? " Output" : "",
90 halted ? " Halted" : "",
91 toggle,
92 endnum,
93 funcaddr,
94 (stat & ED_ALLOCATED) ? " Allocated" : "");
95 printk(KERN_DEBUG " tail_td = 0x%x\n", ed_tail_td(ed));
96 printk(KERN_DEBUG " head_td = 0x%x\n", ed_head_td(ed));
97 printk(KERN_DEBUG " next_ed = 0x%x\n", le32_to_cpup(&ed->next_ed));
98 } /* show_ohci_ed() */
101 void show_ohci_td(struct ohci_td *td)
103 int info = le32_to_cpup(&td->info);
104 int td_round = info & OHCI_TD_ROUND;
105 int td_dir = info & OHCI_TD_D;
106 int td_int_delay = (info & OHCI_TD_IOC_DELAY) >> 21;
107 int td_toggle = (info & OHCI_TD_DT) >> 24;
108 int td_errcnt = td_errorcount(*td);
109 int td_cc = OHCI_TD_CC_GET(info);
111 printk(KERN_DEBUG " ohci TD hardware fields:\n");
112 printk(KERN_DEBUG " info = 0x%x\n", info);
113 printk(KERN_DEBUG " %s%s%s%d %s %s%d\n",
114 td_round ? "Rounding " : "",
115 (td_dir == OHCI_TD_D_IN) ? "Input " :
116 (td_dir == OHCI_TD_D_OUT) ? "Output " :
117 (td_dir == OHCI_TD_D_SETUP) ? "Setup " : "",
118 "IntDelay ", td_int_delay,
119 (td_toggle < 2) ? " " :
120 (td_toggle & 1) ? "Data1" : "Data0",
121 "ErrorCnt ", td_errcnt);
122 printk(KERN_DEBUG " ComplCode 0x%x, %sAccessed, %sActive\n",
123 td_cc,
124 td_cc_accessed(*td) ? "" : "Not ",
125 td_active(*td) ? "" : "Not ");
127 printk(KERN_DEBUG " %s%s\n",
128 td_allocated(*td) ? "Allocated" : "Free",
129 td_dummy(*td) ? " DUMMY" : "");
131 printk(KERN_DEBUG " cur_buf = 0x%x\n", le32_to_cpup(&td->cur_buf));
132 printk(KERN_DEBUG " next_td = 0x%x\n", le32_to_cpup(&td->next_td));
133 printk(KERN_DEBUG " buf_end = 0x%x\n", le32_to_cpup(&td->buf_end));
134 printk(KERN_DEBUG " ohci TD driver fields:\n");
135 printk(KERN_DEBUG " data = %p\n", td->data);
136 printk(KERN_DEBUG " dev_id = %p\n", td->dev_id);
137 printk(KERN_DEBUG " ed = %p\n", td->ed);
138 if (td->data != NULL) {
139 unsigned char *d = td->data;
140 printk(KERN_DEBUG " DATA: %02x %02x %02x %02x %02x %02x %02x %02x\n",
141 d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7] );
143 } /* show_ohci_td() */
146 void show_ohci_td_chain(struct ohci_td *td)
148 struct ohci_td *cur_td;
149 if (td == NULL) return;
151 printk(KERN_DEBUG "+++ OHCI TD Chain %lx: +++\n", virt_to_bus(td));
153 cur_td = td;
154 for (;;) {
155 show_ohci_td(cur_td);
156 if (!cur_td->next_td) break;
157 cur_td = bus_to_virt(le32_to_cpup(&cur_td->next_td));
158 /* we can't trust -anything- we find inside of a dummy TD */
159 if (td_dummy(*cur_td)) break;
162 printk(KERN_DEBUG "--- End TD Chain %lx: ---\n", virt_to_bus(td));
163 } /* show_ohci_td_chain () */
166 void show_ohci_device(struct ohci_device *dev)
168 int idx;
169 printk(KERN_DEBUG " ohci_device usb = %p\n", dev->usb);
170 printk(KERN_DEBUG " ohci_device ohci = %p\n", dev->ohci);
171 printk(KERN_DEBUG " ohci_device ohci_hcca = %p\n", dev->hcca);
172 for (idx=0; idx<3 /*NUM_EDS*/; ++idx) {
173 printk(KERN_DEBUG " [ed num %d] ", idx);
174 show_ohci_ed(&dev->ed[idx]);
176 for (idx=0; idx<3 /*NUM_TDS*/; ++idx) {
177 printk(KERN_DEBUG " [td num %d] ", idx);
178 show_ohci_td(&dev->td[idx]);
180 printk(KERN_DEBUG " ohci_device data\n ");
181 for (idx=0; idx<4; ++idx) {
182 printk(KERN_DEBUG " %08lx", dev->data[idx]);
184 printk(KERN_DEBUG "\n");
185 } /* show_ohci_device() */
188 void show_ohci_hcca(struct ohci_hcca *hcca)
190 int idx;
192 printk(KERN_DEBUG " ohci_hcca\n");
194 for (idx=0; idx<NUM_INTS; idx++) {
195 printk(KERN_DEBUG " int_table[%2d] == %x\n", idx,
196 le32_to_cpup(hcca->int_table + idx));
199 printk(KERN_DEBUG " frame_no == %d\n",
200 le16_to_cpup(&hcca->frame_no));
201 printk(KERN_DEBUG " donehead == 0x%08x\n",
202 le32_to_cpup(&hcca->donehead));
203 } /* show_ohci_hcca() */
206 /* vim:sw=8