]>
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 | ||
10 | #define LCRVAL LCR_8N1 /* 8 data, 1 stop, no parity */ | |
11 | #define MCRVAL (MCR_DTR | MCR_RTS) /* RTS/DTR */ | |
12 | #define FCRVAL (FCR_FIFO_EN | FCR_RXSR | FCR_TXSR) /* Clear & enable FIFOs */ | |
13 | ||
14 | void NS16550_init (NS16550_t com_port, int baud_divisor) | |
15 | { | |
16 | com_port->ier = 0x00; | |
8ed96046 | 17 | #ifdef CONFIG_OMAP |
232c150a | 18 | com_port->mdr1 = 0x7; /* mode select reset TL16C750*/ |
945af8d7 | 19 | #endif |
e85390dc | 20 | com_port->lcr = LCR_BKSE | LCRVAL; |
7ec8bb15 WD |
21 | com_port->dll = 0; |
22 | com_port->dlm = 0; | |
e85390dc WD |
23 | com_port->lcr = LCRVAL; |
24 | com_port->mcr = MCRVAL; | |
25 | com_port->fcr = FCRVAL; | |
7ec8bb15 WD |
26 | com_port->lcr = LCR_BKSE | LCRVAL; |
27 | com_port->dll = baud_divisor & 0xff; | |
28 | com_port->dlm = (baud_divisor >> 8) & 0xff; | |
29 | com_port->lcr = LCRVAL; | |
8ed96046 WD |
30 | #if defined(CONFIG_OMAP) |
31 | #if defined(CONFIG_APTIX) | |
32 | com_port->mdr1 = 3; /* /13 mode so Aptix 6MHz can hit 115200 */ | |
33 | #else | |
34 | com_port->mdr1 = 0; /* /16 is proper to hit 115200 with 48MHz */ | |
35 | #endif | |
b4746d8b | 36 | #endif /* CONFIG_OMAP */ |
e85390dc WD |
37 | } |
38 | ||
f5675aa5 | 39 | #ifndef CONFIG_NS16550_MIN_FUNCTIONS |
e85390dc WD |
40 | void NS16550_reinit (NS16550_t com_port, int baud_divisor) |
41 | { | |
42 | com_port->ier = 0x00; | |
7ec8bb15 WD |
43 | com_port->lcr = LCR_BKSE | LCRVAL; |
44 | com_port->dll = 0; | |
45 | com_port->dlm = 0; | |
46 | com_port->lcr = LCRVAL; | |
47 | com_port->mcr = MCRVAL; | |
48 | com_port->fcr = FCRVAL; | |
e85390dc WD |
49 | com_port->lcr = LCR_BKSE; |
50 | com_port->dll = baud_divisor & 0xff; | |
51 | com_port->dlm = (baud_divisor >> 8) & 0xff; | |
52 | com_port->lcr = LCRVAL; | |
e85390dc | 53 | } |
f5675aa5 | 54 | #endif /* CONFIG_NS16550_MIN_FUNCTIONS */ |
e85390dc WD |
55 | |
56 | void NS16550_putc (NS16550_t com_port, char c) | |
57 | { | |
58 | while ((com_port->lsr & LSR_THRE) == 0); | |
59 | com_port->thr = c; | |
60 | } | |
61 | ||
f5675aa5 | 62 | #ifndef CONFIG_NS16550_MIN_FUNCTIONS |
e85390dc WD |
63 | char NS16550_getc (NS16550_t com_port) |
64 | { | |
232c150a WD |
65 | while ((com_port->lsr & LSR_DR) == 0) { |
66 | #ifdef CONFIG_USB_TTY | |
67 | extern void usbtty_poll(void); | |
68 | usbtty_poll(); | |
69 | #endif | |
70 | } | |
e85390dc WD |
71 | return (com_port->rbr); |
72 | } | |
73 | ||
74 | int NS16550_tstc (NS16550_t com_port) | |
75 | { | |
76 | return ((com_port->lsr & LSR_DR) != 0); | |
77 | } | |
78 | ||
f5675aa5 | 79 | #endif /* CONFIG_NS16550_MIN_FUNCTIONS */ |