2 * Copyright 2007-2009 Analog Devices Inc.
4 * Licensed under the GPL-2 or later.
7 #include <linux/serial.h>
9 #include <asm/portmux.h>
11 #define UART_GET_CHAR(uart) bfin_read16(((uart)->port.membase + OFFSET_RBR))
12 #define UART_GET_DLL(uart) bfin_read16(((uart)->port.membase + OFFSET_DLL))
13 #define UART_GET_DLH(uart) bfin_read16(((uart)->port.membase + OFFSET_DLH))
14 #define UART_GET_IER(uart) bfin_read16(((uart)->port.membase + OFFSET_IER_SET))
15 #define UART_GET_LCR(uart) bfin_read16(((uart)->port.membase + OFFSET_LCR))
16 #define UART_GET_LSR(uart) bfin_read16(((uart)->port.membase + OFFSET_LSR))
17 #define UART_GET_GCTL(uart) bfin_read16(((uart)->port.membase + OFFSET_GCTL))
18 #define UART_GET_MSR(uart) bfin_read16(((uart)->port.membase + OFFSET_MSR))
19 #define UART_GET_MCR(uart) bfin_read16(((uart)->port.membase + OFFSET_MCR))
21 #define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v)
22 #define UART_PUT_DLL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLL),v)
23 #define UART_SET_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER_SET),v)
24 #define UART_CLEAR_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER_CLEAR),v)
25 #define UART_PUT_DLH(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLH),v)
26 #define UART_PUT_LSR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LSR),v)
27 #define UART_PUT_LCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LCR),v)
28 #define UART_CLEAR_LSR(uart) bfin_write16(((uart)->port.membase + OFFSET_LSR), -1)
29 #define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v)
30 #define UART_PUT_MCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_MCR),v)
31 #define UART_CLEAR_SCTS(uart) bfin_write16(((uart)->port.membase + OFFSET_MSR),SCTS)
33 #define UART_SET_DLAB(uart) /* MMRs not muxed on BF54x */
34 #define UART_CLEAR_DLAB(uart) /* MMRs not muxed on BF54x */
36 #define UART_GET_CTS(x) (UART_GET_MSR(x) & CTS)
37 #define UART_DISABLE_RTS(x) UART_PUT_MCR(x, UART_GET_MCR(x) & ~(ARTS|MRTS))
38 #define UART_ENABLE_RTS(x) UART_PUT_MCR(x, UART_GET_MCR(x) | MRTS | ARTS)
39 #define UART_ENABLE_INTS(x, v) UART_SET_IER(x, v)
40 #define UART_DISABLE_INTS(x) UART_CLEAR_IER(x, 0xF)
42 #if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS) || \
43 defined(CONFIG_BFIN_UART2_CTSRTS) || defined(CONFIG_BFIN_UART3_CTSRTS)
44 # define CONFIG_SERIAL_BFIN_HARD_CTSRTS
47 #define BFIN_UART_TX_FIFO_SIZE 2
50 * The pin configuration is different from schematic
52 struct bfin_serial_port
{
53 struct uart_port port
;
54 unsigned int old_status
;
56 #ifdef CONFIG_SERIAL_BFIN_DMA
59 struct circ_buf rx_dma_buf
;
60 struct timer_list rx_dma_timer
;
62 unsigned int tx_dma_channel
;
63 unsigned int rx_dma_channel
;
64 struct work_struct tx_dma_workqueue
;
66 #ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
73 struct bfin_serial_res
{
74 unsigned long uart_base_addr
;
77 #ifdef CONFIG_SERIAL_BFIN_DMA
78 unsigned int uart_tx_dma_channel
;
79 unsigned int uart_rx_dma_channel
;
81 #ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
87 struct bfin_serial_res bfin_serial_resource
[] = {
88 #ifdef CONFIG_SERIAL_BFIN_UART0
93 #ifdef CONFIG_SERIAL_BFIN_DMA
97 #ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
103 #ifdef CONFIG_SERIAL_BFIN_UART1
108 #ifdef CONFIG_SERIAL_BFIN_DMA
112 #ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
118 #ifdef CONFIG_SERIAL_BFIN_UART2
123 #ifdef CONFIG_SERIAL_BFIN_DMA
127 #ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
133 #ifdef CONFIG_SERIAL_BFIN_UART3
138 #ifdef CONFIG_SERIAL_BFIN_DMA
142 #ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
150 #define DRIVER_NAME "bfin-uart"