]> err.no Git - linux-2.6/commitdiff
[ARM] 4357/1: AT91: Support slower serial baud-rates
authorAndrew Victor <andrew@sanpeople.com>
Thu, 3 May 2007 11:26:24 +0000 (12:26 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 3 May 2007 13:12:45 +0000 (14:12 +0100)
Allow slower serial baud-rates by switching the UART clock from MCK to
MCK/8.

Based on patches by Mike Wolfram and Russell King.

Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
drivers/serial/atmel_serial.c
drivers/serial/atmel_serial.h

index 935f48fa501d5b398a3913281b5740e160ec4b85..3320bcd92c0a3b54de5b3da4c52a9c1683bb84eb 100644 (file)
@@ -484,11 +484,16 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios * termios,
        unsigned long flags;
        unsigned int mode, imr, quot, baud;
 
+       /* Get current mode register */
+       mode = UART_GET_MR(port) & ~(ATMEL_US_USCLKS | ATMEL_US_CHRL | ATMEL_US_NBSTOP | ATMEL_US_PAR);
+
        baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
        quot = uart_get_divisor(port, baud);
 
-       /* Get current mode register */
-       mode = UART_GET_MR(port) & ~(ATMEL_US_CHRL | ATMEL_US_NBSTOP | ATMEL_US_PAR);
+       if (quot > 65535) {             /* BRGR is 16-bit, so switch to slower clock */
+               quot /= 8;
+               mode |= ATMEL_US_USCLKS_MCK_DIV8;
+       }
 
        /* byte size */
        switch (termios->c_cflag & CSIZE) {
index 11b44360e108f088afdbe7b9bfcf0d2a2718dc8a..e0141776517c4fec9714d0077a8dac21d5f0c851 100644 (file)
@@ -46,6 +46,9 @@
 #define                        ATMEL_US_USMODE_ISO7816_T1      6
 #define                        ATMEL_US_USMODE_IRDA            8
 #define                ATMEL_US_USCLKS         (3   <<  4)             /* Clock Selection */
+#define                        ATMEL_US_USCLKS_MCK             (0 <<  4)
+#define                        ATMEL_US_USCLKS_MCK_DIV8        (1 <<  4)
+#define                        ATMEL_US_USCLKS_SCK             (3 <<  4)
 #define                ATMEL_US_CHRL           (3   <<  6)             /* Character Length */
 #define                        ATMEL_US_CHRL_5                 (0 <<  6)
 #define                        ATMEL_US_CHRL_6                 (1 <<  6)