gadget_chips.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. #ifndef __GADGET_CHIPS_H
  15. #define __GADGET_CHIPS_H
  16. #ifdef CONFIG_USB_GADGET_NET2280
  17. #define gadget_is_net2280(g) !strcmp("net2280", (g)->name)
  18. #else
  19. #define gadget_is_net2280(g) 0
  20. #endif
  21. #ifdef CONFIG_USB_GADGET_AMD5536UDC
  22. #define gadget_is_amd5536udc(g) !strcmp("amd5536udc", (g)->name)
  23. #else
  24. #define gadget_is_amd5536udc(g) 0
  25. #endif
  26. #ifdef CONFIG_USB_GADGET_DUMMY_HCD
  27. #define gadget_is_dummy(g) !strcmp("dummy_udc", (g)->name)
  28. #else
  29. #define gadget_is_dummy(g) 0
  30. #endif
  31. #ifdef CONFIG_USB_GADGET_PXA25X
  32. #define gadget_is_pxa(g) !strcmp("pxa25x_udc", (g)->name)
  33. #else
  34. #define gadget_is_pxa(g) 0
  35. #endif
  36. #ifdef CONFIG_USB_GADGET_GOKU
  37. #define gadget_is_goku(g) !strcmp("goku_udc", (g)->name)
  38. #else
  39. #define gadget_is_goku(g) 0
  40. #endif
  41. #ifdef CONFIG_USB_GADGET_OMAP
  42. #define gadget_is_omap(g) !strcmp("omap_udc", (g)->name)
  43. #else
  44. #define gadget_is_omap(g) 0
  45. #endif
  46. /* various unstable versions available */
  47. #ifdef CONFIG_USB_GADGET_PXA27X
  48. #define gadget_is_pxa27x(g) !strcmp("pxa27x_udc", (g)->name)
  49. #else
  50. #define gadget_is_pxa27x(g) 0
  51. #endif
  52. #ifdef CONFIG_USB_GADGET_ATMEL_USBA
  53. #define gadget_is_atmel_usba(g) !strcmp("atmel_usba_udc", (g)->name)
  54. #else
  55. #define gadget_is_atmel_usba(g) 0
  56. #endif
  57. #ifdef CONFIG_USB_GADGET_S3C2410
  58. #define gadget_is_s3c2410(g) !strcmp("s3c2410_udc", (g)->name)
  59. #else
  60. #define gadget_is_s3c2410(g) 0
  61. #endif
  62. #ifdef CONFIG_USB_GADGET_AT91
  63. #define gadget_is_at91(g) !strcmp("at91_udc", (g)->name)
  64. #else
  65. #define gadget_is_at91(g) 0
  66. #endif
  67. #ifdef CONFIG_USB_GADGET_IMX
  68. #define gadget_is_imx(g) !strcmp("imx_udc", (g)->name)
  69. #else
  70. #define gadget_is_imx(g) 0
  71. #endif
  72. #ifdef CONFIG_USB_GADGET_FSL_USB2
  73. #define gadget_is_fsl_usb2(g) !strcmp("fsl-usb2-udc", (g)->name)
  74. #else
  75. #define gadget_is_fsl_usb2(g) 0
  76. #endif
  77. /* Mentor high speed "dual role" controller, in peripheral role */
  78. #ifdef CONFIG_USB_GADGET_MUSB_HDRC
  79. #define gadget_is_musbhdrc(g) !strcmp("musb-hdrc", (g)->name)
  80. #else
  81. #define gadget_is_musbhdrc(g) 0
  82. #endif
  83. #ifdef CONFIG_USB_GADGET_LANGWELL
  84. #define gadget_is_langwell(g) (!strcmp("langwell_udc", (g)->name))
  85. #else
  86. #define gadget_is_langwell(g) 0
  87. #endif
  88. #ifdef CONFIG_USB_GADGET_M66592
  89. #define gadget_is_m66592(g) !strcmp("m66592_udc", (g)->name)
  90. #else
  91. #define gadget_is_m66592(g) 0
  92. #endif
  93. /* Freescale CPM/QE UDC SUPPORT */
  94. #ifdef CONFIG_USB_GADGET_FSL_QE
  95. #define gadget_is_fsl_qe(g) !strcmp("fsl_qe_udc", (g)->name)
  96. #else
  97. #define gadget_is_fsl_qe(g) 0
  98. #endif
  99. #ifdef CONFIG_USB_GADGET_CI13XXX_PCI
  100. #define gadget_is_ci13xxx_pci(g) (!strcmp("ci13xxx_pci", (g)->name))
  101. #else
  102. #define gadget_is_ci13xxx_pci(g) 0
  103. #endif
  104. // CONFIG_USB_GADGET_SX2
  105. // CONFIG_USB_GADGET_AU1X00
  106. // ...
  107. #ifdef CONFIG_USB_GADGET_R8A66597
  108. #define gadget_is_r8a66597(g) !strcmp("r8a66597_udc", (g)->name)
  109. #else
  110. #define gadget_is_r8a66597(g) 0
  111. #endif
  112. #ifdef CONFIG_USB_S3C_HSOTG
  113. #define gadget_is_s3c_hsotg(g) (!strcmp("s3c-hsotg", (g)->name))
  114. #else
  115. #define gadget_is_s3c_hsotg(g) 0
  116. #endif
  117. #ifdef CONFIG_USB_GADGET_EG20T
  118. #define gadget_is_pch(g) (!strcmp("pch_udc", (g)->name))
  119. #else
  120. #define gadget_is_pch(g) 0
  121. #endif
  122. #ifdef CONFIG_USB_GADGET_CI13XXX_MSM
  123. #define gadget_is_ci13xxx_msm(g) (!strcmp("ci13xxx_msm", (g)->name))
  124. #else
  125. #define gadget_is_ci13xxx_msm(g) 0
  126. #endif
  127. /**
  128. * usb_gadget_controller_number - support bcdDevice id convention
  129. * @gadget: the controller being driven
  130. *
  131. * Return a 2-digit BCD value associated with the peripheral controller,
  132. * suitable for use as part of a bcdDevice value, or a negative error code.
  133. *
  134. * NOTE: this convention is purely optional, and has no meaning in terms of
  135. * any USB specification. If you want to use a different convention in your
  136. * gadget driver firmware -- maybe a more formal revision ID -- feel free.
  137. *
  138. * Hosts see these bcdDevice numbers, and are allowed (but not encouraged!)
  139. * to change their behavior accordingly. For example it might help avoiding
  140. * some chip bug.
  141. */
  142. static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
  143. {
  144. if (gadget_is_net2280(gadget))
  145. return 0x01;
  146. else if (gadget_is_dummy(gadget))
  147. return 0x02;
  148. else if (gadget_is_pxa(gadget))
  149. return 0x03;
  150. else if (gadget_is_goku(gadget))
  151. return 0x06;
  152. else if (gadget_is_omap(gadget))
  153. return 0x08;
  154. else if (gadget_is_pxa27x(gadget))
  155. return 0x11;
  156. else if (gadget_is_s3c2410(gadget))
  157. return 0x12;
  158. else if (gadget_is_at91(gadget))
  159. return 0x13;
  160. else if (gadget_is_imx(gadget))
  161. return 0x14;
  162. else if (gadget_is_musbhdrc(gadget))
  163. return 0x16;
  164. else if (gadget_is_atmel_usba(gadget))
  165. return 0x18;
  166. else if (gadget_is_fsl_usb2(gadget))
  167. return 0x19;
  168. else if (gadget_is_amd5536udc(gadget))
  169. return 0x20;
  170. else if (gadget_is_m66592(gadget))
  171. return 0x21;
  172. else if (gadget_is_fsl_qe(gadget))
  173. return 0x22;
  174. else if (gadget_is_ci13xxx_pci(gadget))
  175. return 0x23;
  176. else if (gadget_is_langwell(gadget))
  177. return 0x24;
  178. else if (gadget_is_r8a66597(gadget))
  179. return 0x25;
  180. else if (gadget_is_s3c_hsotg(gadget))
  181. return 0x26;
  182. else if (gadget_is_pch(gadget))
  183. return 0x27;
  184. else if (gadget_is_ci13xxx_msm(gadget))
  185. return 0x28;
  186. return -ENOENT;
  187. }
  188. /**
  189. * gadget_supports_altsettings - return true if altsettings work
  190. * @gadget: the gadget in question
  191. */
  192. static inline bool gadget_supports_altsettings(struct usb_gadget *gadget)
  193. {
  194. /* PXA 21x/25x/26x has no altsettings at all */
  195. if (gadget_is_pxa(gadget))
  196. return false;
  197. /* PXA 27x and 3xx have *broken* altsetting support */
  198. if (gadget_is_pxa27x(gadget))
  199. return false;
  200. /* Everything else is *presumably* fine ... */
  201. return true;
  202. }
  203. #endif /* __GADGET_CHIPS_H */