diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2007-10-01 22:15:13 -0400 |
---|---|---|
committer | Josh Boyer <jwboyer@linux.vnet.ibm.com> | 2007-10-03 08:23:13 -0400 |
commit | 7ddc5f978b16c024b6c1fcecbda6815d3d3222ef (patch) | |
tree | c6772bcbf1c19583b9aaf1303aea09e12e2568a0 /arch/powerpc/boot/uartlite.c | |
parent | 340ffd267c85fc28da7cfd681b177c816af800cf (diff) |
[POWERPC] Virtex: Add uartlite bootwrapper driver
Allows the bootwrapper to use the uartlite device for console output.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
Diffstat (limited to 'arch/powerpc/boot/uartlite.c')
-rw-r--r-- | arch/powerpc/boot/uartlite.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/arch/powerpc/boot/uartlite.c b/arch/powerpc/boot/uartlite.c new file mode 100644 index 000000000000..f4249a74c367 --- /dev/null +++ b/arch/powerpc/boot/uartlite.c | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * Xilinx UARTLITE bootloader driver | ||
3 | * | ||
4 | * Copyright (C) 2007 Secret Lab Technologies Ltd. | ||
5 | * | ||
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. | ||
9 | */ | ||
10 | |||
11 | #include <stdarg.h> | ||
12 | #include <stddef.h> | ||
13 | #include "types.h" | ||
14 | #include "string.h" | ||
15 | #include "stdio.h" | ||
16 | #include "io.h" | ||
17 | #include "ops.h" | ||
18 | |||
19 | static void * reg_base; | ||
20 | |||
21 | static int uartlite_open(void) | ||
22 | { | ||
23 | /* Clear the RX FIFO */ | ||
24 | out_be32(reg_base + 0x0C, 0x2); | ||
25 | return 0; | ||
26 | } | ||
27 | |||
28 | static void uartlite_putc(unsigned char c) | ||
29 | { | ||
30 | while ((in_be32(reg_base + 0x8) & 0x08) != 0); /* spin */ | ||
31 | out_be32(reg_base + 0x4, c); | ||
32 | } | ||
33 | |||
34 | static unsigned char uartlite_getc(void) | ||
35 | { | ||
36 | while ((in_be32(reg_base + 0x8) & 0x01) == 0); /* spin */ | ||
37 | return in_be32(reg_base); | ||
38 | } | ||
39 | |||
40 | static u8 uartlite_tstc(void) | ||
41 | { | ||
42 | return ((in_be32(reg_base + 0x8) & 0x01) != 0); | ||
43 | } | ||
44 | |||
45 | int uartlite_console_init(void *devp, struct serial_console_data *scdp) | ||
46 | { | ||
47 | int n; | ||
48 | unsigned long reg_phys; | ||
49 | |||
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)) | ||
53 | return -1; | ||
54 | |||
55 | reg_base = (void *)reg_phys; | ||
56 | } | ||
57 | |||
58 | scdp->open = uartlite_open; | ||
59 | scdp->putc = uartlite_putc; | ||
60 | scdp->getc = uartlite_getc; | ||
61 | scdp->tstc = uartlite_tstc; | ||
62 | scdp->close = NULL; | ||
63 | return 0; | ||
64 | } | ||