drv_usb.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _DRV_USB_H_
  13. #define _DRV_USB_H_
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #include <stdbool.h>
  18. #include <osi_api.h>
  19. #include "hal_config.h"
  20. #include "quec_proj_config.h"
  21. #define USB_VID_SPRD (0x1782)
  22. #define USB_VID_RDA_DOWNLOAD (0x0525)
  23. #define USB_PID_RDA_DOWNLOAD (0xa4a7)
  24. #define USB_PID_SERIALS (0x4d10)
  25. #define USB_PID_RNDIS_AND_SERIALS (0x4d11)
  26. #define USB_PID_NPI_SERIAL (0x4d12)
  27. #define USB_PID_ECM_AND_SERIALS (0x4d13)
  28. #define USB_PID_ECM_ACM_SERIAL (0x4d15)
  29. //8850
  30. #define USB_PID_8850_SERIALS (0x4d17)
  31. #define USB_PID_8850_ACM_SERIALS (0x4d18)
  32. #define USB_PID_8850_RNDIS_AND_SERIALS (0x4d19)
  33. #define USB_PID_8850_ECM_AND_SERIALS (0x4d20)
  34. #define USB_PID_8850_NPI_SERIAL (0x4d30)
  35. #ifdef CONFIG_QUEC_PROJECT_FEATURE
  36. #define QUEC_USB_VID_DEFAULT (0x2c7c)
  37. #define QUEC_USB_PID_DEFAULT (0x0904)
  38. #endif
  39. enum usb_detect_mode
  40. {
  41. USB_DETMODE_CHARGER = 0,
  42. USB_DETMODE_AON = 1,
  43. };
  44. typedef enum
  45. {
  46. DRV_USB_CHARGER_ONLY = 0,
  47. DRV_USB_RDA_ROM_SERIAL, // [USL0], (0525, a4a7)
  48. DRV_USB_SERIALS, // [USL[0-7]], (1782, 4d10)
  49. DRV_USB_RNDIS_AND_SERIALS, // [RNDIS, USL[0-7]], (1782, 4d11)
  50. DRV_USB_NPI_SERIAL, // [USL1], (1782, 4d12)
  51. DRV_USB_ECM_AND_SERIALS, // [ECM, USL[0-7]], (1782, 4d11)
  52. DRV_USB_ECM_ACM_SERIALS, // [ECM, USL0, USL4, ACM0, ACM1, ACM2, ACM3], (1782, 4d15)
  53. DRV_USB_SINGLE_INTF_START, // single interface work mode start
  54. DRV_USB_RNDIS_ONLY = DRV_USB_SINGLE_INTF_START, // (1782, 4d11)
  55. DRV_USB_ECM_ONLY, // (1782, 4d11)
  56. DRV_USB_MTP_ONLY, // (1782, 4d11)
  57. DRV_USB_SINGLE_INTF_END = DRV_USB_MTP_ONLY, // single interface work mode end
  58. DRV_USB_WORK_MODE_NUM,
  59. } drvUsbWorkMode_t;
  60. typedef enum
  61. {
  62. DRV_8850USB_CHARGER_ONLY,
  63. DRV_8850USB_ACM_SERIALS,
  64. DRV_8850USB_SERIALS,
  65. DRV_8850USB_RNDIS_AND_SERIALS,
  66. DRV_8850USB_NPI_SERIAL,
  67. DRV_8850USB_ECM_AND_SERIALS,
  68. DRV_8850USB_ECM_ACM_SERIALS,
  69. DRV_8850USB_RNDIS_ONLY,
  70. DRV_8850USB_ECM_ONLY,
  71. DRV_8850USB_MTP_ONLY,
  72. DRV_8850USB_WORK_MODE_NUM,
  73. } drvUsbWorkMode_8850_t;
  74. /**
  75. * @brief Init usb module, assert if fail
  76. */
  77. void drvUsbInit();
  78. /**
  79. * @brief Get usb work queue
  80. *
  81. * This work queue should only be used by USB class drivers.
  82. *
  83. * @return usb work queue
  84. */
  85. osiWorkQueue_t *drvUsbWorkQueue();
  86. /**
  87. * @brief Set USB work mode
  88. *
  89. * If it is the same as current mode, do nothing.
  90. * Else if USB is working, stop it thereafter reset mode.
  91. *
  92. * @param mode usb work mode
  93. * @return
  94. * - true success
  95. * - false not support or fail
  96. */
  97. bool drvUsbSetWorkMode(drvUsbWorkMode_t mode);
  98. /**
  99. * @brief Mtp notify vfs to change file
  100. */
  101. void MtpNotify();
  102. /**
  103. * @brief Set USB work mode
  104. *
  105. * 8850 FPGA USB NPI SERIASL DEBUG
  106. *
  107. * @param mode usb work mode
  108. * @return
  109. * - true success
  110. * - false fail
  111. */
  112. bool setNPISerial();
  113. /**
  114. * @brief Set USB work mode
  115. *
  116. * 8850 FPGA USB SERIASLS DEBUG
  117. *
  118. * @param mode usb work mode
  119. * @return
  120. * - true success
  121. * - false fail
  122. */
  123. bool setSerials();
  124. /**
  125. * @brief Set USB work mode
  126. *
  127. * 8850 FPGA USB ACM SERIASLS DEBUG
  128. *
  129. * @param mode usb work mode
  130. * @return
  131. * - true success
  132. * - false fail
  133. */
  134. bool setACMSerials();
  135. /**
  136. * @brief Set USB work mode
  137. *
  138. * 8850 FPGA USB ECM DEBUG
  139. *
  140. * @param mode usb work mode
  141. * @return
  142. * - true success
  143. * - false fail
  144. */
  145. bool setEcm();
  146. /**
  147. * @brief Set USB work mode
  148. *
  149. * 8850 FPGA USB RNDIS DEBUG
  150. *
  151. * @param mode usb work mode
  152. * @return
  153. * - true success
  154. * - false fail
  155. */
  156. bool setRndis();
  157. /**
  158. * @brief Get current USB work mode
  159. *
  160. * @return current work mode
  161. */
  162. drvUsbWorkMode_t drvUsbCurrentMode();
  163. /**
  164. * @brief Set 8850 USB work mode
  165. *
  166. * If it is the same as current mode, do nothing.
  167. * Else if USB is working, stop it thereafter reset mode.
  168. *
  169. * @param mode usb work mode
  170. * @return
  171. * - true success
  172. * - false not support or fail
  173. */
  174. bool drv8850UsbSetWorkMode(drvUsbWorkMode_8850_t mode);
  175. /**
  176. * @brief Get current 8850 USB work mode
  177. *
  178. * @return current work mode
  179. */
  180. drvUsbWorkMode_8850_t drv8850UsbCurrentMode();
  181. /**
  182. * @brief the Usb is connected to host or not
  183. * @return
  184. * - true connected
  185. * - flase not connect
  186. */
  187. bool drvUsbIsConnected();
  188. /**
  189. * @brief Enable usb feature
  190. *
  191. * @param debounce debounce time in milliseconds
  192. */
  193. void drvUsbEnable(uint32_t debounce);
  194. /**
  195. * @brief Disable usb feature
  196. */
  197. void drvUsbDisable();
  198. /**
  199. * @brief Enable 8850 usb feature
  200. *
  201. * @param debounce debounce time in milliseconds
  202. */
  203. void drvmUsbEnable();
  204. /**
  205. * @brief Disable 8850 usb feature
  206. */
  207. void drvmUsbDisable();
  208. /**
  209. * @brief reset usb feature
  210. */
  211. void drvUsbReset();
  212. /**
  213. * @brief Check usb is enabled or not
  214. *
  215. * @return enabled if true else false
  216. */
  217. bool drvUsbIsEnabled();
  218. /**
  219. * @brief wakeup the host
  220. *
  221. * @return false if not support else true
  222. */
  223. bool drvUsbRemoteWakeup();
  224. /**
  225. * @brief set usb cable attached
  226. *
  227. * @param attach usb cable attached
  228. */
  229. void drvUsbSetAttach(bool attach);
  230. /**
  231. * @brief usb suspend or other status
  232. *
  233. * @return false if not support else true
  234. */
  235. bool drvUsbIsSuspend();
  236. #ifdef __cplusplus
  237. }
  238. #endif
  239. #endif // _DRV_USB_H_