3 * originally from linux source (arch/ppc/boot/ns16550.c)
4 * modified to use CONFIG_SYS_ISA_MEM and new defines
11 #define UART_LCRVAL UART_LCR_8N1 /* 8 data, 1 stop, no parity */
12 #define UART_MCRVAL (UART_MCR_DTR | \
13 UART_MCR_RTS) /* RTS/DTR */
14 #define UART_FCRVAL (UART_FCR_FIFO_EN | \
16 UART_FCR_TXSR) /* Clear & enable FIFOs */
18 void NS16550_init (NS16550_t com_port, int baud_divisor)
21 #if defined(CONFIG_OMAP) && !defined(CONFIG_OMAP3_ZOOM2)
22 com_port->mdr1 = 0x7; /* mode select reset TL16C750*/
24 com_port->lcr = UART_LCR_BKSE | UART_LCRVAL;
27 com_port->lcr = UART_LCRVAL;
28 com_port->mcr = UART_MCRVAL;
29 com_port->fcr = UART_FCRVAL;
30 com_port->lcr = UART_LCR_BKSE | UART_LCRVAL;
31 com_port->dll = baud_divisor & 0xff;
32 com_port->dlm = (baud_divisor >> 8) & 0xff;
33 com_port->lcr = UART_LCRVAL;
34 #if defined(CONFIG_OMAP) && !defined(CONFIG_OMAP3_ZOOM2)
35 #if defined(CONFIG_APTIX)
36 com_port->mdr1 = 3; /* /13 mode so Aptix 6MHz can hit 115200 */
38 com_port->mdr1 = 0; /* /16 is proper to hit 115200 with 48MHz */
40 #endif /* CONFIG_OMAP */
43 #ifndef CONFIG_NS16550_MIN_FUNCTIONS
44 void NS16550_reinit (NS16550_t com_port, int baud_divisor)
47 com_port->lcr = UART_LCR_BKSE | UART_LCRVAL;
50 com_port->lcr = UART_LCRVAL;
51 com_port->mcr = UART_MCRVAL;
52 com_port->fcr = UART_FCRVAL;
53 com_port->lcr = UART_LCR_BKSE;
54 com_port->dll = baud_divisor & 0xff;
55 com_port->dlm = (baud_divisor >> 8) & 0xff;
56 com_port->lcr = UART_LCRVAL;
58 #endif /* CONFIG_NS16550_MIN_FUNCTIONS */
60 void NS16550_putc (NS16550_t com_port, char c)
62 while ((com_port->lsr & UART_LSR_THRE) == 0);
66 #ifndef CONFIG_NS16550_MIN_FUNCTIONS
67 char NS16550_getc (NS16550_t com_port)
69 while ((com_port->lsr & UART_LSR_DR) == 0) {
71 extern void usbtty_poll(void);
76 return (com_port->rbr);
79 int NS16550_tstc (NS16550_t com_port)
81 return ((com_port->lsr & UART_LSR_DR) != 0);
84 #endif /* CONFIG_NS16550_MIN_FUNCTIONS */