stm32_uart_regs.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /*
  2. * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef STM32_UART_REGS_H
  7. #define STM32_UART_REGS_H
  8. #include <lib/utils_def.h>
  9. #define USART_CR1 U(0x00)
  10. #define USART_CR2 U(0x04)
  11. #define USART_CR3 U(0x08)
  12. #define USART_BRR U(0x0C)
  13. #define USART_GTPR U(0x10)
  14. #define USART_RTOR U(0x14)
  15. #define USART_RQR U(0x18)
  16. #define USART_ISR U(0x1C)
  17. #define USART_ICR U(0x20)
  18. #define USART_RDR U(0x24)
  19. #define USART_TDR U(0x28)
  20. #define USART_PRESC U(0x2C)
  21. /* USART_CR1 register fields */
  22. #define USART_CR1_UE BIT(0)
  23. #define USART_CR1_UESM BIT(1)
  24. #define USART_CR1_RE BIT(2)
  25. #define USART_CR1_TE BIT(3)
  26. #define USART_CR1_IDLEIE BIT(4)
  27. #define USART_CR1_RXNEIE BIT(5)
  28. #define USART_CR1_TCIE BIT(6)
  29. #define USART_CR1_TXEIE BIT(7)
  30. #define USART_CR1_PEIE BIT(8)
  31. #define USART_CR1_PS BIT(9)
  32. #define USART_CR1_PCE BIT(10)
  33. #define USART_CR1_WAKE BIT(11)
  34. #define USART_CR1_M (BIT(28) | BIT(12))
  35. #define USART_CR1_M0 BIT(12)
  36. #define USART_CR1_MME BIT(13)
  37. #define USART_CR1_CMIE BIT(14)
  38. #define USART_CR1_OVER8 BIT(15)
  39. #define USART_CR1_DEDT GENMASK(20, 16)
  40. #define USART_CR1_DEDT_0 BIT(16)
  41. #define USART_CR1_DEDT_1 BIT(17)
  42. #define USART_CR1_DEDT_2 BIT(18)
  43. #define USART_CR1_DEDT_3 BIT(19)
  44. #define USART_CR1_DEDT_4 BIT(20)
  45. #define USART_CR1_DEAT GENMASK(25, 21)
  46. #define USART_CR1_DEAT_0 BIT(21)
  47. #define USART_CR1_DEAT_1 BIT(22)
  48. #define USART_CR1_DEAT_2 BIT(23)
  49. #define USART_CR1_DEAT_3 BIT(24)
  50. #define USART_CR1_DEAT_4 BIT(25)
  51. #define USART_CR1_RTOIE BIT(26)
  52. #define USART_CR1_EOBIE BIT(27)
  53. #define USART_CR1_M1 BIT(28)
  54. #define USART_CR1_FIFOEN BIT(29)
  55. #define USART_CR1_TXFEIE BIT(30)
  56. #define USART_CR1_RXFFIE BIT(31)
  57. /* USART_CR2 register fields */
  58. #define USART_CR2_SLVEN BIT(0)
  59. #define USART_CR2_DIS_NSS BIT(3)
  60. #define USART_CR2_ADDM7 BIT(4)
  61. #define USART_CR2_LBDL BIT(5)
  62. #define USART_CR2_LBDIE BIT(6)
  63. #define USART_CR2_LBCL BIT(8)
  64. #define USART_CR2_CPHA BIT(9)
  65. #define USART_CR2_CPOL BIT(10)
  66. #define USART_CR2_CLKEN BIT(11)
  67. #define USART_CR2_STOP GENMASK(13, 12)
  68. #define USART_CR2_STOP_0 BIT(12)
  69. #define USART_CR2_STOP_1 BIT(13)
  70. #define USART_CR2_LINEN BIT(14)
  71. #define USART_CR2_SWAP BIT(15)
  72. #define USART_CR2_RXINV BIT(16)
  73. #define USART_CR2_TXINV BIT(17)
  74. #define USART_CR2_DATAINV BIT(18)
  75. #define USART_CR2_MSBFIRST BIT(19)
  76. #define USART_CR2_ABREN BIT(20)
  77. #define USART_CR2_ABRMODE GENMASK(22, 21)
  78. #define USART_CR2_ABRMODE_0 BIT(21)
  79. #define USART_CR2_ABRMODE_1 BIT(22)
  80. #define USART_CR2_RTOEN BIT(23)
  81. #define USART_CR2_ADD GENMASK(31, 24)
  82. /* USART_CR3 register fields */
  83. #define USART_CR3_EIE BIT(0)
  84. #define USART_CR3_IREN BIT(1)
  85. #define USART_CR3_IRLP BIT(2)
  86. #define USART_CR3_HDSEL BIT(3)
  87. #define USART_CR3_NACK BIT(4)
  88. #define USART_CR3_SCEN BIT(5)
  89. #define USART_CR3_DMAR BIT(6)
  90. #define USART_CR3_DMAT BIT(7)
  91. #define USART_CR3_RTSE BIT(8)
  92. #define USART_CR3_CTSE BIT(9)
  93. #define USART_CR3_CTSIE BIT(10)
  94. #define USART_CR3_ONEBIT BIT(11)
  95. #define USART_CR3_OVRDIS BIT(12)
  96. #define USART_CR3_DDRE BIT(13)
  97. #define USART_CR3_DEM BIT(14)
  98. #define USART_CR3_DEP BIT(15)
  99. #define USART_CR3_SCARCNT GENMASK(19, 17)
  100. #define USART_CR3_SCARCNT_0 BIT(17)
  101. #define USART_CR3_SCARCNT_1 BIT(18)
  102. #define USART_CR3_SCARCNT_2 BIT(19)
  103. #define USART_CR3_WUS GENMASK(21, 20)
  104. #define USART_CR3_WUS_0 BIT(20)
  105. #define USART_CR3_WUS_1 BIT(21)
  106. #define USART_CR3_WUFIE BIT(22)
  107. #define USART_CR3_TXFTIE BIT(23)
  108. #define USART_CR3_TCBGTIE BIT(24)
  109. #define USART_CR3_RXFTCFG GENMASK(27, 25)
  110. #define USART_CR3_RXFTCFG_0 BIT(25)
  111. #define USART_CR3_RXFTCFG_1 BIT(26)
  112. #define USART_CR3_RXFTCFG_2 BIT(27)
  113. #define USART_CR3_RXFTIE BIT(28)
  114. #define USART_CR3_TXFTCFG GENMASK(31, 29)
  115. #define USART_CR3_TXFTCFG_0 BIT(29)
  116. #define USART_CR3_TXFTCFG_1 BIT(30)
  117. #define USART_CR3_TXFTCFG_2 BIT(31)
  118. /* USART_BRR register fields */
  119. #define USART_BRR_DIV_FRACTION GENMASK(3, 0)
  120. #define USART_BRR_DIV_MANTISSA GENMASK(15, 4)
  121. /* USART_GTPR register fields */
  122. #define USART_GTPR_PSC GENMASK(7, 0)
  123. #define USART_GTPR_GT GENMASK(15, 8)
  124. /* USART_RTOR register fields */
  125. #define USART_RTOR_RTO GENMASK(23, 0)
  126. #define USART_RTOR_BLEN GENMASK(31, 24)
  127. /* USART_RQR register fields */
  128. #define USART_RQR_ABRRQ BIT(0)
  129. #define USART_RQR_SBKRQ BIT(1)
  130. #define USART_RQR_MMRQ BIT(2)
  131. #define USART_RQR_RXFRQ BIT(3)
  132. #define USART_RQR_TXFRQ BIT(4)
  133. /* USART_ISR register fields */
  134. #define USART_ISR_PE BIT(0)
  135. #define USART_ISR_FE BIT(1)
  136. #define USART_ISR_NE BIT(2)
  137. #define USART_ISR_ORE BIT(3)
  138. #define USART_ISR_IDLE BIT(4)
  139. #define USART_ISR_RXNE BIT(5)
  140. #define USART_ISR_TC BIT(6)
  141. #define USART_ISR_TXE BIT(7)
  142. #define USART_ISR_LBDF BIT(8)
  143. #define USART_ISR_CTSIF BIT(9)
  144. #define USART_ISR_CTS BIT(10)
  145. #define USART_ISR_RTOF BIT(11)
  146. #define USART_ISR_EOBF BIT(12)
  147. #define USART_ISR_UDR BIT(13)
  148. #define USART_ISR_ABRE BIT(14)
  149. #define USART_ISR_ABRF BIT(15)
  150. #define USART_ISR_BUSY BIT(16)
  151. #define USART_ISR_CMF BIT(17)
  152. #define USART_ISR_SBKF BIT(18)
  153. #define USART_ISR_RWU BIT(19)
  154. #define USART_ISR_WUF BIT(20)
  155. #define USART_ISR_TEACK BIT(21)
  156. #define USART_ISR_REACK BIT(22)
  157. #define USART_ISR_TXFE BIT(23)
  158. #define USART_ISR_RXFF BIT(24)
  159. #define USART_ISR_TCBGT BIT(25)
  160. #define USART_ISR_RXFT BIT(26)
  161. #define USART_ISR_TXFT BIT(27)
  162. /* USART_ICR register fields */
  163. #define USART_ICR_PECF BIT(0)
  164. #define USART_ICR_FECF BIT(1)
  165. #define USART_ICR_NCF BIT(2)
  166. #define USART_ICR_ORECF BIT(3)
  167. #define USART_ICR_IDLECF BIT(4)
  168. #define USART_ICR_TCCF BIT(6)
  169. #define USART_ICR_TCBGT BIT(7)
  170. #define USART_ICR_LBDCF BIT(8)
  171. #define USART_ICR_CTSCF BIT(9)
  172. #define USART_ICR_RTOCF BIT(11)
  173. #define USART_ICR_EOBCF BIT(12)
  174. #define USART_ICR_UDRCF BIT(13)
  175. #define USART_ICR_CMCF BIT(17)
  176. #define USART_ICR_WUCF BIT(20)
  177. /* USART_RDR register fields */
  178. #define USART_RDR_RDR GENMASK(8, 0)
  179. /* USART_TDR register fields */
  180. #define USART_TDR_TDR GENMASK(8, 0)
  181. /* USART_PRESC register fields */
  182. #define USART_PRESC_PRESCALER GENMASK(3, 0)
  183. #endif /* STM32_UART_REGS_H */