blob: 9306381353a2c3d68f49c5233c5e8944b1389183 [file] [log] [blame]
wdenk3a473b22004-01-03 00:43:19 +00001/*
2 * NS16550 Serial Port
Stefan Roesea47a12b2010-04-15 16:07:28 +02003 * originally from linux source (arch/powerpc/boot/ns16550.h)
wdenk3a473b22004-01-03 00:43:19 +00004 * modified slightly to
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +02005 * have addresses as offsets from CONFIG_SYS_ISA_BASE
wdenk3a473b22004-01-03 00:43:19 +00006 * 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 * further modified to support the DUART in the Galileo eval board
12 * modifications (c) Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
13 */
14
15#ifndef __NS16550_H__
16#define __NS16550_H__
17
18/* the padding is necessary because on the galileo board the UART is
19 wired in with the 3 address lines shifted over by 2 bits */
20struct NS16550
21{
22 unsigned char rbr; /* 0 = 0-3*/
23 int pad1:24;
24
25 unsigned char ier; /* 1 = 4-7*/
26 int pad2:24;
27
28 unsigned char fcr; /* 2 = 8-b*/
29 int pad3:24;
30
31 unsigned char lcr; /* 3 = c-f*/
32 int pad4:24;
33
34 unsigned char mcr; /* 4 = 10-13*/
35 int pad5:24;
36
37 unsigned char lsr; /* 5 = 14-17*/
38 int pad6:24;
39
40 unsigned char msr; /* 6 =18-1b*/
41 int pad7:24;
42
43 unsigned char scr; /* 7 =1c-1f*/
44 int pad8:24;
45} __attribute__ ((packed));
46
47/* aliases */
48#define thr rbr
49#define iir fcr
50#define dll rbr
51#define dlm ier
52
53#define FCR_FIFO_EN 0x01 /*fifo enable*/
Mike Williams16263082011-07-22 04:01:30 +000054#define FCR_RXSR 0x02 /*receiver soft reset*/
wdenk3a473b22004-01-03 00:43:19 +000055#define FCR_TXSR 0x04 /*transmitter soft reset*/
56
57
58#define MCR_DTR 0x01
59#define MCR_RTS 0x02
60#define MCR_DMA_EN 0x04
61#define MCR_TX_DFR 0x08
62
63
64#define LCR_WLS_MSK 0x03 /* character length slect mask*/
65#define LCR_WLS_5 0x00 /* 5 bit character length */
66#define LCR_WLS_6 0x01 /* 6 bit character length */
67#define LCR_WLS_7 0x02 /* 7 bit character length */
68#define LCR_WLS_8 0x03 /* 8 bit character length */
69#define LCR_STB 0x04 /* Number of stop Bits, off = 1, on = 1.5 or 2) */
70#define LCR_PEN 0x08 /* Parity eneble*/
71#define LCR_EPS 0x10 /* Even Parity Select*/
72#define LCR_STKP 0x20 /* Stick Parity*/
73#define LCR_SBRK 0x40 /* Set Break*/
74#define LCR_BKSE 0x80 /* Bank select enable*/
75
76#define LSR_DR 0x01 /* Data ready */
77#define LSR_OE 0x02 /* Overrun */
78#define LSR_PE 0x04 /* Parity error */
79#define LSR_FE 0x08 /* Framing error */
80#define LSR_BI 0x10 /* Break */
81#define LSR_THRE 0x20 /* Xmit holding register empty */
82#define LSR_TEMT 0x40 /* Xmitter empty */
83#define LSR_ERR 0x80 /* Error */
84
85/* useful defaults for LCR*/
86#define LCR_8N1 0x03
87
88
89#define COM1 0x03F8
90#define COM2 0x02F8
91
92volatile struct NS16550 * NS16550_init(int chan, int baud_divisor);
93void NS16550_putc(volatile struct NS16550 *com_port, unsigned char c);
94unsigned char NS16550_getc(volatile struct NS16550 *com_port);
95int NS16550_tstc(volatile struct NS16550 *com_port);
96void NS16550_reinit(volatile struct NS16550 *com_port, int baud_divisor);
97
98typedef struct NS16550 *NS16550_t;
99
100extern const NS16550_t COM_PORTS[];
101
102#endif