remove unneeded code
[pandora-x-loader.git] / drivers / ns16550.c
1 /*
2  * This file is licensed under
3  * the terms of the GNU General Public License version 2.  This program
4  * is licensed "as is" without any warranty of any kind, whether express
5  * or implied.
6  *  
7  * COM1 NS16550 support
8  * originally from linux source (arch/ppc/boot/ns16550.c)
9  * modified to use CFG_ISA_MEM and new defines
10  */
11
12 #include <config.h>
13
14 #ifdef CFG_PRINTF
15 #ifdef CFG_NS16550
16
17 #include <ns16550.h>
18
19 #define LCRVAL LCR_8N1                                  /* 8 data, 1 stop, no parity */
20 #define MCRVAL (MCR_DTR | MCR_RTS)                      /* RTS/DTR */
21 #define FCRVAL (FCR_FIFO_EN | FCR_RXSR | FCR_TXSR)      /* Clear & enable FIFOs */
22
23 void NS16550_init (NS16550_t com_port, int baud_divisor)
24 {
25         com_port->ier = 0x00;
26 #ifdef CONFIG_OMAP
27         com_port->mdr1 = 0x7;   /* mode select reset TL16C750*/
28 #endif
29         com_port->lcr = LCR_BKSE | LCRVAL;
30         com_port->dll = baud_divisor & 0xff;
31         com_port->dlm = (baud_divisor >> 8) & 0xff;
32         com_port->lcr = LCRVAL;
33         com_port->mcr = MCRVAL;
34         com_port->fcr = FCRVAL;
35 #if defined(CONFIG_OMAP)
36         com_port->mdr1 = 0;     /* select uart mode */
37 #endif
38 }
39
40 void NS16550_reinit (NS16550_t com_port, int baud_divisor)
41 {
42         com_port->ier = 0x00;
43         com_port->lcr = LCR_BKSE;
44         com_port->dll = baud_divisor & 0xff;
45         com_port->dlm = (baud_divisor >> 8) & 0xff;
46         com_port->lcr = LCRVAL;
47         com_port->mcr = MCRVAL;
48         com_port->fcr = FCRVAL;
49 }
50
51 void NS16550_putc (NS16550_t com_port, char c)
52 {
53         while ((com_port->lsr & LSR_THRE) == 0);
54         com_port->thr = c;
55 }
56
57 char NS16550_getc (NS16550_t com_port)
58 {
59         while ((com_port->lsr & LSR_DR) == 0);
60         return (com_port->rbr);
61 }
62
63 int NS16550_tstc (NS16550_t com_port)
64 {
65         return ((com_port->lsr & LSR_DR) != 0);
66 }
67
68 #endif
69 #endif