blob: 0b7b3896f9c4b4cbb97d0fe5e5d354d5f19030d7 [file] [log] [blame]
wdenk71fc6c52002-08-06 19:52:25 +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 * further modified to support the 8245 duart
11 * modifications (c) Paul Jimenez, Musenki, Inc. 2001.
12 */
13
14
15struct NS16550
16 {
17 unsigned char rbrthrdlb; /* 0 */
18 unsigned char ierdmb; /* 1 */
19 unsigned char iirfcrafr; /* 2 */
20 unsigned char lcr; /* 3 */
21 unsigned char mcr; /* 4 */
22 unsigned char lsr; /* 5 */
23 unsigned char msr; /* 6 */
24 unsigned char scr; /* 7 */
25 unsigned char reserved[2]; /* 8 & 9 */
26 unsigned char dsr; /* 10 */
27 unsigned char dcr; /* 11 */
28 };
29
30
31#define rbr rbrthrdlb
32#define thr rbrthrdlb
33#define dll rbrthrdlb
34#define ier ierdmb
35#define dlm ierdmb
36#define iir iirfcrafr
37#define fcr iirfcrafr
38#define afr iirfcrafr
39
40#define FCR_FIFO_EN 0x01 /*fifo enable*/
41#define FCR_RXSR 0x02 /*reciever soft reset*/
42#define FCR_TXSR 0x04 /*transmitter soft reset*/
43#define FCR_DMS 0x08 /* DMA Mode Select */
44
45#define MCR_RTS 0x02 /* Readyu to Send */
46#define MCR_LOOP 0x10 /* Local loopback mode enable */
47/* #define MCR_DTR 0x01 noton 8245 duart */
48/* #define MCR_DMA_EN 0x04 noton 8245 duart */
49/* #define MCR_TX_DFR 0x08 noton 8245 duart */
50
51#define LCR_WLS_MSK 0x03 /* character length slect mask*/
52#define LCR_WLS_5 0x00 /* 5 bit character length */
53#define LCR_WLS_6 0x01 /* 6 bit character length */
54#define LCR_WLS_7 0x02 /* 7 bit character length */
55#define LCR_WLS_8 0x03 /* 8 bit character length */
56#define LCR_STB 0x04 /* Number of stop Bits, off = 1, on = 1.5 or 2) */
57#define LCR_PEN 0x08 /* Parity eneble*/
58#define LCR_EPS 0x10 /* Even Parity Select*/
59#define LCR_STKP 0x20 /* Stick Parity*/
60#define LCR_SBRK 0x40 /* Set Break*/
61#define LCR_BKSE 0x80 /* Bank select enable - aka DLAB on 8245 */
62
63#define LSR_DR 0x01 /* Data ready */
64#define LSR_OE 0x02 /* Overrun */
65#define LSR_PE 0x04 /* Parity error */
66#define LSR_FE 0x08 /* Framing error */
67#define LSR_BI 0x10 /* Break */
68#define LSR_THRE 0x20 /* Xmit holding register empty */
69#define LSR_TEMT 0x40 /* Xmitter empty */
70#define LSR_ERR 0x80 /* Error */
71
72/* useful defaults for LCR*/
73#define LCR_8N1 0x03
74
75
76volatile struct NS16550 * NS16550_init(int chan, int baud_divisor);
77void NS16550_putc(volatile struct NS16550 *com_port, unsigned char c);
78unsigned char NS16550_getc(volatile struct NS16550 *com_port);
79int NS16550_tstc(volatile struct NS16550 *com_port);
80void NS16550_reinit(volatile struct NS16550 *com_port, int baud_divisor);