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