usb_aotg_lark.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. /*
  2. * Copyright (c) 2020 Actions Corporation.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file
  8. * @brief USB Actions OTG controller (lark) driver private definitions
  9. *
  10. * This file contains the Actions OTG USB controller (lark) driver private
  11. * definitions.
  12. */
  13. #ifndef __USB_AOTG_LARK_H__
  14. #define __USB_AOTG_LARK_H__
  15. #include <soc_regs.h>
  16. #include <soc_irq.h>
  17. /* USB IN EP index */
  18. enum usb_aotg_in_ep_idx {
  19. USB_AOTG_IN_EP_0 = 0,
  20. USB_AOTG_IN_EP_1,
  21. USB_AOTG_IN_EP_2,
  22. USB_AOTG_IN_EP_3,
  23. USB_AOTG_IN_EP_4,
  24. USB_AOTG_IN_EP_NUM
  25. };
  26. /* USB OUT EP index */
  27. enum usb_aotg_out_ep_idx {
  28. USB_AOTG_OUT_EP_0 = 0,
  29. USB_AOTG_OUT_EP_1,
  30. USB_AOTG_OUT_EP_2,
  31. USB_AOTG_OUT_EP_3,
  32. USB_AOTG_OUT_EP_4,
  33. USB_AOTG_OUT_EP_NUM
  34. };
  35. /*********************************** Common **********************************/
  36. /* FIFO Clock */
  37. #define USB_MEM_CLK CMU_MEMCLKSRC1
  38. #define USB_RAM_CLKSRC_BIT 8
  39. #define USB_MEM_CLK_EN CMU_MEMCLKEN1
  40. #define USB_RAM_CLKEN_BIT 8
  41. /* USB AOTG IRQ line */
  42. #define USB_AOTG_IRQ IRQ_ID_USB
  43. /*********************************** Global **********************************/
  44. /* USB AOTG Base Address */
  45. #define USB_AOTG_BASE 0x40050000
  46. /* USB AVDD Control */
  47. #define UAVDDCTL (USB_AOTG_BASE+0x428)
  48. #define USB_VDD UAVDDCTL
  49. #define USB_VDD_EN 6
  50. #define USB_VDD_VOLTAGE_MASK 0x7f
  51. /* defalut output voltage: 1.10V */
  52. #define USB_VDD_VOLTAGE_DEFAULT (0x1 << 4)
  53. /** Debug */
  54. #define USBDEBUG (USB_AOTG_BASE + 0x427)
  55. #define USBDEBUG_EN 4
  56. #define USBDEBUG_MODE_MASK 0x0F
  57. /* Testing */
  58. #define BKDOOR (USB_AOTG_BASE + 0x40D)
  59. #define HS_DISABLE 7
  60. /** Line Status */
  61. #define LINESTATUS (USB_AOTG_BASE + 0x422)
  62. #define LINE_DM 4
  63. #define LINE_DP 3
  64. #define LINESTATE_MASK (0x3 << 3)
  65. #define LINESTATE_DM (1 << LINE_DM)
  66. #define LINESTATE_DP (1 << LINE_DP)
  67. #define OTGRESET 0
  68. /** DPDM */
  69. #define DPDMCTRL (USB_AOTG_BASE + 0x421)
  70. /* plug-in (connect/disconnect) */
  71. #define PLUGIN 6
  72. /* Line status detect enable (default: enable) */
  73. #define LSDETEN 4
  74. /* 500K pull-up enable */
  75. #define DM_PULL_UP 3
  76. #define DP_PULL_UP 2
  77. /* 15K pull-down disable */
  78. #define DM_PULL_DOWN 1
  79. #define DP_PULL_DOWN 0
  80. #define DPDM_DEVICE (0x1F)
  81. #define DPDM_HOST (0x10)
  82. /** Idpin & Vbus */
  83. #define IDVBUSCTRL (USB_AOTG_BASE + 0x420)
  84. #define SOFT_IDPIN 3
  85. #define SOFT_IDEN 2
  86. #define IDVBUS_DEVICE (0x0C)
  87. #define IDVBUS_HOST (0x04)
  88. /** Auto In mode IN Token timer */
  89. #define AUTOINTIMER (USB_AOTG_BASE + 0x410)
  90. /** USB Control and Status */
  91. #define USBCS (USB_AOTG_BASE + 0x1A3)
  92. /* Soft disconnect */
  93. #define USBCS_DISCONN 6
  94. /* Remote wakeup */
  95. #define USBCS_WAKEUP 5
  96. #define USBCS_SPEED 1
  97. #define USBCS_LS 0
  98. /** Device Address */
  99. #define FNADDR (USB_AOTG_BASE + 0x1A6)
  100. /* USB Clock Gate */
  101. #define USBCLKGATE (USB_AOTG_BASE + 0x1A7)
  102. #define CLKGATE_SUSPEND 0
  103. /** USB OTG FSM State */
  104. #define USBSTATE (USB_AOTG_BASE + 0x1BD)
  105. /* Alias */
  106. #define OTGSTATE USBSTATE
  107. #define OTG_A_IDLE 0x0
  108. #define OTG_A_WAIT_BCON 0x2
  109. #define OTG_A_HOST 0x3
  110. #define OTG_A_SUSPEND 0x4
  111. #define OTG_B_IDLE 0x8
  112. #define OTG_B_PERIPHERAL 0x9
  113. /** USB OTG FSM Control */
  114. #define USBCTRL (USB_AOTG_BASE + 0x1BE)
  115. /* Alias */
  116. #define OTGCTRL USBCTRL
  117. #define OTGCTRL_FORCE 7
  118. #define OTGCTRL_BUSREQ 0
  119. /** USB Status */
  120. #define USBSTATUS (USB_AOTG_BASE + 0x1BF)
  121. /* 0: mini-A; 1: mini-B */
  122. #define USBSTATUS_ID 6
  123. #define USBSTATUS_CONN 1
  124. /************************************ IRQ ************************************/
  125. /** USB Core */
  126. #define USBIEN (USB_AOTG_BASE + 0x198)
  127. #define USBIEN_NTR 6
  128. #define USBIEN_HS 5
  129. #define USBIEN_RESET 4
  130. #define USBIEN_SUSPEND 3
  131. #define USBIEN_TOKEN 2
  132. #define USBIEN_SOF 1
  133. #define USBIEN_SETUP 0
  134. #define USBIRQ (USB_AOTG_BASE + 0x18C)
  135. #define USBIRQ_NTR 6
  136. /* High-speed */
  137. #define USBIRQ_HS 5
  138. /* USB Bus Reset */
  139. #define USBIRQ_RESET 4
  140. /* Suspend Signal */
  141. #define USBIRQ_SUSPEND 3
  142. /* SETUP Token */
  143. #define USBIRQ_TOKEN 2
  144. /* SOF Packet */
  145. #define USBIRQ_SOF 1
  146. /* SETUP Data */
  147. #define USBIRQ_SETUP 0
  148. /** OTG FSM */
  149. #define OTGIEN (USB_AOTG_BASE + 0x1C0)
  150. /* a_peripheral/b_peripheral */
  151. #define OTGIEN_PERIPHERAL 4
  152. /* a_host/b_host */
  153. #define OTGIEN_LOCSOF 2
  154. /* a_idle/b_idle */
  155. #define OTGIEN_IDLE 0
  156. #define OTGIRQ (USB_AOTG_BASE + 0x1BC)
  157. #define OTGIRQ_PERIPHERAL 4
  158. #define OTGIRQ_LOCSOF 2
  159. #define OTGIRQ_IDLE 0
  160. /** Specific OTG FSM IRQ */
  161. #define OTGSTATE_IEN (USB_AOTG_BASE + 0x405)
  162. #define OTGSTATE_IRQ (USB_AOTG_BASE + 0x404)
  163. #define OTGSTATE_B_WAIT_ACON 2
  164. #define OTGSTATE_A_WAIT_BCON 1
  165. #define OTGSTATE_A_SUSPEND 0
  166. /** USB External Interrupt request */
  167. #define USBEIRQ (USB_AOTG_BASE + 0x400)
  168. /* Alias: same register */
  169. #define USBEIEN USBEIRQ
  170. /* External */
  171. #define USBEIRQ_EXTERN 7
  172. /* Wakeup */
  173. #define USBEIRQ_WAKEUP 6
  174. /* Resume */
  175. #define USBEIRQ_RESUME 5
  176. /* Connnect/disconnect */
  177. #define USBEIRQ_CONDISC 4
  178. /* External */
  179. #define USBEIEN_EXTERN 3
  180. /* Wakeup */
  181. #define USBEIEN_WAKEUP 2
  182. /* Resume */
  183. #define USBEIEN_RESUME 1
  184. /* Connnect/disconnect */
  185. #define USBEIEN_CONDISC 0
  186. #define USBEIEN_MASK (0x0f)
  187. #define USBEIRQ_MASK (0xf0)
  188. /** Interrupt Vector */
  189. #define IVECT (USB_AOTG_BASE + 0x1A0)
  190. /* Device */
  191. /* Setup Data */
  192. #define UIV_SUDAV 0x00
  193. #define UIV_SOF 0x04
  194. /* Setup Token */
  195. #define UIV_SUTOK 0x08
  196. #define UIV_SUSPEND 0x0c
  197. #define UIV_USBRST 0x10
  198. #define UIV_HSPEED 0x14
  199. /* Endpoint */
  200. #define UIV_HCOUT0ERR 0x16
  201. #define UIV_EP0IN 0x18
  202. #define UIV_HCIN0ERR 0x1a
  203. #define UIV_EP0OUT 0x1c
  204. #define UIV_EP0PING 0x20
  205. #define UIV_HCOUT1ERR 0x22
  206. #define UIV_EP1IN 0x24
  207. #define UIV_HCIN1ERR 0x26
  208. #define UIV_EP1OUT 0x28
  209. #define UIV_EP1PING 0x2c
  210. #define UIV_HCOUT2ERR 0x2e
  211. #define UIV_EP2IN 0x30
  212. #define UIV_HCIN2ERR 0x32
  213. #define UIV_EP2OUT 0x34
  214. #define UIV_EP2PING 0x38
  215. #define UIV_HCOUT3ERR 0x3a
  216. #define UIV_EP3IN 0x3c
  217. #define UIV_HCIN3ERR 0x3e
  218. #define UIV_EP3OUT 0x40
  219. #define UIV_EP3PING 0x44
  220. #define UIV_HCOUT4ERR 0x46
  221. #define UIV_EP4IN 0x48
  222. #define UIV_HCIN4ERR 0x4A
  223. #define UIV_EP4OUT 0x4C
  224. #define UIV_EP4PING 0x50
  225. /* IN Token */
  226. #define UIV_INTOKEN 0xe0
  227. /* OUT Token */
  228. #define UIV_OUTTOKEN 0xe4
  229. #define UIV_OTGIRQ 0xd8
  230. /* Controller */
  231. #define UIV_RESUME 0xe6
  232. #define UIV_CONDISC 0xe8
  233. /* OTG */
  234. #define UIV_OTGSTATE 0xea
  235. /* EP OUT Short Packet */
  236. #define UIV_EPOUTSHTPKT 0xec
  237. #define UIV_HCINEND 0xee
  238. #define UIV_HCOUTEMPTY 0xf0
  239. #define UIV_NTR 0xf2
  240. #define UIV_EPIN_VEC2ADDR(vector) ((vector - UIV_EP0IN) / 12)
  241. #define UIV_EPOUT_VEC2ADDR(vector) ((vector - UIV_EP0OUT) / 12)
  242. #define UIV_HCINERR_VEC2ADDR(vector) ((vector - UIV_HCIN0ERR) / 12)
  243. #define UIV_HCOUTERR_VEC2ADDR(vector) ((vector - UIV_HCOUT0ERR) / 12)
  244. /** Endpoint Interrupt request */
  245. /* OUT IRQ */
  246. #define OUT04IEN (USB_AOTG_BASE + 0x196)
  247. #define OUTIEN OUT04IEN
  248. #define OUT04IRQ (USB_AOTG_BASE + 0x18A)
  249. #define OUTIRQ OUT04IRQ
  250. #define IRQ_EP0OUT 0
  251. #define IRQ_EP1OUT 1
  252. #define IRQ_EP2OUT 2
  253. #define IRQ_EP3OUT 3
  254. #define IRQ_EPxOUT(ep) (ep)
  255. /** OUT Endpoints Short Packet Control */
  256. #define OUT_SHTPKT (USB_AOTG_BASE + 0x401)
  257. #define IRQ_EP4OUT_SHTPKT 4
  258. #define IRQ_EP3OUT_SHTPKT 3
  259. #define IRQ_EP2OUT_SHTPKT 2
  260. #define IRQ_EP1OUT_SHTPKT 1
  261. /* IN IRQ */
  262. #define IN04IEN (USB_AOTG_BASE + 0x194)
  263. #define INIEN IN04IEN
  264. #define IN04IRQ (USB_AOTG_BASE + 0x188)
  265. #define INIRQ IN04IRQ
  266. #define IRQ_EP0IN 0
  267. #define IRQ_EP1IN 1
  268. #define IRQ_EP2IN 2
  269. #define IRQ_EP3IN 3
  270. #define IRQ_EP4IN 3
  271. #define IRQ_EPxIN(ep) (ep)
  272. #define INEMPTY_IRQ (USB_AOTG_BASE + 0x402)
  273. #define INEMPTY_IEN (USB_AOTG_BASE + 0x403)
  274. #define IRQ_IN4EMPTY 4
  275. #define IRQ_IN3EMPTY 3
  276. #define IRQ_IN2EMPTY 2
  277. #define IRQ_IN1EMPTY 1
  278. #define IEN_IN4EMPTY 4
  279. #define IEN_IN3EMPTY 3
  280. #define IEN_IN2EMPTY 2
  281. #define IEN_IN1EMPTY 1
  282. #define IRQ_INxEMPTY(ep) (ep)
  283. #define IEN_INxEMPTY(ep) (ep)
  284. #define INEMPTY_IRQ_MASK (0x1e)
  285. #define INEMPTY_IEN_MASK (0x1e)
  286. #define INEMPTY_IRQ_SHIFT 1
  287. #define INEMPTY_IEN_SHIFT 1
  288. /* shift to base 0 */
  289. #define INEMPTY_IRQ2ADDR(bit) (bit + 1)
  290. #define INEMPTY_IEN2ADDR(bit) (bit + 1)
  291. /** IN Token IRQ */
  292. #define IN04TOKIEN (USB_AOTG_BASE + 0x19C)
  293. #define IN_TOKIEN IN04TOKIEN
  294. #define IN04TOKIRQ (USB_AOTG_BASE + 0x190)
  295. #define IN_TOKIRQ IN04TOKIRQ
  296. #define EP0IN_TOKEN 0
  297. #define EP1IN_TOKEN 1
  298. #define EP2IN_TOKEN 2
  299. #define EP3IN_TOKEN 3
  300. #define EP4IN_TOKEN 4
  301. #define EPIN_TOKEN_NUM 5
  302. #define EPIN_TOKEN_MASK 0x1F
  303. /** OUT Token IRQ */
  304. #define OUT04TOKIEN (USB_AOTG_BASE + 0x19D)
  305. #define OUT_TOKIEN OUT04TOKIEN
  306. #define OUT04TOKIRQ (USB_AOTG_BASE + 0x191)
  307. #define OUT_TOKIRQ OUT04TOKIRQ
  308. #define EP0OUT_TOKEN 0
  309. #define EP1OUT_TOKEN 1
  310. #define EP2OUT_TOKEN 2
  311. #define EP3OUT_TOKEN 3
  312. #define EP4OUT_TOKEN 4
  313. #define EPOUT_TOKEN_NUM 5
  314. #define EPOUT_TOKEN_MASK 0x1F
  315. /************************************ FIFO ***********************************/
  316. /*
  317. * AOTG USB Controller FIFO layout (add by order...)
  318. * Luckily, we don't need to take care of ep0 FIFO.
  319. *
  320. * URAM0 FIFO (only for ep1-in dma): 2KB [0x0, 0x800)
  321. * URAM1 FIFO (only for ep2-out dma): 2KB [0x800, 0x1000)
  322. * URAM2 FIFO (for ep1-out, ep2-in, ep3-in/out ep4-in/out cpu): 4KB [0x1000, 0x1FFF)
  323. * URAM3 FIFO (only for ep0): 128-byte
  324. */
  325. /* FIFO start address */
  326. #define URAM0_FIFO_START 0x0
  327. #define URAM1_FIFO_START 0x800
  328. #define URAM2_FIFO_START 0x1000
  329. #define NORMAL_FIFO_START URAM2_FIFO_START
  330. /* Arbitrary single independent FIFO block size */
  331. #define NORMAL_FIFO_BLOCK 512
  332. /*
  333. * Arbitrary allocaction for NORMAL_FIFO_START, need to optimize!
  334. */
  335. #define EP1IN_FIFO_START URAM0_FIFO_START
  336. #define EP2OUT_FIFO_START URAM1_FIFO_START
  337. #define EP1OUT_FIFO_START NORMAL_FIFO_START
  338. #define EP2IN_FIFO_START (NORMAL_FIFO_START + NORMAL_FIFO_BLOCK)
  339. #define EP3OUT_FIFO_START (NORMAL_FIFO_START + NORMAL_FIFO_BLOCK * 2)
  340. #define EP3IN_FIFO_START (NORMAL_FIFO_START + NORMAL_FIFO_BLOCK * 3)
  341. #define EP4OUT_FIFO_START (NORMAL_FIFO_START + NORMAL_FIFO_BLOCK * 4)
  342. #define EP4IN_FIFO_START (NORMAL_FIFO_START + NORMAL_FIFO_BLOCK * 6)
  343. /** FIFO Control */
  344. #define FIFOCTRL (USB_AOTG_BASE + 0x1A8)
  345. /* FIFO Auto */
  346. #define FIFOCTRL_AUTO 5
  347. /* FIFO Direction */
  348. #define FIFOCTRL_IO_IN 4
  349. /* Endpoint address */
  350. #define FIFOCTRL_NUM_MASK 0x0F
  351. /** FIFO Data */
  352. #define FIFO1DAT (USB_AOTG_BASE + 0x084)
  353. #define FIFO2DAT (USB_AOTG_BASE + 0x088)
  354. #define FIFO3DAT (USB_AOTG_BASE + 0x08C)
  355. #define FIFO4DAT (USB_AOTG_BASE + 0x090)
  356. #define FIFOxDAT(ep) (FIFO1DAT + (ep - 1) * 4)
  357. /** FIFO Address */
  358. #define EP1OUT_STADDR (USB_AOTG_BASE + 0x304)
  359. #define EP2OUT_STADDR (USB_AOTG_BASE + 0x308)
  360. #define EP3OUT_STADDR (USB_AOTG_BASE + 0x30C)
  361. #define EP4OUT_STADDR (USB_AOTG_BASE + 0x310)
  362. #define EPxOUT_STADDR(ep) (EP1OUT_STADDR + (ep - 1) * 4)
  363. #define EP1IN_STADDR (USB_AOTG_BASE + 0x344)
  364. #define EP2IN_STADDR (USB_AOTG_BASE + 0x348)
  365. #define EP3IN_STADDR (USB_AOTG_BASE + 0x34C)
  366. #define EP4IN_STADDR (USB_AOTG_BASE + 0x350)
  367. #define EPxIN_STADDR(ep) (EP1IN_STADDR + (ep - 1) * 4)
  368. /** Ep0 In Data */
  369. #define EP0INDATA (USB_AOTG_BASE + 0x100)
  370. #define EP0IN_FIFO EP0INDATA
  371. /** Ep0 Out Data */
  372. #define EP0OUTDATA (USB_AOTG_BASE + 0x140)
  373. #define EP0OUT_FIFO EP0OUTDATA
  374. /** Setup Data */
  375. #define SETUPDAT0 (USB_AOTG_BASE + 0x180)
  376. #define SETUPDAT1 (USB_AOTG_BASE + 0x181)
  377. #define SETUPDAT2 (USB_AOTG_BASE + 0x182)
  378. #define SETUPDAT3 (USB_AOTG_BASE + 0x183)
  379. #define SETUPDAT4 (USB_AOTG_BASE + 0x184)
  380. #define SETUPDAT5 (USB_AOTG_BASE + 0x185)
  381. #define SETUPDAT6 (USB_AOTG_BASE + 0x186)
  382. #define SETUPDAT7 (USB_AOTG_BASE + 0x187)
  383. #define SETUP_FIFO SETUPDAT0
  384. /** Byte Counter */
  385. #define OUT0BC (USB_AOTG_BASE + 0x000)
  386. #define IN0BC (USB_AOTG_BASE + 0x001)
  387. /* Out Endpoint */
  388. #define OUT1BCL (USB_AOTG_BASE + 0x008)
  389. #define OUT1BCH (USB_AOTG_BASE + 0x009)
  390. #define OUT1BC OUT1BCL
  391. #define OUT2BCL (USB_AOTG_BASE + 0x010)
  392. #define OUT2BCH (USB_AOTG_BASE + 0x011)
  393. #define OUT2BC OUT2BCL
  394. #define OUT3BCL (USB_AOTG_BASE + 0x018)
  395. #define OUT3BCH (USB_AOTG_BASE + 0x019)
  396. #define OUT3BC OUT3BCL
  397. #define OUT4BCL (USB_AOTG_BASE + 0x020)
  398. #define OUT4BCH (USB_AOTG_BASE + 0x021)
  399. #define OUT4BC OUT4BCL
  400. #define OUTxBC(ep) (OUT1BC + (ep - 1) * 8)
  401. /* In Endpoint */
  402. #define IN1BCL (USB_AOTG_BASE + 0x00C)
  403. #define IN1BCH (USB_AOTG_BASE + 0x00D)
  404. #define IN1BC IN1BCL
  405. #define IN2BCL (USB_AOTG_BASE + 0x014)
  406. #define IN2BCH (USB_AOTG_BASE + 0x015)
  407. #define IN2BC IN2BCL
  408. #define IN3BCL (USB_AOTG_BASE + 0x01C)
  409. #define IN3BCH (USB_AOTG_BASE + 0x01D)
  410. #define IN3BC IN3BCL
  411. #define IN4BCL (USB_AOTG_BASE + 0x024)
  412. #define IN4BCH (USB_AOTG_BASE + 0x025)
  413. #define IN4BC IN4BCL
  414. #define INxBC(ep) (IN1BC + (ep - 1) * 8)
  415. #define INxBCL(ep) (IN1BCL + (ep - 1) * 8)
  416. #define INxBCH(ep) (IN1BCH + (ep - 1) * 8)
  417. /************************************ HCD ***********************************/
  418. /** Host Endpoint Control */
  419. #define HCEP0CTRL (USB_AOTG_BASE + 0x0C0)
  420. #define HCOUT0CTRL HCEP0CTRL
  421. #define HCOUT1CTRL (USB_AOTG_BASE + 0x0C4)
  422. #define HCOUT2CTRL (USB_AOTG_BASE + 0x0C8)
  423. #define HCOUT3CTRL (USB_AOTG_BASE + 0x0CC)
  424. #define HCOUT4CTRL (USB_AOTG_BASE + 0x0D0)
  425. #define HCOUTxCTRL(ep) (HCEP0CTRL + ep * 4)
  426. #define HCIN0CTRL HCEP0CTRL
  427. #define HCIN1CTRL (USB_AOTG_BASE + 0x0C6)
  428. #define HCIN2CTRL (USB_AOTG_BASE + 0x0CA)
  429. #define HCIN3CTRL (USB_AOTG_BASE + 0x0CE)
  430. #define HCIN4CTRL (USB_AOTG_BASE + 0x0D2)
  431. #define HCINxCTRL(ep) ((ep == 0) ? HCIN0CTRL : (HCIN1CTRL + (ep - 1) * 4))
  432. /* default: 0 */
  433. #define HCEPCTRL_EP_ADDR(ep) (ep & 0x0F)
  434. /** Host Endpoint Error */
  435. #define HCOUT0ERR (USB_AOTG_BASE + 0x0C1)
  436. #define HCOUT1ERR (USB_AOTG_BASE + 0x0C5)
  437. #define HCOUT2ERR (USB_AOTG_BASE + 0x0C9)
  438. #define HCOUT3ERR (USB_AOTG_BASE + 0x0CD)
  439. #define HCOUT4ERR (USB_AOTG_BASE + 0x0D1)
  440. #define HCOUTxERR(ep) (HCOUT0ERR + ep * 4)
  441. #define HCIN0ERR (USB_AOTG_BASE + 0x0C3)
  442. #define HCIN1ERR (USB_AOTG_BASE + 0x0C7)
  443. #define HCIN2ERR (USB_AOTG_BASE + 0x0CB)
  444. #define HCIN3ERR (USB_AOTG_BASE + 0x0CF)
  445. #define HCIN4ERR (USB_AOTG_BASE + 0x0D3)
  446. #define HCINxERR(ep) (HCIN0ERR + ep * 4)
  447. /* HCEPERR_DOPING: only for ep-out */
  448. #define HCEPERR_DOPING 6
  449. #define HCEPERR_RESEND 5
  450. #define HCEPERR_TYPE_MASK (0x7 << 2)
  451. #define HCEPERR_CNT_MASK 0x3
  452. /* Error types */
  453. #define NO_ERR (0x0 << 2)
  454. #define ERR_CRC (0x1 << 2)
  455. #define ERR_TOGGLE (0x2 << 2)
  456. #define ERR_STALL (0x3 << 2)
  457. #define ERR_TIMEOUT (0x4 << 2)
  458. #define ERR_PID (0x5 << 2)
  459. #define ERR_OVERRUN (0x6 << 2)
  460. #define ERR_UNDERRUN (0x7 << 2)
  461. /* Error count maximum */
  462. #define ERR_COUNT_MAX 10
  463. #define HCIN03ERRIRQ (USB_AOTG_BASE + 0x1B4)
  464. #define HCINEPERRIRQ HCIN03ERRIRQ
  465. #define HCOUT03ERRIRQ (USB_AOTG_BASE + 0x1B6)
  466. #define HCOUTEPERRIRQ HCOUT03ERRIRQ
  467. #define HCEPxERRIRQ(ep) (ep)
  468. #define HCIN03ERRIEN (USB_AOTG_BASE + 0x1B8)
  469. #define HCINEPERRIEN HCIN03ERRIEN
  470. #define HCOUT03ERRIEN (USB_AOTG_BASE + 0x1BA)
  471. #define HCOUTEPERRIEN HCOUT03ERRIEN
  472. #define HCEPxERRIEN(ep) (ep)
  473. /** Host IN Endpoint Control */
  474. #define HCINCTRL (USB_AOTG_BASE + 0x411)
  475. #define HCINx_START(ep) (ep)
  476. /* set: stop IN token when a short packet received */
  477. #define HCINx_SHORT(ep) ((ep - 1) * 2)
  478. /** Host IN End interrupt */
  479. #define HCINENDINT (USB_AOTG_BASE + 0x403)
  480. #define IRQ_HCIN4END 4
  481. #define IRQ_HCIN3END 3
  482. #define IRQ_HCIN2END 2
  483. #define IRQ_HCIN1END 1
  484. #define IEN_HCIN4END 4
  485. #define IEN_HCIN3END 3
  486. #define IEN_HCIN2END 2
  487. #define IEN_HCIN1END 1
  488. /** Host IN packet count */
  489. #define HCIN1CNTL (USB_AOTG_BASE + 0x412)
  490. #define HCIN1CNTH (USB_AOTG_BASE + 0x413)
  491. #define HCIN1CNT HCIN1CNTL
  492. #define HCIN2CNTL (USB_AOTG_BASE + 0x414)
  493. #define HCIN2CNTH (USB_AOTG_BASE + 0x415)
  494. #define HCIN2CNT HCIN2CNTL
  495. #define HCIN3CNTL (USB_AOTG_BASE + 0x416)
  496. #define HCIN3CNTH (USB_AOTG_BASE + 0x417)
  497. #define HCIN3CNT HCIN3CNTL
  498. #define HCIN4CNTL (USB_AOTG_BASE + 0x418)
  499. #define HCIN4CNTH (USB_AOTG_BASE + 0x419)
  500. #define HCIN4CNT HCIN4CNTL
  501. #define HCINxCNT(ep) (HCIN1CNT + (ep - 1) * 2)
  502. #define HCINxCNTL(ep) (HCIN1CNTL + (ep - 1) * 2)
  503. #define HCINxCNTH(ep) (HCIN1CNTH + (ep - 1) * 2)
  504. /** Host Port Control */
  505. #define HCPORTCTRL (USB_AOTG_BASE + 0x1AB)
  506. /* default: RST_55MS */
  507. #define RST_10MS (0x0 << 6)
  508. #define RST_55MS (0x1 << 6)
  509. #define RST_1_6MS (0x2 << 6)
  510. /* Port Reset */
  511. #define PORTRST 5
  512. /* Test_J */
  513. #define PORTTST_J (0x1 << 0)
  514. /* Test_K */
  515. #define PORTTST_K (0x2 << 0)
  516. /* Test_SE0_NAK */
  517. #define PORTTST_SE0 (0x4 << 0)
  518. /* Test_Packet */
  519. #define PORTTST_PKT (0x8 << 0)
  520. /* Test_Force_Enable */
  521. #define PORTTST_FE (0x10 << 0)
  522. /** Host Frame */
  523. #define HCFRMNL (USB_AOTG_BASE + 0x1AC)
  524. #define HCFRMNH (USB_AOTG_BASE + 0x1AD)
  525. #define HCFRMN HCFRMNL
  526. #define HCFRMREMAINL (USB_AOTG_BASE + 0x1AE)
  527. #define HCFRMREMAINH (USB_AOTG_BASE + 0x1AF)
  528. #define HCFRMREMAIN HCFRMREMAINL
  529. /************************************ Endp ***********************************/
  530. /** Endpoint 0 Control and Status */
  531. #define EP0CS (USB_AOTG_BASE + 0x002)
  532. #define EP0CS_SETTOGGLE 6
  533. #define EP0CS_CLRTOGGLE 5
  534. #define EP0CS_HCSET 4
  535. #define EP0CS_OUTBUSY 3
  536. #define EP0CS_INBUSY 2
  537. /* Endpoint 0 NAK */
  538. #define EP0CS_NAK 1
  539. /* Endpoint 0 STALL */
  540. #define EP0CS_STALL 0
  541. /** Endpoint Control and Status */
  542. #define OUT1CS (USB_AOTG_BASE + 0x00B)
  543. #define OUT2CS (USB_AOTG_BASE + 0x013)
  544. #define OUT3CS (USB_AOTG_BASE + 0x01B)
  545. #define OUT4CS (USB_AOTG_BASE + 0x023)
  546. #define OUTxCS(ep) (OUT1CS + (ep - 1) * 8)
  547. #define IN1CS (USB_AOTG_BASE + 0x00F)
  548. #define IN2CS (USB_AOTG_BASE + 0x017)
  549. #define IN3CS (USB_AOTG_BASE + 0x01F)
  550. #define IN4CS (USB_AOTG_BASE + 0x027)
  551. #define INxCS(ep) (IN1CS + (ep - 1) * 8)
  552. #define EPCS_AUTO 4
  553. #define EPCS_NPAK_MASK 0x0C
  554. #define EPCS_NPAK_00 (0x0 < 2)
  555. #define EPCS_NPAK_01 (0x1 < 2)
  556. #define EPCS_NPAK_10 (0x2 < 2)
  557. #define EPCS_NPAK_11 (0x3 < 2)
  558. #define EPCS_NPAK 2
  559. #define EPCS_BUSY 1
  560. #define EPCS_ERR 0
  561. /** Endpoint Control */
  562. #define OUT1CTRL (USB_AOTG_BASE + 0x00A)
  563. #define OUT2CTRL (USB_AOTG_BASE + 0x012)
  564. #define OUT3CTRL (USB_AOTG_BASE + 0x01A)
  565. #define OUT4CTRL (USB_AOTG_BASE + 0x022)
  566. #define OUTxCTRL(ep) (OUT1CTRL + (ep - 1) * 8)
  567. #define IN1CTRL (USB_AOTG_BASE + 0x00E)
  568. #define IN2CTRL (USB_AOTG_BASE + 0x016)
  569. #define IN3CTRL (USB_AOTG_BASE + 0x01E)
  570. #define IN4CTRL (USB_AOTG_BASE + 0x026)
  571. #define INxCTRL(ep) (IN1CTRL + (ep - 1) * 8)
  572. #define EPCTRL_VALID 7
  573. #define EPCTRL_STALL 6
  574. #define EPCTRL_TYPE 0x0C
  575. #define EPCTRL_BUF 0x03
  576. /* 3 ISO packets per microframe */
  577. #define EPCTRL_ISOC_3 5
  578. /* 2 ISO packets per microframe */
  579. #define EPCTRL_ISOC_2 4
  580. /** NAK Control for OUT Endpoints */
  581. #define NAKOUTCTRL (USB_AOTG_BASE + 0x40C)
  582. #define EP3_NAK 3
  583. #define EP2_NAK 2
  584. #define EP1_NAK 1
  585. /** Endpoint Reset */
  586. #define EPRST (USB_AOTG_BASE + 0x1A2)
  587. /* Endpoint FIFO Reset */
  588. #define EPRST_FIFORST 6
  589. /* Endpoint Toggle Reset */
  590. #define EPRST_TOGRST 5
  591. /* Endpoint Direction */
  592. #define EPRST_IO_IN 4
  593. /* Endpoint address */
  594. #define EPRST_NUM_MASK 0x0F
  595. /** Ep max packet size */
  596. /* Ep0 max packet size: not configure */
  597. #define OUT0MAXPKT (USB_AOTG_BASE + 0x1E0)
  598. #define EP0MAXPKT OUT0MAXPKT
  599. /* Ep-out max packet size */
  600. #define OUT1MAXPKTL (USB_AOTG_BASE + 0x1E2)
  601. #define OUT1MAXPKTH (USB_AOTG_BASE + 0x1E3)
  602. #define OUT1MAXPKT OUT1MAXPKTL
  603. #define OUT2MAXPKTL (USB_AOTG_BASE + 0x1E4)
  604. #define OUT2MAXPKTH (USB_AOTG_BASE + 0x1E5)
  605. #define OUT2MAXPKT OUT2MAXPKTL
  606. #define OUT3MAXPKTL (USB_AOTG_BASE + 0x1E6)
  607. #define OUT3MAXPKTH (USB_AOTG_BASE + 0x1E7)
  608. #define OUT3MAXPKT OUT3MAXPKTL
  609. #define OUT4MAXPKTL (USB_AOTG_BASE + 0x1E8)
  610. #define OUT4MAXPKTH (USB_AOTG_BASE + 0x1E9)
  611. #define OUT4MAXPKT OUT4MAXPKTL
  612. #define OUTxMAXPKT(ep) (OUT1MAXPKT + (ep - 1) * 2)
  613. #define OUTxMAXPKTL(ep) (OUT1MAXPKTL + (ep - 1) * 2)
  614. #define OUTxMAXPKTH(ep) (OUT1MAXPKTH + (ep - 1) * 2)
  615. /* Ep-in max packet size */
  616. #define IN1MAXPKTL (USB_AOTG_BASE + 0x3E2)
  617. #define IN1MAXPKTH (USB_AOTG_BASE + 0x3E3)
  618. #define IN1MAXPKT IN1MAXPKTL
  619. #define IN2MAXPKTL (USB_AOTG_BASE + 0x3E4)
  620. #define IN2MAXPKTH (USB_AOTG_BASE + 0x3E5)
  621. #define IN2MAXPKT IN2MAXPKTL
  622. #define IN3MAXPKTL (USB_AOTG_BASE + 0x3E6)
  623. #define IN3MAXPKTH (USB_AOTG_BASE + 0x3E7)
  624. #define IN3MAXPKT IN3MAXPKTL
  625. #define IN4MAXPKTL (USB_AOTG_BASE + 0x3E8)
  626. #define IN4MAXPKTH (USB_AOTG_BASE + 0x3E9)
  627. #define IN4MAXPKT IN4MAXPKTL
  628. #define INxMAXPKT(ep) (IN1MAXPKT + (ep - 1) * 2)
  629. /************************************ PHY ************************************/
  630. #define USBPHYCTRL (USB_AOTG_BASE + 0x423)
  631. #define PHY_PLLEN 7
  632. #define PHY_DALLUALLEN 6
  633. #define USBPHYCTRL_ENABLE 0xC0
  634. #define USBPHYCTRL_DISABLE 0x0
  635. #define VDCTRL (USB_AOTG_BASE + 0x424)
  636. #define VDSTATE (USB_AOTG_BASE + 0x425)
  637. #define USBEFUSEREF (USB_AOTG_BASE + 0x426)
  638. /************************************ DMA ************************************/
  639. /* IN Endpoint DMA */
  640. #define IN1_DMACTL (USB_AOTG_BASE + 0x430)
  641. #define IN1_DMALEN1L (USB_AOTG_BASE + 0x434)
  642. #define IN1_DMALEN1M (USB_AOTG_BASE + 0x435)
  643. #define IN1_DMALEN1H (USB_AOTG_BASE + 0x436)
  644. #define IN1_DMALEN2L (USB_AOTG_BASE + 0x438)
  645. #define IN1_DMALEN2M (USB_AOTG_BASE + 0x439)
  646. #define IN1_DMALEN2H (USB_AOTG_BASE + 0x43A)
  647. #define IN1_DMAREMAIN1L (USB_AOTG_BASE + 0x43C)
  648. #define IN1_DMAREMAIN1M (USB_AOTG_BASE + 0x43D)
  649. #define IN1_DMAREMAIN1H (USB_AOTG_BASE + 0x43E)
  650. #define IN1_DMAREMAIN2L (USB_AOTG_BASE + 0x440)
  651. #define IN1_DMAREMAIN2M (USB_AOTG_BASE + 0x441)
  652. #define IN1_DMAREMAIN2H (USB_AOTG_BASE + 0x442)
  653. /* OUT Endpoint DMA */
  654. #define OUT2_DMACTL (USB_AOTG_BASE + 0x444)
  655. #define OUT2_DMALENL (USB_AOTG_BASE + 0x448)
  656. #define OUT2_DMALENM (USB_AOTG_BASE + 0x449)
  657. #define OUT2_DMALENH (USB_AOTG_BASE + 0x44A)
  658. #define OUT2_DMAREMAINL (USB_AOTG_BASE + 0x44C)
  659. #define OUT2_DMAREMAINM (USB_AOTG_BASE + 0x44D)
  660. #define OUT2_DMAREMAINH (USB_AOTG_BASE + 0x44E)
  661. /* 0: normal; 1: reset */
  662. #define DMACTL_FIFORST 7
  663. /* 0: burst8; 1: single */
  664. #define DMACTL_MODE 4
  665. /* 0: disabled; 1: enabled */
  666. #define DMACTL_AUTOLOAD 3
  667. /* 0: disabled; 1: enabled */
  668. #define DMACTL_START 0
  669. /********************************* Functions *********************************/
  670. /*
  671. * Turn USB controller power on
  672. */
  673. static inline void usb_aotg_power_on(void)
  674. {
  675. }
  676. /*
  677. * Turn USB controller power off
  678. */
  679. static inline void usb_aotg_power_off(void)
  680. {
  681. }
  682. /*
  683. * USB PHY configuration
  684. */
  685. static void usb_phy_setting(uint8_t reg, uint8_t value)
  686. {
  687. uint8_t low, high, tmp;
  688. low = reg & 0x0f;
  689. high = (reg >> 4) & 0x0f;
  690. tmp = usb_read8(VDCTRL) & 0x80;
  691. /* write vstatus */
  692. usb_write8(VDSTATE, value);
  693. /* write vcontrol */
  694. low |= 0x10;
  695. usb_write8(VDCTRL, (low | tmp));
  696. k_busy_wait(1);
  697. low &= 0x0f;
  698. usb_write8(VDCTRL, (low | tmp));
  699. k_busy_wait(1);
  700. low |= 0x10;
  701. usb_write8(VDCTRL, (low | tmp));
  702. k_busy_wait(1);
  703. high |= 0x10;
  704. usb_write8(VDCTRL, (high | tmp));
  705. k_busy_wait(1);
  706. high &= 0x0f;
  707. usb_write8(VDCTRL, (high | tmp));
  708. k_busy_wait(1);
  709. high |= 0x10;
  710. usb_write8(VDCTRL, (high | tmp));
  711. k_busy_wait(1);
  712. }
  713. static inline void usb_aotg_reset_specific(void)
  714. {
  715. uint8_t val = usb_read8(USB_VDD);
  716. /* enable usb phy pll */
  717. usb_write8(USBPHYCTRL, USBPHYCTRL_ENABLE);
  718. k_busy_wait(10);
  719. usb_write8(USBEFUSEREF, 0x80);
  720. /* Turn USB controller power on */
  721. val &= ~USB_VDD_VOLTAGE_MASK;
  722. val |= (USB_VDD_VOLTAGE_DEFAULT | BIT(USB_VDD_EN));
  723. usb_write8(USB_VDD, val);
  724. k_busy_wait(10);
  725. }
  726. static inline void usb_aotg_disable_specific(void)
  727. {
  728. usb_phy_setting(0xe7, 0x0);
  729. /* disable PHY PLL */
  730. usb_write8(USBPHYCTRL, USBPHYCTRL_DISABLE);
  731. /* Turn USB controller power off */
  732. usb_write8(USB_VDD, usb_read8(USB_VDD) & (~BIT(USB_VDD_EN)));
  733. }
  734. static inline void aotg_dc_phy_init(void)
  735. {
  736. usb_phy_setting(0xe1, 0x63);
  737. k_busy_wait(10);
  738. usb_phy_setting(0x84, 0x1a);
  739. usb_phy_setting(0xe7, 0x0b);
  740. usb_phy_setting(0xe7, 0x0f);
  741. usb_phy_setting(0xe3, 0x1e);
  742. usb_phy_setting(0xe2, 0x8c);
  743. usb_phy_setting(0x91, 0x06);
  744. }
  745. static inline int aotg_dc_epout_alloc_fifo_specific(uint8_t ep_idx)
  746. {
  747. switch (ep_idx) {
  748. case USB_AOTG_OUT_EP_1:
  749. usb_write32(EP1OUT_STADDR, EP1OUT_FIFO_START);
  750. break;
  751. case USB_AOTG_OUT_EP_2:
  752. usb_write32(EP2OUT_STADDR, EP2OUT_FIFO_START);
  753. break;
  754. case USB_AOTG_OUT_EP_3:
  755. usb_write32(EP3OUT_STADDR, EP3OUT_FIFO_START);
  756. break;
  757. case USB_AOTG_OUT_EP_4:
  758. usb_write32(EP4OUT_STADDR, EP4OUT_FIFO_START);
  759. break;
  760. default:
  761. return -EINVAL;
  762. }
  763. return 0;
  764. }
  765. static inline int aotg_dc_epin_alloc_fifo_specific(uint8_t ep_idx)
  766. {
  767. switch (ep_idx) {
  768. case USB_AOTG_IN_EP_1:
  769. usb_write32(EP1IN_STADDR, EP1IN_FIFO_START);
  770. break;
  771. case USB_AOTG_IN_EP_2:
  772. usb_write32(EP2IN_STADDR, EP2IN_FIFO_START);
  773. break;
  774. case USB_AOTG_IN_EP_3:
  775. usb_write32(EP3IN_STADDR, EP3IN_FIFO_START);
  776. break;
  777. case USB_AOTG_IN_EP_4:
  778. usb_write32(EP4IN_STADDR, EP4IN_FIFO_START);
  779. break;
  780. default:
  781. return -EINVAL;
  782. }
  783. return 0;
  784. }
  785. /*
  786. * Switch FIFO clock to make sure it is available for AOTG
  787. */
  788. static inline int aotg_dc_fifo_enable(void)
  789. {
  790. usb_set_bit32(USB_MEM_CLK, USB_RAM_CLKSRC_BIT);
  791. usb_set_bit32(USB_MEM_CLK, USB_RAM_CLKEN_BIT);
  792. return 0;
  793. }
  794. static inline int aotg_dc_fifo_disable(void)
  795. {
  796. usb_clear_bit32(USB_MEM_CLK, USB_RAM_CLKSRC_BIT);
  797. usb_clear_bit32(USB_MEM_CLK, USB_RAM_CLKEN_BIT);
  798. return 0;
  799. }
  800. static inline void aotg_dc_force_fs(void)
  801. {
  802. usb_set_bit8(BKDOOR, HS_DISABLE);
  803. }
  804. static inline int aotg_hc_epout_alloc_fifo_specific(uint8_t ep_idx)
  805. {
  806. switch (ep_idx) {
  807. case USB_AOTG_OUT_EP_1:
  808. usb_write32(EP1OUT_STADDR, EP1OUT_FIFO_START);
  809. break;
  810. case USB_AOTG_OUT_EP_2:
  811. usb_write32(EP2OUT_STADDR, EP2OUT_FIFO_START);
  812. break;
  813. case USB_AOTG_OUT_EP_3:
  814. usb_write32(EP3OUT_STADDR, EP3OUT_FIFO_START);
  815. break;
  816. case USB_AOTG_OUT_EP_4:
  817. usb_write32(EP4OUT_STADDR, EP4OUT_FIFO_START);
  818. break;
  819. default:
  820. return -EINVAL;
  821. }
  822. return 0;
  823. }
  824. static inline int aotg_hc_epin_alloc_fifo_specific(uint8_t ep_idx)
  825. {
  826. switch (ep_idx) {
  827. case USB_AOTG_IN_EP_1:
  828. usb_write32(EP1IN_STADDR, EP1IN_FIFO_START);
  829. break;
  830. case USB_AOTG_IN_EP_2:
  831. usb_write32(EP2IN_STADDR, EP2IN_FIFO_START);
  832. break;
  833. case USB_AOTG_IN_EP_3:
  834. usb_write32(EP3IN_STADDR, EP3IN_FIFO_START);
  835. break;
  836. case USB_AOTG_IN_EP_4:
  837. usb_write32(EP4IN_STADDR, EP4IN_FIFO_START);
  838. break;
  839. default:
  840. return -EINVAL;
  841. }
  842. return 0;
  843. }
  844. static inline void aotg_hc_phy_init(void)
  845. {
  846. usb_phy_setting(0xe0, 0xa3);
  847. usb_phy_setting(0x84, 0x1a);
  848. usb_phy_setting(0xe7, 0x0b);
  849. usb_phy_setting(0xe7, 0x0f);
  850. usb_phy_setting(0xe3, 0x1e);
  851. usb_phy_setting(0x87, 0x94);
  852. usb_phy_setting(0x91, 0x08);
  853. }
  854. /*
  855. * Switch FIFO clock to make sure it is available for AOTG
  856. */
  857. static inline int aotg_hc_fifo_enable(void)
  858. {
  859. uint32_t value = usb_read32(USB_MEM_CLK);
  860. value |= (1<<8);
  861. usb_write32(USB_MEM_CLK, value);
  862. value = usb_read32(USB_MEM_CLK_EN);
  863. value |= (1<<8);
  864. usb_write32(USB_MEM_CLK_EN, value);
  865. return 0;
  866. }
  867. static inline int aotg_hc_fifo_disable(void)
  868. {
  869. uint32_t value = usb_read32(USB_MEM_CLK);
  870. value |= ~(1<<8);
  871. usb_write32(USB_MEM_CLK, value);
  872. value = usb_read32(USB_MEM_CLK_EN);
  873. value |= ~(1<<8);
  874. usb_write32(USB_MEM_CLK_EN, value);
  875. return 0;
  876. }
  877. static inline int usb_aotg_dpdm_init(void)
  878. {
  879. return 0;
  880. }
  881. static inline int usb_aotg_dpdm_exit(void)
  882. {
  883. return 0;
  884. }
  885. #endif /* __USB_AOTG_LARK_H__ */