]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/Marvell/common/ns16550.c
3 * originally from linux source (arch/ppc/boot/ns16550.c)
4 * modified to use CONFIG_SYS_ISA_MEM and new defines
6 * further modified by Josh Huber <huber@mclx.com> to support
7 * the DUART on the Galileo Eval board. (db64360)
16 const NS16550_t COM_PORTS
[] = { (NS16550_t
) (CONFIG_SYS_DUART_IO
+ 0),
17 (NS16550_t
) (CONFIG_SYS_DUART_IO
+ 0x20)
20 volatile struct NS16550
*NS16550_init (int chan
, int baud_divisor
)
22 volatile struct NS16550
*com_port
;
24 com_port
= (struct NS16550
*) COM_PORTS
[chan
];
26 com_port
->lcr
= LCR_BKSE
; /* Access baud rate */
27 com_port
->dll
= baud_divisor
& 0xff; /* 9600 baud */
28 com_port
->dlm
= (baud_divisor
>> 8) & 0xff;
29 com_port
->lcr
= LCR_8N1
; /* 8 data, 1 stop, no parity */
30 com_port
->mcr
= MCR_DTR
| MCR_RTS
; /* RTS/DTR */
32 /* Clear & enable FIFOs */
33 com_port
->fcr
= FCR_FIFO_EN
| FCR_RXSR
| FCR_TXSR
;
37 void NS16550_reinit (volatile struct NS16550
*com_port
, int baud_divisor
)
40 com_port
->lcr
= LCR_BKSE
; /* Access baud rate */
41 com_port
->dll
= baud_divisor
& 0xff; /* 9600 baud */
42 com_port
->dlm
= (baud_divisor
>> 8) & 0xff;
43 com_port
->lcr
= LCR_8N1
; /* 8 data, 1 stop, no parity */
44 com_port
->mcr
= MCR_DTR
| MCR_RTS
; /* RTS/DTR */
46 /* Clear & enable FIFOs */
47 com_port
->fcr
= FCR_FIFO_EN
| FCR_RXSR
| FCR_TXSR
;
50 void NS16550_putc (volatile struct NS16550
*com_port
, unsigned char c
)
52 while ((com_port
->lsr
& LSR_THRE
) == 0);
56 unsigned char NS16550_getc (volatile struct NS16550
*com_port
)
58 while ((com_port
->lsr
& LSR_DR
) == 0);
59 return (com_port
->rbr
);
62 int NS16550_tstc (volatile struct NS16550
*com_port
)
64 return ((com_port
->lsr
& LSR_DR
) != 0);