tty: serial: atmel: Separate mode clearing between UART and USART
authorSergiu Moga <sergiu.moga@microchip.com>
Thu, 22 Sep 2022 11:33:44 +0000 (14:33 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Sep 2022 14:31:42 +0000 (16:31 +0200)
When clearing the mode of the serial IP inside the atmel_set_termios()
method, make sure that the difference between the bitfields placement
of the UART IP's and USART IP's is taken into account, as some of
them overlap with each other. For example, ATMEL_UA_BRSRCCK overlaps
with ATMEL_US_NBSTOP and ATMEL_US_USCLKS overlaps with ATMEL_UA_FILTER.

Furthermore, add definitions for the Baud Rate Source Clock and the
Filter bitfields of the Mode Register of UART IP's, since they were
missing.

Signed-off-by: Sergiu Moga <sergiu.moga@microchip.com>
Link: https://lore.kernel.org/r/20220922113347.144383-7-sergiu.moga@microchip.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/atmel_serial.c
drivers/tty/serial/atmel_serial.h

index ab4a9dfae07d149426759f2523596b39624a9d17..e3e14cb7668b4c4d91ccf58756b2ee06bc25dcfd 100644 (file)
@@ -2134,8 +2134,11 @@ static void atmel_set_termios(struct uart_port *port,
        mode = old_mode = atmel_uart_readl(port, ATMEL_US_MR);
 
        /* reset the mode, clock divisor, parity, stop bits and data size */
-       mode &= ~(ATMEL_US_USCLKS | ATMEL_US_CHRL | ATMEL_US_NBSTOP |
-                 ATMEL_US_PAR | ATMEL_US_USMODE);
+       if (atmel_port->is_usart)
+               mode &= ~(ATMEL_US_NBSTOP | ATMEL_US_PAR | ATMEL_US_CHRL |
+                         ATMEL_US_USCLKS | ATMEL_US_USMODE);
+       else
+               mode &= ~(ATMEL_UA_BRSRCCK | ATMEL_US_PAR | ATMEL_UA_FILTER);
 
        baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16);
 
index 0d8a0f9cc5c33330a644f670f4b6be1d26d0aa06..2a525b58e11a163b0b0d7480c5b16e54af0de5f4 100644 (file)
@@ -50,6 +50,7 @@
 #define                ATMEL_US_USCLKS_MCK             (0 <<  4)
 #define                ATMEL_US_USCLKS_MCK_DIV8        (1 <<  4)
 #define                ATMEL_US_USCLKS_SCK             (3 <<  4)
+#define        ATMEL_UA_FILTER         BIT(4)
 #define        ATMEL_US_CHRL           GENMASK(7, 6)   /* Character Length */
 #define                ATMEL_US_CHRL_5                 (0 <<  6)
 #define                ATMEL_US_CHRL_6                 (1 <<  6)
@@ -67,6 +68,7 @@
 #define                ATMEL_US_NBSTOP_1               (0 << 12)
 #define                ATMEL_US_NBSTOP_1_5             (1 << 12)
 #define                ATMEL_US_NBSTOP_2               (2 << 12)
+#define        ATMEL_UA_BRSRCCK        BIT(12) /* Clock Selection for UART */
 #define        ATMEL_US_CHMODE         GENMASK(15, 14) /* Channel Mode */
 #define                ATMEL_US_CHMODE_NORMAL          (0 << 14)
 #define                ATMEL_US_CHMODE_ECHO            (1 << 14)