musb_debug.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  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. /* Define MUSB_DEBUG before including this file to get debug macros */
  21. #ifdef MUSB_DEBUG
  22. #define MUSB_FLAGS_PRINT(v, x, y) \
  23. if (((v) & MUSB_##x##_##y)) \
  24. serial_printf("\t\t"#y"\n")
  25. static inline void musb_print_pwr(u8 b)
  26. {
  27. serial_printf("\tpower 0x%2.2x\n", b);
  28. MUSB_FLAGS_PRINT(b, POWER, ISOUPDATE);
  29. MUSB_FLAGS_PRINT(b, POWER, SOFTCONN);
  30. MUSB_FLAGS_PRINT(b, POWER, HSENAB);
  31. MUSB_FLAGS_PRINT(b, POWER, HSMODE);
  32. MUSB_FLAGS_PRINT(b, POWER, RESET);
  33. MUSB_FLAGS_PRINT(b, POWER, RESUME);
  34. MUSB_FLAGS_PRINT(b, POWER, SUSPENDM);
  35. MUSB_FLAGS_PRINT(b, POWER, ENSUSPEND);
  36. }
  37. static inline void musb_print_csr0(u16 w)
  38. {
  39. serial_printf("\tcsr0 0x%4.4x\n", w);
  40. MUSB_FLAGS_PRINT(w, CSR0, FLUSHFIFO);
  41. MUSB_FLAGS_PRINT(w, CSR0_P, SVDSETUPEND);
  42. MUSB_FLAGS_PRINT(w, CSR0_P, SVDRXPKTRDY);
  43. MUSB_FLAGS_PRINT(w, CSR0_P, SENDSTALL);
  44. MUSB_FLAGS_PRINT(w, CSR0_P, SETUPEND);
  45. MUSB_FLAGS_PRINT(w, CSR0_P, DATAEND);
  46. MUSB_FLAGS_PRINT(w, CSR0_P, SENTSTALL);
  47. MUSB_FLAGS_PRINT(w, CSR0, TXPKTRDY);
  48. MUSB_FLAGS_PRINT(w, CSR0, RXPKTRDY);
  49. }
  50. static inline void musb_print_intrusb(u8 b)
  51. {
  52. serial_printf("\tintrusb 0x%2.2x\n", b);
  53. MUSB_FLAGS_PRINT(b, INTR, VBUSERROR);
  54. MUSB_FLAGS_PRINT(b, INTR, SESSREQ);
  55. MUSB_FLAGS_PRINT(b, INTR, DISCONNECT);
  56. MUSB_FLAGS_PRINT(b, INTR, CONNECT);
  57. MUSB_FLAGS_PRINT(b, INTR, SOF);
  58. MUSB_FLAGS_PRINT(b, INTR, RESUME);
  59. MUSB_FLAGS_PRINT(b, INTR, SUSPEND);
  60. if (b & MUSB_INTR_BABBLE)
  61. serial_printf("\t\tMUSB_INTR_RESET or MUSB_INTR_BABBLE\n");
  62. }
  63. static inline void musb_print_intrtx(u16 w)
  64. {
  65. serial_printf("\tintrtx 0x%4.4x\n", w);
  66. }
  67. static inline void musb_print_intrrx(u16 w)
  68. {
  69. serial_printf("\tintrx 0x%4.4x\n", w);
  70. }
  71. static inline void musb_print_devctl(u8 b)
  72. {
  73. serial_printf("\tdevctl 0x%2.2x\n", b);
  74. if (b & MUSB_DEVCTL_BDEVICE)
  75. serial_printf("\t\tB device\n");
  76. else
  77. serial_printf("\t\tA device\n");
  78. if (b & MUSB_DEVCTL_FSDEV)
  79. serial_printf("\t\tFast Device -(host mode)\n");
  80. if (b & MUSB_DEVCTL_LSDEV)
  81. serial_printf("\t\tSlow Device -(host mode)\n");
  82. if (b & MUSB_DEVCTL_HM)
  83. serial_printf("\t\tHost mode\n");
  84. else
  85. serial_printf("\t\tPeripherial mode\n");
  86. if (b & MUSB_DEVCTL_HR)
  87. serial_printf("\t\tHost request started(B device)\n");
  88. else
  89. serial_printf("\t\tHost request finished(B device)\n");
  90. if (b & MUSB_DEVCTL_BDEVICE) {
  91. if (b & MUSB_DEVCTL_SESSION)
  92. serial_printf("\t\tStart of session(B device)\n");
  93. else
  94. serial_printf("\t\tEnd of session(B device)\n");
  95. } else {
  96. if (b & MUSB_DEVCTL_SESSION)
  97. serial_printf("\t\tStart of session(A device)\n");
  98. else
  99. serial_printf("\t\tEnd of session(A device)\n");
  100. }
  101. }
  102. static inline void musb_print_config(u8 b)
  103. {
  104. serial_printf("\tconfig 0x%2.2x\n", b);
  105. if (b & MUSB_CONFIGDATA_MPRXE)
  106. serial_printf("\t\tAuto combine rx bulk packets\n");
  107. if (b & MUSB_CONFIGDATA_MPTXE)
  108. serial_printf("\t\tAuto split tx bulk packets\n");
  109. if (b & MUSB_CONFIGDATA_BIGENDIAN)
  110. serial_printf("\t\tBig Endian ordering\n");
  111. else
  112. serial_printf("\t\tLittle Endian ordering\n");
  113. if (b & MUSB_CONFIGDATA_HBRXE)
  114. serial_printf("\t\tHigh speed rx iso endpoint\n");
  115. if (b & MUSB_CONFIGDATA_HBTXE)
  116. serial_printf("\t\tHigh speed tx iso endpoint\n");
  117. if (b & MUSB_CONFIGDATA_DYNFIFO)
  118. serial_printf("\t\tDynamic fifo sizing\n");
  119. if (b & MUSB_CONFIGDATA_SOFTCONE)
  120. serial_printf("\t\tSoft Connect\n");
  121. if (b & MUSB_CONFIGDATA_UTMIDW)
  122. serial_printf("\t\t16 bit data width\n");
  123. else
  124. serial_printf("\t\t8 bit data width\n");
  125. }
  126. static inline void musb_print_rxmaxp(u16 w)
  127. {
  128. serial_printf("\trxmaxp 0x%4.4x\n", w);
  129. }
  130. static 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. if (w & MUSB_RXCSR_P_ISO)
  147. serial_printf("\t\tiso mode\n");
  148. else
  149. serial_printf("\t\tbulk mode\n");
  150. }
  151. static inline void musb_print_txmaxp(u16 w)
  152. {
  153. serial_printf("\ttxmaxp 0x%4.4x\n", w);
  154. }
  155. static inline void musb_print_txcsr(u16 w)
  156. {
  157. serial_printf("\ttxcsr 0x%4.4x\n", w);
  158. MUSB_FLAGS_PRINT(w, TXCSR, TXPKTRDY);
  159. MUSB_FLAGS_PRINT(w, TXCSR, FIFONOTEMPTY);
  160. MUSB_FLAGS_PRINT(w, TXCSR, FLUSHFIFO);
  161. MUSB_FLAGS_PRINT(w, TXCSR, CLRDATATOG);
  162. MUSB_FLAGS_PRINT(w, TXCSR_P, UNDERRUN);
  163. MUSB_FLAGS_PRINT(w, TXCSR_P, SENTSTALL);
  164. MUSB_FLAGS_PRINT(w, TXCSR_P, SENDSTALL);
  165. if (w & MUSB_TXCSR_MODE)
  166. serial_printf("\t\tTX mode\n");
  167. else
  168. serial_printf("\t\tRX mode\n");
  169. }
  170. #else
  171. /* stubs */
  172. #define musb_print_pwr(b)
  173. #define musb_print_csr0(w)
  174. #define musb_print_intrusb(b)
  175. #define musb_print_intrtx(w)
  176. #define musb_print_intrrx(w)
  177. #define musb_print_devctl(b)
  178. #define musb_print_config(b)
  179. #define musb_print_rxmaxp(w)
  180. #define musb_print_rxcsr(w)
  181. #define musb_print_txmaxp(w)
  182. #define musb_print_txcsr(w)
  183. #endif /* MUSB_DEBUG */