Commit 1a5a01a1 authored by Sergiu Moga's avatar Sergiu Moga Committed by Greg Kroah-Hartman
Browse files

tty: serial: atmel: Separate mode clearing between UART and USART



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: default avatarSergiu Moga <sergiu.moga@microchip.com>
Link: https://lore.kernel.org/r/20220922113347.144383-7-sergiu.moga@microchip.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 79cb5035
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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);

+2 −0
Original line number Diff line number Diff line
@@ -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)