5 #define ARM_UART_TXD 0x0000 //Write data to this address initiates a character transmission through tx fifo.
6 #define ARM_UART_RXD 0x0004 //Reading this register retrieves the next data byte from the rx fifo.
7 #define ARM_UART_STS0 0x0008
8 #define ARM_UART_STS1 0x000C
9 #define ARM_UART_IEN 0x0010
10 #define ARM_UART_ICLR 0x0014
11 #define ARM_UART_CTL0 0x0018
12 #define ARM_UART_CTL1 0x001C
13 #define ARM_UART_CTL2 0x0020
14 #define ARM_UART_CLKD0 0x0024
15 #define ARM_UART_CLKD1 0x0028
16 #define ARM_UART_STS2 0x002C //Add for sc6600b
18 //The corresponding bit of UART_STS0 register.
19 #define UARTSTS_RX_FIFO_FULL_OUT (1 << 0) //Row Rx_fifo_full_tout.This bit is set when the number of rx fifo data bytes is larger than the rx interrupt watermark value or when receive time is out. Auto cleared when the condition disappears.
20 #define UARTSTS_TX_FIFO_EMPTY (1 << 1) //Row Tx_fifo_emptyThis bit is set when the number of tx fifo data bytes is less than the tx interrupt watermark value. Auto cleared when the condition disappears.
21 #define UARTSTS_PARITY_ERR (1 << 2) //Row parity_error
22 #define UARTSTS_FRAMING_ERR (1 << 3) //Row framing_error
23 #define UARTSTS_RXF_OVERRUN (1 << 4) //Row rxf_overrun
24 #define UARTSTS_DSR_CHANGE (1 << 5) //Row dsr_change
25 #define UARTSTS_CTS_CHANGE (1 << 6) //Row cts_change
26 #define UARTSTS_BREAK_DETECT (1 << 7) //Row break_detect
27 #define UARTSTS_DSR (1 << 8) //DSR: Data set ready
28 #define UARTSTS_CTS (1 << 9) //CTS: clear to send
29 #define UARTSTS_RTS (1 << 10) //RTS: Request to send
30 #define UARTSTS_RXD (1 << 11) //RXD: rx data in
31 #define UARTSTS_TXD (1 << 12) //TXD: tx data out
33 //The corresponding bit of UART_STS1 register.
34 #define RX_FIFO_CNT_MSK 0x000F
35 #define TX_FIFO_CNT_MSK 0x00F0
37 //The corresponding bit of UART_IEN register.
38 #define UARTIEN_RX_FIFO_FULL_OUT (1 << 0) //Rx_fifo_full_tout interrupt enable
39 #define UARTIEN_TX_FIFO_EMPTY (1 << 1) //Tx_fifo_empty interrupt enable
40 #define UARTIEN_PARITY_ERR (1 << 2) //Parity_error interrupt enable
41 #define UARTIEN_FRAMING_ERR (1 << 3) //Framing_error interrupt enable
42 #define UARTIEN_RXF_OVERRUN (1 << 4) //Rxf_overrun interrupt enable
43 #define UARTIEN_DSR_CHANGE (1 << 5) //Dsr_change interrupt enable
44 #define UARTIEN_CTS_CHANGE (1 << 6) //Cts_change interrupt enable
45 #define UARTIEN_BREAK_DETECT (1 << 7) //Break_detect interrupt enable
47 //The corresponding bit of UART_ICLR register.
48 #define UARTICLR_PARITY_ERR (1 << 2) //Write "1" Clear parity_error interrupt
49 #define UARTICLR_FRAMING_ERR (1 << 3) //Write "1" Clear framing_error interrupt
50 #define UARTICLR_RXF_OVERRUN (1 << 4) //Write "1" Clear rx_fifo_overrun interrupt
51 #define UARTICLR_DSR_CHANGE (1 << 5) //Write "1" Clear dsr_change interrupt
52 #define UARTICLR_CTS_CHANGE (1 << 6) //Write "1" Clear cts_change interrupt
53 #define UARTICLR_BREAK_DETECT (1 << 7) //Write "1" Clear break_detect interrupt
55 //The corresponding bit of UART_CTL0 register.
56 #define UARTICLR_PARITY_ERR (1 << 2) //Write "1" Clear parity_error interrupt
57 #define UARTICLR_FRAMING_ERR (1 << 3) //Write "1" Clear framing_error interrupt
58 #define UARTICLR_RXF_OVERRUN (1 << 4) //Write "1" Clear rx_fifo_overrun interrupt
59 #define UARTICLR_DSR_CHANGE (1 << 5) //Write "1" Clear dsr_change interrupt
60 #define UARTICLR_CTS_CHANGE (1 << 6) //Write "1" Clear cts_change interrupt
61 #define UARTICLR_BREAK_DETECT (1 << 7) //Write "1" Clear break_detect interrupt
63 //The corresponding bit of UART_CTL0 register.
64 #define UARTCTL_PARITY_B (1 << 0)
65 #define UARTCTL_PARITY_EVEN 0
66 #define UARTCTL_PARITY_ODD (1 << 0)
68 #define UARTCTL_PARITY_EN (1 << 1)
70 #define UARTCTL_BL_MSK (0x03 << 2)
71 #define UARTCTL_BL5BITS 0
72 #define UARTCTL_BL6BITS (1 << 2)
73 #define UARTCTL_BL7BITS (2 << 2)
74 #define UARTCTL_BL8BITS (3 << 2)
76 #define UARTCTL_SL_MSK (0x03 << 4)
77 #define UARTCTL_SL0BITS 0
78 #define UARTCTL_SL1BITS (1 << 4)
79 #define UARTCTL_SL1HBITS (2 << 4)
80 #define UARTCTL_SL2BITS (3 << 4)
82 #define UARTCTL_RTS (1 << 6) //Ready To SendWhen receive hardware flow control is not set, this bit controls the output of rtsn. When rhwf is set, this bit is controlled by the rx fifo level.
83 #define UARTCTL_TX_EMPTY (1 << 7) //Send BreakWhen tx fifo is empty and tx is idle, setting this bit forces the tx data output low.Need to be cleared by mcu.
84 #define UARTCTL_DTR (1 << 8) //Data Terminal ReadyThis bit controls the dtrn output
86 //The corresponding bit of UART_STS2 register.
87 #define RX_FIFO_FULL_OUT_MSK (1 << 0) //Masked Rx_fifo_full_toutThis bit is set when the number of rx fifo data bytes is larger than the rx interrupt watermark value or when receive time is out. Auto cleared when the condition disappears.
88 #define TX_FIFO_EMPTY_MSK (1 << 1) //Masked Tx_fifo_emptyThis bit is set when the number of tx fifo data bytes is less than the tx interrupt watermark value. Auto cleared when the condition disappears.
89 #define PARITY_ERR_MSK (1 << 2) //Masked Parity_error
90 #define FRAMING_ERR_MSK (1 << 3) //Masked Framing_error
91 #define RXF_CHANGE_MSK (1 << 4) //Masked Rxf_overrun
92 #define DSR_CHANGE_MSK (1 << 5) //Masked Dsr_change
93 #define CTS_MSK (1 << 6) //Masked Cts_change
94 #define BREAK_DETECT_MSK (1 << 7) //Masked Break_detect
98 //-----------------------------------------------
100 ////GREG_BASE 0x8B000000
102 #define GEN0_UART0 (0x1)
103 #define GEN0_UART1 (0x2)
104 /* default baud rate value. clock frequency of 14.7456MHz */
105 /* Baud rate divisor = (Fuartclk / (16 * BaudRate)) - 1 */
107 /* Baud Rate. ( CLK = 12.998 MHz ) */
108 #define BAUD_1200_13M 0x2A50
109 #define BAUD_2400_13M 0x1528
110 #define BAUD_4800_13M 0x0A94
111 #define BAUD_9600_13M 0x054A
112 #define BAUD_19200_13M 0x02A5
113 #define BAUD_38400_13M 0x0152
114 #define BAUD_57600_13M 0x00E1
115 #define BAUD_115200_13M 0x0071
116 #define BAUD_230400_13M 0x0038
117 #define BAUD_460800_13M 0x001C
118 #define BAUD_921600_13M 0x000E
119 /* Baud Rate. ( CLK = 26 MHz ) */
120 #define BAUD_1200_26M 0x54A0
121 #define BAUD_2400_26M 0x2A50
122 #define BAUD_4800_26M 0x1528
123 #define BAUD_9600_26M 0x0A94
124 #define BAUD_19200_26M 0x054A
125 #define BAUD_38400_26M 0x02A5
126 #define BAUD_57600_26M 0x0152
127 #define BAUD_115200_26M 0x00E2
128 #define BAUD_230400_26M 0x0071
129 #define BAUD_460800_26M 0x0038
130 #define BAUD_921600_26M 0x001C
133 #define CPU_CLOCK 12998000
135 /* Baud Rate. ( CLK = 26 MHz ) */
136 #define BAUD_4800 0x1528
137 #define BAUD_9600 0x0A94
138 #define BAUD_19200 0x054A
139 #define BAUD_38400 0x02A5
140 #define BAUD_57600 0x0152
141 #define BAUD_115200 0x00E2
142 #define BAUD_230400 0x0071
143 #define BAUD_460800 0x0038
144 #define BAUD_921600 0x001C
146 #define CPU_CLOCK (12998000 << 1)
151 ( *( ( volatile unsigned int* )( r ) ) )
154 /* UART primitives */
155 #define SIO_GET_RX_STATUS( p ) ( REG( ( p ) + ARM_UART_STS1 ) & 0xFF )
156 #define SIO_RX_READY( s ) ( 0 != ( s ) )
157 #define SIO_GET_CHAR( p ) ( unsigned char )( REG( ( p ) + ARM_UART_RXD ) & 0xFF )
159 #define SIO_GET_TX_STATUS(p) ( ( ( REG( ( p ) + ARM_UART_STS1 ) ) >> 8 ) && 0xFF )
160 #define SIO_TX_READY(s) ( 0 == ( s ) )
161 #define SIO_PUT_CHAR(p,c) ( REG( ( p ) + ARM_UART_TXD ) = ( unsigned int )( ( c ) & 0xFF ) )
163 #define COM1_DEBUG (1)
164 #define COM0_USER (0)
165 #define HWORD(p) ((p >> 16) & 0x0FFFF)
166 #define LWORD(p) (p & 0x0FFFF)
167 #define HBYTE(p) ((p >> 8) & 0x0FF)
168 #define LBYTE(p) (p & 0x0FF)
169 #define MSB(p) ((p >> 4) & 0x0F)
170 #define LSB(p) ((p) & 0x0F)
172 //Ending define For UART