Blackfin Serial Driver: abstract away DLAB differences into header
authorMike Frysinger <vapier.adi@gmail.com>
Wed, 7 May 2008 03:41:26 +0000 (11:41 +0800)
committerBryan Wu <cooloney@kernel.org>
Wed, 7 May 2008 03:41:26 +0000 (11:41 +0800)
Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
drivers/serial/bfin_5xx.c
include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
include/asm-blackfin/mach-bf561/bfin_serial_5xx.h

index 869c99aa77a48684179ba2b43479fb883979a884..d6b4ead693b7b08f798bf12e9e6f09e81287af77 100644 (file)
@@ -136,10 +136,7 @@ void kgdb_put_debug_char(int chr)
                SSYNC();
        }
 
-#ifndef CONFIG_BF54x
-       UART_PUT_LCR(uart, UART_GET_LCR(uart)&(~DLAB));
-       SSYNC();
-#endif
+       UART_CLEAR_DLAB(uart);
        UART_PUT_CHAR(uart, (unsigned char)chr);
        SSYNC();
 }
@@ -158,10 +155,7 @@ int kgdb_get_debug_char(void)
        while(!(UART_GET_LSR(uart) & DR)) {
                SSYNC();
        }
-#ifndef CONFIG_BF54x
-       UART_PUT_LCR(uart, UART_GET_LCR(uart)&(~DLAB));
-       SSYNC();
-#endif
+       UART_CLEAR_DLAB(uart);
        chr = UART_GET_CHAR(uart);
        SSYNC();
 
@@ -764,26 +758,15 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
        UART_PUT_IER(uart, 0);
 #endif
 
-#ifndef CONFIG_BF54x
        /* Set DLAB in LCR to Access DLL and DLH */
-       val = UART_GET_LCR(uart);
-       val |= DLAB;
-       UART_PUT_LCR(uart, val);
-       SSYNC();
-#endif
+       UART_SET_DLAB(uart);
 
        UART_PUT_DLL(uart, quot & 0xFF);
-       SSYNC();
        UART_PUT_DLH(uart, (quot >> 8) & 0xFF);
        SSYNC();
 
-#ifndef CONFIG_BF54x
        /* Clear DLAB in LCR to Access THR RBR IER */
-       val = UART_GET_LCR(uart);
-       val &= ~DLAB;
-       UART_PUT_LCR(uart, val);
-       SSYNC();
-#endif
+       UART_CLEAR_DLAB(uart);
 
        UART_PUT_LCR(uart, lcr);
 
@@ -946,8 +929,7 @@ bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud,
        status = UART_GET_IER(uart) & (ERBFI | ETBEI);
        if (status == (ERBFI | ETBEI)) {
                /* ok, the port was enabled */
-               unsigned short lcr, val;
-               unsigned short dlh, dll;
+               u16 lcr, dlh, dll;
 
                lcr = UART_GET_LCR(uart);
 
@@ -964,22 +946,14 @@ bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud,
                        case 2: *bits = 7; break;
                        case 3: *bits = 8; break;
                }
-#ifndef CONFIG_BF54x
                /* Set DLAB in LCR to Access DLL and DLH */
-               val = UART_GET_LCR(uart);
-               val |= DLAB;
-               UART_PUT_LCR(uart, val);
-#endif
+               UART_SET_DLAB(uart);
 
                dll = UART_GET_DLL(uart);
                dlh = UART_GET_DLH(uart);
 
-#ifndef CONFIG_BF54x
                /* Clear DLAB in LCR to Access THR RBR IER */
-               val = UART_GET_LCR(uart);
-               val &= ~DLAB;
-               UART_PUT_LCR(uart, val);
-#endif
+               UART_CLEAR_DLAB(uart);
 
                *baud = get_sclk() / (16*(dll | dlh << 8));
        }
index 1bbfc2d75bde22794ef12c67f79f57dab9455fca..26e3c8076b4e5cafe08bb5ef97468a0f0db421f2 100644 (file)
@@ -50,6 +50,9 @@
 #define UART_PUT_LCR(uart, v)    bfin_write16(((uart)->port.membase + OFFSET_LCR), v)
 #define UART_PUT_GCTL(uart, v)   bfin_write16(((uart)->port.membase + OFFSET_GCTL), v)
 
+#define UART_SET_DLAB(uart)     do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
+#define UART_CLEAR_DLAB(uart)   do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
+
 #if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS)
 # define CONFIG_SERIAL_BFIN_CTSRTS
 
index d22f052d6c806700a0316e70aab76378995ae096..d016603b661518eedcad888adeadbb8e6faf005f 100644 (file)
@@ -50,6 +50,9 @@
 #define UART_PUT_LCR(uart,v)    bfin_write16(((uart)->port.membase + OFFSET_LCR),v)
 #define UART_PUT_GCTL(uart,v)   bfin_write16(((uart)->port.membase + OFFSET_GCTL),v)
 
+#define UART_SET_DLAB(uart)     do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
+#define UART_CLEAR_DLAB(uart)   do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
+
 #ifdef CONFIG_BFIN_UART0_CTSRTS
 # define CONFIG_SERIAL_BFIN_CTSRTS
 # ifndef CONFIG_UART0_CTS_PIN
index ae2362c0bf975469c4d04f6a8692956fa483ffa6..f79d1a0e9129bb0f3e74e64d8c831227fcf460f1 100644 (file)
@@ -50,6 +50,9 @@
 #define UART_PUT_LCR(uart,v)    bfin_write16(((uart)->port.membase + OFFSET_LCR),v)
 #define UART_PUT_GCTL(uart,v)   bfin_write16(((uart)->port.membase + OFFSET_GCTL),v)
 
+#define UART_SET_DLAB(uart)     do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
+#define UART_CLEAR_DLAB(uart)   do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
+
 #if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS)
 # define CONFIG_SERIAL_BFIN_CTSRTS
 
index 6547027cd3e62174a0bd5a0f9ee2aa0a6429fe5d..5eb46a77d919fd5eb2fab2caebf1ca25abce618d 100644 (file)
@@ -54,6 +54,9 @@
 #define UART_PUT_GCTL(uart,v)   bfin_write16(((uart)->port.membase + OFFSET_GCTL),v)
 #define UART_PUT_MCR(uart,v)    bfin_write16(((uart)->port.membase + OFFSET_MCR),v)
 
+#define UART_SET_DLAB(uart)     /* MMRs not muxed on BF54x */
+#define UART_CLEAR_DLAB(uart)   /* MMRs not muxed on BF54x */
+
 #if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS)
 # define CONFIG_SERIAL_BFIN_CTSRTS
 
index c209f0df47f7eea44f2de8ca5f5d19b8cd656349..7a962876929619e5da8a0e3abc1f029a602a807b 100644 (file)
@@ -50,6 +50,9 @@
 #define UART_PUT_LCR(uart,v)    bfin_write16(((uart)->port.membase + OFFSET_LCR),v)
 #define UART_PUT_GCTL(uart,v)   bfin_write16(((uart)->port.membase + OFFSET_GCTL),v)
 
+#define UART_SET_DLAB(uart)     do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
+#define UART_CLEAR_DLAB(uart)   do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
+
 #ifdef CONFIG_BFIN_UART0_CTSRTS
 # define CONFIG_SERIAL_BFIN_CTSRTS
 # ifndef CONFIG_UART0_CTS_PIN