Import 2.2.0pre6
[davej-history.git] / arch / ppc / boot / ns16550.c
blobdb0b94d0395d1ecd64fd28550db607cdbfffe454
1 /*
2 * COM1 NS16550 support
3 */
5 #include "ns16550.h"
6 typedef struct NS16550 *NS16550_t;
8 const NS16550_t COM_PORTS[] = { (NS16550_t) COM1,
9 (NS16550_t) COM2,
10 (NS16550_t) COM3,
11 (NS16550_t) COM4 };
13 volatile struct NS16550 *
14 NS16550_init(int chan)
16 volatile struct NS16550 *com_port;
17 volatile unsigned char xx;
18 com_port = (struct NS16550 *) COM_PORTS[chan];
19 /* See if port is present */
20 com_port->lcr = 0x00;
21 com_port->ier = 0xFF;
22 #if 0
23 if (com_port->ier != 0x0F) return ((struct NS16550 *)0);
24 #endif
25 com_port->ier = 0x00;
26 com_port->lcr = 0x80; /* Access baud rate */
27 com_port->dll = 0xc; /* 9600 baud */
28 com_port->dlm = 0xc >> 8;
29 com_port->lcr = 0x03; /* 8 data, 1 stop, no parity */
30 com_port->mcr = 0x03; /* RTS/DTR */
31 com_port->fcr = 0x07; /* Clear & enable FIFOs */
32 return (com_port);
36 NS16550_putc(volatile struct NS16550 *com_port, unsigned char c)
38 volatile int i;
39 while ((com_port->lsr & LSR_THRE) == 0) ;
40 com_port->thr = c;
43 unsigned char
44 NS16550_getc(volatile struct NS16550 *com_port)
46 while ((com_port->lsr & LSR_DR) == 0) ;
47 return (com_port->rbr);
50 NS16550_tstc(volatile struct NS16550 *com_port)
52 return ((com_port->lsr & LSR_DR) != 0);