dwc2_compat.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #ifndef _DWC2_COMPAT_H
  2. #define _DWC2_COMPAT_H
  3. /* OTG defines lots of enumeration states before device reset */
  4. enum usb_otg_state {
  5. OTG_STATE_UNDEFINED = 0,
  6. /* single-role peripheral, and dual-role default-b */
  7. OTG_STATE_B_IDLE,
  8. OTG_STATE_B_SRP_INIT,
  9. OTG_STATE_B_PERIPHERAL,
  10. /* extra dual-role default-b states */
  11. OTG_STATE_B_WAIT_ACON,
  12. OTG_STATE_B_HOST,
  13. /* dual-role default-a */
  14. OTG_STATE_A_IDLE,
  15. OTG_STATE_A_WAIT_VRISE,
  16. OTG_STATE_A_WAIT_BCON,
  17. OTG_STATE_A_HOST,
  18. OTG_STATE_A_SUSPEND,
  19. OTG_STATE_A_PERIPHERAL,
  20. OTG_STATE_A_WAIT_VFALL,
  21. OTG_STATE_A_VBUS_ERR,
  22. };
  23. enum usb_dr_mode {
  24. USB_DR_MODE_UNKNOWN,
  25. USB_DR_MODE_HOST,
  26. USB_DR_MODE_PERIPHERAL,
  27. USB_DR_MODE_OTG,
  28. };
  29. #define URB_DIR_IN 0x0200 /* Transfer from device to host */
  30. #define URB_DIR_OUT 0
  31. #define URB_DIR_MASK URB_DIR_IN
  32. #define URB_DMA_MAP_SINGLE 0x00010000 /* Non-scatter-gather mapping */
  33. #define URB_DMA_MAP_PAGE 0x00020000 /* HCD-unsupported S-G */
  34. #define URB_DMA_MAP_SG 0x00040000 /* HCD-supported S-G */
  35. #define URB_MAP_LOCAL 0x00080000 /* HCD-local-memory mapping */
  36. #define URB_SETUP_MAP_SINGLE 0x00100000 /* Setup packet DMA mapped */
  37. #define URB_SETUP_MAP_LOCAL 0x00200000 /* HCD-local setup packet */
  38. #define URB_DMA_SG_COMBINED 0x00400000 /* S-G entries were combined */
  39. #define URB_ALIGNED_TEMP_BUFFER 0x00800000 /* Temp buffer was alloc'd */
  40. #define USB_RESUME_TIMEOUT 40 /* ms */
  41. /* class requests from the USB 2.0 hub spec, table 11-15 */
  42. #define HUB_CLASS_REQ(dir, type, request) ((((dir) | (type)) << 8) | (request))
  43. /* GetBusState and SetHubDescriptor are optional, omitted */
  44. #define ClearHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_CLEAR_FEATURE)
  45. #define ClearPortFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_CLEAR_FEATURE)
  46. #define GetHubDescriptor HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, USB_REQ_GET_DESCRIPTOR)
  47. #define GetHubStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, USB_REQ_GET_STATUS)
  48. #define GetPortStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, USB_REQ_GET_STATUS)
  49. #define SetHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_SET_FEATURE)
  50. #define SetPortFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_SET_FEATURE)
  51. /*
  52. * Port feature numbers
  53. * See USB 2.0 spec Table 11-17
  54. */
  55. #define USB_PORT_FEAT_CONNECTION 0
  56. #define USB_PORT_FEAT_ENABLE 1
  57. #define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */
  58. #define USB_PORT_FEAT_OVER_CURRENT 3
  59. #define USB_PORT_FEAT_RESET 4
  60. #define USB_PORT_FEAT_L1 5 /* L1 suspend */
  61. #define USB_PORT_FEAT_POWER 8
  62. #define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */
  63. #define USB_PORT_FEAT_C_CONNECTION 16
  64. #define USB_PORT_FEAT_C_ENABLE 17
  65. #define USB_PORT_FEAT_C_SUSPEND 18
  66. #define USB_PORT_FEAT_C_OVER_CURRENT 19
  67. #define USB_PORT_FEAT_C_RESET 20
  68. #define USB_PORT_FEAT_TEST 21
  69. #define USB_PORT_FEAT_INDICATOR 22
  70. #define USB_PORT_FEAT_C_PORT_L1 23
  71. /*
  72. * wPortChange bit field
  73. * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10
  74. * Bits 0 to 5 shown, bits 6 to 15 are reserved
  75. */
  76. #define USB_PORT_STAT_C_CONNECTION 0x0001
  77. #define USB_PORT_STAT_C_ENABLE 0x0002
  78. #define USB_PORT_STAT_C_SUSPEND 0x0004
  79. #define USB_PORT_STAT_C_OVERCURRENT 0x0008
  80. #define USB_PORT_STAT_C_RESET 0x0010
  81. #define USB_PORT_STAT_C_L1 0x0020
  82. /*
  83. * wPortStatus bit field
  84. * See USB 2.0 spec Table 11-21
  85. */
  86. #define USB_PORT_STAT_CONNECTION 0x0001
  87. #define USB_PORT_STAT_ENABLE 0x0002
  88. #define USB_PORT_STAT_SUSPEND 0x0004
  89. #define USB_PORT_STAT_OVERCURRENT 0x0008
  90. #define USB_PORT_STAT_RESET 0x0010
  91. #define USB_PORT_STAT_L1 0x0020
  92. /* bits 6 to 7 are reserved */
  93. #define USB_PORT_STAT_POWER 0x0100
  94. #define USB_PORT_STAT_LOW_SPEED 0x0200
  95. #define USB_PORT_STAT_HIGH_SPEED 0x0400
  96. #define USB_PORT_STAT_TEST 0x0800
  97. #define USB_PORT_STAT_INDICATOR 0x1000
  98. /* bits 13 to 15 are reserved */
  99. /*
  100. * wHubCharacteristics (masks)
  101. * See USB 2.0 spec Table 11-13, offset 3
  102. */
  103. #define HUB_CHAR_LPSM 0x0003 /* Logical Power Switching Mode mask */
  104. #define HUB_CHAR_COMMON_LPSM 0x0000 /* All ports power control at once */
  105. #define HUB_CHAR_INDV_PORT_LPSM 0x0001 /* per-port power control */
  106. #define HUB_CHAR_NO_LPSM 0x0002 /* no power switching */
  107. #define HUB_CHAR_COMPOUND 0x0004 /* hub is part of a compound device */
  108. #define HUB_CHAR_OCPM 0x0018 /* Over-Current Protection Mode mask */
  109. #define HUB_CHAR_COMMON_OCPM 0x0000 /* All ports Over-Current reporting */
  110. #define HUB_CHAR_INDV_PORT_OCPM 0x0008 /* per-port Over-current reporting */
  111. #define HUB_CHAR_NO_OCPM 0x0010 /* No Over-current Protection support */
  112. #define HUB_CHAR_TTTT 0x0060 /* TT Think Time mask */
  113. #define HUB_CHAR_PORTIND 0x0080 /* per-port indicators (LEDs) */
  114. #endif