blob: b387fc36ee4381c0aec9a602c8a5cdc4d692857a [file] [log] [blame]
Tom Rixf298e4b2009-10-31 12:37:41 -05001/*
2 * Copyright (c) 2009 Wind River Systems, Inc.
3 * Tom Rix <Tom.Rix@windriver.com>
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Tom Rixf298e4b2009-10-31 12:37:41 -05006 */
7
8/* Define MUSB_DEBUG before including this file to get debug macros */
9#ifdef MUSB_DEBUG
10
11#define MUSB_FLAGS_PRINT(v, x, y) \
12 if (((v) & MUSB_##x##_##y)) \
13 serial_printf("\t\t"#y"\n")
14
15static inline void musb_print_pwr(u8 b)
16{
17 serial_printf("\tpower 0x%2.2x\n", b);
18 MUSB_FLAGS_PRINT(b, POWER, ISOUPDATE);
19 MUSB_FLAGS_PRINT(b, POWER, SOFTCONN);
20 MUSB_FLAGS_PRINT(b, POWER, HSENAB);
21 MUSB_FLAGS_PRINT(b, POWER, HSMODE);
22 MUSB_FLAGS_PRINT(b, POWER, RESET);
23 MUSB_FLAGS_PRINT(b, POWER, RESUME);
24 MUSB_FLAGS_PRINT(b, POWER, SUSPENDM);
25 MUSB_FLAGS_PRINT(b, POWER, ENSUSPEND);
26}
27
28static inline void musb_print_csr0(u16 w)
29{
30 serial_printf("\tcsr0 0x%4.4x\n", w);
31 MUSB_FLAGS_PRINT(w, CSR0, FLUSHFIFO);
32 MUSB_FLAGS_PRINT(w, CSR0_P, SVDSETUPEND);
33 MUSB_FLAGS_PRINT(w, CSR0_P, SVDRXPKTRDY);
34 MUSB_FLAGS_PRINT(w, CSR0_P, SENDSTALL);
35 MUSB_FLAGS_PRINT(w, CSR0_P, SETUPEND);
36 MUSB_FLAGS_PRINT(w, CSR0_P, DATAEND);
37 MUSB_FLAGS_PRINT(w, CSR0_P, SENTSTALL);
38 MUSB_FLAGS_PRINT(w, CSR0, TXPKTRDY);
39 MUSB_FLAGS_PRINT(w, CSR0, RXPKTRDY);
40}
41
42static inline void musb_print_intrusb(u8 b)
43{
44 serial_printf("\tintrusb 0x%2.2x\n", b);
45 MUSB_FLAGS_PRINT(b, INTR, VBUSERROR);
46 MUSB_FLAGS_PRINT(b, INTR, SESSREQ);
47 MUSB_FLAGS_PRINT(b, INTR, DISCONNECT);
48 MUSB_FLAGS_PRINT(b, INTR, CONNECT);
49 MUSB_FLAGS_PRINT(b, INTR, SOF);
50 MUSB_FLAGS_PRINT(b, INTR, RESUME);
51 MUSB_FLAGS_PRINT(b, INTR, SUSPEND);
52
53 if (b & MUSB_INTR_BABBLE)
54 serial_printf("\t\tMUSB_INTR_RESET or MUSB_INTR_BABBLE\n");
55
56}
57
58static inline void musb_print_intrtx(u16 w)
59{
60 serial_printf("\tintrtx 0x%4.4x\n", w);
61}
62
63static inline void musb_print_intrrx(u16 w)
64{
65 serial_printf("\tintrx 0x%4.4x\n", w);
66}
67
68static inline void musb_print_devctl(u8 b)
69{
70 serial_printf("\tdevctl 0x%2.2x\n", b);
71 if (b & MUSB_DEVCTL_BDEVICE)
72 serial_printf("\t\tB device\n");
73 else
74 serial_printf("\t\tA device\n");
75 if (b & MUSB_DEVCTL_FSDEV)
76 serial_printf("\t\tFast Device -(host mode)\n");
77 if (b & MUSB_DEVCTL_LSDEV)
78 serial_printf("\t\tSlow Device -(host mode)\n");
79 if (b & MUSB_DEVCTL_HM)
80 serial_printf("\t\tHost mode\n");
81 else
82 serial_printf("\t\tPeripherial mode\n");
83 if (b & MUSB_DEVCTL_HR)
84 serial_printf("\t\tHost request started(B device)\n");
85 else
86 serial_printf("\t\tHost request finished(B device)\n");
87 if (b & MUSB_DEVCTL_BDEVICE) {
88 if (b & MUSB_DEVCTL_SESSION)
89 serial_printf("\t\tStart of session(B device)\n");
90 else
91 serial_printf("\t\tEnd of session(B device)\n");
92 } else {
93 if (b & MUSB_DEVCTL_SESSION)
94 serial_printf("\t\tStart of session(A device)\n");
95 else
96 serial_printf("\t\tEnd of session(A device)\n");
97 }
98}
99
100static inline void musb_print_config(u8 b)
101{
102 serial_printf("\tconfig 0x%2.2x\n", b);
103 if (b & MUSB_CONFIGDATA_MPRXE)
104 serial_printf("\t\tAuto combine rx bulk packets\n");
105 if (b & MUSB_CONFIGDATA_MPTXE)
106 serial_printf("\t\tAuto split tx bulk packets\n");
107 if (b & MUSB_CONFIGDATA_BIGENDIAN)
108 serial_printf("\t\tBig Endian ordering\n");
109 else
110 serial_printf("\t\tLittle Endian ordering\n");
111 if (b & MUSB_CONFIGDATA_HBRXE)
112 serial_printf("\t\tHigh speed rx iso endpoint\n");
113 if (b & MUSB_CONFIGDATA_HBTXE)
114 serial_printf("\t\tHigh speed tx iso endpoint\n");
115 if (b & MUSB_CONFIGDATA_DYNFIFO)
116 serial_printf("\t\tDynamic fifo sizing\n");
117 if (b & MUSB_CONFIGDATA_SOFTCONE)
118 serial_printf("\t\tSoft Connect\n");
119 if (b & MUSB_CONFIGDATA_UTMIDW)
120 serial_printf("\t\t16 bit data width\n");
121 else
122 serial_printf("\t\t8 bit data width\n");
123}
124
125static inline void musb_print_rxmaxp(u16 w)
126{
127 serial_printf("\trxmaxp 0x%4.4x\n", w);
128}
129
130static inline void musb_print_rxcsr(u16 w)
131{
132 serial_printf("\trxcsr 0x%4.4x\n", w);
133 MUSB_FLAGS_PRINT(w, RXCSR, AUTOCLEAR);
134 MUSB_FLAGS_PRINT(w, RXCSR, DMAENAB);
135 MUSB_FLAGS_PRINT(w, RXCSR, DISNYET);
136 MUSB_FLAGS_PRINT(w, RXCSR, PID_ERR);
137 MUSB_FLAGS_PRINT(w, RXCSR, DMAMODE);
138 MUSB_FLAGS_PRINT(w, RXCSR, CLRDATATOG);
139 MUSB_FLAGS_PRINT(w, RXCSR, FLUSHFIFO);
140 MUSB_FLAGS_PRINT(w, RXCSR, DATAERROR);
141 MUSB_FLAGS_PRINT(w, RXCSR, FIFOFULL);
142 MUSB_FLAGS_PRINT(w, RXCSR, RXPKTRDY);
143 MUSB_FLAGS_PRINT(w, RXCSR_P, SENTSTALL);
144 MUSB_FLAGS_PRINT(w, RXCSR_P, SENDSTALL);
145 MUSB_FLAGS_PRINT(w, RXCSR_P, OVERRUN);
146
147 if (w & MUSB_RXCSR_P_ISO)
148 serial_printf("\t\tiso mode\n");
149 else
150 serial_printf("\t\tbulk mode\n");
151
152}
153
154static inline void musb_print_txmaxp(u16 w)
155{
156 serial_printf("\ttxmaxp 0x%4.4x\n", w);
157}
158
159static inline void musb_print_txcsr(u16 w)
160{
161 serial_printf("\ttxcsr 0x%4.4x\n", w);
162 MUSB_FLAGS_PRINT(w, TXCSR, TXPKTRDY);
163 MUSB_FLAGS_PRINT(w, TXCSR, FIFONOTEMPTY);
164 MUSB_FLAGS_PRINT(w, TXCSR, FLUSHFIFO);
165 MUSB_FLAGS_PRINT(w, TXCSR, CLRDATATOG);
166 MUSB_FLAGS_PRINT(w, TXCSR_P, UNDERRUN);
167 MUSB_FLAGS_PRINT(w, TXCSR_P, SENTSTALL);
168 MUSB_FLAGS_PRINT(w, TXCSR_P, SENDSTALL);
169
170 if (w & MUSB_TXCSR_MODE)
171 serial_printf("\t\tTX mode\n");
172 else
173 serial_printf("\t\tRX mode\n");
174}
175
176#else
177
178/* stubs */
179
180#define musb_print_pwr(b)
181#define musb_print_csr0(w)
182#define musb_print_intrusb(b)
183#define musb_print_intrtx(w)
184#define musb_print_intrrx(w)
185#define musb_print_devctl(b)
186#define musb_print_config(b)
187#define musb_print_rxmaxp(w)
188#define musb_print_rxcsr(w)
189#define musb_print_txmaxp(w)
190#define musb_print_txcsr(w)
191
192#endif /* MUSB_DEBUG */