Merge branch 'idle-release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb...
[pandora-kernel.git] / arch / arm / plat-omap / include / plat / omap-serial.h
1 /*
2  * Driver for OMAP-UART controller.
3  * Based on drivers/serial/8250.c
4  *
5  * Copyright (C) 2010 Texas Instruments.
6  *
7  * Authors:
8  *      Govindraj R     <govindraj.raja@ti.com>
9  *      Thara Gopinath  <thara@ti.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  */
16
17 #ifndef __OMAP_SERIAL_H__
18 #define __OMAP_SERIAL_H__
19
20 #include <linux/serial_core.h>
21 #include <linux/platform_device.h>
22
23 #include <plat/mux.h>
24
25 #define DRIVER_NAME     "omap-hsuart"
26
27 /*
28  * Use tty device name as ttyO, [O -> OMAP]
29  * in bootargs we specify as console=ttyO0 if uart1
30  * is used as console uart.
31  */
32 #define OMAP_SERIAL_NAME        "ttyO"
33
34 #define OMAP_MDR1_DISABLE       0x07
35 #define OMAP_MDR1_MODE13X       0x03
36 #define OMAP_MDR1_MODE16X       0x00
37 #define OMAP_MODE13X_SPEED      230400
38
39 /*
40  * LCR = 0XBF: Switch to Configuration Mode B.
41  * In configuration mode b allow access
42  * to EFR,DLL,DLH.
43  * Reference OMAP TRM Chapter 17
44  * Section: 1.4.3 Mode Selection
45  */
46 #define OMAP_UART_LCR_CONF_MDB  0XBF
47
48 /* WER = 0x7F
49  * Enable module level wakeup in WER reg
50  */
51 #define OMAP_UART_WER_MOD_WKUP  0X7F
52
53 /* Enable XON/XOFF flow control on output */
54 #define OMAP_UART_SW_TX         0x04
55
56 /* Enable XON/XOFF flow control on input */
57 #define OMAP_UART_SW_RX         0x04
58
59 #define OMAP_UART_SYSC_RESET    0X07
60 #define OMAP_UART_TCR_TRIG      0X0F
61 #define OMAP_UART_SW_CLR        0XF0
62 #define OMAP_UART_FIFO_CLR      0X06
63
64 #define OMAP_UART_DMA_CH_FREE   -1
65
66 #define RX_TIMEOUT              (3 * HZ)
67 #define OMAP_MAX_HSUART_PORTS   4
68
69 #define MSR_SAVE_FLAGS          UART_MSR_ANY_DELTA
70
71 struct omap_uart_port_info {
72         bool                    dma_enabled;    /* To specify DMA Mode */
73         unsigned int            uartclk;        /* UART clock rate */
74         void __iomem            *membase;       /* ioremap cookie or NULL */
75         resource_size_t         mapbase;        /* resource base */
76         unsigned long           irqflags;       /* request_irq flags */
77         upf_t                   flags;          /* UPF_* flags */
78 };
79
80 struct uart_omap_dma {
81         u8                      uart_dma_tx;
82         u8                      uart_dma_rx;
83         int                     rx_dma_channel;
84         int                     tx_dma_channel;
85         dma_addr_t              rx_buf_dma_phys;
86         dma_addr_t              tx_buf_dma_phys;
87         unsigned int            uart_base;
88         /*
89          * Buffer for rx dma.It is not required for tx because the buffer
90          * comes from port structure.
91          */
92         unsigned char           *rx_buf;
93         unsigned int            prev_rx_dma_pos;
94         int                     tx_buf_size;
95         int                     tx_dma_used;
96         int                     rx_dma_used;
97         spinlock_t              tx_lock;
98         spinlock_t              rx_lock;
99         /* timer to poll activity on rx dma */
100         struct timer_list       rx_timer;
101         int                     rx_buf_size;
102         int                     rx_timeout;
103 };
104
105 struct uart_omap_port {
106         struct uart_port        port;
107         struct uart_omap_dma    uart_dma;
108         struct platform_device  *pdev;
109
110         unsigned char           ier;
111         unsigned char           lcr;
112         unsigned char           mcr;
113         unsigned char           fcr;
114         unsigned char           efr;
115
116         int                     use_dma;
117         /*
118          * Some bits in registers are cleared on a read, so they must
119          * be saved whenever the register is read but the bits will not
120          * be immediately processed.
121          */
122         unsigned int            lsr_break_flag;
123         unsigned char           msr_saved_flags;
124         char                    name[20];
125         unsigned long           port_activity;
126 };
127
128 #endif /* __OMAP_SERIAL_H__ */