/drivers/usb/gadget/gadget_chips.h

https://bitbucket.org/slukk/jb-tsm-kernel-4.2 · C Header · 249 lines · 176 code · 32 blank · 41 comment · 47 complexity · 7b5e8f2cff0bb5a7b9d17c9eb4e29911 MD5 · raw file

  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_S3C_HSUDC
  118. #define gadget_is_s3c_hsudc(g) (!strcmp("s3c-hsudc", (g)->name))
  119. #else
  120. #define gadget_is_s3c_hsudc(g) 0
  121. #endif
  122. #ifdef CONFIG_USB_GADGET_EG20T
  123. #define gadget_is_pch(g) (!strcmp("pch_udc", (g)->name))
  124. #else
  125. #define gadget_is_pch(g) 0
  126. #endif
  127. #ifdef CONFIG_USB_GADGET_CI13XXX_MSM
  128. #define gadget_is_ci13xxx_msm(g) (!strcmp("ci13xxx_msm", (g)->name))
  129. #else
  130. #define gadget_is_ci13xxx_msm(g) 0
  131. #endif
  132. #ifdef CONFIG_USB_GADGET_RENESAS_USBHS
  133. #define gadget_is_renesas_usbhs(g) (!strcmp("renesas_usbhs_udc", (g)->name))
  134. #else
  135. #define gadget_is_renesas_usbhs(g) 0
  136. #endif
  137. /**
  138. * usb_gadget_controller_number - support bcdDevice id convention
  139. * @gadget: the controller being driven
  140. *
  141. * Return a 2-digit BCD value associated with the peripheral controller,
  142. * suitable for use as part of a bcdDevice value, or a negative error code.
  143. *
  144. * NOTE: this convention is purely optional, and has no meaning in terms of
  145. * any USB specification. If you want to use a different convention in your
  146. * gadget driver firmware -- maybe a more formal revision ID -- feel free.
  147. *
  148. * Hosts see these bcdDevice numbers, and are allowed (but not encouraged!)
  149. * to change their behavior accordingly. For example it might help avoiding
  150. * some chip bug.
  151. */
  152. static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
  153. {
  154. if (gadget_is_net2280(gadget))
  155. return 0x01;
  156. else if (gadget_is_dummy(gadget))
  157. return 0x02;
  158. else if (gadget_is_pxa(gadget))
  159. return 0x03;
  160. else if (gadget_is_goku(gadget))
  161. return 0x06;
  162. else if (gadget_is_omap(gadget))
  163. return 0x08;
  164. else if (gadget_is_pxa27x(gadget))
  165. return 0x11;
  166. else if (gadget_is_s3c2410(gadget))
  167. return 0x12;
  168. else if (gadget_is_at91(gadget))
  169. return 0x13;
  170. else if (gadget_is_imx(gadget))
  171. return 0x14;
  172. else if (gadget_is_musbhdrc(gadget))
  173. return 0x16;
  174. else if (gadget_is_atmel_usba(gadget))
  175. return 0x18;
  176. else if (gadget_is_fsl_usb2(gadget))
  177. return 0x19;
  178. else if (gadget_is_amd5536udc(gadget))
  179. return 0x20;
  180. else if (gadget_is_m66592(gadget))
  181. return 0x21;
  182. else if (gadget_is_fsl_qe(gadget))
  183. return 0x22;
  184. else if (gadget_is_ci13xxx_pci(gadget))
  185. return 0x23;
  186. else if (gadget_is_langwell(gadget))
  187. return 0x24;
  188. else if (gadget_is_r8a66597(gadget))
  189. return 0x25;
  190. else if (gadget_is_s3c_hsotg(gadget))
  191. return 0x26;
  192. else if (gadget_is_pch(gadget))
  193. return 0x27;
  194. else if (gadget_is_ci13xxx_msm(gadget))
  195. return 0x28;
  196. else if (gadget_is_renesas_usbhs(gadget))
  197. return 0x29;
  198. else if (gadget_is_s3c_hsudc(gadget))
  199. return 0x30;
  200. return -ENOENT;
  201. }
  202. /**
  203. * gadget_supports_altsettings - return true if altsettings work
  204. * @gadget: the gadget in question
  205. */
  206. static inline bool gadget_supports_altsettings(struct usb_gadget *gadget)
  207. {
  208. /* PXA 21x/25x/26x has no altsettings at all */
  209. if (gadget_is_pxa(gadget))
  210. return false;
  211. /* PXA 27x and 3xx have *broken* altsetting support */
  212. if (gadget_is_pxa27x(gadget))
  213. return false;
  214. /* Everything else is *presumably* fine ... */
  215. return true;
  216. }
  217. #endif /* __GADGET_CHIPS_H */