[POWERPC] Uartlite: Add macros for register names
authorGrant Likely <grant.likely@secretlab.ca>
Tue, 2 Oct 2007 16:44:15 +0000 (02:44 +1000)
committerJosh Boyer <jwboyer@linux.vnet.ibm.com>
Wed, 3 Oct 2007 12:37:03 +0000 (07:37 -0500)
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>
arch/powerpc/boot/uartlite.c

index f4249a74c36780b1f2a1b6d596189eb5b3a3c4df..38a470b329e30687817cf6f9769a6959624f5e2a 100644 (file)
 #include "io.h"
 #include "ops.h"
 
+#define ULITE_RX               0x00
+#define ULITE_TX               0x04
+#define ULITE_STATUS           0x08
+#define ULITE_CONTROL          0x0c
+
+#define ULITE_STATUS_RXVALID   0x01
+#define ULITE_STATUS_TXFULL    0x08
+
+#define ULITE_CONTROL_RST_RX   0x02
+
 static void * reg_base;
 
 static int uartlite_open(void)
 {
        /* Clear the RX FIFO */
-       out_be32(reg_base + 0x0C, 0x2);
+       out_be32(reg_base + ULITE_CONTROL, ULITE_CONTROL_RST_RX);
        return 0;
 }
 
 static void uartlite_putc(unsigned char c)
 {
-       while ((in_be32(reg_base + 0x8) & 0x08) != 0); /* spin */
-       out_be32(reg_base + 0x4, c);
+       u32 reg = ULITE_STATUS_TXFULL;
+       while (reg & ULITE_STATUS_TXFULL) /* spin on TXFULL bit */
+               reg = in_be32(reg_base + ULITE_STATUS);
+       out_be32(reg_base + ULITE_TX, c);
 }
 
 static unsigned char uartlite_getc(void)
 {
-       while ((in_be32(reg_base + 0x8) & 0x01) == 0); /* spin */
-       return in_be32(reg_base);
+       u32 reg = ULITE_STATUS_RXVALID;
+       while (reg & ULITE_STATUS_RXVALID) /* spin on RXVALID bit */
+               reg = in_be32(reg_base + ULITE_STATUS);
+       return in_be32(reg_base + ULITE_RX);
 }
 
 static u8 uartlite_tstc(void)
 {
-       return ((in_be32(reg_base + 0x8) & 0x01) != 0);
+       u32 reg = in_be32(reg_base + ULITE_STATUS);
+       return reg & ULITE_STATUS_RXVALID;
 }
 
 int uartlite_console_init(void *devp, struct serial_console_data *scdp)