uart.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * uart.h -- ColdFire internal UART support defines.
  3. *
  4. * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
  5. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. /****************************************************************************/
  26. #ifndef uart_h
  27. #define uart_h
  28. /****************************************************************************/
  29. /* UART module registers */
  30. /* Register read/write struct */
  31. typedef struct uart {
  32. u8 umr; /* 0x00 Mode Register */
  33. u8 resv0[0x3];
  34. union {
  35. u8 usr; /* 0x04 Status Register */
  36. u8 ucsr; /* 0x04 Clock Select Register */
  37. };
  38. u8 resv1[0x3];
  39. u8 ucr; /* 0x08 Command Register */
  40. u8 resv2[0x3];
  41. union {
  42. u8 utb; /* 0x0c Transmit Buffer */
  43. u8 urb; /* 0x0c Receive Buffer */
  44. };
  45. u8 resv3[0x3];
  46. union {
  47. u8 uipcr; /* 0x10 Input Port Change Register */
  48. u8 uacr; /* 0x10 Auxiliary Control reg */
  49. };
  50. u8 resv4[0x3];
  51. union {
  52. u8 uimr; /* 0x14 Interrupt Mask reg */
  53. u8 uisr; /* 0x14 Interrupt Status reg */
  54. };
  55. u8 resv5[0x3];
  56. u8 ubg1; /* 0x18 Counter Timer Upper Register */
  57. u8 resv6[0x3];
  58. u8 ubg2; /* 0x1c Counter Timer Lower Register */
  59. u8 resv7[0x17];
  60. u8 uip; /* 0x34 Input Port Register */
  61. u8 resv8[0x3];
  62. u8 uop1; /* 0x38 Output Port Set Register */
  63. u8 resv9[0x3];
  64. u8 uop0; /* 0x3c Output Port Reset Register */
  65. } uart_t;
  66. /*********************************************************************
  67. * Universal Asynchronous Receiver Transmitter (UART)
  68. *********************************************************************/
  69. /* Bit definitions and macros for UMR */
  70. #define UART_UMR_BC(x) (((x)&0x03))
  71. #define UART_UMR_PT (0x04)
  72. #define UART_UMR_PM(x) (((x)&0x03)<<3)
  73. #define UART_UMR_ERR (0x20)
  74. #define UART_UMR_RXIRQ (0x40)
  75. #define UART_UMR_RXRTS (0x80)
  76. #define UART_UMR_SB(x) (((x)&0x0F))
  77. #define UART_UMR_TXCTS (0x10) /* Trsnsmit CTS */
  78. #define UART_UMR_TXRTS (0x20) /* Transmit RTS */
  79. #define UART_UMR_CM(x) (((x)&0x03)<<6) /* CM bits */
  80. #define UART_UMR_PM_MULTI_ADDR (0x1C)
  81. #define UART_UMR_PM_MULTI_DATA (0x18)
  82. #define UART_UMR_PM_NONE (0x10)
  83. #define UART_UMR_PM_FORCE_HI (0x0C)
  84. #define UART_UMR_PM_FORCE_LO (0x08)
  85. #define UART_UMR_PM_ODD (0x04)
  86. #define UART_UMR_PM_EVEN (0x00)
  87. #define UART_UMR_BC_5 (0x00)
  88. #define UART_UMR_BC_6 (0x01)
  89. #define UART_UMR_BC_7 (0x02)
  90. #define UART_UMR_BC_8 (0x03)
  91. #define UART_UMR_CM_NORMAL (0x00)
  92. #define UART_UMR_CM_ECH (0x40)
  93. #define UART_UMR_CM_LOCAL_LOOP (0x80)
  94. #define UART_UMR_CM_REMOTE_LOOP (0xC0)
  95. #define UART_UMR_SB_STOP_BITS_1 (0x07)
  96. #define UART_UMR_SB_STOP_BITS_15 (0x08)
  97. #define UART_UMR_SB_STOP_BITS_2 (0x0F)
  98. /* Bit definitions and macros for USR */
  99. #define UART_USR_RXRDY (0x01)
  100. #define UART_USR_FFULL (0x02)
  101. #define UART_USR_TXRDY (0x04)
  102. #define UART_USR_TXEMP (0x08)
  103. #define UART_USR_OE (0x10)
  104. #define UART_USR_PE (0x20)
  105. #define UART_USR_FE (0x40)
  106. #define UART_USR_RB (0x80)
  107. /* Bit definitions and macros for UCSR */
  108. #define UART_UCSR_TCS(x) (((x)&0x0F))
  109. #define UART_UCSR_RCS(x) (((x)&0x0F)<<4)
  110. #define UART_UCSR_RCS_SYS_CLK (0xD0)
  111. #define UART_UCSR_RCS_CTM16 (0xE0)
  112. #define UART_UCSR_RCS_CTM (0xF0)
  113. #define UART_UCSR_TCS_SYS_CLK (0x0D)
  114. #define UART_UCSR_TCS_CTM16 (0x0E)
  115. #define UART_UCSR_TCS_CTM (0x0F)
  116. /* Bit definitions and macros for UCR */
  117. #define UART_UCR_RXC(x) (((x)&0x03))
  118. #define UART_UCR_TXC(x) (((x)&0x03)<<2)
  119. #define UART_UCR_MISC(x) (((x)&0x07)<<4)
  120. #define UART_UCR_NONE (0x00)
  121. #define UART_UCR_STOP_BREAK (0x70)
  122. #define UART_UCR_START_BREAK (0x60)
  123. #define UART_UCR_BKCHGINT (0x50)
  124. #define UART_UCR_RESET_ERROR (0x40)
  125. #define UART_UCR_RESET_TX (0x30)
  126. #define UART_UCR_RESET_RX (0x20)
  127. #define UART_UCR_RESET_MR (0x10)
  128. #define UART_UCR_TX_DISABLED (0x08)
  129. #define UART_UCR_TX_ENABLED (0x04)
  130. #define UART_UCR_RX_DISABLED (0x02)
  131. #define UART_UCR_RX_ENABLED (0x01)
  132. /* Bit definitions and macros for UIPCR */
  133. #define UART_UIPCR_CTS (0x01)
  134. #define UART_UIPCR_COS (0x10)
  135. /* Bit definitions and macros for UACR */
  136. #define UART_UACR_IEC (0x01)
  137. /* Bit definitions and macros for UIMR */
  138. #define UART_UIMR_TXRDY (0x01)
  139. #define UART_UIMR_RXRDY_FU (0x02)
  140. #define UART_UIMR_DB (0x04)
  141. #define UART_UIMR_COS (0x80)
  142. /* Bit definitions and macros for UISR */
  143. #define UART_UISR_TXRDY (0x01)
  144. #define UART_UISR_RXRDY_FU (0x02)
  145. #define UART_UISR_DB (0x04)
  146. #define UART_UISR_RXFTO (0x08)
  147. #define UART_UISR_TXFIFO (0x10)
  148. #define UART_UISR_RXFIFO (0x20)
  149. #define UART_UISR_COS (0x80)
  150. /* Bit definitions and macros for UIP */
  151. #define UART_UIP_CTS (0x01)
  152. /* Bit definitions and macros for UOP1 */
  153. #define UART_UOP1_RTS (0x01)
  154. /* Bit definitions and macros for UOP0 */
  155. #define UART_UOP0_RTS (0x01)
  156. /****************************************************************************/
  157. #endif /* mcfuart_h */