dwcotg.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. /*
  2. * USB host driver for BCM2835
  3. * Synopsis DesignWare Core USB 2.0 OTG controller
  4. *
  5. * Device register definitions
  6. */
  7. typedef unsigned int Reg;
  8. typedef struct Dwcregs Dwcregs;
  9. typedef struct Hostchan Hostchan;
  10. enum {
  11. Maxchans = 16, /* actual number of channels in ghwcfg2 */
  12. };
  13. struct Dwcregs {
  14. /* Core global registers 0x000-0x140 */
  15. Reg gotgctl; /* OTG Control and Status */
  16. Reg gotgint; /* OTG Interrupt */
  17. Reg gahbcfg; /* Core AHB Configuration */
  18. Reg gusbcfg; /* Core USB Configuration */
  19. Reg grstctl; /* Core Reset */
  20. Reg gintsts; /* Core Interrupt */
  21. Reg gintmsk; /* Core Interrupt Mask */
  22. Reg grxstsr; /* Receive Status Queue Read (RO) */
  23. Reg grxstsp; /* Receive Status Queue Read & POP (RO) */
  24. Reg grxfsiz; /* Receive FIFO Size */
  25. Reg gnptxfsiz; /* Non Periodic Transmit FIFO Size */
  26. Reg gnptxsts; /* Non Periodic Transmit FIFO/Queue Status (RO) */
  27. Reg gi2cctl; /* I2C Access */
  28. Reg gpvndctl; /* PHY Vendor Control */
  29. Reg ggpio; /* General Purpose Input/Output */
  30. Reg guid; /* User ID */
  31. Reg gsnpsid; /* Synopsys ID (RO) */
  32. Reg ghwcfg1; /* User HW Config1 (RO) (DEVICE) */
  33. Reg ghwcfg2; /* User HW Config2 (RO) */
  34. Reg ghwcfg3; /* User HW Config3 (RO) */
  35. Reg ghwcfg4; /* User HW Config4 (RO)*/
  36. Reg glpmcfg; /* Core LPM Configuration */
  37. Reg gpwrdn; /* Global PowerDn */
  38. Reg gdfifocfg; /* Global DFIFO SW Config (DEVICE?) */
  39. Reg adpctl; /* ADP Control */
  40. Reg reserved0[39];
  41. Reg hptxfsiz; /* Host Periodic Transmit FIFO Size */
  42. Reg dtxfsiz[15]; /* Device Periodic Transmit FIFOs (DEVICE) */
  43. char pad0[0x400-0x140];
  44. /* Host global registers 0x400-0x420 */
  45. Reg hcfg; /* Configuration */
  46. Reg hfir; /* Frame Interval */
  47. Reg hfnum; /* Frame Number / Frame Remaining (RO) */
  48. Reg reserved1;
  49. Reg hptxsts; /* Periodic Transmit FIFO / Queue Status */
  50. Reg haint; /* All Channels Interrupt */
  51. Reg haintmsk; /* All Channels Interrupt Mask */
  52. Reg hflbaddr; /* Frame List Base Address */
  53. char pad1[0x440-0x420];
  54. /* Host port register 0x440 */
  55. Reg hport0; /* Host Port 0 Control and Status */
  56. char pad2[0x500-0x444];
  57. /* Host channel specific registers 0x500-0x700 */
  58. struct Hostchan {
  59. Reg hcchar; /* Characteristic */
  60. Reg hcsplt; /* Split Control */
  61. Reg hcint; /* Interrupt */
  62. Reg hcintmsk; /* Interrupt Mask */
  63. Reg hctsiz; /* Transfer Size */
  64. Reg hcdma; /* DMA Address */
  65. Reg reserved;
  66. Reg hcdmab; /* DMA Buffer Address */
  67. } hchan[Maxchans];
  68. char pad3[0xE00-0x700];
  69. /* Power & clock gating control register 0xE00 */
  70. Reg pcgcctl;
  71. };
  72. enum {
  73. /* gotgctl */
  74. Sesreqscs = 1<<0,
  75. Sesreq = 1<<1,
  76. Vbvalidoven = 1<<2,
  77. Vbvalidovval = 1<<3,
  78. Avalidoven = 1<<4,
  79. Avalidovval = 1<<5,
  80. Bvalidoven = 1<<6,
  81. Bvalidovval = 1<<7,
  82. Hstnegscs = 1<<8,
  83. Hnpreq = 1<<9,
  84. Hstsethnpen = 1<<10,
  85. Devhnpen = 1<<11,
  86. Conidsts = 1<<16,
  87. Dbnctime = 1<<17,
  88. Asesvld = 1<<18,
  89. Bsesvld = 1<<19,
  90. Otgver = 1<<20,
  91. Multvalidbc = 0x1F<<22,
  92. Chirpen = 1<<27,
  93. /* gotgint */
  94. Sesenddet = 1<<2,
  95. Sesreqsucstschng= 1<<8,
  96. Hstnegsucstschng= 1<<9,
  97. Hstnegdet = 1<<17,
  98. Adevtoutchng = 1<<18,
  99. Debdone = 1<<19,
  100. Mvic = 1<<20,
  101. /* gahbcfg */
  102. Glblintrmsk = 1<<0,
  103. /* bits 1:4 redefined for BCM2835 */
  104. Axiburstlen = 0x3<<1,
  105. BURST1 = 3<<1,
  106. BURST2 = 2<<1,
  107. BURST3 = 1<<1,
  108. BURST4 = 0<<1,
  109. Axiwaitwrites = 1<<4,
  110. Dmaenable = 1<<5,
  111. Nptxfemplvl = 1<<7,
  112. NPTX_HALFEMPTY = 0<<7,
  113. NPTX_EMPTY = 1<<7,
  114. Ptxfemplvl = 1<<8,
  115. PTX_HALFEMPTY = 0<<8,
  116. PTX_EMPTY = 1<<8,
  117. Remmemsupp = 1<<21,
  118. Notialldmawrit = 1<<22,
  119. Ahbsingle = 1<<23,
  120. /* gusbcfg */
  121. Toutcal = 0x7<<0,
  122. Phyif = 1<<3,
  123. Ulpi_utmi_sel = 1<<4,
  124. Fsintf = 1<<5,
  125. FsUnidir = 0<<5,
  126. FsBidir = 1<<5,
  127. Physel = 1<<6,
  128. PhyHighspeed = 0<<6,
  129. PhyFullspeed = 1<<6,
  130. Ddrsel = 1<<7,
  131. Srpcap = 1<<8,
  132. Hnpcap = 1<<9,
  133. Usbtrdtim = 0xf<<10,
  134. OUsbtrdtim = 10,
  135. Phylpwrclksel = 1<<15,
  136. Otgutmifssel = 1<<16,
  137. Ulpi_fsls = 1<<17,
  138. Ulpi_auto_res = 1<<18,
  139. Ulpi_clk_sus_m = 1<<19,
  140. Ulpi_ext_vbus_drv= 1<<20,
  141. Ulpi_int_vbus_indicator= 1<<21,
  142. Term_sel_dl_pulse= 1<<22,
  143. Indicator_complement= 1<<23,
  144. Indicator_pass_through= 1<<24,
  145. Ulpi_int_prot_dis= 1<<25,
  146. Ic_usb_cap = 1<<26,
  147. Ic_traffic_pull_remove= 1<<27,
  148. Tx_end_delay = 1<<28,
  149. Force_host_mode = 1<<29,
  150. Force_dev_mode = 1<<30,
  151. /* grstctl */
  152. Csftrst = 1<<0,
  153. Hsftrst = 1<<1,
  154. Hstfrm = 1<<2,
  155. Intknqflsh = 1<<3,
  156. Rxfflsh = 1<<4,
  157. Txfflsh = 1<<5,
  158. Txfnum = 0x1f<<6,
  159. TXF_ALL = 0x10<<6,
  160. Dmareq = 1<<30,
  161. Ahbidle = 1<<31,
  162. /* gintsts, gintmsk */
  163. Curmode = 1<<0,
  164. HOSTMODE = 1<<0,
  165. DEVMODE = 0<<0,
  166. Modemismatch = 1<<1,
  167. Otgintr = 1<<2,
  168. Sofintr = 1<<3,
  169. Rxstsqlvl = 1<<4,
  170. Nptxfempty = 1<<5,
  171. Ginnakeff = 1<<6,
  172. Goutnakeff = 1<<7,
  173. Ulpickint = 1<<8,
  174. I2cintr = 1<<9,
  175. Erlysuspend = 1<<10,
  176. Usbsuspend = 1<<11,
  177. Usbreset = 1<<12,
  178. Enumdone = 1<<13,
  179. Isooutdrop = 1<<14,
  180. Eopframe = 1<<15,
  181. Restoredone = 1<<16,
  182. Epmismatch = 1<<17,
  183. Inepintr = 1<<18,
  184. Outepintr = 1<<19,
  185. Incomplisoin = 1<<20,
  186. Incomplisoout = 1<<21,
  187. Fetsusp = 1<<22,
  188. Resetdet = 1<<23,
  189. Portintr = 1<<24,
  190. Hcintr = 1<<25,
  191. Ptxfempty = 1<<26,
  192. Lpmtranrcvd = 1<<27,
  193. Conidstschng = 1<<28,
  194. Disconnect = 1<<29,
  195. Sessreqintr = 1<<30,
  196. Wkupintr = 1<<31,
  197. /* grxsts[rp] */
  198. Chnum = 0xf<<0,
  199. Bcnt = 0x7ff<<4,
  200. Dpid = 0x3<<15,
  201. Pktsts = 0xf<<17,
  202. PKTSTS_IN = 2<<17,
  203. PKTSTS_IN_XFER_COMP = 3<<17,
  204. PKTSTS_DATA_TOGGLE_ERR = 5<<17,
  205. PKTSTS_CH_HALTED = 7<<17,
  206. /* hptxfsiz, gnptxfsiz */
  207. Startaddr = 0xffff<<0,
  208. Depth = 0xffff<<16,
  209. ODepth = 16,
  210. /* gnptxsts */
  211. Nptxfspcavail = 0xffff<<0,
  212. Nptxqspcavail = 0xff<<16,
  213. Nptxqtop_terminate= 1<<24,
  214. Nptxqtop_token = 0x3<<25,
  215. Nptxqtop_chnep = 0xf<<27,
  216. /* gpvndctl */
  217. Regdata = 0xff<<0,
  218. Vctrl = 0xff<<8,
  219. Regaddr16_21 = 0x3f<<16,
  220. Regwr = 1<<22,
  221. Newregreq = 1<<25,
  222. Vstsbsy = 1<<26,
  223. Vstsdone = 1<<27,
  224. Disulpidrvr = 1<<31,
  225. /* ggpio */
  226. Gpi = 0xffff<<0,
  227. Gpo = 0xffff<<16,
  228. /* ghwcfg2 */
  229. Op_mode = 0x7<<0,
  230. HNP_SRP_CAPABLE_OTG = 0<<0,
  231. SRP_ONLY_CAPABLE_OTG = 1<<0,
  232. NO_HNP_SRP_CAPABLE = 2<<0,
  233. SRP_CAPABLE_DEVICE = 3<<0,
  234. NO_SRP_CAPABLE_DEVICE = 4<<0,
  235. SRP_CAPABLE_HOST = 5<<0,
  236. NO_SRP_CAPABLE_HOST = 6<<0,
  237. Architecture = 0x3<<3,
  238. SLAVE_ONLY = 0<<3,
  239. EXT_DMA = 1<<3,
  240. INT_DMA = 2<<3,
  241. Point2point = 1<<5,
  242. Hs_phy_type = 0x3<<6,
  243. PHY_NOT_SUPPORTED = 0<<6,
  244. PHY_UTMI = 1<<6,
  245. PHY_ULPI = 2<<6,
  246. PHY_UTMI_ULPI = 3<<6,
  247. Fs_phy_type = 0x3<<8,
  248. Num_dev_ep = 0xf<<10,
  249. Num_host_chan = 0xf<<14,
  250. ONum_host_chan = 14,
  251. Perio_ep_supported= 1<<18,
  252. Dynamic_fifo = 1<<19,
  253. Nonperio_tx_q_depth= 0x3<<22,
  254. Host_perio_tx_q_depth= 0x3<<24,
  255. Dev_token_q_depth= 0x1f<<26,
  256. Otg_enable_ic_usb= 1<<31,
  257. /* ghwcfg3 */
  258. Xfer_size_cntr_width = 0xf<<0,
  259. Packet_size_cntr_width = 0x7<<4,
  260. Otg_func = 1<<7,
  261. I2c = 1<<8,
  262. Vendor_ctrl_if = 1<<9,
  263. Optional_features = 1<<10,
  264. Synch_reset_type = 1<<11,
  265. Adp_supp = 1<<12,
  266. Otg_enable_hsic = 1<<13,
  267. Bc_support = 1<<14,
  268. Otg_lpm_en = 1<<15,
  269. Dfifo_depth = 0xffff<<16,
  270. ODfifo_depth = 16,
  271. /* ghwcfg4 */
  272. Num_dev_perio_in_ep = 0xf<<0,
  273. Power_optimiz = 1<<4,
  274. Min_ahb_freq = 1<<5,
  275. Hiber = 1<<6,
  276. Xhiber = 1<<7,
  277. Utmi_phy_data_width = 0x3<<14,
  278. Num_dev_mode_ctrl_ep = 0xf<<16,
  279. Iddig_filt_en = 1<<20,
  280. Vbus_valid_filt_en = 1<<21,
  281. A_valid_filt_en = 1<<22,
  282. B_valid_filt_en = 1<<23,
  283. Session_end_filt_en = 1<<24,
  284. Ded_fifo_en = 1<<25,
  285. Num_in_eps = 0xf<<26,
  286. Desc_dma = 1<<30,
  287. Desc_dma_dyn = 1<<31,
  288. /* glpmcfg */
  289. Lpm_cap_en = 1<<0,
  290. Appl_resp = 1<<1,
  291. Hird = 0xf<<2,
  292. Rem_wkup_en = 1<<6,
  293. En_utmi_sleep = 1<<7,
  294. Hird_thres = 0x1f<<8,
  295. Lpm_resp = 0x3<<13,
  296. Prt_sleep_sts = 1<<15,
  297. Sleep_state_resumeok= 1<<16,
  298. Lpm_chan_index = 0xf<<17,
  299. Retry_count = 0x7<<21,
  300. Send_lpm = 1<<24,
  301. Retry_count_sts = 0x7<<25,
  302. Hsic_connect = 1<<30,
  303. Inv_sel_hsic = 1<<31,
  304. /* gpwrdn */
  305. Pmuintsel = 1<<0,
  306. Pmuactv = 1<<1,
  307. Restore = 1<<2,
  308. Pwrdnclmp = 1<<3,
  309. Pwrdnrstn = 1<<4,
  310. Pwrdnswtch = 1<<5,
  311. Dis_vbus = 1<<6,
  312. Lnstschng = 1<<7,
  313. Lnstchng_msk = 1<<8,
  314. Rst_det = 1<<9,
  315. Rst_det_msk = 1<<10,
  316. Disconn_det = 1<<11,
  317. Disconn_det_msk = 1<<12,
  318. Connect_det = 1<<13,
  319. Connect_det_msk = 1<<14,
  320. Srp_det = 1<<15,
  321. Srp_det_msk = 1<<16,
  322. Sts_chngint = 1<<17,
  323. Sts_chngint_msk = 1<<18,
  324. Linestate = 0x3<<19,
  325. Idsts = 1<<21,
  326. Bsessvld = 1<<22,
  327. Adp_int = 1<<23,
  328. Mult_val_id_bc = 0x1f<<24,
  329. /* gdfifocfg */
  330. Gdfifocfg = 0xffff<<0,
  331. Epinfobase = 0xffff<<16,
  332. /* adpctl */
  333. Prb_dschg = 0x3<<0,
  334. Prb_delta = 0x3<<2,
  335. Prb_per = 0x3<<4,
  336. Rtim = 0x7ff<<6,
  337. Enaprb = 1<<17,
  338. Enasns = 1<<18,
  339. Adpres = 1<<19,
  340. Adpen = 1<<20,
  341. Adp_prb_int = 1<<21,
  342. Adp_sns_int = 1<<22,
  343. Adp_tmout_int = 1<<23,
  344. Adp_prb_int_msk = 1<<24,
  345. Adp_sns_int_msk = 1<<25,
  346. Adp_tmout_int_msk= 1<<26,
  347. Ar = 0x3<<27,
  348. /* hcfg */
  349. Fslspclksel = 0x3<<0,
  350. HCFG_30_60_MHZ = 0<<0,
  351. HCFG_48_MHZ = 1<<0,
  352. HCFG_6_MHZ = 2<<0,
  353. Fslssupp = 1<<2,
  354. Ena32khzs = 1<<7,
  355. Resvalid = 0xff<<8,
  356. Descdma = 1<<23,
  357. Frlisten = 0x3<<24,
  358. Modechtimen = 1<<31,
  359. /* hfir */
  360. Frint = 0xffff<<0,
  361. Hfirrldctrl = 1<<16,
  362. /* hfnum */
  363. Frnum = 0xffff<<0,
  364. MAX_FRNUM = 0x3FFF<<0,
  365. Frrem = 0xffff<<16,
  366. /* hptxsts */
  367. Ptxfspcavail = 0xffff<<0,
  368. Ptxqspcavail = 0xff<<16,
  369. Ptxqtop_terminate= 1<<24,
  370. Ptxqtop_token = 0x3<<25,
  371. Ptxqtop_chnum = 0xf<<27,
  372. Ptxqtop_odd = 1<<31,
  373. /* haint, haintmsk */
  374. #define CHANINT(n) (1<<(n))
  375. /* hport0 */
  376. Prtconnsts = 1<<0, /* connect status (RO) */
  377. Prtconndet = 1<<1, /* connect detected R/W1C) */
  378. Prtena = 1<<2, /* enable (R/W1C) */
  379. Prtenchng = 1<<3, /* enable/disable change (R/W1C) */
  380. Prtovrcurract = 1<<4, /* overcurrent active (RO) */
  381. Prtovrcurrchng = 1<<5, /* overcurrent change (R/W1C) */
  382. Prtres = 1<<6, /* resume */
  383. Prtsusp = 1<<7, /* suspend */
  384. Prtrst = 1<<8, /* reset */
  385. Prtlnsts = 0x3<<10, /* line state {D+,D-} (RO) */
  386. Prtpwr = 1<<12, /* power on */
  387. Prttstctl = 0xf<<13, /* test */
  388. Prtspd = 0x3<<17, /* speed (RO) */
  389. HIGHSPEED = 0<<17,
  390. FULLSPEED = 1<<17,
  391. LOWSPEED = 2<<17,
  392. /* hcchar */
  393. Mps = 0x7ff<<0, /* endpoint maximum packet size */
  394. Epnum = 0xf<<11, /* endpoint number */
  395. OEpnum = 11,
  396. Epdir = 1<<15, /* endpoint direction */
  397. Epout = 0<<15,
  398. Epin = 1<<15,
  399. Lspddev = 1<<17, /* device is lowspeed */
  400. Eptype = 0x3<<18, /* endpoint type */
  401. Epctl = 0<<18,
  402. Episo = 1<<18,
  403. Epbulk = 2<<18,
  404. Epintr = 3<<18,
  405. Multicnt = 0x3<<20, /* transactions per μframe */
  406. /* or retries per periodic split */
  407. OMulticnt = 20,
  408. Devaddr = 0x7f<<22, /* device address */
  409. ODevaddr = 22,
  410. Oddfrm = 1<<29, /* xfer in odd frame (iso/interrupt) */
  411. Chdis = 1<<30, /* channel disable (write 1 only) */
  412. Chen = 1<<31, /* channel enable (write 1 only) */
  413. /* hcsplt */
  414. Prtaddr = 0x7f<<0, /* port address of recipient */
  415. /* transaction translator */
  416. Hubaddr = 0x7f<<7, /* dev address of transaction */
  417. /* translator's hub */
  418. OHubaddr = 7,
  419. Xactpos = 0x3<<14, /* payload's position within transaction */
  420. POS_MID = 0<<14,
  421. POS_END = 1<<14,
  422. POS_BEGIN = 2<<14,
  423. POS_ALL = 3<<14, /* all of data (<= 188 bytes) */
  424. Compsplt = 1<<16, /* do complete split */
  425. Spltena = 1<<31, /* channel enabled to do splits */
  426. /* hcint, hcintmsk */
  427. Xfercomp = 1<<0, /* transfer completed without error */
  428. Chhltd = 1<<1, /* channel halted */
  429. Ahberr = 1<<2, /* AHB dma error */
  430. Stall = 1<<3,
  431. Nak = 1<<4,
  432. Ack = 1<<5,
  433. Nyet = 1<<6,
  434. Xacterr = 1<<7, /* transaction error (crc, t/o, bit stuff, eop) */
  435. Bblerr = 1<<8,
  436. Frmovrun = 1<<9,
  437. Datatglerr = 1<<10,
  438. Bna = 1<<11,
  439. Xcs_xact = 1<<12,
  440. Frm_list_roll = 1<<13,
  441. /* hctsiz */
  442. Xfersize = 0x7ffff<<0, /* expected total bytes */
  443. Pktcnt = 0x3ff<<19, /* expected number of packets */
  444. OPktcnt = 19,
  445. Pid = 0x3<<29, /* packet id for initial transaction */
  446. DATA0 = 0<<29,
  447. DATA1 = 2<<29, /* sic */
  448. DATA2 = 1<<29, /* sic */
  449. MDATA = 3<<29, /* (non-ctl ep) */
  450. SETUP = 3<<29, /* (ctl ep) */
  451. Dopng = 1<<31, /* do PING protocol */
  452. /* pcgcctl */
  453. Stoppclk = 1<<0,
  454. Gatehclk = 1<<1,
  455. Pwrclmp = 1<<2,
  456. Rstpdwnmodule = 1<<3,
  457. Enbl_sleep_gating = 1<<5,
  458. Phy_in_sleep = 1<<6,
  459. Deep_sleep = 1<<7,
  460. Resetaftsusp = 1<<8,
  461. Restoremode = 1<<9,
  462. Enbl_extnd_hiber = 1<<10,
  463. Extnd_hiber_pwrclmp = 1<<11,
  464. Extnd_hiber_switch = 1<<12,
  465. Ess_reg_restored = 1<<13,
  466. Prt_clk_sel = 0x3<<14,
  467. Port_power = 1<<16,
  468. Max_xcvrselect = 0x3<<17,
  469. Max_termsel = 1<<19,
  470. Mac_dev_addr = 0x7f<<20,
  471. P2hd_dev_enum_spd = 0x3<<27,
  472. P2hd_prt_spd = 0x3<<29,
  473. If_dev_mode = 1<<31,
  474. };