diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2007-10-02 12:44:15 -0400 |
---|---|---|
committer | Josh Boyer <jwboyer@linux.vnet.ibm.com> | 2007-10-03 08:37:03 -0400 |
commit | be1b4d34e3a379d20d50e75a95aa5c3f0c7cf612 (patch) | |
tree | 0cc0b54496f75dcfced9df35b35e78aad15e7358 /arch/powerpc/boot/uartlite.c | |
parent | 69c9c94303e309c02cf4b3e671a46a34fd0c4b0b (diff) |
[POWERPC] Uartlite: Add macros for register names
Add macros to define register names to improve readability.
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 | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/arch/powerpc/boot/uartlite.c b/arch/powerpc/boot/uartlite.c index f4249a74c367..38a470b329e3 100644 --- a/arch/powerpc/boot/uartlite.c +++ b/arch/powerpc/boot/uartlite.c | |||
@@ -16,30 +16,45 @@ | |||
16 | #include "io.h" | 16 | #include "io.h" |
17 | #include "ops.h" | 17 | #include "ops.h" |
18 | 18 | ||
19 | #define ULITE_RX 0x00 | ||
20 | #define ULITE_TX 0x04 | ||
21 | #define ULITE_STATUS 0x08 | ||
22 | #define ULITE_CONTROL 0x0c | ||
23 | |||
24 | #define ULITE_STATUS_RXVALID 0x01 | ||
25 | #define ULITE_STATUS_TXFULL 0x08 | ||
26 | |||
27 | #define ULITE_CONTROL_RST_RX 0x02 | ||
28 | |||
19 | static void * reg_base; | 29 | static void * reg_base; |
20 | 30 | ||
21 | static int uartlite_open(void) | 31 | static int uartlite_open(void) |
22 | { | 32 | { |
23 | /* Clear the RX FIFO */ | 33 | /* Clear the RX FIFO */ |
24 | out_be32(reg_base + 0x0C, 0x2); | 34 | out_be32(reg_base + ULITE_CONTROL, ULITE_CONTROL_RST_RX); |
25 | return 0; | 35 | return 0; |
26 | } | 36 | } |
27 | 37 | ||
28 | static void uartlite_putc(unsigned char c) | 38 | static void uartlite_putc(unsigned char c) |
29 | { | 39 | { |
30 | while ((in_be32(reg_base + 0x8) & 0x08) != 0); /* spin */ | 40 | u32 reg = ULITE_STATUS_TXFULL; |
31 | out_be32(reg_base + 0x4, c); | 41 | while (reg & ULITE_STATUS_TXFULL) /* spin on TXFULL bit */ |
42 | reg = in_be32(reg_base + ULITE_STATUS); | ||
43 | out_be32(reg_base + ULITE_TX, c); | ||
32 | } | 44 | } |
33 | 45 | ||
34 | static unsigned char uartlite_getc(void) | 46 | static unsigned char uartlite_getc(void) |
35 | { | 47 | { |
36 | while ((in_be32(reg_base + 0x8) & 0x01) == 0); /* spin */ | 48 | u32 reg = ULITE_STATUS_RXVALID; |
37 | return in_be32(reg_base); | 49 | while (reg & ULITE_STATUS_RXVALID) /* spin on RXVALID bit */ |
50 | reg = in_be32(reg_base + ULITE_STATUS); | ||
51 | return in_be32(reg_base + ULITE_RX); | ||
38 | } | 52 | } |
39 | 53 | ||
40 | static u8 uartlite_tstc(void) | 54 | static u8 uartlite_tstc(void) |
41 | { | 55 | { |
42 | return ((in_be32(reg_base + 0x8) & 0x01) != 0); | 56 | u32 reg = in_be32(reg_base + ULITE_STATUS); |
57 | return reg & ULITE_STATUS_RXVALID; | ||
43 | } | 58 | } |
44 | 59 | ||
45 | int uartlite_console_init(void *devp, struct serial_console_data *scdp) | 60 | int uartlite_console_init(void *devp, struct serial_console_data *scdp) |