atmel_usart.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /*
  2. * Register definitions for the Atmel USART3 module.
  3. *
  4. * Copyright (C) 2005-2006 Atmel Corporation
  5. *
  6. * Modified to support C structure SoC access by
  7. * Andreas Bießmann <biessmann@corscience.de>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #ifndef __DRIVERS_ATMEL_USART_H__
  24. #define __DRIVERS_ATMEL_USART_H__
  25. /* USART3 register footprint */
  26. typedef struct atmel_usart3 {
  27. u32 cr;
  28. u32 mr;
  29. u32 ier;
  30. u32 idr;
  31. u32 imr;
  32. u32 csr;
  33. u32 rhr;
  34. u32 thr;
  35. u32 brgr;
  36. u32 rtor;
  37. u32 ttgr;
  38. u32 reserved0[5];
  39. u32 fidi;
  40. u32 ner;
  41. u32 reserved1;
  42. u32 ifr;
  43. u32 man;
  44. u32 reserved2[54]; // version and PDC not needed
  45. } atmel_usart3_t;
  46. /* Bitfields in CR */
  47. #define USART3_RSTRX_OFFSET 2
  48. #define USART3_RSTRX_SIZE 1
  49. #define USART3_RSTTX_OFFSET 3
  50. #define USART3_RSTTX_SIZE 1
  51. #define USART3_RXEN_OFFSET 4
  52. #define USART3_RXEN_SIZE 1
  53. #define USART3_RXDIS_OFFSET 5
  54. #define USART3_RXDIS_SIZE 1
  55. #define USART3_TXEN_OFFSET 6
  56. #define USART3_TXEN_SIZE 1
  57. #define USART3_TXDIS_OFFSET 7
  58. #define USART3_TXDIS_SIZE 1
  59. #define USART3_RSTSTA_OFFSET 8
  60. #define USART3_RSTSTA_SIZE 1
  61. #define USART3_STTBRK_OFFSET 9
  62. #define USART3_STTBRK_SIZE 1
  63. #define USART3_STPBRK_OFFSET 10
  64. #define USART3_STPBRK_SIZE 1
  65. #define USART3_STTTO_OFFSET 11
  66. #define USART3_STTTO_SIZE 1
  67. #define USART3_SENDA_OFFSET 12
  68. #define USART3_SENDA_SIZE 1
  69. #define USART3_RSTIT_OFFSET 13
  70. #define USART3_RSTIT_SIZE 1
  71. #define USART3_RSTNACK_OFFSET 14
  72. #define USART3_RSTNACK_SIZE 1
  73. #define USART3_RETTO_OFFSET 15
  74. #define USART3_RETTO_SIZE 1
  75. #define USART3_DTREN_OFFSET 16
  76. #define USART3_DTREN_SIZE 1
  77. #define USART3_DTRDIS_OFFSET 17
  78. #define USART3_DTRDIS_SIZE 1
  79. #define USART3_RTSEN_OFFSET 18
  80. #define USART3_RTSEN_SIZE 1
  81. #define USART3_RTSDIS_OFFSET 19
  82. #define USART3_RTSDIS_SIZE 1
  83. #define USART3_COMM_TX_OFFSET 30
  84. #define USART3_COMM_TX_SIZE 1
  85. #define USART3_COMM_RX_OFFSET 31
  86. #define USART3_COMM_RX_SIZE 1
  87. /* Bitfields in MR */
  88. #define USART3_USART_MODE_OFFSET 0
  89. #define USART3_USART_MODE_SIZE 4
  90. #define USART3_USCLKS_OFFSET 4
  91. #define USART3_USCLKS_SIZE 2
  92. #define USART3_CHRL_OFFSET 6
  93. #define USART3_CHRL_SIZE 2
  94. #define USART3_SYNC_OFFSET 8
  95. #define USART3_SYNC_SIZE 1
  96. #define USART3_PAR_OFFSET 9
  97. #define USART3_PAR_SIZE 3
  98. #define USART3_NBSTOP_OFFSET 12
  99. #define USART3_NBSTOP_SIZE 2
  100. #define USART3_CHMODE_OFFSET 14
  101. #define USART3_CHMODE_SIZE 2
  102. #define USART3_MSBF_OFFSET 16
  103. #define USART3_MSBF_SIZE 1
  104. #define USART3_MODE9_OFFSET 17
  105. #define USART3_MODE9_SIZE 1
  106. #define USART3_CLKO_OFFSET 18
  107. #define USART3_CLKO_SIZE 1
  108. #define USART3_OVER_OFFSET 19
  109. #define USART3_OVER_SIZE 1
  110. #define USART3_INACK_OFFSET 20
  111. #define USART3_INACK_SIZE 1
  112. #define USART3_DSNACK_OFFSET 21
  113. #define USART3_DSNACK_SIZE 1
  114. #define USART3_MAX_ITERATION_OFFSET 24
  115. #define USART3_MAX_ITERATION_SIZE 3
  116. #define USART3_FILTER_OFFSET 28
  117. #define USART3_FILTER_SIZE 1
  118. /* Bitfields in CSR */
  119. #define USART3_RXRDY_OFFSET 0
  120. #define USART3_RXRDY_SIZE 1
  121. #define USART3_TXRDY_OFFSET 1
  122. #define USART3_TXRDY_SIZE 1
  123. #define USART3_RXBRK_OFFSET 2
  124. #define USART3_RXBRK_SIZE 1
  125. #define USART3_ENDRX_OFFSET 3
  126. #define USART3_ENDRX_SIZE 1
  127. #define USART3_ENDTX_OFFSET 4
  128. #define USART3_ENDTX_SIZE 1
  129. #define USART3_OVRE_OFFSET 5
  130. #define USART3_OVRE_SIZE 1
  131. #define USART3_FRAME_OFFSET 6
  132. #define USART3_FRAME_SIZE 1
  133. #define USART3_PARE_OFFSET 7
  134. #define USART3_PARE_SIZE 1
  135. #define USART3_TIMEOUT_OFFSET 8
  136. #define USART3_TIMEOUT_SIZE 1
  137. #define USART3_TXEMPTY_OFFSET 9
  138. #define USART3_TXEMPTY_SIZE 1
  139. #define USART3_ITERATION_OFFSET 10
  140. #define USART3_ITERATION_SIZE 1
  141. #define USART3_TXBUFE_OFFSET 11
  142. #define USART3_TXBUFE_SIZE 1
  143. #define USART3_RXBUFF_OFFSET 12
  144. #define USART3_RXBUFF_SIZE 1
  145. #define USART3_NACK_OFFSET 13
  146. #define USART3_NACK_SIZE 1
  147. #define USART3_RIIC_OFFSET 16
  148. #define USART3_RIIC_SIZE 1
  149. #define USART3_DSRIC_OFFSET 17
  150. #define USART3_DSRIC_SIZE 1
  151. #define USART3_DCDIC_OFFSET 18
  152. #define USART3_DCDIC_SIZE 1
  153. #define USART3_CTSIC_OFFSET 19
  154. #define USART3_CTSIC_SIZE 1
  155. #define USART3_RI_OFFSET 20
  156. #define USART3_RI_SIZE 1
  157. #define USART3_DSR_OFFSET 21
  158. #define USART3_DSR_SIZE 1
  159. #define USART3_DCD_OFFSET 22
  160. #define USART3_DCD_SIZE 1
  161. #define USART3_CTS_OFFSET 23
  162. #define USART3_CTS_SIZE 1
  163. /* Bitfields in RHR */
  164. #define USART3_RXCHR_OFFSET 0
  165. #define USART3_RXCHR_SIZE 9
  166. /* Bitfields in THR */
  167. #define USART3_TXCHR_OFFSET 0
  168. #define USART3_TXCHR_SIZE 9
  169. /* Bitfields in BRGR */
  170. #define USART3_CD_OFFSET 0
  171. #define USART3_CD_SIZE 16
  172. /* Bitfields in RTOR */
  173. #define USART3_TO_OFFSET 0
  174. #define USART3_TO_SIZE 16
  175. /* Bitfields in TTGR */
  176. #define USART3_TG_OFFSET 0
  177. #define USART3_TG_SIZE 8
  178. /* Bitfields in FIDI */
  179. #define USART3_FI_DI_RATIO_OFFSET 0
  180. #define USART3_FI_DI_RATIO_SIZE 11
  181. /* Bitfields in NER */
  182. #define USART3_NB_ERRORS_OFFSET 0
  183. #define USART3_NB_ERRORS_SIZE 8
  184. /* Bitfields in XXR */
  185. #define USART3_XOFF_OFFSET 0
  186. #define USART3_XOFF_SIZE 8
  187. #define USART3_XON_OFFSET 8
  188. #define USART3_XON_SIZE 8
  189. /* Bitfields in IFR */
  190. #define USART3_IRDA_FILTER_OFFSET 0
  191. #define USART3_IRDA_FILTER_SIZE 8
  192. /* Bitfields in RCR */
  193. #define USART3_RXCTR_OFFSET 0
  194. #define USART3_RXCTR_SIZE 16
  195. /* Bitfields in TCR */
  196. #define USART3_TXCTR_OFFSET 0
  197. #define USART3_TXCTR_SIZE 16
  198. /* Bitfields in RNCR */
  199. #define USART3_RXNCR_OFFSET 0
  200. #define USART3_RXNCR_SIZE 16
  201. /* Bitfields in TNCR */
  202. #define USART3_TXNCR_OFFSET 0
  203. #define USART3_TXNCR_SIZE 16
  204. /* Bitfields in PTCR */
  205. #define USART3_RXTEN_OFFSET 0
  206. #define USART3_RXTEN_SIZE 1
  207. #define USART3_RXTDIS_OFFSET 1
  208. #define USART3_RXTDIS_SIZE 1
  209. #define USART3_TXTEN_OFFSET 8
  210. #define USART3_TXTEN_SIZE 1
  211. #define USART3_TXTDIS_OFFSET 9
  212. #define USART3_TXTDIS_SIZE 1
  213. /* Constants for USART_MODE */
  214. #define USART3_USART_MODE_NORMAL 0
  215. #define USART3_USART_MODE_RS485 1
  216. #define USART3_USART_MODE_HARDWARE 2
  217. #define USART3_USART_MODE_MODEM 3
  218. #define USART3_USART_MODE_ISO7816_T0 4
  219. #define USART3_USART_MODE_ISO7816_T1 6
  220. #define USART3_USART_MODE_IRDA 8
  221. /* Constants for USCLKS */
  222. #define USART3_USCLKS_MCK 0
  223. #define USART3_USCLKS_MCK_DIV 1
  224. #define USART3_USCLKS_SCK 3
  225. /* Constants for CHRL */
  226. #define USART3_CHRL_5 0
  227. #define USART3_CHRL_6 1
  228. #define USART3_CHRL_7 2
  229. #define USART3_CHRL_8 3
  230. /* Constants for PAR */
  231. #define USART3_PAR_EVEN 0
  232. #define USART3_PAR_ODD 1
  233. #define USART3_PAR_SPACE 2
  234. #define USART3_PAR_MARK 3
  235. #define USART3_PAR_NONE 4
  236. #define USART3_PAR_MULTI 6
  237. /* Constants for NBSTOP */
  238. #define USART3_NBSTOP_1 0
  239. #define USART3_NBSTOP_1_5 1
  240. #define USART3_NBSTOP_2 2
  241. /* Constants for CHMODE */
  242. #define USART3_CHMODE_NORMAL 0
  243. #define USART3_CHMODE_ECHO 1
  244. #define USART3_CHMODE_LOCAL_LOOP 2
  245. #define USART3_CHMODE_REMOTE_LOOP 3
  246. /* Constants for MSBF */
  247. #define USART3_MSBF_LSBF 0
  248. #define USART3_MSBF_MSBF 1
  249. /* Constants for OVER */
  250. #define USART3_OVER_X16 0
  251. #define USART3_OVER_X8 1
  252. /* Constants for CD */
  253. #define USART3_CD_DISABLE 0
  254. #define USART3_CD_BYPASS 1
  255. /* Constants for TO */
  256. #define USART3_TO_DISABLE 0
  257. /* Constants for TG */
  258. #define USART3_TG_DISABLE 0
  259. /* Constants for FI_DI_RATIO */
  260. #define USART3_FI_DI_RATIO_DISABLE 0
  261. /* Bit manipulation macros */
  262. #define USART3_BIT(name) \
  263. (1 << USART3_##name##_OFFSET)
  264. #define USART3_BF(name,value) \
  265. (((value) & ((1 << USART3_##name##_SIZE) - 1)) \
  266. << USART3_##name##_OFFSET)
  267. #define USART3_BFEXT(name,value) \
  268. (((value) >> USART3_##name##_OFFSET) \
  269. & ((1 << USART3_##name##_SIZE) - 1))
  270. #define USART3_BFINS(name,value,old) \
  271. (((old) & ~(((1 << USART3_##name##_SIZE) - 1) \
  272. << USART3_##name##_OFFSET)) \
  273. | USART3_BF(name,value))
  274. #endif /* __DRIVERS_ATMEL_USART_H__ */