2 * Xilinx UARTLITE bootloader driver
4 * Copyright (C) 2007 Secret Lab Technologies Ltd.
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
19 static void * reg_base;
21 static int uartlite_open(void)
23 /* Clear the RX FIFO */
24 out_be32(reg_base + 0x0C, 0x2);
28 static void uartlite_putc(unsigned char c)
30 while ((in_be32(reg_base + 0x8) & 0x08) != 0); /* spin */
31 out_be32(reg_base + 0x4, c);
34 static unsigned char uartlite_getc(void)
36 while ((in_be32(reg_base + 0x8) & 0x01) == 0); /* spin */
37 return in_be32(reg_base);
40 static u8 uartlite_tstc(void)
42 return ((in_be32(reg_base + 0x8) & 0x01) != 0);
45 int uartlite_console_init(void *devp, struct serial_console_data *scdp)
48 unsigned long reg_phys;
50 n = getprop(devp, "virtual-reg", ®_base, sizeof(reg_base));
51 if (n != sizeof(reg_base)) {
52 if (!dt_xlate_reg(devp, 0, ®_phys, NULL))
55 reg_base = (void *)reg_phys;
58 scdp->open = uartlite_open;
59 scdp->putc = uartlite_putc;
60 scdp->getc = uartlite_getc;
61 scdp->tstc = uartlite_tstc;