omap1: remove support for 1710 and 1510
[pandora-x-loader.git] / include / ns16550.h
1 /*
2  *This file is licensed under
3  * the terms of the GNU General Public License version 2.  This program
4  * is licensed "as is" without any warranty of any kind, whether express
5  * or implied.
6  *  
7  * NS16550 Serial Port
8  * originally from linux source (arch/ppc/boot/ns16550.h)
9  * modified slightly to
10  * have addresses as offsets from CFG_ISA_BASE
11  * added a few more definitions
12  * added prototypes for ns16550.c
13  * reduced no of com ports to 2
14  * modifications (c) Rob Taylor, Flying Pig Systems. 2000.
15  */
16
17 #if (CFG_NS16550_REG_SIZE == 1)
18 struct NS16550 {
19         unsigned char rbr;              /* 0 */
20         unsigned char ier;              /* 1 */
21         unsigned char fcr;              /* 2 */
22         unsigned char lcr;              /* 3 */
23         unsigned char mcr;              /* 4 */
24         unsigned char lsr;              /* 5 */
25         unsigned char msr;              /* 6 */
26         unsigned char scr;              /* 7 */
27 } __attribute__ ((packed));
28 #elif (CFG_NS16550_REG_SIZE == 2)
29 struct NS16550 {
30         unsigned short rbr;             /* 0 */
31         unsigned short ier;             /* 1 */
32         unsigned short fcr;             /* 2 */
33         unsigned short lcr;             /* 3 */
34         unsigned short mcr;             /* 4 */
35         unsigned short lsr;             /* 5 */
36         unsigned short msr;             /* 6 */
37         unsigned short scr;             /* 7 */
38 } __attribute__ ((packed));
39 #elif (CFG_NS16550_REG_SIZE == 4)
40 struct NS16550 {
41         unsigned long rbr;              /* 0 */
42         unsigned long ier;              /* 1 */
43         unsigned long fcr;              /* 2 */
44         unsigned long lcr;              /* 3 */
45         unsigned long mcr;              /* 4 */
46         unsigned long lsr;              /* 5 */
47         unsigned long msr;              /* 6 */
48         unsigned long scr;              /* 7 */
49 } __attribute__ ((packed));
50 #elif (CFG_NS16550_REG_SIZE == -4)
51 struct NS16550 {
52         unsigned char rbr;              /* 0 */
53         int pad1:24;
54         unsigned char ier;              /* 1 */
55         int pad2:24;
56         unsigned char fcr;              /* 2 */
57         int pad3:24;
58         unsigned char lcr;              /* 3 */
59         int pad4:24;
60         unsigned char mcr;              /* 4 */
61         int pad5:24;
62         unsigned char lsr;              /* 5 */
63         int pad6:24;
64         unsigned char msr;              /* 6 */
65         int pad7:24;
66         unsigned char scr;              /* 7 */
67         int pad8:24;
68 #if defined(CONFIG_OMAP)
69         unsigned char mdr1;             /* mode select reset TL16C750*/
70 #endif
71 #ifdef CONFIG_OMAP1510
72         int pad9:24;
73         unsigned long pad[10];
74         unsigned char osc_12m_sel;
75         int pad10:24;
76 #endif
77 } __attribute__ ((packed));
78 #else
79 #error "Please define NS16550 registers size."
80 #endif
81
82 #define thr rbr
83 #define iir fcr
84 #define dll rbr
85 #define dlm ier
86
87 typedef volatile struct NS16550 *NS16550_t;
88
89 #define FCR_FIFO_EN     0x01            /* Fifo enable */
90 #define FCR_RXSR        0x02            /* Receiver soft reset */
91 #define FCR_TXSR        0x04            /* Transmitter soft reset */
92
93 #define MCR_DTR         0x01
94 #define MCR_RTS         0x02
95 #define MCR_DMA_EN      0x04
96 #define MCR_TX_DFR      0x08
97
98 #define LCR_WLS_MSK     0x03            /* character length slect mask */
99 #define LCR_WLS_5       0x00            /* 5 bit character length */
100 #define LCR_WLS_6       0x01            /* 6 bit character length */
101 #define LCR_WLS_7       0x02            /* 7 bit character length */
102 #define LCR_WLS_8       0x03            /* 8 bit character length */
103 #define LCR_STB         0x04            /* Number of stop Bits, off = 1, on = 1.5 or 2) */
104 #define LCR_PEN         0x08            /* Parity eneble */
105 #define LCR_EPS         0x10            /* Even Parity Select */
106 #define LCR_STKP        0x20            /* Stick Parity */
107 #define LCR_SBRK        0x40            /* Set Break */
108 #define LCR_BKSE        0x80            /* Bank select enable */
109
110 #define LSR_DR          0x01            /* Data ready */
111 #define LSR_OE          0x02            /* Overrun */
112 #define LSR_PE          0x04            /* Parity error */
113 #define LSR_FE          0x08            /* Framing error */
114 #define LSR_BI          0x10            /* Break */
115 #define LSR_THRE        0x20            /* Xmit holding register empty */
116 #define LSR_TEMT        0x40            /* Xmitter empty */
117 #define LSR_ERR         0x80            /* Error */
118
119 #ifdef CONFIG_OMAP1510
120 #define OSC_12M_SEL     0x01            /* selects 6.5 * current clk div */
121 #endif
122
123 /* useful defaults for LCR */
124 #define LCR_8N1         0x03
125
126 void    NS16550_init   (NS16550_t com_port, int baud_divisor);
127 void    NS16550_putc   (NS16550_t com_port, char c);
128 char    NS16550_getc   (NS16550_t com_port);
129 int     NS16550_tstc   (NS16550_t com_port);
130 void    NS16550_reinit (NS16550_t com_port, int baud_divisor);