2 * Copyright (c) 2009 Wind River Systems, Inc.
3 * Tom Rix <Tom.Rix@windriver.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 /* Define MUSB_DEBUG before including this file to get debug macros */
24 #define MUSB_FLAGS_PRINT(v, x, y) \
25 if (((v) & MUSB_##x##_##y)) \
26 serial_printf("\t\t"#y"\n")
28 static inline void musb_print_pwr(u8 b)
30 serial_printf("\tpower 0x%2.2x\n", b);
31 MUSB_FLAGS_PRINT(b, POWER, ISOUPDATE);
32 MUSB_FLAGS_PRINT(b, POWER, SOFTCONN);
33 MUSB_FLAGS_PRINT(b, POWER, HSENAB);
34 MUSB_FLAGS_PRINT(b, POWER, HSMODE);
35 MUSB_FLAGS_PRINT(b, POWER, RESET);
36 MUSB_FLAGS_PRINT(b, POWER, RESUME);
37 MUSB_FLAGS_PRINT(b, POWER, SUSPENDM);
38 MUSB_FLAGS_PRINT(b, POWER, ENSUSPEND);
41 static inline void musb_print_csr0(u16 w)
43 serial_printf("\tcsr0 0x%4.4x\n", w);
44 MUSB_FLAGS_PRINT(w, CSR0, FLUSHFIFO);
45 MUSB_FLAGS_PRINT(w, CSR0_P, SVDSETUPEND);
46 MUSB_FLAGS_PRINT(w, CSR0_P, SVDRXPKTRDY);
47 MUSB_FLAGS_PRINT(w, CSR0_P, SENDSTALL);
48 MUSB_FLAGS_PRINT(w, CSR0_P, SETUPEND);
49 MUSB_FLAGS_PRINT(w, CSR0_P, DATAEND);
50 MUSB_FLAGS_PRINT(w, CSR0_P, SENTSTALL);
51 MUSB_FLAGS_PRINT(w, CSR0, TXPKTRDY);
52 MUSB_FLAGS_PRINT(w, CSR0, RXPKTRDY);
55 static inline void musb_print_intrusb(u8 b)
57 serial_printf("\tintrusb 0x%2.2x\n", b);
58 MUSB_FLAGS_PRINT(b, INTR, VBUSERROR);
59 MUSB_FLAGS_PRINT(b, INTR, SESSREQ);
60 MUSB_FLAGS_PRINT(b, INTR, DISCONNECT);
61 MUSB_FLAGS_PRINT(b, INTR, CONNECT);
62 MUSB_FLAGS_PRINT(b, INTR, SOF);
63 MUSB_FLAGS_PRINT(b, INTR, RESUME);
64 MUSB_FLAGS_PRINT(b, INTR, SUSPEND);
66 if (b & MUSB_INTR_BABBLE)
67 serial_printf("\t\tMUSB_INTR_RESET or MUSB_INTR_BABBLE\n");
71 static inline void musb_print_intrtx(u16 w)
73 serial_printf("\tintrtx 0x%4.4x\n", w);
76 static inline void musb_print_intrrx(u16 w)
78 serial_printf("\tintrx 0x%4.4x\n", w);
81 static inline void musb_print_devctl(u8 b)
83 serial_printf("\tdevctl 0x%2.2x\n", b);
84 if (b & MUSB_DEVCTL_BDEVICE)
85 serial_printf("\t\tB device\n");
87 serial_printf("\t\tA device\n");
88 if (b & MUSB_DEVCTL_FSDEV)
89 serial_printf("\t\tFast Device -(host mode)\n");
90 if (b & MUSB_DEVCTL_LSDEV)
91 serial_printf("\t\tSlow Device -(host mode)\n");
92 if (b & MUSB_DEVCTL_HM)
93 serial_printf("\t\tHost mode\n");
95 serial_printf("\t\tPeripherial mode\n");
96 if (b & MUSB_DEVCTL_HR)
97 serial_printf("\t\tHost request started(B device)\n");
99 serial_printf("\t\tHost request finished(B device)\n");
100 if (b & MUSB_DEVCTL_BDEVICE) {
101 if (b & MUSB_DEVCTL_SESSION)
102 serial_printf("\t\tStart of session(B device)\n");
104 serial_printf("\t\tEnd of session(B device)\n");
106 if (b & MUSB_DEVCTL_SESSION)
107 serial_printf("\t\tStart of session(A device)\n");
109 serial_printf("\t\tEnd of session(A device)\n");
113 static inline void musb_print_config(u8 b)
115 serial_printf("\tconfig 0x%2.2x\n", b);
116 if (b & MUSB_CONFIGDATA_MPRXE)
117 serial_printf("\t\tAuto combine rx bulk packets\n");
118 if (b & MUSB_CONFIGDATA_MPTXE)
119 serial_printf("\t\tAuto split tx bulk packets\n");
120 if (b & MUSB_CONFIGDATA_BIGENDIAN)
121 serial_printf("\t\tBig Endian ordering\n");
123 serial_printf("\t\tLittle Endian ordering\n");
124 if (b & MUSB_CONFIGDATA_HBRXE)
125 serial_printf("\t\tHigh speed rx iso endpoint\n");
126 if (b & MUSB_CONFIGDATA_HBTXE)
127 serial_printf("\t\tHigh speed tx iso endpoint\n");
128 if (b & MUSB_CONFIGDATA_DYNFIFO)
129 serial_printf("\t\tDynamic fifo sizing\n");
130 if (b & MUSB_CONFIGDATA_SOFTCONE)
131 serial_printf("\t\tSoft Connect\n");
132 if (b & MUSB_CONFIGDATA_UTMIDW)
133 serial_printf("\t\t16 bit data width\n");
135 serial_printf("\t\t8 bit data width\n");
138 static inline void musb_print_rxmaxp(u16 w)
140 serial_printf("\trxmaxp 0x%4.4x\n", w);
143 static inline void musb_print_rxcsr(u16 w)
145 serial_printf("\trxcsr 0x%4.4x\n", w);
146 MUSB_FLAGS_PRINT(w, RXCSR, AUTOCLEAR);
147 MUSB_FLAGS_PRINT(w, RXCSR, DMAENAB);
148 MUSB_FLAGS_PRINT(w, RXCSR, DISNYET);
149 MUSB_FLAGS_PRINT(w, RXCSR, PID_ERR);
150 MUSB_FLAGS_PRINT(w, RXCSR, DMAMODE);
151 MUSB_FLAGS_PRINT(w, RXCSR, CLRDATATOG);
152 MUSB_FLAGS_PRINT(w, RXCSR, FLUSHFIFO);
153 MUSB_FLAGS_PRINT(w, RXCSR, DATAERROR);
154 MUSB_FLAGS_PRINT(w, RXCSR, FIFOFULL);
155 MUSB_FLAGS_PRINT(w, RXCSR, RXPKTRDY);
156 MUSB_FLAGS_PRINT(w, RXCSR_P, SENTSTALL);
157 MUSB_FLAGS_PRINT(w, RXCSR_P, SENDSTALL);
158 MUSB_FLAGS_PRINT(w, RXCSR_P, OVERRUN);
160 if (w & MUSB_RXCSR_P_ISO)
161 serial_printf("\t\tiso mode\n");
163 serial_printf("\t\tbulk mode\n");
167 static inline void musb_print_txmaxp(u16 w)
169 serial_printf("\ttxmaxp 0x%4.4x\n", w);
172 static inline void musb_print_txcsr(u16 w)
174 serial_printf("\ttxcsr 0x%4.4x\n", w);
175 MUSB_FLAGS_PRINT(w, TXCSR, TXPKTRDY);
176 MUSB_FLAGS_PRINT(w, TXCSR, FIFONOTEMPTY);
177 MUSB_FLAGS_PRINT(w, TXCSR, FLUSHFIFO);
178 MUSB_FLAGS_PRINT(w, TXCSR, CLRDATATOG);
179 MUSB_FLAGS_PRINT(w, TXCSR_P, UNDERRUN);
180 MUSB_FLAGS_PRINT(w, TXCSR_P, SENTSTALL);
181 MUSB_FLAGS_PRINT(w, TXCSR_P, SENDSTALL);
183 if (w & MUSB_TXCSR_MODE)
184 serial_printf("\t\tTX mode\n");
186 serial_printf("\t\tRX mode\n");
193 #define musb_print_pwr(b)
194 #define musb_print_csr0(w)
195 #define musb_print_intrusb(b)
196 #define musb_print_intrtx(w)
197 #define musb_print_intrrx(w)
198 #define musb_print_devctl(b)
199 #define musb_print_config(b)
200 #define musb_print_rxmaxp(w)
201 #define musb_print_rxcsr(w)
202 #define musb_print_txmaxp(w)
203 #define musb_print_txcsr(w)
205 #endif /* MUSB_DEBUG */