2008-04-24 19:09:15 +00:00
|
|
|
/*
|
2009-09-24 14:11:24 +00:00
|
|
|
* Copyright 2007-2009 Analog Devices Inc.
|
2008-04-24 19:09:15 +00:00
|
|
|
*
|
2009-09-24 14:11:24 +00:00
|
|
|
* Licensed under the GPL-2 or later.
|
2008-04-24 19:09:15 +00:00
|
|
|
*/
|
|
|
|
|
2007-06-21 03:34:16 +00:00
|
|
|
#include <linux/serial.h>
|
|
|
|
#include <asm/dma.h>
|
2007-10-11 02:57:54 +00:00
|
|
|
#include <asm/portmux.h>
|
2007-06-21 03:34:16 +00:00
|
|
|
|
|
|
|
#define UART_GET_CHAR(uart) bfin_read16(((uart)->port.membase + OFFSET_RBR))
|
|
|
|
#define UART_GET_DLL(uart) bfin_read16(((uart)->port.membase + OFFSET_DLL))
|
|
|
|
#define UART_GET_DLH(uart) bfin_read16(((uart)->port.membase + OFFSET_DLH))
|
2007-07-12 14:41:45 +00:00
|
|
|
#define UART_GET_IER(uart) bfin_read16(((uart)->port.membase + OFFSET_IER_SET))
|
2007-06-21 03:34:16 +00:00
|
|
|
#define UART_GET_LCR(uart) bfin_read16(((uart)->port.membase + OFFSET_LCR))
|
|
|
|
#define UART_GET_LSR(uart) bfin_read16(((uart)->port.membase + OFFSET_LSR))
|
|
|
|
#define UART_GET_GCTL(uart) bfin_read16(((uart)->port.membase + OFFSET_GCTL))
|
2008-02-02 09:05:02 +00:00
|
|
|
#define UART_GET_MSR(uart) bfin_read16(((uart)->port.membase + OFFSET_MSR))
|
|
|
|
#define UART_GET_MCR(uart) bfin_read16(((uart)->port.membase + OFFSET_MCR))
|
2007-06-21 03:34:16 +00:00
|
|
|
|
|
|
|
#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v)
|
|
|
|
#define UART_PUT_DLL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLL),v)
|
2007-07-12 14:41:45 +00:00
|
|
|
#define UART_SET_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER_SET),v)
|
2009-04-07 15:52:26 +00:00
|
|
|
#define UART_CLEAR_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER_CLEAR),v)
|
2007-06-21 03:34:16 +00:00
|
|
|
#define UART_PUT_DLH(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLH),v)
|
2007-07-12 14:41:45 +00:00
|
|
|
#define UART_PUT_LSR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LSR),v)
|
2007-06-21 03:34:16 +00:00
|
|
|
#define UART_PUT_LCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LCR),v)
|
2007-12-24 11:40:05 +00:00
|
|
|
#define UART_CLEAR_LSR(uart) bfin_write16(((uart)->port.membase + OFFSET_LSR), -1)
|
2007-06-21 03:34:16 +00:00
|
|
|
#define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v)
|
2008-02-02 09:05:02 +00:00
|
|
|
#define UART_PUT_MCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_MCR),v)
|
2009-04-07 15:52:26 +00:00
|
|
|
#define UART_CLEAR_SCTS(uart) bfin_write16(((uart)->port.membase + OFFSET_MSR),SCTS)
|
2007-06-21 03:34:16 +00:00
|
|
|
|
2008-05-07 03:41:26 +00:00
|
|
|
#define UART_SET_DLAB(uart) /* MMRs not muxed on BF54x */
|
|
|
|
#define UART_CLEAR_DLAB(uart) /* MMRs not muxed on BF54x */
|
|
|
|
|
2008-06-03 04:19:45 +00:00
|
|
|
#define UART_GET_CTS(x) (UART_GET_MSR(x) & CTS)
|
2009-04-07 15:52:26 +00:00
|
|
|
#define UART_DISABLE_RTS(x) UART_PUT_MCR(x, UART_GET_MCR(x) & ~(ARTS|MRTS))
|
|
|
|
#define UART_ENABLE_RTS(x) UART_PUT_MCR(x, UART_GET_MCR(x) | MRTS | ARTS)
|
2008-06-03 04:19:45 +00:00
|
|
|
#define UART_ENABLE_INTS(x, v) UART_SET_IER(x, v)
|
|
|
|
#define UART_DISABLE_INTS(x) UART_CLEAR_IER(x, 0xF)
|
|
|
|
|
2009-04-07 15:52:26 +00:00
|
|
|
#if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS) || \
|
|
|
|
defined(CONFIG_BFIN_UART2_CTSRTS) || defined(CONFIG_BFIN_UART3_CTSRTS)
|
|
|
|
# define CONFIG_SERIAL_BFIN_HARD_CTSRTS
|
2007-06-21 03:34:16 +00:00
|
|
|
#endif
|
2008-10-13 09:33:42 +00:00
|
|
|
|
|
|
|
#define BFIN_UART_TX_FIFO_SIZE 2
|
|
|
|
|
2007-06-21 03:34:16 +00:00
|
|
|
/*
|
|
|
|
* The pin configuration is different from schematic
|
|
|
|
*/
|
|
|
|
struct bfin_serial_port {
|
|
|
|
struct uart_port port;
|
|
|
|
unsigned int old_status;
|
2009-04-07 15:52:26 +00:00
|
|
|
int status_irq;
|
2007-06-21 03:34:16 +00:00
|
|
|
#ifdef CONFIG_SERIAL_BFIN_DMA
|
|
|
|
int tx_done;
|
|
|
|
int tx_count;
|
|
|
|
struct circ_buf rx_dma_buf;
|
|
|
|
struct timer_list rx_dma_timer;
|
|
|
|
int rx_dma_nrows;
|
|
|
|
unsigned int tx_dma_channel;
|
|
|
|
unsigned int rx_dma_channel;
|
|
|
|
struct work_struct tx_dma_workqueue;
|
|
|
|
#endif
|
2009-04-07 15:52:26 +00:00
|
|
|
#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
|
|
|
|
int scts;
|
|
|
|
int cts_pin;
|
|
|
|
int rts_pin;
|
2007-06-21 03:34:16 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bfin_serial_res {
|
|
|
|
unsigned long uart_base_addr;
|
|
|
|
int uart_irq;
|
2009-04-07 15:52:26 +00:00
|
|
|
int uart_status_irq;
|
2007-06-21 03:34:16 +00:00
|
|
|
#ifdef CONFIG_SERIAL_BFIN_DMA
|
|
|
|
unsigned int uart_tx_dma_channel;
|
|
|
|
unsigned int uart_rx_dma_channel;
|
|
|
|
#endif
|
2009-04-07 15:52:26 +00:00
|
|
|
#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
|
|
|
|
int uart_cts_pin;
|
|
|
|
int uart_rts_pin;
|
2007-06-21 03:34:16 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bfin_serial_res bfin_serial_resource[] = {
|
|
|
|
#ifdef CONFIG_SERIAL_BFIN_UART0
|
|
|
|
{
|
|
|
|
0xFFC00400,
|
|
|
|
IRQ_UART0_RX,
|
2009-04-07 15:52:26 +00:00
|
|
|
IRQ_UART0_ERROR,
|
2007-06-21 03:34:16 +00:00
|
|
|
#ifdef CONFIG_SERIAL_BFIN_DMA
|
|
|
|
CH_UART0_TX,
|
|
|
|
CH_UART0_RX,
|
|
|
|
#endif
|
2009-04-07 15:52:26 +00:00
|
|
|
#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
|
|
|
|
0,
|
|
|
|
0,
|
2007-06-21 03:34:16 +00:00
|
|
|
#endif
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_SERIAL_BFIN_UART1
|
|
|
|
{
|
|
|
|
0xFFC02000,
|
|
|
|
IRQ_UART1_RX,
|
2009-04-07 15:52:26 +00:00
|
|
|
IRQ_UART1_ERROR,
|
2007-06-21 03:34:16 +00:00
|
|
|
#ifdef CONFIG_SERIAL_BFIN_DMA
|
|
|
|
CH_UART1_TX,
|
|
|
|
CH_UART1_RX,
|
2009-03-03 09:59:39 +00:00
|
|
|
#endif
|
2009-04-07 15:52:26 +00:00
|
|
|
#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
|
|
|
|
GPIO_PE10,
|
|
|
|
GPIO_PE9,
|
2007-06-21 03:34:16 +00:00
|
|
|
#endif
|
2007-07-12 14:41:45 +00:00
|
|
|
},
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_SERIAL_BFIN_UART2
|
|
|
|
{
|
|
|
|
0xFFC02100,
|
|
|
|
IRQ_UART2_RX,
|
2009-04-07 15:52:26 +00:00
|
|
|
IRQ_UART2_ERROR,
|
2007-07-12 14:41:45 +00:00
|
|
|
#ifdef CONFIG_SERIAL_BFIN_DMA
|
|
|
|
CH_UART2_TX,
|
|
|
|
CH_UART2_RX,
|
|
|
|
#endif
|
2009-04-07 15:52:26 +00:00
|
|
|
#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
|
|
|
|
0,
|
|
|
|
0,
|
2007-07-12 14:41:45 +00:00
|
|
|
#endif
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_SERIAL_BFIN_UART3
|
|
|
|
{
|
|
|
|
0xFFC03100,
|
|
|
|
IRQ_UART3_RX,
|
2009-04-07 15:52:26 +00:00
|
|
|
IRQ_UART3_ERROR,
|
2007-07-12 14:41:45 +00:00
|
|
|
#ifdef CONFIG_SERIAL_BFIN_DMA
|
|
|
|
CH_UART3_TX,
|
|
|
|
CH_UART3_RX,
|
2009-03-03 09:59:39 +00:00
|
|
|
#endif
|
2009-04-07 15:52:26 +00:00
|
|
|
#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
|
|
|
|
GPIO_PB3,
|
|
|
|
GPIO_PB2,
|
2007-06-21 03:34:16 +00:00
|
|
|
#endif
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2007-10-11 02:57:54 +00:00
|
|
|
#define DRIVER_NAME "bfin-uart"
|