blob: e17a11edca614a4e513668ddacf2d1c10073912c [file] [log] [blame]
wdenk717b5aa2002-04-27 11:09:31 +00001/*
2 * NS16550 Serial Port
3 * originally from linux source (arch/ppc/boot/ns16550.h)
4 * modified slightly to
5 * have addresses as offsets from CFG_ISA_BASE
6 * added a few more definitions
7 * added prototypes for ns16550.c
8 * reduced no of com ports to 2
9 * modifications (c) Rob Taylor, Flying Pig Systems. 2000.
10 */
11
12#if (CFG_NS16550_REG_SIZE == 1)
13struct NS16550 {
14 unsigned char rbr; /* 0 */
15 unsigned char ier; /* 1 */
16 unsigned char fcr; /* 2 */
17 unsigned char lcr; /* 3 */
18 unsigned char mcr; /* 4 */
19 unsigned char lsr; /* 5 */
20 unsigned char msr; /* 6 */
21 unsigned char scr; /* 7 */
wdenke3a06802004-06-06 23:13:55 +000022#if defined(CONFIG_OMAP730)
23 unsigned char mdr1; /* 8 */
24 unsigned char reg9; /* 9 */
25 unsigned char regA; /* A */
26 unsigned char regB; /* B */
27 unsigned char regC; /* C */
28 unsigned char regD; /* D */
29 unsigned char regE; /* E */
30 unsigned char regF; /* F */
31 unsigned char reg10; /* 10 */
32 unsigned char ssr; /* 11*/
33#endif
wdenk717b5aa2002-04-27 11:09:31 +000034} __attribute__ ((packed));
35#elif (CFG_NS16550_REG_SIZE == 2)
36struct NS16550 {
37 unsigned short rbr; /* 0 */
38 unsigned short ier; /* 1 */
39 unsigned short fcr; /* 2 */
40 unsigned short lcr; /* 3 */
41 unsigned short mcr; /* 4 */
42 unsigned short lsr; /* 5 */
43 unsigned short msr; /* 6 */
44 unsigned short scr; /* 7 */
45} __attribute__ ((packed));
46#elif (CFG_NS16550_REG_SIZE == 4)
47struct NS16550 {
48 unsigned long rbr; /* 0 */
49 unsigned long ier; /* 1 */
50 unsigned long fcr; /* 2 */
51 unsigned long lcr; /* 3 */
52 unsigned long mcr; /* 4 */
53 unsigned long lsr; /* 5 */
54 unsigned long msr; /* 6 */
55 unsigned long scr; /* 7 */
56} __attribute__ ((packed));
57#elif (CFG_NS16550_REG_SIZE == -4)
58struct NS16550 {
59 unsigned char rbr; /* 0 */
60 int pad1:24;
61 unsigned char ier; /* 1 */
62 int pad2:24;
63 unsigned char fcr; /* 2 */
64 int pad3:24;
65 unsigned char lcr; /* 3 */
66 int pad4:24;
67 unsigned char mcr; /* 4 */
68 int pad5:24;
69 unsigned char lsr; /* 5 */
70 int pad6:24;
71 unsigned char msr; /* 6 */
72 int pad7:24;
73 unsigned char scr; /* 7 */
74 int pad8:24;
wdenkf8062712005-01-09 23:16:25 +000075#if defined(CONFIG_OMAP)
wdenkf6f96f72003-07-15 20:04:06 +000076 unsigned char mdr1; /* mode select reset TL16C750*/
wdenk7eaacc52003-08-29 22:00:43 +000077#endif
78#ifdef CONFIG_OMAP1510
wdenkf6f96f72003-07-15 20:04:06 +000079 int pad9:24;
80 unsigned long pad[10];
81 unsigned char osc_12m_sel;
82 int pad10:24;
83#endif
wdenk717b5aa2002-04-27 11:09:31 +000084} __attribute__ ((packed));
85#else
86#error "Please define NS16550 registers size."
87#endif
88
89#define thr rbr
90#define iir fcr
91#define dll rbr
92#define dlm ier
93
94typedef volatile struct NS16550 *NS16550_t;
95
96#define FCR_FIFO_EN 0x01 /* Fifo enable */
97#define FCR_RXSR 0x02 /* Receiver soft reset */
98#define FCR_TXSR 0x04 /* Transmitter soft reset */
99
100#define MCR_DTR 0x01
101#define MCR_RTS 0x02
102#define MCR_DMA_EN 0x04
103#define MCR_TX_DFR 0x08
104
105#define LCR_WLS_MSK 0x03 /* character length slect mask */
106#define LCR_WLS_5 0x00 /* 5 bit character length */
107#define LCR_WLS_6 0x01 /* 6 bit character length */
108#define LCR_WLS_7 0x02 /* 7 bit character length */
109#define LCR_WLS_8 0x03 /* 8 bit character length */
110#define LCR_STB 0x04 /* Number of stop Bits, off = 1, on = 1.5 or 2) */
111#define LCR_PEN 0x08 /* Parity eneble */
112#define LCR_EPS 0x10 /* Even Parity Select */
113#define LCR_STKP 0x20 /* Stick Parity */
114#define LCR_SBRK 0x40 /* Set Break */
115#define LCR_BKSE 0x80 /* Bank select enable */
116
117#define LSR_DR 0x01 /* Data ready */
118#define LSR_OE 0x02 /* Overrun */
119#define LSR_PE 0x04 /* Parity error */
120#define LSR_FE 0x08 /* Framing error */
121#define LSR_BI 0x10 /* Break */
122#define LSR_THRE 0x20 /* Xmit holding register empty */
123#define LSR_TEMT 0x40 /* Xmitter empty */
124#define LSR_ERR 0x80 /* Error */
125
wdenkf6f96f72003-07-15 20:04:06 +0000126#ifdef CONFIG_OMAP1510
127#define OSC_12M_SEL 0x01 /* selects 6.5 * current clk div */
128#endif
129
wdenk717b5aa2002-04-27 11:09:31 +0000130/* useful defaults for LCR */
131#define LCR_8N1 0x03
132
133void NS16550_init (NS16550_t com_port, int baud_divisor);
134void NS16550_putc (NS16550_t com_port, char c);
135char NS16550_getc (NS16550_t com_port);
136int NS16550_tstc (NS16550_t com_port);
137void NS16550_reinit (NS16550_t com_port, int baud_divisor);