usb_std.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted (subject to the limitations in the
  7. * disclaimer below) provided that the following conditions are met:
  8. *
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. *
  12. * * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the
  15. * distribution.
  16. *
  17. * * Neither the name of Qualcomm Atheros nor the names of its
  18. * contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  22. * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
  23. * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
  24. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  25. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  30. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  31. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  32. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  33. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #ifndef USB_STD_H
  36. #define USB_STD_H
  37. #define mDEV_REQ_REQ_DIR() (ControlCmd.Direction)
  38. #define mDEV_REQ_REQ_TYPE() (ControlCmd.Type)
  39. #define mDEV_REQ_REQ_RECI() (ControlCmd.Object)
  40. #define mDEV_REQ_REQ() (ControlCmd.Request)
  41. #define mDEV_REQ_VALUE() (ControlCmd.Value)
  42. #define mDEV_REQ_VALUE_LOW() (mLOW_BYTE(mDEV_REQ_VALUE()))
  43. #define mDEV_REQ_VALUE_HIGH() (mHIGH_BYTE(mDEV_REQ_VALUE()))
  44. #define mDEV_REQ_INDEX() (ControlCmd.Index)
  45. #define mDEV_REQ_LENGTH() (ControlCmd.Length)
  46. /******************** USB Protocol Definition *************************/
  47. /* Standard Request Code (Table 9-4) */
  48. #define USB_GET_STATUS 0
  49. #define USB_CLEAR_FEATURE 1
  50. #define USB_SET_FEATURE 3
  51. #define USB_SET_ADDRESS 5
  52. #define USB_GET_DESCRIPTOR 6
  53. #define USB_SET_DESCRIPTOR 7
  54. #define USB_GET_CONFIGURATION 8
  55. #define USB_SET_CONFIGURATION 9
  56. #define USB_GET_INTERFACE 10
  57. #define USB_SET_INTERFACE 11
  58. #define USB_SYNCH_FRAME 12
  59. /* Descriptor Type (Table 9-5) */
  60. #define USB_DESC_TYPE_DEVICE 1
  61. #define USB_DESC_TYPE_CONFIG 2
  62. #define USB_DESC_TYPE_STRING 3
  63. #define USB_DESC_TYPE_INTERFACE 4
  64. #define USB_DESC_TYPE_ENDPOINT 5
  65. /* Endpoint Attribute (Table 9-10) */
  66. #define USB_EP_ATTR_CTRL 0
  67. #define USB_EP_ATTR_ISOCH 1
  68. #define USB_EP_ATTR_BULK 2
  69. #define USB_EP_ATTR_INTRPT 3
  70. /*********************** for USB 2.0 **********************************/
  71. // Table 9-5. Descriptor Types
  72. #define DT_DEVICE 1
  73. #define DT_CONFIGURATION 2
  74. #define DT_STRING 3
  75. #define DT_INTERFACE 4
  76. #define DT_ENDPOINT 5
  77. #define DT_DEVICE_QUALIFIER 6
  78. #define DT_OTHER_SPEED_CONFIGURATION 7
  79. #define DT_INTERFACE_POWER 8
  80. /**********************************************************************/
  81. // Values for bmAttributes Field in USB_CONFIGURATION_DESCRIPTOR
  82. #define USB_BUS_POWERED 0x80
  83. #define USB_SELF_POWERED 0x40
  84. #define USB_REMOTE_WAKEUP 0x20
  85. #define cUSB_REQTYPE_DIR_POS 7
  86. #define cUSB_REQTYPE_DIR_LEN 1
  87. #define cUSB_REQTYPE_TYPE_POS 5
  88. #define cUSB_REQTYPE_TYPE_LEN 2
  89. #define cUSB_REQTYPE_RX_POS 0
  90. #define cUSB_REQTYPE_RX_LEN 5
  91. /* for USB State */
  92. #define cUSB_DEFAULT_STATE 0
  93. #define cUSB_ADDRESS_STATE 1
  94. #define cUSB_CONFIG_STATE 2
  95. /* for Data transfer direction */
  96. #define bmUSB_HOST_DIR 7 /* Bit 7 */
  97. #define cUSB_DIR_HOST_OUT 0
  98. #define cUSB_DIR_HOST_IN 1
  99. /* for Type */
  100. #define cUSB_REQTYPE_STD 0
  101. #define cUSB_REQTYPE_CLASS 1
  102. #define cUSB_REQTYPE_VENDOR 2
  103. /* for Recipient */
  104. #define cUSB_REQTYPE_DEVICE 0
  105. #define cUSB_REQTYPE_INTERFACE 1
  106. #define cUSB_REQTYPE_ENDPOINT 2
  107. #define cUSB_REQTYPE_OTHER 3
  108. /* for Descriptor Type */
  109. #define cUSB_DESTYPE_DEVICE 1
  110. #define cUSB_DESTYPE_CONFIG 2
  111. #define cUSB_DESTYPE_STRING 3
  112. #define cUSB_DESTYPE_INTERFACE 4
  113. #define cUSB_DESTYPE_ENDPOINT 5
  114. #define cUSB_DESTYPE_END cUSB_DESTYPE_ENDPOINT // for range check
  115. /* for Feature selector */
  116. #define cUSB_FEATSEL_RMWAKEUP 0
  117. #define cUSB_FEATSEL_EPHAL 1
  118. #define cUSB_FEATSEL_END cUSB_FEATSEL_EPHAL // for range check
  119. #define bmREQ_RECI 0
  120. #define bmwREQ_RECI 5 // mMASKS(bmwREQ_RECI, bmREQ_RECI)
  121. #define bmREQ_TYPE 5
  122. #define bmwREQ_TYPE 2 // mMASKS(bmwREQ_TYPE, bmREQ_TYPE)
  123. #define bmREQ_DIR 7
  124. #define bmwREQ_DIR 1
  125. #endif