Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11794502pjo; Thu, 2 Jan 2020 14:24:01 -0800 (PST) X-Google-Smtp-Source: APXvYqz/0vwW+5g8RW/P5w1jiJxgCrqGPR4cs/o613GJBiNcN0LBuKjiz33RUJjVEgomJ0E081ga X-Received: by 2002:a05:6808:2d2:: with SMTP id a18mr244596oid.120.1578003840986; Thu, 02 Jan 2020 14:24:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578003840; cv=none; d=google.com; s=arc-20160816; b=NgyJf1JmyhVZZH8asNudyKOHrTwqa0WNY5M/cCXnBryyyDJcediw0lMCWEtMteizTu wcK12Z59+Kf7C4p+HIc3JYpVIzZKf44fg8GKA+9MwVWu8A4w67JYASdzxtQqaFk51K6p o3D5pxzhJMdVCoNSpr5M4BXKA21oEGX16/MQ+3SO9feo7ba3cFYudmk3U52QcpEu8EBh G+58dYePwbIBO/LaTOggrgM1cfV87yjsRegpsdR8sCpDWfxiTRtJyiLBXM9lPLcoU9Cu 1WdURQxVVJdrL2qn1t6Bb1m0jOqCH9fkcWlU8vBMq7nBLOCeQ5XctqPCkNHTHu0zTzy/ LFBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OzWlk1PHSPqKTMSw+/YHnFf++55o20OfgXu5Gh9GzCE=; b=w1VytkgPt8oIPgZRxr/APi68TVziVSOCcNUCwJo9We6OnkIvXRlenbA2idnqGkjgUv juR6gdBksTYFVNaEALwk47gDbDfRYmsowlK6tFvKOvkBS8mqBhE1CXABXRQJaZ7hyGAB XMBnzDHomIVeY237cx3LxZ9PmUr8aJ2DkPYGQFUa2MaiZvJlhyaPxIH1Pxgwsoh2vo+Z S8UOoK2b88i9Q04x7sysdef3voqYBx3Ahm6/+Dp8g3mdbgSwy/+/Mmtz9QAKW2xZrYCy A90GHsaqZxd1OWWEHcHZi+r6mBGsQCqLMaGVMe0ck1M7UX0yQ56rNWZJWdUsf7rCk1Xk CGKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="lpbJH/C9"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n139si27833053oig.121.2020.01.02.14.23.49; Thu, 02 Jan 2020 14:24:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="lpbJH/C9"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728950AbgABWXK (ORCPT + 99 others); Thu, 2 Jan 2020 17:23:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:44416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729203AbgABWXE (ORCPT ); Thu, 2 Jan 2020 17:23:04 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E6FDE21D7D; Thu, 2 Jan 2020 22:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003783; bh=0BoAm34Asy31l41x/NqZ75+i5jcgeDXKfVAPQYuGWjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lpbJH/C982QSXAMiMM2a67SgCcLWp9Sq3Laf2feMNHK+Dno6e38My/Urgkl8M7U3N rAugu00wShMs32T6To9OgnC+h/JZfqE3y8cgSB0EdbI4W+ncS1/os8OhMV30bp7iP0 JXf05H+OVyGu8S+tFnTDNcX7GS+nHLz1SFDkIiIQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Engraf , Ludovic Desroches , Richard Genoud , Sasha Levin Subject: [PATCH 4.19 113/114] tty/serial: atmel: fix out of range clock divider handling Date: Thu, 2 Jan 2020 23:08:05 +0100 Message-Id: <20200102220040.512118203@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220029.183913184@linuxfoundation.org> References: <20200102220029.183913184@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Engraf [ Upstream commit cb47b9f8630ae3fa3f5fbd0c7003faba7abdf711 ] Use MCK_DIV8 when the clock divider is > 65535. Unfortunately the mode register was already written thus the clock selection is ignored. Fix by doing the baud rate calulation before setting the mode. Fixes: 5bf5635ac170 ("tty/serial: atmel: add fractional baud rate support") Signed-off-by: David Engraf Acked-by: Ludovic Desroches Acked-by: Richard Genoud Cc: stable Link: https://lore.kernel.org/r/20191216085403.17050-1-david.engraf@sysgo.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/atmel_serial.c | 43 ++++++++++++++++--------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index dd8949e8fcd7..f34520e9ad6e 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -2154,27 +2154,6 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, mode |= ATMEL_US_USMODE_NORMAL; } - /* set the mode, clock divisor, parity, stop bits and data size */ - atmel_uart_writel(port, ATMEL_US_MR, mode); - - /* - * when switching the mode, set the RTS line state according to the - * new mode, otherwise keep the former state - */ - if ((old_mode & ATMEL_US_USMODE) != (mode & ATMEL_US_USMODE)) { - unsigned int rts_state; - - if ((mode & ATMEL_US_USMODE) == ATMEL_US_USMODE_HWHS) { - /* let the hardware control the RTS line */ - rts_state = ATMEL_US_RTSDIS; - } else { - /* force RTS line to low level */ - rts_state = ATMEL_US_RTSEN; - } - - atmel_uart_writel(port, ATMEL_US_CR, rts_state); - } - /* * Set the baud rate: * Fractional baudrate allows to setup output frequency more @@ -2200,6 +2179,28 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, quot = cd | fp << ATMEL_US_FP_OFFSET; atmel_uart_writel(port, ATMEL_US_BRGR, quot); + + /* set the mode, clock divisor, parity, stop bits and data size */ + atmel_uart_writel(port, ATMEL_US_MR, mode); + + /* + * when switching the mode, set the RTS line state according to the + * new mode, otherwise keep the former state + */ + if ((old_mode & ATMEL_US_USMODE) != (mode & ATMEL_US_USMODE)) { + unsigned int rts_state; + + if ((mode & ATMEL_US_USMODE) == ATMEL_US_USMODE_HWHS) { + /* let the hardware control the RTS line */ + rts_state = ATMEL_US_RTSDIS; + } else { + /* force RTS line to low level */ + rts_state = ATMEL_US_RTSEN; + } + + atmel_uart_writel(port, ATMEL_US_CR, rts_state); + } + atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); atmel_port->tx_stopped = false; -- 2.20.1