hpm_uart_regs.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_UART_H
  8. #define HPM_UART_H
  9. typedef struct {
  10. __R uint8_t RESERVED0[4]; /* 0x0 - 0x3: Reserved */
  11. __RW uint32_t IDLE_CFG; /* 0x4: Idle Configuration Register */
  12. __RW uint32_t ADDR_CFG; /* 0x8: address match config register */
  13. __RW uint32_t IIR2; /* 0xC: Interrupt Identification Register2 */
  14. __RW uint32_t CFG; /* 0x10: Configuration Register */
  15. __RW uint32_t OSCR; /* 0x14: Over Sample Control Register */
  16. __RW uint32_t FCRR; /* 0x18: FIFO Control Register config */
  17. __RW uint32_t MOTO_CFG; /* 0x1C: moto system control register */
  18. union {
  19. __R uint32_t RBR; /* 0x20: Receiver Buffer Register (when DLAB = 0) */
  20. __W uint32_t THR; /* 0x20: Transmitter Holding Register (when DLAB = 0) */
  21. __RW uint32_t DLL; /* 0x20: Divisor Latch LSB (when DLAB = 1) */
  22. };
  23. union {
  24. __RW uint32_t IER; /* 0x24: Interrupt Enable Register (when DLAB = 0) */
  25. __RW uint32_t DLM; /* 0x24: Divisor Latch MSB (when DLAB = 1) */
  26. };
  27. union {
  28. __RW uint32_t IIR; /* 0x28: Interrupt Identification Register */
  29. __W uint32_t FCR; /* 0x28: FIFO Control Register */
  30. };
  31. __RW uint32_t LCR; /* 0x2C: Line Control Register */
  32. __RW uint32_t MCR; /* 0x30: Modem Control Register ( */
  33. __R uint32_t LSR; /* 0x34: Line Status Register */
  34. __R uint32_t MSR; /* 0x38: Modem Status Register */
  35. } UART_Type;
  36. /* Bitfield definition for register: IDLE_CFG */
  37. /*
  38. * TX_IDLE_COND (RW)
  39. *
  40. * IDLE Detection Condition
  41. * 0 - Treat as idle if TX pin is logic one
  42. * 1 - Treat as idle if UART state machine state is idle
  43. */
  44. #define UART_IDLE_CFG_TX_IDLE_COND_MASK (0x2000000UL)
  45. #define UART_IDLE_CFG_TX_IDLE_COND_SHIFT (25U)
  46. #define UART_IDLE_CFG_TX_IDLE_COND_SET(x) (((uint32_t)(x) << UART_IDLE_CFG_TX_IDLE_COND_SHIFT) & UART_IDLE_CFG_TX_IDLE_COND_MASK)
  47. #define UART_IDLE_CFG_TX_IDLE_COND_GET(x) (((uint32_t)(x) & UART_IDLE_CFG_TX_IDLE_COND_MASK) >> UART_IDLE_CFG_TX_IDLE_COND_SHIFT)
  48. /*
  49. * TX_IDLE_EN (RW)
  50. *
  51. * UART TX Idle Detect Enable
  52. * 0 - Disable
  53. * 1 - Enable
  54. */
  55. #define UART_IDLE_CFG_TX_IDLE_EN_MASK (0x1000000UL)
  56. #define UART_IDLE_CFG_TX_IDLE_EN_SHIFT (24U)
  57. #define UART_IDLE_CFG_TX_IDLE_EN_SET(x) (((uint32_t)(x) << UART_IDLE_CFG_TX_IDLE_EN_SHIFT) & UART_IDLE_CFG_TX_IDLE_EN_MASK)
  58. #define UART_IDLE_CFG_TX_IDLE_EN_GET(x) (((uint32_t)(x) & UART_IDLE_CFG_TX_IDLE_EN_MASK) >> UART_IDLE_CFG_TX_IDLE_EN_SHIFT)
  59. /*
  60. * TX_IDLE_THR (RW)
  61. *
  62. * Threshold for UART transmit Idle detection (in terms of bits)
  63. */
  64. #define UART_IDLE_CFG_TX_IDLE_THR_MASK (0xFF0000UL)
  65. #define UART_IDLE_CFG_TX_IDLE_THR_SHIFT (16U)
  66. #define UART_IDLE_CFG_TX_IDLE_THR_SET(x) (((uint32_t)(x) << UART_IDLE_CFG_TX_IDLE_THR_SHIFT) & UART_IDLE_CFG_TX_IDLE_THR_MASK)
  67. #define UART_IDLE_CFG_TX_IDLE_THR_GET(x) (((uint32_t)(x) & UART_IDLE_CFG_TX_IDLE_THR_MASK) >> UART_IDLE_CFG_TX_IDLE_THR_SHIFT)
  68. /*
  69. * RXEN (RW)
  70. *
  71. * UART receive enable.
  72. * 0 - hold RX input to high, avoide wrong data input when config pinmux
  73. * 1 - bypass RX input from PIN
  74. * software should set it after config pinmux
  75. */
  76. #define UART_IDLE_CFG_RXEN_MASK (0x800U)
  77. #define UART_IDLE_CFG_RXEN_SHIFT (11U)
  78. #define UART_IDLE_CFG_RXEN_SET(x) (((uint32_t)(x) << UART_IDLE_CFG_RXEN_SHIFT) & UART_IDLE_CFG_RXEN_MASK)
  79. #define UART_IDLE_CFG_RXEN_GET(x) (((uint32_t)(x) & UART_IDLE_CFG_RXEN_MASK) >> UART_IDLE_CFG_RXEN_SHIFT)
  80. /*
  81. * RX_IDLE_COND (RW)
  82. *
  83. * IDLE Detection Condition
  84. * 0 - Treat as idle if RX pin is logic one
  85. * 1 - Treat as idle if UART state machine state is idle
  86. */
  87. #define UART_IDLE_CFG_RX_IDLE_COND_MASK (0x200U)
  88. #define UART_IDLE_CFG_RX_IDLE_COND_SHIFT (9U)
  89. #define UART_IDLE_CFG_RX_IDLE_COND_SET(x) (((uint32_t)(x) << UART_IDLE_CFG_RX_IDLE_COND_SHIFT) & UART_IDLE_CFG_RX_IDLE_COND_MASK)
  90. #define UART_IDLE_CFG_RX_IDLE_COND_GET(x) (((uint32_t)(x) & UART_IDLE_CFG_RX_IDLE_COND_MASK) >> UART_IDLE_CFG_RX_IDLE_COND_SHIFT)
  91. /*
  92. * RX_IDLE_EN (RW)
  93. *
  94. * UART Idle Detect Enable
  95. * 0 - Disable
  96. * 1 - Enable
  97. * it should be enabled if enable address match feature
  98. */
  99. #define UART_IDLE_CFG_RX_IDLE_EN_MASK (0x100U)
  100. #define UART_IDLE_CFG_RX_IDLE_EN_SHIFT (8U)
  101. #define UART_IDLE_CFG_RX_IDLE_EN_SET(x) (((uint32_t)(x) << UART_IDLE_CFG_RX_IDLE_EN_SHIFT) & UART_IDLE_CFG_RX_IDLE_EN_MASK)
  102. #define UART_IDLE_CFG_RX_IDLE_EN_GET(x) (((uint32_t)(x) & UART_IDLE_CFG_RX_IDLE_EN_MASK) >> UART_IDLE_CFG_RX_IDLE_EN_SHIFT)
  103. /*
  104. * RX_IDLE_THR (RW)
  105. *
  106. * Threshold for UART Receive Idle detection (in terms of bits)
  107. */
  108. #define UART_IDLE_CFG_RX_IDLE_THR_MASK (0xFFU)
  109. #define UART_IDLE_CFG_RX_IDLE_THR_SHIFT (0U)
  110. #define UART_IDLE_CFG_RX_IDLE_THR_SET(x) (((uint32_t)(x) << UART_IDLE_CFG_RX_IDLE_THR_SHIFT) & UART_IDLE_CFG_RX_IDLE_THR_MASK)
  111. #define UART_IDLE_CFG_RX_IDLE_THR_GET(x) (((uint32_t)(x) & UART_IDLE_CFG_RX_IDLE_THR_MASK) >> UART_IDLE_CFG_RX_IDLE_THR_SHIFT)
  112. /* Bitfield definition for register: ADDR_CFG */
  113. /*
  114. * TXEN_9BIT (RW)
  115. *
  116. * set to use 9bit mode for transmitter,
  117. * will set the MSB for the first character as address flag, keep 0 for others.
  118. */
  119. #define UART_ADDR_CFG_TXEN_9BIT_MASK (0x100000UL)
  120. #define UART_ADDR_CFG_TXEN_9BIT_SHIFT (20U)
  121. #define UART_ADDR_CFG_TXEN_9BIT_SET(x) (((uint32_t)(x) << UART_ADDR_CFG_TXEN_9BIT_SHIFT) & UART_ADDR_CFG_TXEN_9BIT_MASK)
  122. #define UART_ADDR_CFG_TXEN_9BIT_GET(x) (((uint32_t)(x) & UART_ADDR_CFG_TXEN_9BIT_MASK) >> UART_ADDR_CFG_TXEN_9BIT_SHIFT)
  123. /*
  124. * RXEN_ADDR_MSB (RW)
  125. *
  126. * set to use MSB as address flag at receiver(actually this is done by software set correct MSB in addr0/addr1).
  127. * Clr to use first character as address.
  128. * Only needed if enable address match feature
  129. */
  130. #define UART_ADDR_CFG_RXEN_ADDR_MSB_MASK (0x80000UL)
  131. #define UART_ADDR_CFG_RXEN_ADDR_MSB_SHIFT (19U)
  132. #define UART_ADDR_CFG_RXEN_ADDR_MSB_SET(x) (((uint32_t)(x) << UART_ADDR_CFG_RXEN_ADDR_MSB_SHIFT) & UART_ADDR_CFG_RXEN_ADDR_MSB_MASK)
  133. #define UART_ADDR_CFG_RXEN_ADDR_MSB_GET(x) (((uint32_t)(x) & UART_ADDR_CFG_RXEN_ADDR_MSB_MASK) >> UART_ADDR_CFG_RXEN_ADDR_MSB_SHIFT)
  134. /*
  135. * RXEN_9BIT (RW)
  136. *
  137. * set to use 9bit mode for receiver, only valid if rxen_addr_msb is set
  138. */
  139. #define UART_ADDR_CFG_RXEN_9BIT_MASK (0x40000UL)
  140. #define UART_ADDR_CFG_RXEN_9BIT_SHIFT (18U)
  141. #define UART_ADDR_CFG_RXEN_9BIT_SET(x) (((uint32_t)(x) << UART_ADDR_CFG_RXEN_9BIT_SHIFT) & UART_ADDR_CFG_RXEN_9BIT_MASK)
  142. #define UART_ADDR_CFG_RXEN_9BIT_GET(x) (((uint32_t)(x) & UART_ADDR_CFG_RXEN_9BIT_MASK) >> UART_ADDR_CFG_RXEN_9BIT_SHIFT)
  143. /*
  144. * A1_EN (RW)
  145. *
  146. * enable addr1 compare for the first character.
  147. * If a1_en OR a0_en, then do not receive data if address not match.
  148. * If ~a1_en AND ~a0_en, the receive all data like before.
  149. * NOTE: should set idle_tmout_en if enable address match feature
  150. */
  151. #define UART_ADDR_CFG_A1_EN_MASK (0x20000UL)
  152. #define UART_ADDR_CFG_A1_EN_SHIFT (17U)
  153. #define UART_ADDR_CFG_A1_EN_SET(x) (((uint32_t)(x) << UART_ADDR_CFG_A1_EN_SHIFT) & UART_ADDR_CFG_A1_EN_MASK)
  154. #define UART_ADDR_CFG_A1_EN_GET(x) (((uint32_t)(x) & UART_ADDR_CFG_A1_EN_MASK) >> UART_ADDR_CFG_A1_EN_SHIFT)
  155. /*
  156. * A0_EN (RW)
  157. *
  158. * enable addr0 compare for the first character
  159. */
  160. #define UART_ADDR_CFG_A0_EN_MASK (0x10000UL)
  161. #define UART_ADDR_CFG_A0_EN_SHIFT (16U)
  162. #define UART_ADDR_CFG_A0_EN_SET(x) (((uint32_t)(x) << UART_ADDR_CFG_A0_EN_SHIFT) & UART_ADDR_CFG_A0_EN_MASK)
  163. #define UART_ADDR_CFG_A0_EN_GET(x) (((uint32_t)(x) & UART_ADDR_CFG_A0_EN_MASK) >> UART_ADDR_CFG_A0_EN_SHIFT)
  164. /*
  165. * ADDR1 (RW)
  166. *
  167. * address 1 fileld.
  168. * in 9bit mode, this is the full address byte.
  169. * For other mode(8/7/6/5bit), MSB should be set for address flag.
  170. * If want address==0 to be matched at 8bit mode, should set addr1=0x80
  171. */
  172. #define UART_ADDR_CFG_ADDR1_MASK (0xFF00U)
  173. #define UART_ADDR_CFG_ADDR1_SHIFT (8U)
  174. #define UART_ADDR_CFG_ADDR1_SET(x) (((uint32_t)(x) << UART_ADDR_CFG_ADDR1_SHIFT) & UART_ADDR_CFG_ADDR1_MASK)
  175. #define UART_ADDR_CFG_ADDR1_GET(x) (((uint32_t)(x) & UART_ADDR_CFG_ADDR1_MASK) >> UART_ADDR_CFG_ADDR1_SHIFT)
  176. /*
  177. * ADDR0 (RW)
  178. *
  179. * address 0 field.
  180. */
  181. #define UART_ADDR_CFG_ADDR0_MASK (0xFFU)
  182. #define UART_ADDR_CFG_ADDR0_SHIFT (0U)
  183. #define UART_ADDR_CFG_ADDR0_SET(x) (((uint32_t)(x) << UART_ADDR_CFG_ADDR0_SHIFT) & UART_ADDR_CFG_ADDR0_MASK)
  184. #define UART_ADDR_CFG_ADDR0_GET(x) (((uint32_t)(x) & UART_ADDR_CFG_ADDR0_MASK) >> UART_ADDR_CFG_ADDR0_SHIFT)
  185. /* Bitfield definition for register: IIR2 */
  186. /*
  187. * RXIDLE_FLAG (W1C)
  188. *
  189. * UART RX IDLE Flag, assert after rxd low and then rx idle timeout, write one clear
  190. * 0 - UART RX is busy
  191. * 1 - UART RX is idle
  192. */
  193. #define UART_IIR2_RXIDLE_FLAG_MASK (0x80000000UL)
  194. #define UART_IIR2_RXIDLE_FLAG_SHIFT (31U)
  195. #define UART_IIR2_RXIDLE_FLAG_SET(x) (((uint32_t)(x) << UART_IIR2_RXIDLE_FLAG_SHIFT) & UART_IIR2_RXIDLE_FLAG_MASK)
  196. #define UART_IIR2_RXIDLE_FLAG_GET(x) (((uint32_t)(x) & UART_IIR2_RXIDLE_FLAG_MASK) >> UART_IIR2_RXIDLE_FLAG_SHIFT)
  197. /*
  198. * TXIDLE_FLAG (W1C)
  199. *
  200. * UART TX IDLE Flag, assert after txd low and then tx idle timeout, write one clear
  201. * 0 - UART TX is busy
  202. * 1 - UART TX is idle
  203. */
  204. #define UART_IIR2_TXIDLE_FLAG_MASK (0x40000000UL)
  205. #define UART_IIR2_TXIDLE_FLAG_SHIFT (30U)
  206. #define UART_IIR2_TXIDLE_FLAG_SET(x) (((uint32_t)(x) << UART_IIR2_TXIDLE_FLAG_SHIFT) & UART_IIR2_TXIDLE_FLAG_MASK)
  207. #define UART_IIR2_TXIDLE_FLAG_GET(x) (((uint32_t)(x) & UART_IIR2_TXIDLE_FLAG_MASK) >> UART_IIR2_TXIDLE_FLAG_SHIFT)
  208. /*
  209. * ADDR_MATCH (W1C)
  210. *
  211. * address match irq status, assert if either address match(and enabled). Write one clear
  212. * NOTE: the address byte may not moved by DMA at this point.
  213. * User can wait next addr_match_idle irq for the whole data include address
  214. */
  215. #define UART_IIR2_ADDR_MATCH_MASK (0x20000000UL)
  216. #define UART_IIR2_ADDR_MATCH_SHIFT (29U)
  217. #define UART_IIR2_ADDR_MATCH_SET(x) (((uint32_t)(x) << UART_IIR2_ADDR_MATCH_SHIFT) & UART_IIR2_ADDR_MATCH_MASK)
  218. #define UART_IIR2_ADDR_MATCH_GET(x) (((uint32_t)(x) & UART_IIR2_ADDR_MATCH_MASK) >> UART_IIR2_ADDR_MATCH_SHIFT)
  219. /*
  220. * ADDR_MATCH_IDLE (W1C)
  221. *
  222. * address match and idle irq status, assert at rx bus idle if address match event triggered.
  223. * Write one clear;
  224. */
  225. #define UART_IIR2_ADDR_MATCH_IDLE_MASK (0x10000000UL)
  226. #define UART_IIR2_ADDR_MATCH_IDLE_SHIFT (28U)
  227. #define UART_IIR2_ADDR_MATCH_IDLE_SET(x) (((uint32_t)(x) << UART_IIR2_ADDR_MATCH_IDLE_SHIFT) & UART_IIR2_ADDR_MATCH_IDLE_MASK)
  228. #define UART_IIR2_ADDR_MATCH_IDLE_GET(x) (((uint32_t)(x) & UART_IIR2_ADDR_MATCH_IDLE_MASK) >> UART_IIR2_ADDR_MATCH_IDLE_SHIFT)
  229. /*
  230. * DATA_LOST (W1C)
  231. *
  232. * assert if data lost before address match status, write one clear;
  233. * It will not assert if no address match occurs
  234. */
  235. #define UART_IIR2_DATA_LOST_MASK (0x8000000UL)
  236. #define UART_IIR2_DATA_LOST_SHIFT (27U)
  237. #define UART_IIR2_DATA_LOST_SET(x) (((uint32_t)(x) << UART_IIR2_DATA_LOST_SHIFT) & UART_IIR2_DATA_LOST_MASK)
  238. #define UART_IIR2_DATA_LOST_GET(x) (((uint32_t)(x) & UART_IIR2_DATA_LOST_MASK) >> UART_IIR2_DATA_LOST_SHIFT)
  239. /*
  240. * FIFOED (RO)
  241. *
  242. * FIFOs enabled
  243. * These two bits are 1 when bit 0 of the FIFO Control
  244. * Register (FIFOE) is set to 1.
  245. */
  246. #define UART_IIR2_FIFOED_MASK (0xC0U)
  247. #define UART_IIR2_FIFOED_SHIFT (6U)
  248. #define UART_IIR2_FIFOED_GET(x) (((uint32_t)(x) & UART_IIR2_FIFOED_MASK) >> UART_IIR2_FIFOED_SHIFT)
  249. /*
  250. * INTRID (RO)
  251. *
  252. * Interrupt ID, see IIR2 for detail decoding
  253. */
  254. #define UART_IIR2_INTRID_MASK (0xFU)
  255. #define UART_IIR2_INTRID_SHIFT (0U)
  256. #define UART_IIR2_INTRID_GET(x) (((uint32_t)(x) & UART_IIR2_INTRID_MASK) >> UART_IIR2_INTRID_SHIFT)
  257. /* Bitfield definition for register: CFG */
  258. /*
  259. * FIFOSIZE (RO)
  260. *
  261. * The depth of RXFIFO and TXFIFO
  262. * 0: 16-byte FIFO
  263. * 1: 32-byte FIFO
  264. * 2: 64-byte FIFO
  265. * 3: 128-byte FIFO
  266. */
  267. #define UART_CFG_FIFOSIZE_MASK (0x3U)
  268. #define UART_CFG_FIFOSIZE_SHIFT (0U)
  269. #define UART_CFG_FIFOSIZE_GET(x) (((uint32_t)(x) & UART_CFG_FIFOSIZE_MASK) >> UART_CFG_FIFOSIZE_SHIFT)
  270. /* Bitfield definition for register: OSCR */
  271. /*
  272. * OSC (RW)
  273. *
  274. * Over-sample control
  275. * The value must be an even number; any odd value
  276. * writes to this field will be converted to an even value.
  277. * OSC=0: The over-sample ratio is 32
  278. * OSC<=8: The over-sample ratio is 8
  279. * 8 < OSC< 32: The over sample ratio is OSC
  280. */
  281. #define UART_OSCR_OSC_MASK (0x1FU)
  282. #define UART_OSCR_OSC_SHIFT (0U)
  283. #define UART_OSCR_OSC_SET(x) (((uint32_t)(x) << UART_OSCR_OSC_SHIFT) & UART_OSCR_OSC_MASK)
  284. #define UART_OSCR_OSC_GET(x) (((uint32_t)(x) & UART_OSCR_OSC_MASK) >> UART_OSCR_OSC_SHIFT)
  285. /* Bitfield definition for register: FCRR */
  286. /*
  287. * FIFOT4EN (RW)
  288. *
  289. * set to use new 4bit fifo threshold(TFIFOT4 and RFIFOT4)
  290. * clr to use 2bit(TFIFOT and RFIFOT)
  291. */
  292. #define UART_FCRR_FIFOT4EN_MASK (0x800000UL)
  293. #define UART_FCRR_FIFOT4EN_SHIFT (23U)
  294. #define UART_FCRR_FIFOT4EN_SET(x) (((uint32_t)(x) << UART_FCRR_FIFOT4EN_SHIFT) & UART_FCRR_FIFOT4EN_MASK)
  295. #define UART_FCRR_FIFOT4EN_GET(x) (((uint32_t)(x) & UART_FCRR_FIFOT4EN_MASK) >> UART_FCRR_FIFOT4EN_SHIFT)
  296. /*
  297. * TFIFOT4 (RW)
  298. *
  299. * txfifo threshold(0 for 1byte, 0xF for 16bytes), uart will send tx_dma_req when data in fifo is less than threshold.
  300. */
  301. #define UART_FCRR_TFIFOT4_MASK (0xF0000UL)
  302. #define UART_FCRR_TFIFOT4_SHIFT (16U)
  303. #define UART_FCRR_TFIFOT4_SET(x) (((uint32_t)(x) << UART_FCRR_TFIFOT4_SHIFT) & UART_FCRR_TFIFOT4_MASK)
  304. #define UART_FCRR_TFIFOT4_GET(x) (((uint32_t)(x) & UART_FCRR_TFIFOT4_MASK) >> UART_FCRR_TFIFOT4_SHIFT)
  305. /*
  306. * RFIFOT4 (RW)
  307. *
  308. * rxfifo threshold(0 for 1byte, 0xF for 16bytes).
  309. * Uart will send rx_dma_req if data in fifo reachs the threshold, also will set the rxdata irq if enabled
  310. */
  311. #define UART_FCRR_RFIFOT4_MASK (0xF00U)
  312. #define UART_FCRR_RFIFOT4_SHIFT (8U)
  313. #define UART_FCRR_RFIFOT4_SET(x) (((uint32_t)(x) << UART_FCRR_RFIFOT4_SHIFT) & UART_FCRR_RFIFOT4_MASK)
  314. #define UART_FCRR_RFIFOT4_GET(x) (((uint32_t)(x) & UART_FCRR_RFIFOT4_MASK) >> UART_FCRR_RFIFOT4_SHIFT)
  315. /*
  316. * RFIFOT (RW)
  317. *
  318. * Receiver FIFO trigger level
  319. */
  320. #define UART_FCRR_RFIFOT_MASK (0xC0U)
  321. #define UART_FCRR_RFIFOT_SHIFT (6U)
  322. #define UART_FCRR_RFIFOT_SET(x) (((uint32_t)(x) << UART_FCRR_RFIFOT_SHIFT) & UART_FCRR_RFIFOT_MASK)
  323. #define UART_FCRR_RFIFOT_GET(x) (((uint32_t)(x) & UART_FCRR_RFIFOT_MASK) >> UART_FCRR_RFIFOT_SHIFT)
  324. /*
  325. * TFIFOT (RW)
  326. *
  327. * Transmitter FIFO trigger level
  328. */
  329. #define UART_FCRR_TFIFOT_MASK (0x30U)
  330. #define UART_FCRR_TFIFOT_SHIFT (4U)
  331. #define UART_FCRR_TFIFOT_SET(x) (((uint32_t)(x) << UART_FCRR_TFIFOT_SHIFT) & UART_FCRR_TFIFOT_MASK)
  332. #define UART_FCRR_TFIFOT_GET(x) (((uint32_t)(x) & UART_FCRR_TFIFOT_MASK) >> UART_FCRR_TFIFOT_SHIFT)
  333. /*
  334. * DMAE (RW)
  335. *
  336. * DMA enable
  337. * 0: Disable
  338. * 1: Enable
  339. */
  340. #define UART_FCRR_DMAE_MASK (0x8U)
  341. #define UART_FCRR_DMAE_SHIFT (3U)
  342. #define UART_FCRR_DMAE_SET(x) (((uint32_t)(x) << UART_FCRR_DMAE_SHIFT) & UART_FCRR_DMAE_MASK)
  343. #define UART_FCRR_DMAE_GET(x) (((uint32_t)(x) & UART_FCRR_DMAE_MASK) >> UART_FCRR_DMAE_SHIFT)
  344. /*
  345. * TFIFORST (WO)
  346. *
  347. * Transmitter FIFO reset
  348. * Write 1 to clear all bytes in the TXFIFO and resets its
  349. * counter. The Transmitter Shift Register is not cleared.
  350. * This bit will automatically be cleared.
  351. */
  352. #define UART_FCRR_TFIFORST_MASK (0x4U)
  353. #define UART_FCRR_TFIFORST_SHIFT (2U)
  354. #define UART_FCRR_TFIFORST_SET(x) (((uint32_t)(x) << UART_FCRR_TFIFORST_SHIFT) & UART_FCRR_TFIFORST_MASK)
  355. #define UART_FCRR_TFIFORST_GET(x) (((uint32_t)(x) & UART_FCRR_TFIFORST_MASK) >> UART_FCRR_TFIFORST_SHIFT)
  356. /*
  357. * RFIFORST (WO)
  358. *
  359. * Receiver FIFO reset
  360. * Write 1 to clear all bytes in the RXFIFO and resets its
  361. * counter. The Receiver Shift Register is not cleared.
  362. * This bit will automatically be cleared.
  363. */
  364. #define UART_FCRR_RFIFORST_MASK (0x2U)
  365. #define UART_FCRR_RFIFORST_SHIFT (1U)
  366. #define UART_FCRR_RFIFORST_SET(x) (((uint32_t)(x) << UART_FCRR_RFIFORST_SHIFT) & UART_FCRR_RFIFORST_MASK)
  367. #define UART_FCRR_RFIFORST_GET(x) (((uint32_t)(x) & UART_FCRR_RFIFORST_MASK) >> UART_FCRR_RFIFORST_SHIFT)
  368. /*
  369. * FIFOE (RW)
  370. *
  371. * FIFO enable
  372. * Write 1 to enable both the transmitter and receiver
  373. * FIFOs.
  374. * The FIFOs are reset when the value of this bit toggles.
  375. */
  376. #define UART_FCRR_FIFOE_MASK (0x1U)
  377. #define UART_FCRR_FIFOE_SHIFT (0U)
  378. #define UART_FCRR_FIFOE_SET(x) (((uint32_t)(x) << UART_FCRR_FIFOE_SHIFT) & UART_FCRR_FIFOE_MASK)
  379. #define UART_FCRR_FIFOE_GET(x) (((uint32_t)(x) & UART_FCRR_FIFOE_MASK) >> UART_FCRR_FIFOE_SHIFT)
  380. /* Bitfield definition for register: MOTO_CFG */
  381. /*
  382. * SWTRG (WO)
  383. *
  384. * software trigger. User should avoid use sw/hw trigger at same time, otherwise result unknown.
  385. * Hardware auto reset.
  386. */
  387. #define UART_MOTO_CFG_SWTRG_MASK (0x80000000UL)
  388. #define UART_MOTO_CFG_SWTRG_SHIFT (31U)
  389. #define UART_MOTO_CFG_SWTRG_SET(x) (((uint32_t)(x) << UART_MOTO_CFG_SWTRG_SHIFT) & UART_MOTO_CFG_SWTRG_MASK)
  390. #define UART_MOTO_CFG_SWTRG_GET(x) (((uint32_t)(x) & UART_MOTO_CFG_SWTRG_MASK) >> UART_MOTO_CFG_SWTRG_SHIFT)
  391. /*
  392. * TXSTP_BITS (RW)
  393. *
  394. * if TXSTOP_INSERT is enabled, the STOP bits to be inserted between each byte. 0 for 1 bit; 0xFF for 256bits
  395. */
  396. #define UART_MOTO_CFG_TXSTP_BITS_MASK (0xFF00U)
  397. #define UART_MOTO_CFG_TXSTP_BITS_SHIFT (8U)
  398. #define UART_MOTO_CFG_TXSTP_BITS_SET(x) (((uint32_t)(x) << UART_MOTO_CFG_TXSTP_BITS_SHIFT) & UART_MOTO_CFG_TXSTP_BITS_MASK)
  399. #define UART_MOTO_CFG_TXSTP_BITS_GET(x) (((uint32_t)(x) & UART_MOTO_CFG_TXSTP_BITS_MASK) >> UART_MOTO_CFG_TXSTP_BITS_SHIFT)
  400. /*
  401. * HWTRG_EN (RW)
  402. *
  403. * set to enable hardware trigger(trigger from moto is shared by other UART)
  404. */
  405. #define UART_MOTO_CFG_HWTRG_EN_MASK (0x80U)
  406. #define UART_MOTO_CFG_HWTRG_EN_SHIFT (7U)
  407. #define UART_MOTO_CFG_HWTRG_EN_SET(x) (((uint32_t)(x) << UART_MOTO_CFG_HWTRG_EN_SHIFT) & UART_MOTO_CFG_HWTRG_EN_MASK)
  408. #define UART_MOTO_CFG_HWTRG_EN_GET(x) (((uint32_t)(x) & UART_MOTO_CFG_HWTRG_EN_MASK) >> UART_MOTO_CFG_HWTRG_EN_SHIFT)
  409. /*
  410. * TRG_MODE (RW)
  411. *
  412. * set to enable trigger mode.
  413. * software should push needed data into txbuffer frist, uart will not start transmission at this time.
  414. * User should send trigger signal(by hw or sw), uart will send all data in txfifo till empty
  415. * NOTE: the hw_trigger should be pulse signal from trig mux.
  416. */
  417. #define UART_MOTO_CFG_TRG_MODE_MASK (0x40U)
  418. #define UART_MOTO_CFG_TRG_MODE_SHIFT (6U)
  419. #define UART_MOTO_CFG_TRG_MODE_SET(x) (((uint32_t)(x) << UART_MOTO_CFG_TRG_MODE_SHIFT) & UART_MOTO_CFG_TRG_MODE_MASK)
  420. #define UART_MOTO_CFG_TRG_MODE_GET(x) (((uint32_t)(x) & UART_MOTO_CFG_TRG_MODE_MASK) >> UART_MOTO_CFG_TRG_MODE_SHIFT)
  421. /*
  422. * TRG_CLR_RFIFO (RW)
  423. *
  424. * set to enable the feature that, clear rxfifo at tx trigger(sw or hw), avoid unexpected data in rxfifo.
  425. */
  426. #define UART_MOTO_CFG_TRG_CLR_RFIFO_MASK (0x20U)
  427. #define UART_MOTO_CFG_TRG_CLR_RFIFO_SHIFT (5U)
  428. #define UART_MOTO_CFG_TRG_CLR_RFIFO_SET(x) (((uint32_t)(x) << UART_MOTO_CFG_TRG_CLR_RFIFO_SHIFT) & UART_MOTO_CFG_TRG_CLR_RFIFO_MASK)
  429. #define UART_MOTO_CFG_TRG_CLR_RFIFO_GET(x) (((uint32_t)(x) & UART_MOTO_CFG_TRG_CLR_RFIFO_MASK) >> UART_MOTO_CFG_TRG_CLR_RFIFO_SHIFT)
  430. /*
  431. * TXSTOP_INSERT (RW)
  432. *
  433. * set to insert STOP bits between each tx byte till tx fifo empty.
  434. * NOTE: there will be no 1.5/2 STOP bits if enabled this feature, LCR.STB should be set to 0 if this bit is set
  435. */
  436. #define UART_MOTO_CFG_TXSTOP_INSERT_MASK (0x10U)
  437. #define UART_MOTO_CFG_TXSTOP_INSERT_SHIFT (4U)
  438. #define UART_MOTO_CFG_TXSTOP_INSERT_SET(x) (((uint32_t)(x) << UART_MOTO_CFG_TXSTOP_INSERT_SHIFT) & UART_MOTO_CFG_TXSTOP_INSERT_MASK)
  439. #define UART_MOTO_CFG_TXSTOP_INSERT_GET(x) (((uint32_t)(x) & UART_MOTO_CFG_TXSTOP_INSERT_MASK) >> UART_MOTO_CFG_TXSTOP_INSERT_SHIFT)
  440. /* Bitfield definition for register: RBR */
  441. /*
  442. * RBR (RO)
  443. *
  444. * Receive data read port
  445. */
  446. #define UART_RBR_RBR_MASK (0xFFU)
  447. #define UART_RBR_RBR_SHIFT (0U)
  448. #define UART_RBR_RBR_GET(x) (((uint32_t)(x) & UART_RBR_RBR_MASK) >> UART_RBR_RBR_SHIFT)
  449. /* Bitfield definition for register: THR */
  450. /*
  451. * THR (WO)
  452. *
  453. * Transmit data write port
  454. */
  455. #define UART_THR_THR_MASK (0xFFU)
  456. #define UART_THR_THR_SHIFT (0U)
  457. #define UART_THR_THR_SET(x) (((uint32_t)(x) << UART_THR_THR_SHIFT) & UART_THR_THR_MASK)
  458. #define UART_THR_THR_GET(x) (((uint32_t)(x) & UART_THR_THR_MASK) >> UART_THR_THR_SHIFT)
  459. /* Bitfield definition for register: DLL */
  460. /*
  461. * DLL (RW)
  462. *
  463. * Least significant byte of the Divisor Latch
  464. */
  465. #define UART_DLL_DLL_MASK (0xFFU)
  466. #define UART_DLL_DLL_SHIFT (0U)
  467. #define UART_DLL_DLL_SET(x) (((uint32_t)(x) << UART_DLL_DLL_SHIFT) & UART_DLL_DLL_MASK)
  468. #define UART_DLL_DLL_GET(x) (((uint32_t)(x) & UART_DLL_DLL_MASK) >> UART_DLL_DLL_SHIFT)
  469. /* Bitfield definition for register: IER */
  470. /*
  471. * ERXIDLE (RW)
  472. *
  473. * Enable Receive Idle interrupt
  474. * 0 - Disable Idle interrupt
  475. * 1 - Enable Idle interrupt
  476. */
  477. #define UART_IER_ERXIDLE_MASK (0x80000000UL)
  478. #define UART_IER_ERXIDLE_SHIFT (31U)
  479. #define UART_IER_ERXIDLE_SET(x) (((uint32_t)(x) << UART_IER_ERXIDLE_SHIFT) & UART_IER_ERXIDLE_MASK)
  480. #define UART_IER_ERXIDLE_GET(x) (((uint32_t)(x) & UART_IER_ERXIDLE_MASK) >> UART_IER_ERXIDLE_SHIFT)
  481. /*
  482. * ETXIDLE (RW)
  483. *
  484. * enable transmit idle interrupt
  485. */
  486. #define UART_IER_ETXIDLE_MASK (0x40000000UL)
  487. #define UART_IER_ETXIDLE_SHIFT (30U)
  488. #define UART_IER_ETXIDLE_SET(x) (((uint32_t)(x) << UART_IER_ETXIDLE_SHIFT) & UART_IER_ETXIDLE_MASK)
  489. #define UART_IER_ETXIDLE_GET(x) (((uint32_t)(x) & UART_IER_ETXIDLE_MASK) >> UART_IER_ETXIDLE_SHIFT)
  490. /*
  491. * EADDRM (RW)
  492. *
  493. * enable ADDR_MATCH interrupt
  494. */
  495. #define UART_IER_EADDRM_MASK (0x20000000UL)
  496. #define UART_IER_EADDRM_SHIFT (29U)
  497. #define UART_IER_EADDRM_SET(x) (((uint32_t)(x) << UART_IER_EADDRM_SHIFT) & UART_IER_EADDRM_MASK)
  498. #define UART_IER_EADDRM_GET(x) (((uint32_t)(x) & UART_IER_EADDRM_MASK) >> UART_IER_EADDRM_SHIFT)
  499. /*
  500. * EADDRM_IDLE (RW)
  501. *
  502. * enable ADDR_MATCH_IDLE interrupt
  503. */
  504. #define UART_IER_EADDRM_IDLE_MASK (0x10000000UL)
  505. #define UART_IER_EADDRM_IDLE_SHIFT (28U)
  506. #define UART_IER_EADDRM_IDLE_SET(x) (((uint32_t)(x) << UART_IER_EADDRM_IDLE_SHIFT) & UART_IER_EADDRM_IDLE_MASK)
  507. #define UART_IER_EADDRM_IDLE_GET(x) (((uint32_t)(x) & UART_IER_EADDRM_IDLE_MASK) >> UART_IER_EADDRM_IDLE_SHIFT)
  508. /*
  509. * EDATLOST (RW)
  510. *
  511. * enable DATA_LOST interrupt
  512. */
  513. #define UART_IER_EDATLOST_MASK (0x8000000UL)
  514. #define UART_IER_EDATLOST_SHIFT (27U)
  515. #define UART_IER_EDATLOST_SET(x) (((uint32_t)(x) << UART_IER_EDATLOST_SHIFT) & UART_IER_EDATLOST_MASK)
  516. #define UART_IER_EDATLOST_GET(x) (((uint32_t)(x) & UART_IER_EDATLOST_MASK) >> UART_IER_EDATLOST_SHIFT)
  517. /*
  518. * EMSI (RW)
  519. *
  520. * Enable modem status interrupt
  521. * The interrupt asserts when the status of one of the
  522. * following occurs:
  523. * The status of modem_rin, modem_dcdn,
  524. * modem_dsrn or modem_ctsn (If the auto-cts mode is
  525. * disabled) has been changed.
  526. * If the auto-cts mode is enabled (MCR bit4 (AFE) = 1),
  527. * modem_ctsn would be used to control the transmitter.
  528. */
  529. #define UART_IER_EMSI_MASK (0x8U)
  530. #define UART_IER_EMSI_SHIFT (3U)
  531. #define UART_IER_EMSI_SET(x) (((uint32_t)(x) << UART_IER_EMSI_SHIFT) & UART_IER_EMSI_MASK)
  532. #define UART_IER_EMSI_GET(x) (((uint32_t)(x) & UART_IER_EMSI_MASK) >> UART_IER_EMSI_SHIFT)
  533. /*
  534. * ELSI (RW)
  535. *
  536. * Enable receiver line status interrupt
  537. */
  538. #define UART_IER_ELSI_MASK (0x4U)
  539. #define UART_IER_ELSI_SHIFT (2U)
  540. #define UART_IER_ELSI_SET(x) (((uint32_t)(x) << UART_IER_ELSI_SHIFT) & UART_IER_ELSI_MASK)
  541. #define UART_IER_ELSI_GET(x) (((uint32_t)(x) & UART_IER_ELSI_MASK) >> UART_IER_ELSI_SHIFT)
  542. /*
  543. * ETHEI (RW)
  544. *
  545. * Enable transmitter holding register interrupt
  546. */
  547. #define UART_IER_ETHEI_MASK (0x2U)
  548. #define UART_IER_ETHEI_SHIFT (1U)
  549. #define UART_IER_ETHEI_SET(x) (((uint32_t)(x) << UART_IER_ETHEI_SHIFT) & UART_IER_ETHEI_MASK)
  550. #define UART_IER_ETHEI_GET(x) (((uint32_t)(x) & UART_IER_ETHEI_MASK) >> UART_IER_ETHEI_SHIFT)
  551. /*
  552. * ERBI (RW)
  553. *
  554. * Enable received data available interrupt and the
  555. * character timeout interrupt
  556. * 0: Disable
  557. * 1: Enable
  558. */
  559. #define UART_IER_ERBI_MASK (0x1U)
  560. #define UART_IER_ERBI_SHIFT (0U)
  561. #define UART_IER_ERBI_SET(x) (((uint32_t)(x) << UART_IER_ERBI_SHIFT) & UART_IER_ERBI_MASK)
  562. #define UART_IER_ERBI_GET(x) (((uint32_t)(x) & UART_IER_ERBI_MASK) >> UART_IER_ERBI_SHIFT)
  563. /* Bitfield definition for register: DLM */
  564. /*
  565. * DLM (RW)
  566. *
  567. * Most significant byte of the Divisor Latch
  568. */
  569. #define UART_DLM_DLM_MASK (0xFFU)
  570. #define UART_DLM_DLM_SHIFT (0U)
  571. #define UART_DLM_DLM_SET(x) (((uint32_t)(x) << UART_DLM_DLM_SHIFT) & UART_DLM_DLM_MASK)
  572. #define UART_DLM_DLM_GET(x) (((uint32_t)(x) & UART_DLM_DLM_MASK) >> UART_DLM_DLM_SHIFT)
  573. /* Bitfield definition for register: IIR */
  574. /*
  575. * RXIDLE_FLAG (W1C)
  576. *
  577. * UART IDLE Flag
  578. * 0 - UART is busy
  579. * 1 - UART is idle
  580. * NOTE: when write one to clear this bit, avoid changging FCR register since it's same address as IIR
  581. */
  582. #define UART_IIR_RXIDLE_FLAG_MASK (0x80000000UL)
  583. #define UART_IIR_RXIDLE_FLAG_SHIFT (31U)
  584. #define UART_IIR_RXIDLE_FLAG_SET(x) (((uint32_t)(x) << UART_IIR_RXIDLE_FLAG_SHIFT) & UART_IIR_RXIDLE_FLAG_MASK)
  585. #define UART_IIR_RXIDLE_FLAG_GET(x) (((uint32_t)(x) & UART_IIR_RXIDLE_FLAG_MASK) >> UART_IIR_RXIDLE_FLAG_SHIFT)
  586. /*
  587. * FIFOED (RO)
  588. *
  589. * FIFOs enabled
  590. * These two bits are 1 when bit 0 of the FIFO Control
  591. * Register (FIFOE) is set to 1.
  592. */
  593. #define UART_IIR_FIFOED_MASK (0xC0U)
  594. #define UART_IIR_FIFOED_SHIFT (6U)
  595. #define UART_IIR_FIFOED_GET(x) (((uint32_t)(x) & UART_IIR_FIFOED_MASK) >> UART_IIR_FIFOED_SHIFT)
  596. /*
  597. * INTRID (RO)
  598. *
  599. * Interrupt ID, see IIR2 for detail decoding
  600. */
  601. #define UART_IIR_INTRID_MASK (0xFU)
  602. #define UART_IIR_INTRID_SHIFT (0U)
  603. #define UART_IIR_INTRID_GET(x) (((uint32_t)(x) & UART_IIR_INTRID_MASK) >> UART_IIR_INTRID_SHIFT)
  604. /* Bitfield definition for register: FCR */
  605. /*
  606. * RFIFOT (WO)
  607. *
  608. * Receiver FIFO trigger level
  609. */
  610. #define UART_FCR_RFIFOT_MASK (0xC0U)
  611. #define UART_FCR_RFIFOT_SHIFT (6U)
  612. #define UART_FCR_RFIFOT_SET(x) (((uint32_t)(x) << UART_FCR_RFIFOT_SHIFT) & UART_FCR_RFIFOT_MASK)
  613. #define UART_FCR_RFIFOT_GET(x) (((uint32_t)(x) & UART_FCR_RFIFOT_MASK) >> UART_FCR_RFIFOT_SHIFT)
  614. /*
  615. * TFIFOT (WO)
  616. *
  617. * Transmitter FIFO trigger level
  618. */
  619. #define UART_FCR_TFIFOT_MASK (0x30U)
  620. #define UART_FCR_TFIFOT_SHIFT (4U)
  621. #define UART_FCR_TFIFOT_SET(x) (((uint32_t)(x) << UART_FCR_TFIFOT_SHIFT) & UART_FCR_TFIFOT_MASK)
  622. #define UART_FCR_TFIFOT_GET(x) (((uint32_t)(x) & UART_FCR_TFIFOT_MASK) >> UART_FCR_TFIFOT_SHIFT)
  623. /*
  624. * DMAE (WO)
  625. *
  626. * DMA enable
  627. * 0: Disable
  628. * 1: Enable
  629. */
  630. #define UART_FCR_DMAE_MASK (0x8U)
  631. #define UART_FCR_DMAE_SHIFT (3U)
  632. #define UART_FCR_DMAE_SET(x) (((uint32_t)(x) << UART_FCR_DMAE_SHIFT) & UART_FCR_DMAE_MASK)
  633. #define UART_FCR_DMAE_GET(x) (((uint32_t)(x) & UART_FCR_DMAE_MASK) >> UART_FCR_DMAE_SHIFT)
  634. /*
  635. * TFIFORST (WO)
  636. *
  637. * Transmitter FIFO reset
  638. * Write 1 to clear all bytes in the TXFIFO and resets its
  639. * counter. The Transmitter Shift Register is not cleared.
  640. * This bit will automatically be cleared.
  641. */
  642. #define UART_FCR_TFIFORST_MASK (0x4U)
  643. #define UART_FCR_TFIFORST_SHIFT (2U)
  644. #define UART_FCR_TFIFORST_SET(x) (((uint32_t)(x) << UART_FCR_TFIFORST_SHIFT) & UART_FCR_TFIFORST_MASK)
  645. #define UART_FCR_TFIFORST_GET(x) (((uint32_t)(x) & UART_FCR_TFIFORST_MASK) >> UART_FCR_TFIFORST_SHIFT)
  646. /*
  647. * RFIFORST (WO)
  648. *
  649. * Receiver FIFO reset
  650. * Write 1 to clear all bytes in the RXFIFO and resets its
  651. * counter. The Receiver Shift Register is not cleared.
  652. * This bit will automatically be cleared.
  653. */
  654. #define UART_FCR_RFIFORST_MASK (0x2U)
  655. #define UART_FCR_RFIFORST_SHIFT (1U)
  656. #define UART_FCR_RFIFORST_SET(x) (((uint32_t)(x) << UART_FCR_RFIFORST_SHIFT) & UART_FCR_RFIFORST_MASK)
  657. #define UART_FCR_RFIFORST_GET(x) (((uint32_t)(x) & UART_FCR_RFIFORST_MASK) >> UART_FCR_RFIFORST_SHIFT)
  658. /*
  659. * FIFOE (WO)
  660. *
  661. * FIFO enable
  662. * Write 1 to enable both the transmitter and receiver
  663. * FIFOs.
  664. * The FIFOs are reset when the value of this bit toggles.
  665. */
  666. #define UART_FCR_FIFOE_MASK (0x1U)
  667. #define UART_FCR_FIFOE_SHIFT (0U)
  668. #define UART_FCR_FIFOE_SET(x) (((uint32_t)(x) << UART_FCR_FIFOE_SHIFT) & UART_FCR_FIFOE_MASK)
  669. #define UART_FCR_FIFOE_GET(x) (((uint32_t)(x) & UART_FCR_FIFOE_MASK) >> UART_FCR_FIFOE_SHIFT)
  670. /* Bitfield definition for register: LCR */
  671. /*
  672. * DLAB (RW)
  673. *
  674. * Divisor latch access bit
  675. */
  676. #define UART_LCR_DLAB_MASK (0x80U)
  677. #define UART_LCR_DLAB_SHIFT (7U)
  678. #define UART_LCR_DLAB_SET(x) (((uint32_t)(x) << UART_LCR_DLAB_SHIFT) & UART_LCR_DLAB_MASK)
  679. #define UART_LCR_DLAB_GET(x) (((uint32_t)(x) & UART_LCR_DLAB_MASK) >> UART_LCR_DLAB_SHIFT)
  680. /*
  681. * BC (RW)
  682. *
  683. * Break control
  684. */
  685. #define UART_LCR_BC_MASK (0x40U)
  686. #define UART_LCR_BC_SHIFT (6U)
  687. #define UART_LCR_BC_SET(x) (((uint32_t)(x) << UART_LCR_BC_SHIFT) & UART_LCR_BC_MASK)
  688. #define UART_LCR_BC_GET(x) (((uint32_t)(x) & UART_LCR_BC_MASK) >> UART_LCR_BC_SHIFT)
  689. /*
  690. * SPS (RW)
  691. *
  692. * Stick parity
  693. * 1: Parity bit is constant 0 or 1, depending on bit4 (EPS).
  694. * 0: Disable the sticky bit parity.
  695. */
  696. #define UART_LCR_SPS_MASK (0x20U)
  697. #define UART_LCR_SPS_SHIFT (5U)
  698. #define UART_LCR_SPS_SET(x) (((uint32_t)(x) << UART_LCR_SPS_SHIFT) & UART_LCR_SPS_MASK)
  699. #define UART_LCR_SPS_GET(x) (((uint32_t)(x) & UART_LCR_SPS_MASK) >> UART_LCR_SPS_SHIFT)
  700. /*
  701. * EPS (RW)
  702. *
  703. * Even parity select
  704. * 1: Even parity (an even number of logic-1 is in the data
  705. * and parity bits)
  706. * 0: Old parity.
  707. */
  708. #define UART_LCR_EPS_MASK (0x10U)
  709. #define UART_LCR_EPS_SHIFT (4U)
  710. #define UART_LCR_EPS_SET(x) (((uint32_t)(x) << UART_LCR_EPS_SHIFT) & UART_LCR_EPS_MASK)
  711. #define UART_LCR_EPS_GET(x) (((uint32_t)(x) & UART_LCR_EPS_MASK) >> UART_LCR_EPS_SHIFT)
  712. /*
  713. * PEN (RW)
  714. *
  715. * Parity enable
  716. * When this bit is set, a parity bit is generated in
  717. * transmitted data before the first STOP bit and the parity
  718. * bit would be checked for the received data.
  719. */
  720. #define UART_LCR_PEN_MASK (0x8U)
  721. #define UART_LCR_PEN_SHIFT (3U)
  722. #define UART_LCR_PEN_SET(x) (((uint32_t)(x) << UART_LCR_PEN_SHIFT) & UART_LCR_PEN_MASK)
  723. #define UART_LCR_PEN_GET(x) (((uint32_t)(x) & UART_LCR_PEN_MASK) >> UART_LCR_PEN_SHIFT)
  724. /*
  725. * STB (RW)
  726. *
  727. * Number of STOP bits
  728. * 0: 1 bits
  729. * 1: The number of STOP bit is based on the WLS setting
  730. * When WLS = 0, STOP bit is 1.5 bits
  731. * When WLS = 1, 2, 3, STOP bit is 2 bits
  732. */
  733. #define UART_LCR_STB_MASK (0x4U)
  734. #define UART_LCR_STB_SHIFT (2U)
  735. #define UART_LCR_STB_SET(x) (((uint32_t)(x) << UART_LCR_STB_SHIFT) & UART_LCR_STB_MASK)
  736. #define UART_LCR_STB_GET(x) (((uint32_t)(x) & UART_LCR_STB_MASK) >> UART_LCR_STB_SHIFT)
  737. /*
  738. * WLS (RW)
  739. *
  740. * Word length setting
  741. * 0: 5 bits
  742. * 1: 6 bits
  743. * 2: 7 bits
  744. * 3: 8 bits
  745. */
  746. #define UART_LCR_WLS_MASK (0x3U)
  747. #define UART_LCR_WLS_SHIFT (0U)
  748. #define UART_LCR_WLS_SET(x) (((uint32_t)(x) << UART_LCR_WLS_SHIFT) & UART_LCR_WLS_MASK)
  749. #define UART_LCR_WLS_GET(x) (((uint32_t)(x) & UART_LCR_WLS_MASK) >> UART_LCR_WLS_SHIFT)
  750. /* Bitfield definition for register: MCR */
  751. /*
  752. * AFE (RW)
  753. *
  754. * Auto flow control enable
  755. * 0: Disable
  756. * 1: The auto-CTS and auto-RTS setting is based on the
  757. * RTS bit setting:
  758. * When RTS = 0, auto-CTS only
  759. * When RTS = 1, auto-CTS and auto-RTS
  760. */
  761. #define UART_MCR_AFE_MASK (0x20U)
  762. #define UART_MCR_AFE_SHIFT (5U)
  763. #define UART_MCR_AFE_SET(x) (((uint32_t)(x) << UART_MCR_AFE_SHIFT) & UART_MCR_AFE_MASK)
  764. #define UART_MCR_AFE_GET(x) (((uint32_t)(x) & UART_MCR_AFE_MASK) >> UART_MCR_AFE_SHIFT)
  765. /*
  766. * LOOP (RW)
  767. *
  768. * Enable loopback mode
  769. * 0: Disable
  770. * 1: Enable
  771. */
  772. #define UART_MCR_LOOP_MASK (0x10U)
  773. #define UART_MCR_LOOP_SHIFT (4U)
  774. #define UART_MCR_LOOP_SET(x) (((uint32_t)(x) << UART_MCR_LOOP_SHIFT) & UART_MCR_LOOP_MASK)
  775. #define UART_MCR_LOOP_GET(x) (((uint32_t)(x) & UART_MCR_LOOP_MASK) >> UART_MCR_LOOP_SHIFT)
  776. /*
  777. * RTS (RW)
  778. *
  779. * Request to send
  780. * This bit controls the modem_rtsn output.
  781. * 0: The modem_rtsn output signal will be driven HIGH
  782. * 1: The modem_rtsn output signal will be driven LOW
  783. */
  784. #define UART_MCR_RTS_MASK (0x2U)
  785. #define UART_MCR_RTS_SHIFT (1U)
  786. #define UART_MCR_RTS_SET(x) (((uint32_t)(x) << UART_MCR_RTS_SHIFT) & UART_MCR_RTS_MASK)
  787. #define UART_MCR_RTS_GET(x) (((uint32_t)(x) & UART_MCR_RTS_MASK) >> UART_MCR_RTS_SHIFT)
  788. /* Bitfield definition for register: LSR */
  789. /*
  790. * RXIDLE (RO)
  791. *
  792. * rxidle after timeout, clear after rx idle condition not match
  793. */
  794. #define UART_LSR_RXIDLE_MASK (0x80000000UL)
  795. #define UART_LSR_RXIDLE_SHIFT (31U)
  796. #define UART_LSR_RXIDLE_GET(x) (((uint32_t)(x) & UART_LSR_RXIDLE_MASK) >> UART_LSR_RXIDLE_SHIFT)
  797. /*
  798. * TXIDLE (RO)
  799. *
  800. * txidle after timeout, clear after tx idle condition not match
  801. */
  802. #define UART_LSR_TXIDLE_MASK (0x40000000UL)
  803. #define UART_LSR_TXIDLE_SHIFT (30U)
  804. #define UART_LSR_TXIDLE_GET(x) (((uint32_t)(x) & UART_LSR_TXIDLE_MASK) >> UART_LSR_TXIDLE_SHIFT)
  805. /*
  806. * RFIFO_NUM (RO)
  807. *
  808. * data bytes in rxfifo not read
  809. */
  810. #define UART_LSR_RFIFO_NUM_MASK (0x1F0000UL)
  811. #define UART_LSR_RFIFO_NUM_SHIFT (16U)
  812. #define UART_LSR_RFIFO_NUM_GET(x) (((uint32_t)(x) & UART_LSR_RFIFO_NUM_MASK) >> UART_LSR_RFIFO_NUM_SHIFT)
  813. /*
  814. * TFIFO_NUM (RO)
  815. *
  816. * data bytes in txfifo not sent
  817. */
  818. #define UART_LSR_TFIFO_NUM_MASK (0x1F00U)
  819. #define UART_LSR_TFIFO_NUM_SHIFT (8U)
  820. #define UART_LSR_TFIFO_NUM_GET(x) (((uint32_t)(x) & UART_LSR_TFIFO_NUM_MASK) >> UART_LSR_TFIFO_NUM_SHIFT)
  821. /*
  822. * ERRF (RO)
  823. *
  824. * Error in RXFIFO
  825. * In the FIFO mode, this bit is set when there is at least
  826. * one parity error, framing error, or line break
  827. * associated with data in the RXFIFO. It is cleared when
  828. * this register is read and there is no more error for the
  829. * rest of data in the RXFIFO.
  830. */
  831. #define UART_LSR_ERRF_MASK (0x80U)
  832. #define UART_LSR_ERRF_SHIFT (7U)
  833. #define UART_LSR_ERRF_GET(x) (((uint32_t)(x) & UART_LSR_ERRF_MASK) >> UART_LSR_ERRF_SHIFT)
  834. /*
  835. * TEMT (RO)
  836. *
  837. * Transmitter empty
  838. * This bit is 1 when the THR (TXFIFO in the FIFO
  839. * mode) and the Transmitter Shift Register (TSR) are
  840. * both empty. Otherwise, it is zero.
  841. */
  842. #define UART_LSR_TEMT_MASK (0x40U)
  843. #define UART_LSR_TEMT_SHIFT (6U)
  844. #define UART_LSR_TEMT_GET(x) (((uint32_t)(x) & UART_LSR_TEMT_MASK) >> UART_LSR_TEMT_SHIFT)
  845. /*
  846. * THRE (RO)
  847. *
  848. * Transmitter Holding Register empty
  849. * This bit is 1 when the THR (TXFIFO in the FIFO
  850. * mode) is empty. Otherwise, it is zero.
  851. * If the THRE interrupt is enabled, an interrupt is
  852. * triggered when THRE becomes 1.
  853. */
  854. #define UART_LSR_THRE_MASK (0x20U)
  855. #define UART_LSR_THRE_SHIFT (5U)
  856. #define UART_LSR_THRE_GET(x) (((uint32_t)(x) & UART_LSR_THRE_MASK) >> UART_LSR_THRE_SHIFT)
  857. /*
  858. * LBREAK (RO)
  859. *
  860. * Line break
  861. * This bit is set when the uart_sin input signal was held
  862. * LOWfor longer than the time for a full-word
  863. * transmission. A full-word transmission is the
  864. * transmission of the START, data, parity, and STOP
  865. * bits. It is cleared when this register is read.
  866. * In the FIFO mode, this bit indicates the line break for
  867. * the received data at the top of the RXFIFO.
  868. */
  869. #define UART_LSR_LBREAK_MASK (0x10U)
  870. #define UART_LSR_LBREAK_SHIFT (4U)
  871. #define UART_LSR_LBREAK_GET(x) (((uint32_t)(x) & UART_LSR_LBREAK_MASK) >> UART_LSR_LBREAK_SHIFT)
  872. /*
  873. * FE (RO)
  874. *
  875. * Framing error
  876. * This bit is set when the received STOP bit is not
  877. * HIGH. It is cleared when this register is read.
  878. * In the FIFO mode, this bit indicates the framing error
  879. * for the received data at the top of the RXFIFO.
  880. */
  881. #define UART_LSR_FE_MASK (0x8U)
  882. #define UART_LSR_FE_SHIFT (3U)
  883. #define UART_LSR_FE_GET(x) (((uint32_t)(x) & UART_LSR_FE_MASK) >> UART_LSR_FE_SHIFT)
  884. /*
  885. * PE (RO)
  886. *
  887. * Parity error
  888. * This bit is set when the received parity does not match
  889. * with the parity selected in the LCR[5:4]. It is cleared
  890. * when this register is read.
  891. * In the FIFO mode, this bit indicates the parity error
  892. * for the received data at the top of the RXFIFO.
  893. */
  894. #define UART_LSR_PE_MASK (0x4U)
  895. #define UART_LSR_PE_SHIFT (2U)
  896. #define UART_LSR_PE_GET(x) (((uint32_t)(x) & UART_LSR_PE_MASK) >> UART_LSR_PE_SHIFT)
  897. /*
  898. * OE (RO)
  899. *
  900. * Overrun error
  901. * This bit indicates that data in the Receiver Buffer
  902. * Register (RBR) is overrun.
  903. */
  904. #define UART_LSR_OE_MASK (0x2U)
  905. #define UART_LSR_OE_SHIFT (1U)
  906. #define UART_LSR_OE_GET(x) (((uint32_t)(x) & UART_LSR_OE_MASK) >> UART_LSR_OE_SHIFT)
  907. /*
  908. * DR (RO)
  909. *
  910. * Data ready.
  911. * This bit is set when there are incoming received data
  912. * in the Receiver Buffer Register (RBR). It is cleared
  913. * when all of the received data are read.
  914. */
  915. #define UART_LSR_DR_MASK (0x1U)
  916. #define UART_LSR_DR_SHIFT (0U)
  917. #define UART_LSR_DR_GET(x) (((uint32_t)(x) & UART_LSR_DR_MASK) >> UART_LSR_DR_SHIFT)
  918. /* Bitfield definition for register: MSR */
  919. /*
  920. * CTS (RO)
  921. *
  922. * Clear to send
  923. * 0: The modem_ctsn input signal is HIGH.
  924. * 1: The modem_ctsn input signal is LOW.
  925. */
  926. #define UART_MSR_CTS_MASK (0x10U)
  927. #define UART_MSR_CTS_SHIFT (4U)
  928. #define UART_MSR_CTS_GET(x) (((uint32_t)(x) & UART_MSR_CTS_MASK) >> UART_MSR_CTS_SHIFT)
  929. /*
  930. * DCTS (RC)
  931. *
  932. * Delta clear to send
  933. * This bit is set when the state of the modem_ctsn input
  934. * signal has been changed since the last time this
  935. * register is read.
  936. */
  937. #define UART_MSR_DCTS_MASK (0x1U)
  938. #define UART_MSR_DCTS_SHIFT (0U)
  939. #define UART_MSR_DCTS_GET(x) (((uint32_t)(x) & UART_MSR_DCTS_MASK) >> UART_MSR_DCTS_SHIFT)
  940. #endif /* HPM_UART_H */