3 * originally from linux source (arch/ppc/boot/ns16550.c)
4 * modified to use CFG_ISA_MEM and new defines
13 #define LCRVAL LCR_8N1 /* 8 data, 1 stop, no parity */
14 #define MCRVAL (MCR_DTR | MCR_RTS) /* RTS/DTR */
15 #define FCRVAL (FCR_FIFO_EN | FCR_RXSR | FCR_TXSR) /* Clear & enable FIFOs */
17 void NS16550_init (NS16550_t com_port, int baud_divisor)
20 com_port->lcr = LCR_BKSE | LCRVAL;
21 com_port->dll = baud_divisor & 0xff;
22 com_port->dlm = (baud_divisor >> 8) & 0xff;
23 com_port->lcr = LCRVAL;
24 com_port->mcr = MCRVAL;
25 com_port->fcr = FCRVAL;
28 void NS16550_reinit (NS16550_t com_port, int baud_divisor)
31 com_port->lcr = LCR_BKSE;
32 com_port->dll = baud_divisor & 0xff;
33 com_port->dlm = (baud_divisor >> 8) & 0xff;
34 com_port->lcr = LCRVAL;
35 com_port->mcr = MCRVAL;
36 com_port->fcr = FCRVAL;
39 void NS16550_putc (NS16550_t com_port, char c)
41 while ((com_port->lsr & LSR_THRE) == 0);
45 char NS16550_getc (NS16550_t com_port)
47 while ((com_port->lsr & LSR_DR) == 0);
48 return (com_port->rbr);
51 int NS16550_tstc (NS16550_t com_port)
53 return ((com_port->lsr & LSR_DR) != 0);