common_regs.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. /*
  2. * stm32/common_regs.h
  3. *
  4. * Core and peripheral register definitions.
  5. *
  6. * Written & released by Keir Fraser <keir.xen@gmail.com>
  7. *
  8. * This is free and unencumbered software released into the public domain.
  9. * See the file COPYING for more details, or visit <http://unlicense.org>.
  10. */
  11. /* SysTick timer */
  12. struct stk {
  13. uint32_t ctrl; /* 00: Control and status */
  14. uint32_t load; /* 04: Reload value */
  15. uint32_t val; /* 08: Current value */
  16. uint32_t calib; /* 0C: Calibration value */
  17. };
  18. #define STK_CTRL_COUNTFLAG (1u<<16)
  19. #define STK_CTRL_CLKSOURCE (1u<< 2)
  20. #define STK_CTRL_TICKINT (1u<< 1)
  21. #define STK_CTRL_ENABLE (1u<< 0)
  22. #define STK_MASK ((1u<<24)-1)
  23. #define STK_BASE 0xe000e010
  24. /* System control block */
  25. struct scb {
  26. uint32_t cpuid; /* 00: CPUID base */
  27. uint32_t icsr; /* 04: Interrupt control and state */
  28. uint32_t vtor; /* 08: Vector table offset */
  29. uint32_t aircr; /* 0C: Application interrupt and reset control */
  30. uint32_t scr; /* 10: System control */
  31. uint32_t ccr; /* 14: Configuration and control */
  32. uint32_t shpr1; /* 18: System handler priority reg #1 */
  33. uint32_t shpr2; /* 1C: system handler priority reg #2 */
  34. uint32_t shpr3; /* 20: System handler priority reg #3 */
  35. uint32_t shcsr; /* 24: System handler control and state */
  36. uint32_t cfsr; /* 28: Configurable fault status */
  37. uint32_t hfsr; /* 2C: Hard fault status */
  38. uint32_t _unused; /* 30: - */
  39. uint32_t mmar; /* 34: Memory management fault address */
  40. uint32_t bfar; /* 38: Bus fault address */
  41. };
  42. #define SCB_CCR_STKALIGN (1u<<9)
  43. #define SCB_CCR_BFHFNMIGN (1u<<8)
  44. #define SCB_CCR_DIV_0_TRP (1u<<4)
  45. #define SCB_CCR_UNALIGN_TRP (1u<<3)
  46. #define SCB_CCR_USERSETMPEND (1u<<1)
  47. #define SCB_CCR_NONBASETHRDENA (1u<<0)
  48. #define SCB_SHCSR_USGFAULTENA (1u<<18)
  49. #define SCB_SHCSR_BUSFAULTENA (1u<<17)
  50. #define SCB_SHCSR_MEMFAULTENA (1u<<16)
  51. #define SCB_SHCSR_SVCALLPENDED (1u<<15)
  52. #define SCB_SHCSR_BUSFAULTPENDED (1u<<14)
  53. #define SCB_SHCSR_MEMFAULTPENDED (1u<<13)
  54. #define SCB_SHCSR_USGFAULTPENDED (1u<<12)
  55. #define SCB_SHCSR_SYSTICKACT (1u<<11)
  56. #define SCB_SHCSR_PENDSVACT (1u<<10)
  57. #define SCB_SHCSR_MONITORACT (1u<< 8)
  58. #define SCB_SHCSR_SVCALLACT (1u<< 7)
  59. #define SCB_SHCSR_USGFAULTACT (1u<< 3)
  60. #define SCB_SHCSR_BUSFAULTACT (1u<< 1)
  61. #define SCB_SHCSR_MEMFAULTACT (1u<< 0)
  62. #define SCB_CFSR_DIVBYZERO (1u<<25)
  63. #define SCB_CFSR_UNALIGNED (1u<<24)
  64. #define SCB_CFSR_NOCP (1u<<19)
  65. #define SCB_CFSR_INVPC (1u<<18)
  66. #define SCB_CFSR_INVSTATE (1u<<17)
  67. #define SCB_CFSR_UNDEFINSTR (1u<<16)
  68. #define SCB_CFSR_BFARVALID (1u<<15)
  69. #define SCB_CFSR_STKERR (1u<<12)
  70. #define SCB_CFSR_UNSTKERR (1u<<11)
  71. #define SCB_CFSR_IMPRECISERR (1u<<10)
  72. #define SCB_CFSR_PRECISERR (1u<< 9)
  73. #define SCB_CFSR_IBUSERR (1u<< 8)
  74. #define SCB_CFSR_MMARVALID (1u<< 7)
  75. #define SCB_CFSR_MSTKERR (1u<< 4)
  76. #define SCB_CFSR_MUNSTKERR (1u<< 3)
  77. #define SCB_CFSR_DACCVIOL (1u<< 1)
  78. #define SCB_CFSR_IACCVIOL (1u<< 0)
  79. #define SCB_AIRCR_VECTKEY (0x05fau<<16)
  80. #define SCB_AIRCR_SYSRESETREQ (1u<<2)
  81. #define SCB_BASE 0xe000ed00
  82. /* Nested vectored interrupt controller */
  83. struct nvic {
  84. uint32_t iser[32]; /* 00: Interrupt set-enable */
  85. uint32_t icer[32]; /* 80: Interrupt clear-enable */
  86. uint32_t ispr[32]; /* 100: Interrupt set-pending */
  87. uint32_t icpr[32]; /* 180: Interrupt clear-pending */
  88. uint32_t iabr[64]; /* 200: Interrupt active */
  89. uint8_t ipr[80]; /* 300: Interrupt priority */
  90. };
  91. #define NVIC_BASE 0xe000e100
  92. /* Independent Watchdog */
  93. struct iwdg {
  94. uint32_t kr; /* 00: Key */
  95. uint32_t pr; /* 04: Prescaler */
  96. uint32_t rlr; /* 08: Reload */
  97. uint32_t sr; /* 0C: Status */
  98. };
  99. #define IWDG_BASE 0x40003000
  100. struct exti {
  101. uint32_t imr; /* 00: Interrupt mask */
  102. uint32_t emr; /* 04: Event mask */
  103. uint32_t rtsr; /* 08: Rising trigger selection */
  104. uint32_t ftsr; /* 0C: Falling trigger selection */
  105. uint32_t swier; /* 10: Software interrupt event */
  106. uint32_t pr; /* 14: Pending */
  107. };
  108. /* Timer */
  109. struct tim {
  110. uint32_t cr1; /* 00: Control 1 */
  111. uint32_t cr2; /* 04: Control 2 */
  112. uint32_t smcr; /* 08: Slave mode control */
  113. uint32_t dier; /* 0C: DMA/interrupt enable */
  114. uint32_t sr; /* 10: Status */
  115. uint32_t egr; /* 14: Event generation */
  116. uint32_t ccmr1; /* 18: Capture/compare mode 1 */
  117. uint32_t ccmr2; /* 1C: Capture/compare mode 2 */
  118. uint32_t ccer; /* 20: Capture/compare enable */
  119. uint32_t cnt; /* 24: Counter */
  120. uint32_t psc; /* 28: Prescaler */
  121. uint32_t arr; /* 2C: Auto-reload */
  122. uint32_t rcr; /* 30: Repetition counter */
  123. uint32_t ccr1; /* 34: Capture/compare 1 */
  124. uint32_t ccr2; /* 38: Capture/compare 2 */
  125. uint32_t ccr3; /* 3C: Capture/compare 3 */
  126. uint32_t ccr4; /* 40: Capture/compare 4 */
  127. uint32_t bdtr; /* 44: Break and dead-time */
  128. uint32_t dcr; /* 48: DMA control */
  129. uint32_t dmar; /* 4C: DMA address for full transfer */
  130. uint32_t _pad; /* 50: - */
  131. uint32_t ccmr3; /* 54: Capture/compare mode 3 */
  132. uint32_t ccr5; /* 58: Capture/compare 5 */
  133. uint32_t ccr6; /* 5C: Capture/compare 6 */
  134. };
  135. #define TIM_CR1_ARPE (1u<<7)
  136. #define TIM_CR1_DIR (1u<<4)
  137. #define TIM_CR1_OPM (1u<<3)
  138. #define TIM_CR1_URS (1u<<2)
  139. #define TIM_CR1_UDIS (1u<<1)
  140. #define TIM_CR1_CEN (1u<<0)
  141. #define TIM_CR2_TI1S (1u<<7)
  142. #define TIM_CR2_MMS(x) ((x)<<4)
  143. #define TIM_CR2_CCDS (1u<<3)
  144. #define TIM_SMCR_ETP (1u<<15)
  145. #define TIM_SMCR_ETC (1u<<14)
  146. #define TIM_SMCR_ETPS(x) ((x)<<12)
  147. #define TIM_SMCR_ETF(x) ((x)<<8)
  148. #define TIM_SMCR_MSM (1u<<7)
  149. #define TIM_SMCR_TS(x) ((x)<<4)
  150. #define TIM_SMCR_SMS(x) ((x)<<0)
  151. #define TIM_DIER_TDE (1u<<14)
  152. #define TIM_DIER_CC4DE (1u<<12)
  153. #define TIM_DIER_CC3DE (1u<<11)
  154. #define TIM_DIER_CC2DE (1u<<10)
  155. #define TIM_DIER_CC1DE (1u<<9)
  156. #define TIM_DIER_UDE (1u<<8)
  157. #define TIM_DIER_TIE (1u<<6)
  158. #define TIM_DIER_CC4IE (1u<<4)
  159. #define TIM_DIER_CC3IE (1u<<3)
  160. #define TIM_DIER_CC2IE (1u<<2)
  161. #define TIM_DIER_CC1IE (1u<<1)
  162. #define TIM_DIER_UIE (1u<<0)
  163. #define TIM_SR_CC4OF (1u<<12)
  164. #define TIM_SR_CC3OF (1u<<11)
  165. #define TIM_SR_CC2OF (1u<<10)
  166. #define TIM_SR_CC1OF (1u<<9)
  167. #define TIM_SR_TIF (1u<<6)
  168. #define TIM_SR_CC4IF (1u<<4)
  169. #define TIM_SR_CC3IF (1u<<3)
  170. #define TIM_SR_CC2IF (1u<<2)
  171. #define TIM_SR_CC1IF (1u<<1)
  172. #define TIM_SR_UIF (1u<<0)
  173. #define TIM_EGR_TG (1u<<6)
  174. #define TIM_EGR_CC4G (1u<<4)
  175. #define TIM_EGR_CC3G (1u<<3)
  176. #define TIM_EGR_CC2G (1u<<2)
  177. #define TIM_EGR_CC1G (1u<<1)
  178. #define TIM_EGR_UG (1u<<0)
  179. #define TIM_CCMR1_OC2CE (1u <<15)
  180. #define TIM_CCMR1_OC2M(x) ((x)<<12)
  181. #define TIM_CCMR1_OC2PE (1u <<11)
  182. #define TIM_CCMR1_OC2FE (1u <<10)
  183. #define TIM_CCMR1_CC2S(x) ((x)<< 8)
  184. #define TIM_CCMR1_OC1CE (1u << 7)
  185. #define TIM_CCMR1_OC1M(x) ((x)<< 4)
  186. #define TIM_CCMR1_OC1PE (1u << 3)
  187. #define TIM_CCMR1_OC1FE (1u << 2)
  188. #define TIM_CCMR1_CC1S(x) ((x)<< 0)
  189. #define TIM_CCMR1_IC2F(x) ((x)<<12)
  190. #define TIM_CCMR1_IC2PSC(x) ((x)<<10)
  191. #define TIM_CCMR1_IC1F(x) ((x)<< 4)
  192. #define TIM_CCMR1_IC1PSC(x) ((x)<< 2)
  193. #define TIM_CCMR2_OC4CE (1u <<15)
  194. #define TIM_CCMR2_OC4M(x) ((x)<<12)
  195. #define TIM_CCMR2_OC4PE (1u <<11)
  196. #define TIM_CCMR2_OC4FE (1u <<10)
  197. #define TIM_CCMR2_CC4S(x) ((x)<< 8)
  198. #define TIM_CCMR2_OC3CE (1u << 7)
  199. #define TIM_CCMR2_OC3M(x) ((x)<< 4)
  200. #define TIM_CCMR2_OC3PE (1u << 3)
  201. #define TIM_CCMR2_OC3FE (1u << 2)
  202. #define TIM_CCMR2_CC3S(x) ((x)<< 0)
  203. #define TIM_CCMR2_IC4F(x) ((x)<<12)
  204. #define TIM_CCMR2_IC4PSC(x) ((x)<<10)
  205. #define TIM_CCMR2_IC3F(x) ((x)<< 4)
  206. #define TIM_CCMR2_IC3PSC(x) ((x)<< 2)
  207. #define TIM_OCM_FROZEN (0u)
  208. #define TIM_OCM_SET_HIGH (1u)
  209. #define TIM_OCM_SET_LOW (2u)
  210. #define TIM_OCM_TOGGLE (3u)
  211. #define TIM_OCM_FORCE_LOW (4u)
  212. #define TIM_OCM_FORCE_HIGH (5u)
  213. #define TIM_OCM_PWM1 (6u)
  214. #define TIM_OCM_PWM2 (7u)
  215. #define TIM_OCM_MASK (7u)
  216. #define TIM_CCS_OUTPUT (0u)
  217. #define TIM_CCS_INPUT_TI1 (1u)
  218. #define TIM_CCS_INPUT_TI2 (2u)
  219. #define TIM_CCS_INPUT_TRC (3u)
  220. #define TIM_CCS_MASK (3u)
  221. #define TIM_CCER_CC4P (1u<<13)
  222. #define TIM_CCER_CC4E (1u<<12)
  223. #define TIM_CCER_CC3P (1u<< 9)
  224. #define TIM_CCER_CC3E (1u<< 8)
  225. #define TIM_CCER_CC2P (1u<< 5)
  226. #define TIM_CCER_CC2E (1u<< 4)
  227. #define TIM_CCER_CC1P (1u<< 1)
  228. #define TIM_CCER_CC1E (1u<< 0)
  229. #define TIM_BDTR_MOE (1u<<15)
  230. #define TIM_BDTR_AOE (1u<<14)
  231. #define TIM_BDTR_BKP (1u<<13)
  232. #define TIM_BDTR_BKE (1u<<12)
  233. #define TIM_BDTR_OSSR (1u<<11)
  234. #define TIM_BDTR_OSSI (1u<<10)
  235. #define TIM_BDTR_LOCK(x) ((x)<<8)
  236. #define TIM_BDTR_DTG(x) ((x)<<0)
  237. /* SPI/I2S */
  238. struct spi {
  239. uint32_t cr1; /* 00: Control 1 */
  240. uint32_t cr2; /* 04: Control 2 */
  241. uint32_t sr; /* 08: Status */
  242. uint32_t dr; /* 0C: Data */
  243. uint32_t crcpr; /* 10: CRC polynomial */
  244. uint32_t rxcrcr; /* 14: RX CRC */
  245. uint32_t txcrcr; /* 18: TX CRC */
  246. uint32_t i2scfgr; /* 1C: I2S configuration */
  247. uint32_t i2spr; /* 20: I2S prescaler */
  248. };
  249. #define SPI_CR1_BIDIMODE (1u<<15)
  250. #define SPI_CR1_BIDIOE (1u<<14)
  251. #define SPI_CR1_CRCEN (1u<<13)
  252. #define SPI_CR1_CRCNEXT (1u<<12)
  253. #define SPI_CR1_DFF (1u<<11)
  254. #define SPI_CR1_RXONLY (1u<<10)
  255. #define SPI_CR1_SSM (1u<< 9)
  256. #define SPI_CR1_SSI (1u<< 8)
  257. #define SPI_CR1_LSBFIRST (1u<< 7)
  258. #define SPI_CR1_SPE (1u<< 6)
  259. #define SPI_CR1_BR_DIV2 (0u<< 3)
  260. #define SPI_CR1_BR_DIV4 (1u<< 3)
  261. #define SPI_CR1_BR_DIV8 (2u<< 3)
  262. #define SPI_CR1_BR_DIV16 (3u<< 3)
  263. #define SPI_CR1_BR_DIV32 (4u<< 3)
  264. #define SPI_CR1_BR_DIV64 (5u<< 3)
  265. #define SPI_CR1_BR_DIV128 (6u<< 3)
  266. #define SPI_CR1_BR_DIV256 (7u<< 3)
  267. #define SPI_CR1_BR_MASK (7u<< 3)
  268. #define SPI_CR1_MSTR (1u<< 2)
  269. #define SPI_CR1_CPOL (1u<< 1)
  270. #define SPI_CR1_CPHA (1u<< 0)
  271. #define SPI_CR2_TXEIE (1u<< 7)
  272. #define SPI_CR2_RXNEIE (1u<< 6)
  273. #define SPI_CR2_ERRIE (1u<< 5)
  274. #define SPI_CR2_SSOE (1u<< 2)
  275. #define SPI_CR2_TXDMAEN (1u<< 1)
  276. #define SPI_CR2_RXDMAEN (1u<< 0)
  277. #define SPI_SR_BSY (1u<< 7)
  278. #define SPI_SR_OVR (1u<< 6)
  279. #define SPI_SR_MODF (1u<< 5)
  280. #define SPI_SR_CRCERR (1u<< 4)
  281. #define SPI_SR_USR (1u<< 3)
  282. #define SPI_SR_CHSIDE (1u<< 2)
  283. #define SPI_SR_TXE (1u<< 1)
  284. #define SPI_SR_RXNE (1u<< 0)
  285. #define SPI1_BASE 0x40013000
  286. #define SPI2_BASE 0x40003800
  287. #define SPI3_BASE 0x40003C00
  288. /* USB Full Speed */
  289. struct usb {
  290. uint32_t epr[8]; /* 4*n: Endpoint n */
  291. uint32_t rsvd[8];
  292. uint32_t cntr; /* 40: Control */
  293. uint32_t istr; /* 44: Interrupt status */
  294. uint32_t fnr; /* 48: Frame number */
  295. uint32_t daddr; /* 4C: Device address */
  296. uint32_t btable; /* 50: Buffer table address */
  297. };
  298. struct usb_bufd {
  299. union {
  300. struct {
  301. uint32_t addr_tx; /* 00: Transmission buffer address */
  302. uint32_t count_tx; /* 04: Transmission byte count */
  303. uint32_t addr_rx; /* 08: Reception buffer address */
  304. uint32_t count_rx; /* 0C: Reception byte count */
  305. };
  306. struct {
  307. uint32_t addr_0; /* 00: Double buffer #0 address */
  308. uint32_t count_0; /* 04: Double buffer #0 byte count */
  309. uint32_t addr_1; /* 08: Double buffer #1 address */
  310. uint32_t count_1; /* 0C: Double buffer #1 byte count */
  311. };
  312. };
  313. };
  314. #define USB_EPR_CTR_RX (1u<<15)
  315. #define USB_EPR_DTOG_RX (1u<<14)
  316. #define USB_EPR_STAT_RX(x) ((x)<<12)
  317. #define USB_EPR_SETUP (1u<<11)
  318. #define USB_EPR_EP_TYPE(x) ((x)<<9)
  319. #define USB_EPR_EP_KIND_DBL_BUF (1<<8) /* USB_EP_TYPE_BULK */
  320. #define USB_EPR_EP_KIND_STATUS_OUT (1<<8) /* USB_EP_TYPE_CONTROL */
  321. #define USB_EPR_CTR_TX (1u<< 7)
  322. #define USB_EPR_DTOG_TX (1u<< 6)
  323. #define USB_EPR_STAT_TX(x) ((x)<<4)
  324. #define USB_EPR_EA(x) ((x)<<0)
  325. #define USB_STAT_DISABLED (0u)
  326. #define USB_STAT_STALL (1u)
  327. #define USB_STAT_NAK (2u)
  328. #define USB_STAT_VALID (3u)
  329. #define USB_STAT_MASK (3u)
  330. #define USB_EP_TYPE_BULK (0u)
  331. #define USB_EP_TYPE_CONTROL (1u)
  332. #define USB_EP_TYPE_ISO (2u)
  333. #define USB_EP_TYPE_INTERRUPT (3u)
  334. #define USB_EP_TYPE_MASK (3u)
  335. #define USB_CNTR_CTRM (1u<<15)
  336. #define USB_CNTR_PMAOVRM (1u<<14)
  337. #define USB_CNTR_ERRM (1u<<13)
  338. #define USB_CNTR_WKUPM (1u<<12)
  339. #define USB_CNTR_SUSPM (1u<<11)
  340. #define USB_CNTR_RESETM (1u<<10)
  341. #define USB_CNTR_SOFM (1u<< 9)
  342. #define USB_CNTR_ESOFM (1u<< 8)
  343. #define USB_CNTR_RESUME (1u<< 4)
  344. #define USB_CNTR_FSUSP (1u<< 3)
  345. #define USB_CNTR_LP_MODE (1u<< 2)
  346. #define USB_CNTR_PDWN (1u<< 1)
  347. #define USB_CNTR_FRES (1u<< 0)
  348. #define USB_ISTR_CTR (1u<<15)
  349. #define USB_ISTR_PMAOVR (1u<<14)
  350. #define USB_ISTR_ERR (1u<<13)
  351. #define USB_ISTR_WKUP (1u<<12)
  352. #define USB_ISTR_SUSP (1u<<11)
  353. #define USB_ISTR_RESET (1u<<10)
  354. #define USB_ISTR_SOF (1u<< 9)
  355. #define USB_ISTR_ESOF (1u<< 8)
  356. #define USB_ISTR_DIR (1u<< 4)
  357. #define USB_ISTR_GET_EP_ID(x) ((x)&0xf)
  358. #define USB_FNR_RXDP (1u<<15)
  359. #define USB_FNR_RXDM (1u<<14)
  360. #define USB_FNR_LCK (1u<<13)
  361. #define USB_FNR_GET_LSOF(x) (((x)>>11)&3)
  362. #define USB_FNR_GET_FN(x) ((x)&0x7ff)
  363. #define USB_DADDR_EF (1u<< 7)
  364. #define USB_DADDR_ADD(x) ((x)<<0)
  365. /* USB On-The-Go Full Speed interface */
  366. struct usb_otg {
  367. uint32_t gotctl; /* 00: Control and status */
  368. uint32_t gotgint; /* 04: Interrupt */
  369. uint32_t gahbcfg; /* 08: AHB configuration */
  370. uint32_t gusbcfg; /* 0C: USB configuration */
  371. uint32_t grstctl; /* 10: Reset */
  372. uint32_t gintsts; /* 14: Core interrupt */
  373. uint32_t gintmsk; /* 18: Interrupt mask */
  374. uint32_t grxstsr; /* 1C: Receive status debug read */
  375. uint32_t grxstsp; /* 20: Receive status debug pop */
  376. uint32_t grxfsiz; /* 24: Receive FIFO size */
  377. union {
  378. uint32_t hnptxfsiz; /* 28: Host non-periodic transmit FIFO size */
  379. uint32_t dieptxf0; /* 28: Endpoint 0 transmit FIFO size */
  380. };
  381. uint32_t hnptxsts; /* 2C: Non-periodic transmit FIFO/queue status */
  382. uint32_t _0[2];
  383. uint32_t gccfg; /* 38: General core configuration */
  384. uint32_t cid; /* 3C: Core ID */
  385. uint32_t _1[48];
  386. uint32_t hptxfsiz; /* 100: Host periodic transmit FIFO size */
  387. uint32_t dieptxf1; /* 104: Device IN endpoint transmit FIFO #1 size */
  388. uint32_t dieptxf2; /* 108: Device IN endpoint transmit FIFO #2 size */
  389. uint32_t dieptxf3; /* 10C: Device IN endpoint transmit FIFO #3 size */
  390. uint32_t _2[188];
  391. uint32_t hcfg; /* 400: Host configuration */
  392. uint32_t hfir; /* 404: Host frame interval */
  393. uint32_t hfnum; /* 408: Host frame number / frame time remaining */
  394. uint32_t _3[1]; /* 40C: */
  395. uint32_t hptxsts; /* 410: Host periodic transmit FIFO / queue status */
  396. uint32_t haint; /* 414: Host all channels interrupt status */
  397. uint32_t haintmsk; /* 418: Host all channels interrupt mask */
  398. uint32_t _4[9];
  399. uint32_t hprt; /* 440: Host port control and status */
  400. uint32_t _5[47];
  401. struct {
  402. uint32_t charac; /* +00: Host channel-x characteristics */
  403. uint32_t _0[1];
  404. uint32_t intsts; /* +08: Host channel-x interrupt status */
  405. uint32_t intmsk; /* +0C: Host channel-x interrupt mask */
  406. uint32_t tsiz; /* +10: Host channel x transfer size */
  407. uint32_t _1[3];
  408. } hc[8]; /* 500..5E0: */
  409. uint32_t _6[128];
  410. uint32_t dcfg; /* 800: Device configuration */
  411. uint32_t dctl; /* 804: Device control */
  412. uint32_t dsts; /* 808: Device status */
  413. uint32_t _7[1];
  414. uint32_t diepmsk; /* 810: Device IN endpoint common interrupt mask */
  415. uint32_t doepmsk; /* 814: Device OUT endpoint common interrupt mask */
  416. uint32_t daint; /* 818: Device all endpoints interrupt status */
  417. uint32_t daintmsk; /* 81C: Device all endpoints interrupt mask */
  418. uint32_t _8[2];
  419. uint32_t dvbusdis; /* 828: Device VBUS discharge time */
  420. uint32_t dvbuspulse; /* 82C: Device VBUS pulsing time */
  421. uint32_t _9[1];
  422. uint32_t diepempmsk; /* 834: Device IN endpoint FIFO empty int. mask */
  423. uint32_t _10[50];
  424. struct {
  425. uint32_t ctl; /* +00: Device IN endpoint-x control */
  426. uint32_t _0[1];
  427. uint32_t intsts; /* +08: Device IN endpoint-x interrupt status */
  428. uint32_t _1[3];
  429. uint32_t txfsts; /* +18: Device IN endpoint-x transmit FIFO status */
  430. uint32_t _2[1];
  431. } diep[4]; /* 900..960: */
  432. uint32_t _11[96];
  433. struct {
  434. uint32_t ctl; /* +00: Device OUT endpoint-x control */
  435. uint32_t _0[1];
  436. uint32_t intsts; /* +08: Device OUT endpoint-x interrupt status */
  437. uint32_t _1[1];
  438. uint32_t tsiz; /* +10: Device OUT endpoint-x transmit FIFO status */
  439. uint32_t _2[3];
  440. } doep[4]; /* B00..B60: */
  441. uint32_t _12[160];
  442. uint32_t pcgcctl; /* E00: Power and clock gating control */
  443. };
  444. #define OTG_GAHBCFG_PTXFELVL (1u<< 8)
  445. #define OTG_GAHBCFG_TXFELVL (1u<< 7)
  446. #define OTG_GAHBCFG_GINTMSK (1u<< 0)
  447. #define OTG_GUSBCFG_CTXPKT (1u<<31)
  448. #define OTG_GUSBCFG_FDMOD (1u<<30)
  449. #define OTG_GUSBCFG_FHMOD (1u<<29)
  450. #define OTG_GUSBCFG_TRDT(x) ((x)<<10)
  451. #define OTG_GUSBCFG_HNPCAP (1u<< 9)
  452. #define OTG_GUSBCFG_SRPCAP (1u<< 8)
  453. #define OTG_GUSBCFG_PHYSEL (1u<< 6)
  454. #define OTG_GUSBCFG_TOCAL(x) ((x)<< 0)
  455. /* GINTSTS and GINTMSK */
  456. #define OTG_GINT_WKUPINT (1u<<31) /* Host + Device */
  457. #define OTG_GINT_SRQINT (1u<<30) /* H + D */
  458. #define OTG_GINT_DISCINT (1u<<29) /* H */
  459. #define OTG_GINT_CIDSCHG (1u<<28) /* H + D */
  460. #define OTG_GINT_PTXFE (1u<<26) /* H */
  461. #define OTG_GINT_HCINT (1u<<25) /* H */
  462. #define OTG_GINT_HPRTINT (1u<<24) /* H */
  463. #define OTG_GINT_IPXFR (1u<<21) /* H */
  464. #define OTG_GINT_IISOIXFR (1u<<20) /* D */
  465. #define OTG_GINT_OEPINT (1u<<19) /* D */
  466. #define OTG_GINT_IEPINT (1u<<18) /* D */
  467. #define OTG_GINT_EOPF (1u<<15) /* D */
  468. #define OTG_GINT_ISOODRP (1u<<14) /* D */
  469. #define OTG_GINT_ENUMDNE (1u<<13) /* D */
  470. #define OTG_GINT_USBRST (1u<<12) /* D */
  471. #define OTG_GINT_USBSUSP (1u<<11) /* D */
  472. #define OTG_GINT_ESUSP (1u<<10) /* D */
  473. #define OTG_GINT_GONAKEFF (1u<< 7) /* D */
  474. #define OTG_GINT_GINAKEFF (1u<< 6) /* D */
  475. #define OTG_GINT_NPTXFE (1u<< 5) /* H */
  476. #define OTG_GINT_RXFLVL (1u<< 4) /* H + D */
  477. #define OTG_GINT_SOF (1u<< 3) /* H + D */
  478. #define OTG_GINT_OTGINT (1u<< 2) /* H + D */
  479. #define OTG_GINT_MMIS (1u<< 1) /* H + D */
  480. #define OTG_GINT_CMOD (1u<< 0) /* H + D */
  481. #define OTG_RXSTS_PKTSTS_IN (2u)
  482. #define OTG_RXSTS_PKTSTS(r) (((r)>>17)&0xf)
  483. #define OTG_RXSTS_BCNT(r) (((r)>>4)&0x7ff)
  484. #define OTG_RXSTS_CHNUM(r) ((r)&0xf)
  485. #define OTG_GCCFG_SOFOUTEN (1u<<20)
  486. #define OTG_GCCFG_VBUSBSEN (1u<<19)
  487. #define OTG_GCCFG_VBUSASEN (1u<<18)
  488. #define OTG_GCCFG_PWRDWN (1u<<16)
  489. #define OTG_HCFG_FSLSS (1u<<2)
  490. #define OTG_HCFG_FSLSPCS (3u<<0)
  491. #define OTG_HCFG_FSLSPCS_48 (1u<<0)
  492. #define OTG_HCFG_FSLSPCS_6 (2u<<0)
  493. #define OTG_HPRT_PSPD_FULL (1u<<17)
  494. #define OTG_HPRT_PSPD_LOW (2u<<17)
  495. #define OTG_HPRT_PSPD_MASK (1u<<17) /* read-only */
  496. #define OTG_HPRT_PPWR (1u<<12)
  497. #define OTG_HPRT_PRST (1u<< 8)
  498. #define OTG_HPRT_PSUSP (1u<< 7)
  499. #define OTG_HPRT_PRES (1u<< 6)
  500. #define OTG_HPRT_POCCHNG (1u<< 5) /* raises HPRTINT */
  501. #define OTG_HPRT_POCA (1u<< 4)
  502. #define OTG_HPRT_PENCHNG (1u<< 3) /* raises HPRTINT */
  503. #define OTG_HPRT_PENA (1u<< 2)
  504. #define OTG_HPRT_PCDET (1u<< 1) /* raises HPRTINT */
  505. #define OTG_HPRT_PCSTS (1u<< 0)
  506. #define OTG_HPRT_INTS (OTG_HPRT_POCCHNG|OTG_HPRT_PENCHNG|OTG_HPRT_PCDET| \
  507. OTG_HPRT_PENA) /* PENA is also set-to-clear */
  508. /* HCINTSTS and HCINTMSK */
  509. #define OTG_HCINT_DTERR (1u<<10)
  510. #define OTG_HCINT_FRMOR (1u<< 9)
  511. #define OTG_HCINT_BBERR (1u<< 8)
  512. #define OTG_HCINT_TXERR (1u<< 7)
  513. #define OTG_HCINT_NYET (1u<< 6) /* high-speed only; not STM32F10x */
  514. #define OTG_HCINT_ACK (1u<< 5)
  515. #define OTG_HCINT_NAK (1u<< 4)
  516. #define OTG_HCINT_STALL (1u<< 3)
  517. #define OTG_HCINT_CHH (1u<< 1)
  518. #define OTG_HCINT_XFRC (1u<< 0)
  519. #define OTG_HCCHAR_CHENA (1u<<31)
  520. #define OTG_HCCHAR_CHDIS (1u<<30)
  521. #define OTG_HCCHAR_ODDFRM (1u<<29)
  522. #define OTG_HCCHAR_DAD(x) ((x)<<22)
  523. #define OTG_HCCHAR_MCNT(x) ((x)<<20)
  524. #define OTG_HCCHAR_ETYP_CTRL (0u<<18)
  525. #define OTG_HCCHAR_ETYP_ISO (1u<<18)
  526. #define OTG_HCCHAR_ETYP_BULK (2u<<18)
  527. #define OTG_HCCHAR_ETYP_INT (3u<<18)
  528. #define OTG_HCCHAR_LSDEV (1u<<17)
  529. #define OTG_HCCHAR_EPDIR_OUT (0u<<15)
  530. #define OTG_HCCHAR_EPDIR_IN (1u<<15)
  531. #define OTG_HCCHAR_EPNUM(x) ((x)<<11)
  532. #define OTG_HCCHAR_MPSIZ(x) ((x)<< 0)
  533. #define OTG_HCTSIZ_DPID_DATA0 (0u<<29)
  534. #define OTG_HCTSIZ_DPID_DATA2 (1u<<29)
  535. #define OTG_HCTSIZ_DPID_DATA1 (2u<<29)
  536. #define OTG_HCTSIZ_DPID_MDATA (3u<<29)
  537. #define OTG_HCTSIZ_DPID_SETUP (3u<<29)
  538. #define OTG_HCTSIZ_PKTCNT(x) ((x)<<19)
  539. #define OTG_HCTSIZ_XFRSIZ(x) ((x)<< 0)
  540. /*
  541. * Local variables:
  542. * mode: C
  543. * c-file-style: "Linux"
  544. * c-basic-offset: 4
  545. * tab-width: 4
  546. * indent-tabs-mode: nil
  547. * End:
  548. */