blob: 62380ffc6516a89c5ccdcb7cfca17d85a1b550dd [file] [log] [blame]
Tom Rix09c82bc2009-10-31 12:37:41 -05001/*
2 * Copyright (c) 2009 Wind River Systems, Inc.
3 * Tom Rix <Tom.Rix@windriver.com>
4 *
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.
9 *
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.
14 *
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,
18 * MA 02111-1307 USA
19 */
20
21/* Define MUSB_DEBUG before including this file to get debug macros */
22#ifdef MUSB_DEBUG
23
24#define MUSB_FLAGS_PRINT(v, x, y) \
25 if (((v) & MUSB_##x##_##y)) \
26 serial_printf("\t\t"#y"\n")
27
28static inline void musb_print_pwr(u8 b)
29{
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);
39}
40
41static inline void musb_print_csr0(u16 w)
42{
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);
53}
54
55static inline void musb_print_intrusb(u8 b)
56{
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);
65
66 if (b & MUSB_INTR_BABBLE)
67 serial_printf("\t\tMUSB_INTR_RESET or MUSB_INTR_BABBLE\n");
68
69}
70
71static inline void musb_print_intrtx(u16 w)
72{
73 serial_printf("\tintrtx 0x%4.4x\n", w);
74}
75
76static inline void musb_print_intrrx(u16 w)
77{
78 serial_printf("\tintrx 0x%4.4x\n", w);
79}
80
81static inline void musb_print_devctl(u8 b)
82{
83 serial_printf("\tdevctl 0x%2.2x\n", b);
84 if (b & MUSB_DEVCTL_BDEVICE)
85 serial_printf("\t\tB device\n");
86 else
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");
94 else
95 serial_printf("\t\tPeripherial mode\n");
96 if (b & MUSB_DEVCTL_HR)
97 serial_printf("\t\tHost request started(B device)\n");
98 else
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");
103 else
104 serial_printf("\t\tEnd of session(B device)\n");
105 } else {
106 if (b & MUSB_DEVCTL_SESSION)
107 serial_printf("\t\tStart of session(A device)\n");
108 else
109 serial_printf("\t\tEnd of session(A device)\n");
110 }
111}
112
113static inline void musb_print_config(u8 b)
114{
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");
122 else
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");
134 else
135 serial_printf("\t\t8 bit data width\n");
136}
137
138static inline void musb_print_rxmaxp(u16 w)
139{
140 serial_printf("\trxmaxp 0x%4.4x\n", w);
141}
142
143static inline void musb_print_rxcsr(u16 w)
144{
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);
159
160 if (w & MUSB_RXCSR_P_ISO)
161 serial_printf("\t\tiso mode\n");
162 else
163 serial_printf("\t\tbulk mode\n");
164
165}
166
167static inline void musb_print_txmaxp(u16 w)
168{
169 serial_printf("\ttxmaxp 0x%4.4x\n", w);
170}
171
172static inline void musb_print_txcsr(u16 w)
173{
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);
182
183 if (w & MUSB_TXCSR_MODE)
184 serial_printf("\t\tTX mode\n");
185 else
186 serial_printf("\t\tRX mode\n");
187}
188
189#else
190
191/* stubs */
192
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)
204
205#endif /* MUSB_DEBUG */