From: Richard Genoud <richard.genoud@gmail.com>
To: David Engraf <david.engraf@sysgo.com>,
gregkh@linuxfoundation.org, jslaby@suse.com,
nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com,
ludovic.desroches@microchip.com
Cc: linux-arm-kernel@lists.infradead.org,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] tty/serial: atmel: fix out of range clock divider handling
Date: Mon, 16 Dec 2019 11:03:27 +0100 [thread overview]
Message-ID: <035748de-1265-b2ba-9832-898782bcccf3@gmail.com> (raw)
In-Reply-To: <20191216085403.17050-1-david.engraf@sysgo.com>
Le 16/12/2019 à 09:54, David Engraf a écrit :
> 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 <david.engraf@sysgo.com>
Acked-by: Richard Genoud <richard.genoud@gmail.com>
> ---
> Changes since v1:
> - moves set baud rate block before setting the mode register because
> ATMEL_US_RTSDIS and ATMEL_US_RTSEN depend on ATMEL_US_MR.mode
>
> ---
> 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 a8dc8af83f39..1ba9bc667e13 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -2270,27 +2270,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
> @@ -2317,6 +2296,28 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
>
> if (!(port->iso7816.flags & SER_ISO7816_ENABLED))
> 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;
>
Thanks !
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-12-16 10:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-11 16:29 [PATCH] tty/serial: atmel: fix out of range clock divider handling David Engraf
2019-12-13 9:57 ` Richard Genoud
2019-12-13 13:49 ` David Engraf
2019-12-13 14:03 ` [PATCH v2] " David Engraf
2019-12-13 16:07 ` Greg KH
2019-12-16 8:34 ` David Engraf
2019-12-16 8:54 ` [PATCH v3] " David Engraf
2019-12-16 10:03 ` Richard Genoud [this message]
2019-12-16 10:26 ` Ludovic Desroches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=035748de-1265-b2ba-9832-898782bcccf3@gmail.com \
--to=richard.genoud@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=david.engraf@sysgo.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=ludovic.desroches@microchip.com \
--cc=nicolas.ferre@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).