gadget_chips.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*
  2. * USB device controllers have lots of quirks. Use these macros in
  3. * gadget drivers or other code that needs to deal with them, and which
  4. * autoconfigures instead of using early binding to the hardware.
  5. *
  6. * This SHOULD eventually work like the ARM mach_is_*() stuff, driven by
  7. * some config file that gets updated as new hardware is supported.
  8. * (And avoiding all runtime comparisons in typical one-choice configs!)
  9. *
  10. * NOTE: some of these controller drivers may not be available yet.
  11. * Some are available on 2.4 kernels; several are available, but not
  12. * yet pushed in the 2.6 mainline tree.
  13. */
  14. #ifdef CONFIG_USB_GADGET_NET2280
  15. #define gadget_is_net2280(g) !strcmp("net2280", (g)->name)
  16. #else
  17. #define gadget_is_net2280(g) 0
  18. #endif
  19. #ifdef CONFIG_USB_GADGET_AMD5536UDC
  20. #define gadget_is_amd5536udc(g) !strcmp("amd5536udc", (g)->name)
  21. #else
  22. #define gadget_is_amd5536udc(g) 0
  23. #endif
  24. #ifdef CONFIG_USB_GADGET_DUMMY_HCD
  25. #define gadget_is_dummy(g) !strcmp("dummy_udc", (g)->name)
  26. #else
  27. #define gadget_is_dummy(g) 0
  28. #endif
  29. #ifdef CONFIG_USB_GADGET_PXA2XX
  30. #define gadget_is_pxa(g) !strcmp("pxa2xx_udc", (g)->name)
  31. #else
  32. #define gadget_is_pxa(g) 0
  33. #endif
  34. #ifdef CONFIG_USB_GADGET_GOKU
  35. #define gadget_is_goku(g) !strcmp("goku_udc", (g)->name)
  36. #else
  37. #define gadget_is_goku(g) 0
  38. #endif
  39. /* SH3 UDC -- not yet ported 2.4 --> 2.6 */
  40. #ifdef CONFIG_USB_GADGET_SUPERH
  41. #define gadget_is_sh(g) !strcmp("sh_udc", (g)->name)
  42. #else
  43. #define gadget_is_sh(g) 0
  44. #endif
  45. /* not yet stable on 2.6 (would help "original Zaurus") */
  46. #ifdef CONFIG_USB_GADGET_SA1100
  47. #define gadget_is_sa1100(g) !strcmp("sa1100_udc", (g)->name)
  48. #else
  49. #define gadget_is_sa1100(g) 0
  50. #endif
  51. #ifdef CONFIG_USB_GADGET_LH7A40X
  52. #define gadget_is_lh7a40x(g) !strcmp("lh7a40x_udc", (g)->name)
  53. #else
  54. #define gadget_is_lh7a40x(g) 0
  55. #endif
  56. /* handhelds.org tree (?) */
  57. #ifdef CONFIG_USB_GADGET_MQ11XX
  58. #define gadget_is_mq11xx(g) !strcmp("mq11xx_udc", (g)->name)
  59. #else
  60. #define gadget_is_mq11xx(g) 0
  61. #endif
  62. #ifdef CONFIG_USB_GADGET_OMAP
  63. #define gadget_is_omap(g) !strcmp("omap_udc", (g)->name)
  64. #else
  65. #define gadget_is_omap(g) 0
  66. #endif
  67. /* not yet ported 2.4 --> 2.6 */
  68. #ifdef CONFIG_USB_GADGET_N9604
  69. #define gadget_is_n9604(g) !strcmp("n9604_udc", (g)->name)
  70. #else
  71. #define gadget_is_n9604(g) 0
  72. #endif
  73. /* various unstable versions available */
  74. #ifdef CONFIG_USB_GADGET_PXA27X
  75. #define gadget_is_pxa27x(g) !strcmp("pxa27x_udc", (g)->name)
  76. #else
  77. #define gadget_is_pxa27x(g) 0
  78. #endif
  79. #ifdef CONFIG_USB_GADGET_ATMEL_USBA
  80. #define gadget_is_atmel_usba(g) !strcmp("atmel_usba_udc", (g)->name)
  81. #else
  82. #define gadget_is_atmel_usba(g) 0
  83. #endif
  84. #ifdef CONFIG_USB_GADGET_S3C2410
  85. #define gadget_is_s3c2410(g) !strcmp("s3c2410_udc", (g)->name)
  86. #else
  87. #define gadget_is_s3c2410(g) 0
  88. #endif
  89. #ifdef CONFIG_USB_GADGET_AT91
  90. #define gadget_is_at91(g) !strcmp("at91_udc", (g)->name)
  91. #else
  92. #define gadget_is_at91(g) 0
  93. #endif
  94. /* status unclear */
  95. #ifdef CONFIG_USB_GADGET_IMX
  96. #define gadget_is_imx(g) !strcmp("imx_udc", (g)->name)
  97. #else
  98. #define gadget_is_imx(g) 0
  99. #endif
  100. #ifdef CONFIG_USB_GADGET_FSL_USB2
  101. #define gadget_is_fsl_usb2(g) !strcmp("fsl-usb2-udc", (g)->name)
  102. #else
  103. #define gadget_is_fsl_usb2(g) 0
  104. #endif
  105. /* Mentor high speed function controller */
  106. /* from Montavista kernel (?) */
  107. #ifdef CONFIG_USB_GADGET_MUSBHSFC
  108. #define gadget_is_musbhsfc(g) !strcmp("musbhsfc_udc", (g)->name)
  109. #else
  110. #define gadget_is_musbhsfc(g) 0
  111. #endif
  112. /* Mentor high speed "dual role" controller, in peripheral role */
  113. #ifdef CONFIG_USB_GADGET_MUSB_HDRC
  114. #define gadget_is_musbhdrc(g) !strcmp("musb_hdrc", (g)->name)
  115. #else
  116. #define gadget_is_musbhdrc(g) 0
  117. #endif
  118. /* from Montavista kernel (?) */
  119. #ifdef CONFIG_USB_GADGET_MPC8272
  120. #define gadget_is_mpc8272(g) !strcmp("mpc8272_udc", (g)->name)
  121. #else
  122. #define gadget_is_mpc8272(g) 0
  123. #endif
  124. #ifdef CONFIG_USB_GADGET_M66592
  125. #define gadget_is_m66592(g) !strcmp("m66592_udc", (g)->name)
  126. #else
  127. #define gadget_is_m66592(g) 0
  128. #endif
  129. // CONFIG_USB_GADGET_SX2
  130. // CONFIG_USB_GADGET_AU1X00
  131. // ...
  132. /**
  133. * usb_gadget_controller_number - support bcdDevice id convention
  134. * @gadget: the controller being driven
  135. *
  136. * Return a 2-digit BCD value associated with the peripheral controller,
  137. * suitable for use as part of a bcdDevice value, or a negative error code.
  138. *
  139. * NOTE: this convention is purely optional, and has no meaning in terms of
  140. * any USB specification. If you want to use a different convention in your
  141. * gadget driver firmware -- maybe a more formal revision ID -- feel free.
  142. *
  143. * Hosts see these bcdDevice numbers, and are allowed (but not encouraged!)
  144. * to change their behavior accordingly. For example it might help avoiding
  145. * some chip bug.
  146. */
  147. static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
  148. {
  149. if (gadget_is_net2280(gadget))
  150. return 0x01;
  151. else if (gadget_is_dummy(gadget))
  152. return 0x02;
  153. else if (gadget_is_pxa(gadget))
  154. return 0x03;
  155. else if (gadget_is_sh(gadget))
  156. return 0x04;
  157. else if (gadget_is_sa1100(gadget))
  158. return 0x05;
  159. else if (gadget_is_goku(gadget))
  160. return 0x06;
  161. else if (gadget_is_mq11xx(gadget))
  162. return 0x07;
  163. else if (gadget_is_omap(gadget))
  164. return 0x08;
  165. else if (gadget_is_lh7a40x(gadget))
  166. return 0x09;
  167. else if (gadget_is_n9604(gadget))
  168. return 0x10;
  169. else if (gadget_is_pxa27x(gadget))
  170. return 0x11;
  171. else if (gadget_is_s3c2410(gadget))
  172. return 0x12;
  173. else if (gadget_is_at91(gadget))
  174. return 0x13;
  175. else if (gadget_is_imx(gadget))
  176. return 0x14;
  177. else if (gadget_is_musbhsfc(gadget))
  178. return 0x15;
  179. else if (gadget_is_musbhdrc(gadget))
  180. return 0x16;
  181. else if (gadget_is_mpc8272(gadget))
  182. return 0x17;
  183. else if (gadget_is_atmel_usba(gadget))
  184. return 0x18;
  185. else if (gadget_is_fsl_usb2(gadget))
  186. return 0x19;
  187. else if (gadget_is_amd5536udc(gadget))
  188. return 0x20;
  189. else if (gadget_is_m66592(gadget))
  190. return 0x21;
  191. return -ENOENT;
  192. }