]>
Commit | Line | Data |
---|---|---|
e85390dc WD |
1 | /* |
2 | * COM1 NS16550 support | |
3 | * originally from linux source (arch/ppc/boot/ns16550.c) | |
6d0f6bcf | 4 | * modified to use CONFIG_SYS_ISA_MEM and new defines |
e85390dc WD |
5 | */ |
6 | ||
7 | #include <config.h> | |
e85390dc WD |
8 | #include <ns16550.h> |
9 | ||
200779e3 DZ |
10 | #define UART_LCRVAL UART_LCR_8N1 /* 8 data, 1 stop, no parity */ |
11 | #define UART_MCRVAL (UART_MCR_DTR | \ | |
12 | UART_MCR_RTS) /* RTS/DTR */ | |
13 | #define UART_FCRVAL (UART_FCR_FIFO_EN | \ | |
14 | UART_FCR_RXSR | \ | |
15 | UART_FCR_TXSR) /* Clear & enable FIFOs */ | |
e85390dc WD |
16 | |
17 | void NS16550_init (NS16550_t com_port, int baud_divisor) | |
18 | { | |
19 | com_port->ier = 0x00; | |
8ed96046 | 20 | #ifdef CONFIG_OMAP |
232c150a | 21 | com_port->mdr1 = 0x7; /* mode select reset TL16C750*/ |
945af8d7 | 22 | #endif |
200779e3 | 23 | com_port->lcr = UART_LCR_BKSE | UART_LCRVAL; |
7ec8bb15 WD |
24 | com_port->dll = 0; |
25 | com_port->dlm = 0; | |
200779e3 DZ |
26 | com_port->lcr = UART_LCRVAL; |
27 | com_port->mcr = UART_MCRVAL; | |
28 | com_port->fcr = UART_FCRVAL; | |
29 | com_port->lcr = UART_LCR_BKSE | UART_LCRVAL; | |
7ec8bb15 WD |
30 | com_port->dll = baud_divisor & 0xff; |
31 | com_port->dlm = (baud_divisor >> 8) & 0xff; | |
200779e3 | 32 | com_port->lcr = UART_LCRVAL; |
8ed96046 WD |
33 | #if defined(CONFIG_OMAP) |
34 | #if defined(CONFIG_APTIX) | |
35 | com_port->mdr1 = 3; /* /13 mode so Aptix 6MHz can hit 115200 */ | |
36 | #else | |
37 | com_port->mdr1 = 0; /* /16 is proper to hit 115200 with 48MHz */ | |
38 | #endif | |
b4746d8b | 39 | #endif /* CONFIG_OMAP */ |
e85390dc WD |
40 | } |
41 | ||
f5675aa5 | 42 | #ifndef CONFIG_NS16550_MIN_FUNCTIONS |
e85390dc WD |
43 | void NS16550_reinit (NS16550_t com_port, int baud_divisor) |
44 | { | |
45 | com_port->ier = 0x00; | |
200779e3 | 46 | com_port->lcr = UART_LCR_BKSE | UART_LCRVAL; |
7ec8bb15 WD |
47 | com_port->dll = 0; |
48 | com_port->dlm = 0; | |
200779e3 DZ |
49 | com_port->lcr = UART_LCRVAL; |
50 | com_port->mcr = UART_MCRVAL; | |
51 | com_port->fcr = UART_FCRVAL; | |
52 | com_port->lcr = UART_LCR_BKSE; | |
e85390dc WD |
53 | com_port->dll = baud_divisor & 0xff; |
54 | com_port->dlm = (baud_divisor >> 8) & 0xff; | |
200779e3 | 55 | com_port->lcr = UART_LCRVAL; |
e85390dc | 56 | } |
f5675aa5 | 57 | #endif /* CONFIG_NS16550_MIN_FUNCTIONS */ |
e85390dc WD |
58 | |
59 | void NS16550_putc (NS16550_t com_port, char c) | |
60 | { | |
200779e3 | 61 | while ((com_port->lsr & UART_LSR_THRE) == 0); |
e85390dc WD |
62 | com_port->thr = c; |
63 | } | |
64 | ||
f5675aa5 | 65 | #ifndef CONFIG_NS16550_MIN_FUNCTIONS |
e85390dc WD |
66 | char NS16550_getc (NS16550_t com_port) |
67 | { | |
200779e3 | 68 | while ((com_port->lsr & UART_LSR_DR) == 0) { |
232c150a WD |
69 | #ifdef CONFIG_USB_TTY |
70 | extern void usbtty_poll(void); | |
71 | usbtty_poll(); | |
72 | #endif | |
73 | } | |
e85390dc WD |
74 | return (com_port->rbr); |
75 | } | |
76 | ||
77 | int NS16550_tstc (NS16550_t com_port) | |
78 | { | |
200779e3 | 79 | return ((com_port->lsr & UART_LSR_DR) != 0); |
e85390dc WD |
80 | } |
81 | ||
f5675aa5 | 82 | #endif /* CONFIG_NS16550_MIN_FUNCTIONS */ |