1 | /*
|
---|
2 | * Copyright (c) 2012 Jan Vesely
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 | /** @addtogroup genarch
|
---|
29 | * @{
|
---|
30 | */
|
---|
31 | /**
|
---|
32 | * @file
|
---|
33 | * @brief Texas Instruments AMDM37x on-chip interrupt controller driver.
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef KERN_AMDM37x_UART_H_
|
---|
37 | #define KERN_AMDM37x_UART_H_
|
---|
38 |
|
---|
39 | #include <typedefs.h>
|
---|
40 | #include <console/chardev.h>
|
---|
41 | #include <ddi/irq.h>
|
---|
42 |
|
---|
43 | /* AMDM37x TRM p. 2950 */
|
---|
44 | #define AMDM37x_UART1_BASE_ADDRESS 0x4806a000
|
---|
45 | #define AMDM37x_UART1_SIZE 1024
|
---|
46 | #define AMDM37x_UART1_IRQ 72 /* AMDM37x TRM p. 2418 */
|
---|
47 |
|
---|
48 | #define AMDM37x_UART2_BASE_ADDRESS 0x4806b000
|
---|
49 | #define AMDM37x_UART2_SIZE 1024
|
---|
50 | #define AMDM37x_UART2_IRQ 73 /* AMDM37x TRM p. 2418 */
|
---|
51 |
|
---|
52 | #define AMDM37x_UART3_BASE_ADDRESS 0x49020000
|
---|
53 | #define AMDM37x_UART3_SIZE 1024
|
---|
54 | #define AMDM37x_UART3_IRQ 74 /* AMDM37x TRM p. 2418 */
|
---|
55 |
|
---|
56 | #define AMDM37x_UART4_BASE_ADDRESS 0x49042000
|
---|
57 | #define AMDM37x_UART4_SIZE 1024
|
---|
58 | #define AMDM37x_UART4_IRQ 80 /* AMDM37x TRM p. 2418 */
|
---|
59 |
|
---|
60 | typedef struct {
|
---|
61 | union {
|
---|
62 | /** Stores lower part of the 14-bit baud divisor */
|
---|
63 | ioport32_t dll;
|
---|
64 | #define AMDM37x_UART_DLL_MASK (0xff)
|
---|
65 |
|
---|
66 | /** Receive holding register */
|
---|
67 | const ioport32_t rhr;
|
---|
68 | #define AMDM37x_UART_RHR_MASK (0xff)
|
---|
69 |
|
---|
70 | /** Transmit holding register */
|
---|
71 | ioport32_t thr;
|
---|
72 | #define AMDM37x_UART_THR_MASK (0xff)
|
---|
73 | };
|
---|
74 |
|
---|
75 | union {
|
---|
76 | /** Stores higher part of the 14-bit baud divisor */
|
---|
77 | ioport32_t dlh;
|
---|
78 | #define AMDM37x_UART_DLH_MASK (0x1f)
|
---|
79 |
|
---|
80 | /** Interrupt enable registers */
|
---|
81 | ioport32_t ier;
|
---|
82 | #define AMDM37x_UART_IER_RHR_IRQ_FLAG (1 << 0)
|
---|
83 | #define AMDM37x_UART_IER_THR_IRQ_FLAG (1 << 1)
|
---|
84 | #define AMDM37x_UART_IER_LINE_STS_IRQ_FLAG (1 << 2)
|
---|
85 | #define AMDM37x_UART_IER_MODEM_STS_IRQ_FLAG (1 << 3)
|
---|
86 | #define AMDM37x_UART_IER_SLEEP_MODE_FLAG (1 << 4)
|
---|
87 | #define AMDM37x_UART_IER_XOFF_IRQ_FLAG (1 << 5)
|
---|
88 | #define AMDM37x_UART_IER_RTS_IRQ_FLAG (1 << 6)
|
---|
89 | #define AMDM37x_UART_IER_CTS_IRQ_FLAG (1 << 7)
|
---|
90 |
|
---|
91 | #define AMDM37x_CIR_IER_RHR_IRQ_FLAG (1 << 0)
|
---|
92 | #define AMDM37x_CIR_IER_THR_IRQ_FLAG (1 << 1)
|
---|
93 | #define AMDM37x_CIR_IER_RX_STOP_IRQ_FLAG (1 << 2)
|
---|
94 | #define AMDM37x_CIR_IER_RX_OVERRUN_IRQ_FLAG (1 << 3)
|
---|
95 | #define AMDM37x_CIR_IER_TX_STS_IRQ_FLAG (1 << 5)
|
---|
96 |
|
---|
97 | #define AMDM37x_IRDA_IER_RHR_IRQ_FLAG (1 << 0)
|
---|
98 | #define AMDM37x_IRDA_IER_THR_IRQ_FLAG (1 << 1)
|
---|
99 | #define AMDM37x_IRDA_IER_LAST_RX_BYTE_IRQ_FLAG (1 << 2)
|
---|
100 | #define AMDM37x_IRDA_IER_RX_OVERRUN_IRQ_FLAG (1 << 3)
|
---|
101 | #define AMDM37x_IRDA_IER_STS_FIFO_TRIG_IRQ_FLAG (1 << 4)
|
---|
102 | #define AMDM37x_IRDA_IER_TX_STS_IRQ_FLAG (1 << 5)
|
---|
103 | #define AMDM37x_IRDA_IER_LINE_STS_IRQ_FLAG (1 << 6)
|
---|
104 | #define AMDM37x_IRDA_IER_EOF_IRQ_FLAG (1 << 7)
|
---|
105 | };
|
---|
106 |
|
---|
107 | union {
|
---|
108 | /** Interrupt identification register */
|
---|
109 | const ioport32_t iir;
|
---|
110 | #define AMDM37x_UART_IIR_IRQ_PENDING_FLAG (1 << 0)
|
---|
111 | #define AMDM37x_UART_IIR_TYPE_MASK (0x1f)
|
---|
112 | #define AMDM37x_UART_IIR_TYPE_SHIFT (1)
|
---|
113 | #define AMDM37x_UART_IIR_FCR_MASK (0x3)
|
---|
114 | #define AMDM37x_UART_IIR_FCR_SHIFT (6)
|
---|
115 |
|
---|
116 | #define AMDM37x_CIR_IIR_RHR_IRQ_FLAG (1 << 0)
|
---|
117 | #define AMDM37x_CIR_IIR_THR_IRQ_FLAG (1 << 1)
|
---|
118 | #define AMDM37x_CIR_IIR_RX_STOP_IRQ_FLAG (1 << 2)
|
---|
119 | #define AMDM37x_CIR_IIR_RX_OE_IRQ_FLAG (1 << 3)
|
---|
120 | #define AMDM37x_CIR_IIR_TX_STS_IRQ_FLAG (1 << 5)
|
---|
121 |
|
---|
122 | #define AMDM37x_IRDA_IIR_RHR_IRQ_FLAG (1 << 0)
|
---|
123 | #define AMDM37x_IRDA_IIR_THR_IRQ_FLAG (1 << 1)
|
---|
124 | #define AMDM37x_IRDA_IIR_RX_FIFO_LB_IRQ_FLAG (1 << 2)
|
---|
125 | #define AMDM37x_IRDA_IIR_RX_OE_IRQ_FLAG (1 << 3)
|
---|
126 | #define AMDM37x_IRDA_IIR_STS_FIFO_IRQ_FLAG (1 << 4)
|
---|
127 | #define AMDM37x_IRDA_IIR_TX_STS_IRQ_FLAG (1 << 5)
|
---|
128 | #define AMDM37x_IRDA_IIR_LINE_STS_IRQ_FLAG (1 << 6)
|
---|
129 | #define AMDM37x_IRDA_IIR_EOF_IRQ_FLAG (1 << 7)
|
---|
130 |
|
---|
131 | /** FIFO control register */
|
---|
132 | ioport32_t fcr;
|
---|
133 | #define AMDM37x_UART_FCR_FIFO_EN_FLAG (1 << 0)
|
---|
134 | #define AMDM37x_UART_FCR_RX_FIFO_CLR_FLAG (1 << 1)
|
---|
135 | #define AMDM37x_UART_FCR_TX_FIFO_CLR_FLAG (1 << 3)
|
---|
136 | #define AMDM37x_UART_FCR_DMA_MODE_FLAG (1 << 4)
|
---|
137 |
|
---|
138 | #define AMDM37x_UART_FCR_TX_FIFO_TRIG_MASK (0x3)
|
---|
139 | #define AMDM37x_UART_FCR_TX_FIFO_TRIG_SHIFT (4)
|
---|
140 |
|
---|
141 | #define AMDM37x_UART_FCR_RX_FIFO_TRIG_MASK (0x3)
|
---|
142 | #define AMDM37x_UART_FCR_RX_FIFO_TRIG_SHIFT (6)
|
---|
143 |
|
---|
144 | /** Enhanced feature register */
|
---|
145 | ioport32_t efr;
|
---|
146 | #define AMDM37x_UART_EFR_SW_FLOW_CTRL_RX_MASK (0x3)
|
---|
147 | #define AMDM37x_UART_EFR_SW_FLOW_CTRL_RX_SHIFT (0)
|
---|
148 | #define AMDM37x_UART_EFR_SW_FLOW_CTRL_TX_MASK (0x3)
|
---|
149 | #define AMDM37x_UART_EFR_SW_FLOW_CTRL_TX_SHIFT (2)
|
---|
150 |
|
---|
151 | #define AMDM37x_UART_EFR_SW_FLOW_CTRL_NONE (0x0)
|
---|
152 | #define AMDM37x_UART_EFR_SW_FLOW_CTRL_X2 (0x1)
|
---|
153 | #define AMDM37x_UART_EFR_SW_FLOW_CTRL_X1 (0x2)
|
---|
154 | #define AMDM37x_UART_EFR_SW_FLOW_CTRL_XBOTH (0x3)
|
---|
155 |
|
---|
156 | #define AMDM37x_UART_EFR_ENH_FLAG (1 << 4)
|
---|
157 | #define AMDM37x_UART_EFR_SPEC_CHAR_FLAG (1 << 5)
|
---|
158 | #define AMDM37x_UART_EFR_AUTO_RTS_EN_FLAG (1 << 6)
|
---|
159 | #define AMDM37x_UART_EFR_AUTO_CTS_EN_FLAG (1 << 7)
|
---|
160 | };
|
---|
161 |
|
---|
162 | /** Line control register */
|
---|
163 | ioport32_t lcr;
|
---|
164 | #define AMDM37x_UART_LCR_CHAR_LENGTH_MASK (0x3)
|
---|
165 | #define AMDM37x_UART_LCR_CHAR_LENGTH_SHIFT (0)
|
---|
166 | #define AMDM37x_UART_LCR_CHAR_LENGTH_5BITS (0x0)
|
---|
167 | #define AMDM37x_UART_LCR_CHAR_LENGTH_6BITS (0x1)
|
---|
168 | #define AMDM37x_UART_LCR_CHAR_LENGTH_7BITS (0x2)
|
---|
169 | #define AMDM37x_UART_LCR_CHAR_LENGTH_8BITS (0x3)
|
---|
170 | #define AMDM37x_UART_LCR_NB_STOP_FLAG (1 << 2)
|
---|
171 | #define AMDM37x_UART_LCR_PARITY_EN_FLAG (1 << 3)
|
---|
172 | #define AMDM37x_UART_LCR_PARITY_TYPE1_FLAG (1 << 4)
|
---|
173 | #define AMDM37x_UART_LCR_PARITY_TYPE2_FLAG (1 << 5)
|
---|
174 | #define AMDM37x_UART_LCR_BREAK_EN_FLAG (1 << 6)
|
---|
175 | #define AMDM37x_UART_LCR_DIV_EN_FLAG (1 << 7)
|
---|
176 |
|
---|
177 |
|
---|
178 | union {
|
---|
179 | /** Modem control register */
|
---|
180 | ioport32_t mcr;
|
---|
181 | #define AMDM37x_UART_MCR_DTR_FLAG (1 << 0)
|
---|
182 | #define AMDM37x_UART_MCR_RTS_FLAG (1 << 1)
|
---|
183 | #define AMDM37x_UART_MCR_RI_STS_CH_FLAG (1 << 2)
|
---|
184 | #define AMDM37x_UART_MCR_CD_STS_CH_FLAG (1 << 3)
|
---|
185 | #define AMDM37x_UART_MCR_LOOPBACK_EN_FLAG (1 << 4)
|
---|
186 | #define AMDM37x_UART_MCR_XON_EN_FLAG (1 << 5)
|
---|
187 | #define AMDM37x_UART_MCR_TCR_TLR_FLAG (1 << 6)
|
---|
188 |
|
---|
189 | /** UART: XON1 char, IRDA: ADDR1 address */
|
---|
190 | ioport32_t xon1_addr1;
|
---|
191 | #define AMDM37x_UART_XON1_ADDR1_MASK (0xff)
|
---|
192 | };
|
---|
193 |
|
---|
194 | union {
|
---|
195 | /** Line status register */
|
---|
196 | const ioport32_t lsr;
|
---|
197 | #define AMDM37x_UART_LSR_RX_FIFO_E_FLAG (1 << 0)
|
---|
198 | #define AMDM37x_UART_LSR_RX_OE_FLAG (1 << 1)
|
---|
199 | #define AMDM37x_UART_LSR_RX_PE_FLAG (1 << 2)
|
---|
200 | #define AMDM37x_UART_LSR_RX_FE_FLAG (1 << 3)
|
---|
201 | #define AMDM37x_UART_LSR_RX_BI_FLAG (1 << 4)
|
---|
202 | #define AMDM37x_UART_LSR_TX_FIFO_E_FLAG (1 << 5)
|
---|
203 | #define AMDM37x_UART_LSR_TX_SR_E_FLAG (1 << 6)
|
---|
204 | #define AMDM37x_UART_LSR_RX_FIFO_STS_FLAG (1 << 7)
|
---|
205 |
|
---|
206 | #define AMDM37x_CIR_LSR_RX_FIFO_E_FLAG (1 << 0)
|
---|
207 | #define AMDM37x_CIR_LSR_RX_STOP_FLAG (1 << 5)
|
---|
208 | #define AMDM37x_CIR_LSR_THR_EMPTY_FLAG (1 << 7)
|
---|
209 |
|
---|
210 | #define AMDM37x_IRDA_LSR_RX_FIFO_E_FLAG (1 << 0)
|
---|
211 | #define AMDM37x_IRDA_LSR_STS_FIFO_E_FLAG (1 << 1)
|
---|
212 | #define AMDM37x_IRDA_LSR_CRC_FLAG (1 << 2)
|
---|
213 | #define AMDM37x_IRDA_LSR_ABORT_FLAG (1 << 3)
|
---|
214 | #define AMDM37x_IRDA_LSR_FTL_FLAG (1 << 4)
|
---|
215 | #define AMDM37x_IRDA_LSR_RX_LAST_FLAG (1 << 5)
|
---|
216 | #define AMDM37x_IRDA_LSR_STS_FIFO_FULL_FLAG (1 << 6)
|
---|
217 | #define AMDM37x_IRDA_LSR_THR_EMPTY_FLAG (1 << 7)
|
---|
218 |
|
---|
219 | /** UART: XON2 char, IRDA: ADDR2 address */
|
---|
220 | ioport32_t xon2_addr2;
|
---|
221 | };
|
---|
222 |
|
---|
223 | union {
|
---|
224 | /** Modem status register */
|
---|
225 | const ioport32_t msr;
|
---|
226 | #define AMDM37x_UART_MSR_CTS_STS_FLAG (1 << 0)
|
---|
227 | #define AMDM37x_UART_MSR_DSR_STS_FLAG (1 << 1)
|
---|
228 | #define AMDM37x_UART_MSR_RI_STS_FLAG (1 << 2)
|
---|
229 | #define AMDM37x_UART_MSR_DCD_STS_FLAG (1 << 3)
|
---|
230 | #define AMDM37x_UART_MSR_NCTS_STS_FLAG (1 << 4)
|
---|
231 | #define AMDM37x_UART_MSR_NDSR_STS_FLAG (1 << 5)
|
---|
232 | #define AMDM37x_UART_MSR_NRI_STS_FLAG (1 << 6)
|
---|
233 | #define AMDM37x_UART_MSR_NCD_STS_FLAG (1 << 7)
|
---|
234 |
|
---|
235 | /** Transmission control register */
|
---|
236 | ioport32_t tcr;
|
---|
237 | #define AMDM37x_UART_TCR_FIFO_TRIG_MASK (0xf)
|
---|
238 | #define AMDM37x_UART_TCR_FIFO_TRIG_HALT_SHIFT (0)
|
---|
239 | #define AMDM37x_UART_TCR_FIFO_TRIG_START_SHIFT (4)
|
---|
240 |
|
---|
241 | /** UART: XOFF1 char */
|
---|
242 | ioport32_t xoff1;
|
---|
243 | #define AMDM37x_UART_XOFF1_MASK (0xff)
|
---|
244 | };
|
---|
245 |
|
---|
246 | union {
|
---|
247 | /* Scratchpad register, does nothing */
|
---|
248 | ioport32_t spr;
|
---|
249 | #define AMDM37x_UART_SPR_MASK (0xff)
|
---|
250 |
|
---|
251 | /* Trigger level register */
|
---|
252 | ioport32_t tlr;
|
---|
253 | #define AMDM37x_UART_TLR_LEVEL_MASK (0xf)
|
---|
254 | #define AMDM37x_UART_TLR_TX_FIFO_TRIG_SHIFT (0)
|
---|
255 | #define AMDM37x_UART_TLR_RX_FIFO_TRIG_SHIFT (4)
|
---|
256 |
|
---|
257 | /** UART: XOFF2 char */
|
---|
258 | ioport32_t xoff2;
|
---|
259 | #define AMDM37x_UART_XOFF2_MASK (0xff)
|
---|
260 | };
|
---|
261 |
|
---|
262 | /** Mode definition register. */
|
---|
263 | ioport32_t mdr1;
|
---|
264 | #define AMDM37x_UART_MDR_MS_MASK (0x7)
|
---|
265 | #define AMDM37x_UART_MDR_MS_SHIFT (0)
|
---|
266 | #define AMDM37x_UART_MDR_MS_UART16 (0x0)
|
---|
267 | #define AMDM37x_UART_MDR_MS_SIR (0x1)
|
---|
268 | #define AMDM37x_UART_MDR_MS_UART16_AUTO (0x2)
|
---|
269 | #define AMDM37x_UART_MDR_MS_UART13 (0x3)
|
---|
270 | #define AMDM37x_UART_MDR_MS_MIR (0x4)
|
---|
271 | #define AMDM37x_UART_MDR_MS_FIR (0x5)
|
---|
272 | #define AMDM37x_UART_MDR_MS_CIR (0x6)
|
---|
273 | #define AMDM37x_UART_MDR_MS_DISABLE (0x7)
|
---|
274 |
|
---|
275 | #define AMDM37x_UART_MDR_IR_SLEEP_FLAG (1 << 3)
|
---|
276 | #define AMDM37x_UART_MDR_SET_TXIR_FLAG (1 << 4)
|
---|
277 | #define AMDM37x_UART_MDR_SCT_FLAG (1 << 5)
|
---|
278 | #define AMDM37x_UART_MDR_SIP_FLAG (1 << 6)
|
---|
279 | #define AMDM37x_UART_MDR_FRAME_END_MODE_FLAG (1 << 7)
|
---|
280 |
|
---|
281 | /** Mode definition register */
|
---|
282 | ioport32_t mdr2;
|
---|
283 | #define AMDM37x_UART_MDR_IRTX_UNDERRUN_FLAG (1 << 0)
|
---|
284 | #define AMDM37x_UART_MDR_STS_FIFO_TRIG_MASK (0x3)
|
---|
285 | #define AMDM37x_UART_MDR_STS_FIFO_TRIG_SHIFT (1)
|
---|
286 | #define AMDM37x_UART_MDR_PULSE_SHAPING_FLAG (1 << 3)
|
---|
287 | #define AMDM37x_UART_MDR_CIR_PULSE_MODE_MASK (0x3)
|
---|
288 | #define AMDM37x_UART_MDR_CIR_PULSE_MODE_SHIFT (4)
|
---|
289 | #define AMDM37x_UART_MDR_IRRXINVERT_FLAG (1 << 6)
|
---|
290 |
|
---|
291 |
|
---|
292 | /* UART3 specific */
|
---|
293 | union {
|
---|
294 | /** Status FIFO line status register (IrDA only) */
|
---|
295 | const ioport32_t sflsr;
|
---|
296 | #define AMDM37x_IRDA_SFLSR_CRC_ERROR_FLAG (1 << 1)
|
---|
297 | #define AMDM37x_IRDA_SFLSR_ABORT_FLAG (1 << 2)
|
---|
298 | #define AMDM37x_IRDA_SFLSR_FTL_FLAG (1 << 3)
|
---|
299 | #define AMDM37x_IRDA_SFLSR_OE_FLAG (1 << 4)
|
---|
300 |
|
---|
301 | /** Transmit frame length low (IrDA only) */
|
---|
302 | ioport32_t txfll;
|
---|
303 | #define AMDM37x_UART_TXFLL_MASK (0xff)
|
---|
304 | };
|
---|
305 |
|
---|
306 | /* UART3 specific */
|
---|
307 | union {
|
---|
308 | /** Dummy register to restart TX or RX (IrDA only) */
|
---|
309 | const ioport32_t resume;
|
---|
310 | /** Transmit frame length high (IrDA only) */
|
---|
311 | ioport32_t txflh;
|
---|
312 | #define AMDM37x_UART_TXFLH_MASK (0xff)
|
---|
313 | };
|
---|
314 |
|
---|
315 | /* UART3 specific */
|
---|
316 | union {
|
---|
317 | /** Status FIFO register low (IrDA only) */
|
---|
318 | const ioport32_t sfregl;
|
---|
319 | #define AMDM37x_UART_SFREGL_MASK (0xff)
|
---|
320 | /** Received frame length low (IrDA only) */
|
---|
321 | ioport32_t rxfll;
|
---|
322 | #define AMDM37x_UART_RXFLL_MASK (0xff)
|
---|
323 | };
|
---|
324 |
|
---|
325 | /* UART3 specific */
|
---|
326 | union {
|
---|
327 | /** Status FIFO register high (IrDA only) */
|
---|
328 | const ioport32_t sfregh;
|
---|
329 | #define AMDM37x_UART_SFREGH_MASK (0xf)
|
---|
330 | /** Received frame length high (IrDA only) */
|
---|
331 | ioport32_t rxflh;
|
---|
332 | #define AMDM37x_UART_RXFLH_MASK (0xf)
|
---|
333 | };
|
---|
334 |
|
---|
335 | union {
|
---|
336 | /** UART autobauding status register */
|
---|
337 | const ioport32_t uasr;
|
---|
338 | #define AMDM37x_UART_UASR_SPEED_MASK (0x1f)
|
---|
339 | #define AMDM37x_UART_UASR_SPEED_SHIFT (0)
|
---|
340 | #define AMDM37x_UART_UASR_8BIT_CHAR_FLAG (1 << 5)
|
---|
341 | #define AMDM37x_UART_UASR_PARITY_MASK (0x3)
|
---|
342 | #define AMDM37x_UART_UASR_PARITY_SHIFT (6)
|
---|
343 |
|
---|
344 | /** BOF control register (IrDA only) */
|
---|
345 | ioport32_t blr; /* UART3 sepcific */
|
---|
346 | #define AMDM37x_IRDA_BLR_XBOF_TYPE_FLAG (1 << 6)
|
---|
347 | #define AMDM37x_IRDA_BLR_STS_FIFO_RESET (1 << 7)
|
---|
348 | };
|
---|
349 |
|
---|
350 | /** Auxiliary control register (IrDA only) */
|
---|
351 | ioport32_t acreg; /* UART3 specific */
|
---|
352 | #define AMDM37x_IRDA_ACREG_EOT_EN_FLAG (1 << 0)
|
---|
353 | #define AMDM37x_IRDA_ACREG_ABORT_EN_FLAG (1 << 1)
|
---|
354 | #define AMDM37x_IRDA_ACREG_SCTX_EN_FLAG (1 << 2)
|
---|
355 | #define AMDM37x_IRDA_ACREG_SEND_SIP_FLAG (1 << 3)
|
---|
356 | #define AMDM37x_IRDA_ACREG_DIS_TX_UNDERRUN_FLAG (1 << 4)
|
---|
357 | #define AMDM37x_IRDA_ACREG_DIS_IR_RX_FLAG (1 << 5)
|
---|
358 | #define AMDM37x_IRDA_ACREG_SD_MOD_FLAG (1 << 6)
|
---|
359 | #define AMDM37x_IRDA_ACREG_PULSE_TYPE_FLAG (1 << 7)
|
---|
360 |
|
---|
361 | /** Supplementary control register */
|
---|
362 | ioport32_t scr;
|
---|
363 | #define AMDM37x_UART_SCR_DMA_MODE_CTL_FLAG (1 << 0)
|
---|
364 | #define AMDM37x_UART_SCR_DMA_MODE_MASK (0x3)
|
---|
365 | #define AMDM37x_UART_SCR_DMA_MODE_SHIFT (1)
|
---|
366 | #define AMDM37x_UART_SCR_TX_EMPTY_CTL_IRQ_FLAG (1 << 3)
|
---|
367 | #define AMDM37x_UART_SCR_RX_CTS_WU_EN_FLAG (1 << 4)
|
---|
368 | #define AMDM37x_UART_SCR_TX_TRIG_GRANU1_FLAG (1 << 6)
|
---|
369 | #define AMDM37x_UART_SCR_RX_TRIG_GRANU1_FLAG (1 << 7)
|
---|
370 |
|
---|
371 | /** Supplementary status register */
|
---|
372 | const ioport32_t ssr;
|
---|
373 | #define AMDM37x_UART_SSR_TX_FIFO_FULL_FLAG (1 << 0)
|
---|
374 | #define AMDM37x_UART_SSR_RX_CTS_WU_STS_FLAG (1 << 1)
|
---|
375 | #define AMDM37x_UART_SSR_DMA_COUNTER_RESET_FLAG (1 << 2)
|
---|
376 |
|
---|
377 | /** BOF Length register (IrDA only)*/
|
---|
378 | ioport32_t eblr; /* UART3 specific */
|
---|
379 | #define AMDM37x_IRDA_EBLR_DISABLED (0x00)
|
---|
380 | #define AMDM37x_IRDA_EBLR_RX_STOP_BITS(bits) (bits & 0xff)
|
---|
381 |
|
---|
382 | uint32_t padd0_;
|
---|
383 |
|
---|
384 | /** Module version register */
|
---|
385 | const ioport32_t mvr;
|
---|
386 | #define AMDM37x_UART_MVR_MINOR_MASK (0xf)
|
---|
387 | #define AMDM37x_UART_MVR_MINOR_SHIFT (0)
|
---|
388 | #define AMDM37x_UART_MVR_MAJOR_MASK (0xf)
|
---|
389 | #define AMDM37x_UART_MVR_MAJOR_SHIFT (4)
|
---|
390 |
|
---|
391 | /** System configuration register */
|
---|
392 | ioport32_t sysc;
|
---|
393 | #define AMDM37x_UART_SYSC_AUTOIDLE_FLAG (1 << 0)
|
---|
394 | #define AMDM37x_UART_SYSC_SOFTRESET_FLAG (1 << 1)
|
---|
395 | #define AMDM37x_UART_SYSC_ENWAKEUP_FLAG (1 << 2)
|
---|
396 | #define AMDM37x_UART_SYSC_IDLE_MODE_MASK (0x3)
|
---|
397 | #define AMDM37x_UART_SYSC_IDLE_MODE_SHIFT (3)
|
---|
398 | #define AMDM37x_UART_SYSC_IDLE_MODE_FORCE (0x0)
|
---|
399 | #define AMDM37x_UART_SYSC_IDLE_MODE_NO (0x1)
|
---|
400 | #define AMDM37x_UART_SYSC_IDLE_MODE_SMART (0x2)
|
---|
401 |
|
---|
402 | /** System status register */
|
---|
403 | const ioport32_t syss;
|
---|
404 | #define AMDM37x_UART_SYSS_RESETDONE_FLAG (1 << 0)
|
---|
405 |
|
---|
406 | /** Wake-up enable register */
|
---|
407 | ioport32_t wer;
|
---|
408 | #define AMDM37x_UART_WER_CTS_ACTIVITY_FLAG (1 << 0)
|
---|
409 | #define AMDM37x_UART_WER_RI_ACTIVITY_FLAG (1 << 2)
|
---|
410 | #define AMDM37x_UART_WER_RX_ACTIVITY_FLAG (1 << 4)
|
---|
411 | #define AMDM37x_UART_WER_RHR_IRQ_FLAG (1 << 5)
|
---|
412 | #define AMDM37x_UART_WER_RLS_IRQ_FLAG (1 << 6)
|
---|
413 | #define AMDM37x_UART_WER_TX_WAKEUP_EN_FLAG (1 << 7)
|
---|
414 |
|
---|
415 | /** Carrier frequency prescaler */
|
---|
416 | ioport32_t cfps; /* UART3 specific */
|
---|
417 | #define AMDM37x_UART_CFPS_MASK (0xff)
|
---|
418 |
|
---|
419 | /** Number of bytes in RX fifo */
|
---|
420 | const ioport32_t rx_fifo_lvl;
|
---|
421 | #define AMDM37x_UART_RX_FIFO_LVL_MASK (0xff)
|
---|
422 |
|
---|
423 | /** Number of bytes in TX fifo */
|
---|
424 | const ioport32_t tx_fifo_lvl;
|
---|
425 | #define AMDM37x_UART_TX_FIFO_LVL_MASK (0xff)
|
---|
426 |
|
---|
427 | /** RX/TX empty interrupts */
|
---|
428 | ioport32_t ier2;
|
---|
429 | #define AMDM37x_UART_IER2_RX_FIFO_EMPTY_IRQ_EN_FLAG (1 << 0)
|
---|
430 | #define AMDM37x_UART_IER2_TX_FIFO_EMPTY_IRQ_EN_FLAG (1 << 1)
|
---|
431 |
|
---|
432 | /** RX/TX empty status */
|
---|
433 | ioport32_t isr2;
|
---|
434 | #define AMDM37x_UART_ISR2_RX_FIFO_EMPTY_FLAG (1 << 0)
|
---|
435 | #define AMDM37x_UART_ISR2_TX_FIFO_EMPTY_FLAG (1 << 1)
|
---|
436 |
|
---|
437 | uint32_t padd2_[3];
|
---|
438 |
|
---|
439 | /** Mode definition register 3 */
|
---|
440 | ioport32_t mdr3;
|
---|
441 | #define AMDM37x_UART_MDR3_DIS_CIR_RX_DEMOD_FLAG (1 << 0)
|
---|
442 | } amdm37x_uart_regs_t;
|
---|
443 |
|
---|
444 | typedef struct {
|
---|
445 | amdm37x_uart_regs_t *regs;
|
---|
446 | indev_t *indev;
|
---|
447 | outdev_t outdev;
|
---|
448 | irq_t irq;
|
---|
449 | } amdm37x_uart_t;
|
---|
450 |
|
---|
451 |
|
---|
452 | bool amdm37x_uart_init(amdm37x_uart_t *, inr_t, uintptr_t, size_t);
|
---|
453 | void amdm37x_uart_input_wire(amdm37x_uart_t *, indev_t *);
|
---|
454 |
|
---|
455 | #endif
|
---|
456 |
|
---|
457 | /**
|
---|
458 | * @}
|
---|
459 | */
|
---|