gadget_chips.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 could 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 the runtime comparisons in typical one-choice cases.)
  9. *
  10. * NOTE: some of these controller drivers may not be available yet.
  11. */
  12. #ifdef CONFIG_USB_GADGET_NET2280
  13. #define gadget_is_net2280(g) !strcmp("net2280", (g)->name)
  14. #else
  15. #define gadget_is_net2280(g) 0
  16. #endif
  17. #ifdef CONFIG_USB_GADGET_DUMMY_HCD
  18. #define gadget_is_dummy(g) !strcmp("dummy_udc", (g)->name)
  19. #else
  20. #define gadget_is_dummy(g) 0
  21. #endif
  22. #ifdef CONFIG_USB_GADGET_PXA2XX
  23. #define gadget_is_pxa(g) !strcmp("pxa2xx_udc", (g)->name)
  24. #else
  25. #define gadget_is_pxa(g) 0
  26. #endif
  27. #ifdef CONFIG_USB_GADGET_GOKU
  28. #define gadget_is_goku(g) !strcmp("goku_udc", (g)->name)
  29. #else
  30. #define gadget_is_goku(g) 0
  31. #endif
  32. #ifdef CONFIG_USB_GADGET_SUPERH
  33. #define gadget_is_sh(g) !strcmp("sh_udc", (g)->name)
  34. #else
  35. #define gadget_is_sh(g) 0
  36. #endif
  37. #ifdef CONFIG_USB_GADGET_SA1100
  38. #define gadget_is_sa1100(g) !strcmp("sa1100_udc", (g)->name)
  39. #else
  40. #define gadget_is_sa1100(g) 0
  41. #endif
  42. #ifdef CONFIG_USB_GADGET_LH7A40X
  43. #define gadget_is_lh7a40x(g) !strcmp("lh7a40x_udc", (g)->name)
  44. #else
  45. #define gadget_is_lh7a40x(g) 0
  46. #endif
  47. #ifdef CONFIG_USB_GADGET_MQ11XX
  48. #define gadget_is_mq11xx(g) !strcmp("mq11xx_udc", (g)->name)
  49. #else
  50. #define gadget_is_mq11xx(g) 0
  51. #endif
  52. #ifdef CONFIG_USB_GADGET_OMAP
  53. #define gadget_is_omap(g) !strcmp("omap_udc", (g)->name)
  54. #else
  55. #define gadget_is_omap(g) 0
  56. #endif
  57. #ifdef CONFIG_USB_GADGET_N9604
  58. #define gadget_is_n9604(g) !strcmp("n9604_udc", (g)->name)
  59. #else
  60. #define gadget_is_n9604(g) 0
  61. #endif
  62. #ifdef CONFIG_USB_GADGET_PXA27X
  63. #define gadget_is_pxa27x(g) !strcmp("pxa27x_udc", (g)->name)
  64. #else
  65. #define gadget_is_pxa27x(g) 0
  66. #endif
  67. #ifdef CONFIG_USB_GADGET_S3C2410
  68. #define gadget_is_s3c2410(g) !strcmp("s3c2410_udc", (g)->name)
  69. #else
  70. #define gadget_is_s3c2410(g) 0
  71. #endif
  72. #ifdef CONFIG_USB_GADGET_AT91
  73. #define gadget_is_at91(g) !strcmp("at91_udc", (g)->name)
  74. #else
  75. #define gadget_is_at91(g) 0
  76. #endif
  77. #ifdef CONFIG_USB_GADGET_IMX
  78. #define gadget_is_imx(g) !strcmp("imx_udc", (g)->name)
  79. #else
  80. #define gadget_is_imx(g) 0
  81. #endif
  82. // CONFIG_USB_GADGET_SX2
  83. // CONFIG_USB_GADGET_AU1X00
  84. // ...
  85. /**
  86. * usb_gadget_controller_number - support bcdDevice id convention
  87. * @gadget: the controller being driven
  88. *
  89. * Return a 2-digit BCD value associated with the peripheral controller,
  90. * suitable for use as part of a bcdDevice value, or a negative error code.
  91. *
  92. * NOTE: this convention is purely optional, and has no meaning in terms of
  93. * any USB specification. If you want to use a different convention in your
  94. * gadget driver firmware -- maybe a more formal revision ID -- feel free.
  95. *
  96. * Hosts see these bcdDevice numbers, and are allowed (but not encouraged!)
  97. * to change their behavior accordingly. For example it might help avoiding
  98. * some chip bug.
  99. */
  100. static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
  101. {
  102. if (gadget_is_net2280(gadget))
  103. return 0x01;
  104. else if (gadget_is_dummy(gadget))
  105. return 0x02;
  106. else if (gadget_is_pxa(gadget))
  107. return 0x03;
  108. else if (gadget_is_sh(gadget))
  109. return 0x04;
  110. else if (gadget_is_sa1100(gadget))
  111. return 0x05;
  112. else if (gadget_is_goku(gadget))
  113. return 0x06;
  114. else if (gadget_is_mq11xx(gadget))
  115. return 0x07;
  116. else if (gadget_is_omap(gadget))
  117. return 0x08;
  118. else if (gadget_is_lh7a40x(gadget))
  119. return 0x09;
  120. else if (gadget_is_n9604(gadget))
  121. return 0x10;
  122. else if (gadget_is_pxa27x(gadget))
  123. return 0x11;
  124. else if (gadget_is_s3c2410(gadget))
  125. return 0x12;
  126. else if (gadget_is_at91(gadget))
  127. return 0x13;
  128. else if (gadget_is_imx(gadget))
  129. return 0x14;
  130. return -ENOENT;
  131. }