* [PATCH] tty/serial: atmel: fix out of range clock divider handling @ 2019-12-11 16:29 ` David Engraf 0 siblings, 0 replies; 18+ messages in thread From: David Engraf @ 2019-12-11 16:29 UTC (permalink / raw) To: richard.genoud, gregkh, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches Cc: linux-serial, linux-arm-kernel, linux-kernel, David Engraf Use MCK_DIV8 when the clock divider is > 65535. Unfortunately the mode register was already written thus the clock selection is ignored. Fix by writing the mode register after calculating the baudrate. Signed-off-by: David Engraf <david.engraf@sysgo.com> --- drivers/tty/serial/atmel_serial.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index a8dc8af83f39..9983e2fabbac 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -2270,9 +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 @@ -2315,6 +2312,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, } quot = cd | fp << ATMEL_US_FP_OFFSET; + /* set the mode, clock divisor, parity, stop bits and data size */ + atmel_uart_writel(port, ATMEL_US_MR, mode); + if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) atmel_uart_writel(port, ATMEL_US_BRGR, quot); atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); -- 2.17.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH] tty/serial: atmel: fix out of range clock divider handling @ 2019-12-11 16:29 ` David Engraf 0 siblings, 0 replies; 18+ messages in thread From: David Engraf @ 2019-12-11 16:29 UTC (permalink / raw) To: richard.genoud, gregkh, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches Cc: David Engraf, linux-arm-kernel, linux-serial, linux-kernel Use MCK_DIV8 when the clock divider is > 65535. Unfortunately the mode register was already written thus the clock selection is ignored. Fix by writing the mode register after calculating the baudrate. Signed-off-by: David Engraf <david.engraf@sysgo.com> --- drivers/tty/serial/atmel_serial.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index a8dc8af83f39..9983e2fabbac 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -2270,9 +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 @@ -2315,6 +2312,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, } quot = cd | fp << ATMEL_US_FP_OFFSET; + /* set the mode, clock divisor, parity, stop bits and data size */ + atmel_uart_writel(port, ATMEL_US_MR, mode); + if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) atmel_uart_writel(port, ATMEL_US_BRGR, quot); atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH] tty/serial: atmel: fix out of range clock divider handling 2019-12-11 16:29 ` David Engraf @ 2019-12-13 9:57 ` Richard Genoud -1 siblings, 0 replies; 18+ messages in thread From: Richard Genoud @ 2019-12-13 9:57 UTC (permalink / raw) To: David Engraf, richard.genoud, gregkh, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches Cc: linux-serial, linux-arm-kernel, linux-kernel Hi, Le 11/12/2019 à 17:29, 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 writing the mode register after calculating the baudrate. > > Signed-off-by: David Engraf <david.engraf@sysgo.com> It seems that this bug was introduced by: commit 5bf5635ac170 ("tty/serial: atmel: add fractional baud rate support") Could you add the "Fixes:" header ? Ludovic, could you check if this was your intent at the time ? > --- > drivers/tty/serial/atmel_serial.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c > index a8dc8af83f39..9983e2fabbac 100644 > --- a/drivers/tty/serial/atmel_serial.c > +++ b/drivers/tty/serial/atmel_serial.c > @@ -2270,9 +2270,6 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, > mode |= ATMEL_US_USMODE_NORMAL; > } > I think it's better to mo move the "Set baud rate" block here (cf bellow) > - /* 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 > @@ -2315,6 +2312,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, > } > quot = cd | fp << ATMEL_US_FP_OFFSET; > > + /* set the mode, clock divisor, parity, stop bits and data size */ > + atmel_uart_writel(port, ATMEL_US_MR, mode); > + I think your patch is good, but I'll be happier if instead of moving those 2 lines here, the whole "Set the baud rate" block was moved before "atmel_uart_writel(port, ATMEL_US_MR, mode);" That's because at line 2291 the ATMEL_US_CR register is set with ATMEL_US_RTSDIS or ATMEL_US_RTSEN. And those 2 values have a different effect depending on US_MR.USART_MODE Quoting from the relase manual: RTSEN: 1: Drives RTS pin to 1 if US_MR.USART_MODE field = 2, else drives RTS pin to 0 if US_MR.USART_MODE field = 0. RTSDIS: 1: Drives RTS pin to 0 if US_MR.USART_MODE field = 2, else drives RTS pin to 1 if US_MR.USART_MODE field = 0. So, I think it's better to set the mode register before setting the control register. > if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) > atmel_uart_writel(port, ATMEL_US_BRGR, quot); > atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); > Thanks ! ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] tty/serial: atmel: fix out of range clock divider handling @ 2019-12-13 9:57 ` Richard Genoud 0 siblings, 0 replies; 18+ messages in thread From: Richard Genoud @ 2019-12-13 9:57 UTC (permalink / raw) To: David Engraf, richard.genoud, gregkh, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches Cc: linux-arm-kernel, linux-serial, linux-kernel Hi, Le 11/12/2019 à 17:29, 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 writing the mode register after calculating the baudrate. > > Signed-off-by: David Engraf <david.engraf@sysgo.com> It seems that this bug was introduced by: commit 5bf5635ac170 ("tty/serial: atmel: add fractional baud rate support") Could you add the "Fixes:" header ? Ludovic, could you check if this was your intent at the time ? > --- > drivers/tty/serial/atmel_serial.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c > index a8dc8af83f39..9983e2fabbac 100644 > --- a/drivers/tty/serial/atmel_serial.c > +++ b/drivers/tty/serial/atmel_serial.c > @@ -2270,9 +2270,6 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, > mode |= ATMEL_US_USMODE_NORMAL; > } > I think it's better to mo move the "Set baud rate" block here (cf bellow) > - /* 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 > @@ -2315,6 +2312,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, > } > quot = cd | fp << ATMEL_US_FP_OFFSET; > > + /* set the mode, clock divisor, parity, stop bits and data size */ > + atmel_uart_writel(port, ATMEL_US_MR, mode); > + I think your patch is good, but I'll be happier if instead of moving those 2 lines here, the whole "Set the baud rate" block was moved before "atmel_uart_writel(port, ATMEL_US_MR, mode);" That's because at line 2291 the ATMEL_US_CR register is set with ATMEL_US_RTSDIS or ATMEL_US_RTSEN. And those 2 values have a different effect depending on US_MR.USART_MODE Quoting from the relase manual: RTSEN: 1: Drives RTS pin to 1 if US_MR.USART_MODE field = 2, else drives RTS pin to 0 if US_MR.USART_MODE field = 0. RTSDIS: 1: Drives RTS pin to 0 if US_MR.USART_MODE field = 2, else drives RTS pin to 1 if US_MR.USART_MODE field = 0. So, I think it's better to set the mode register before setting the control register. > if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) > atmel_uart_writel(port, ATMEL_US_BRGR, quot); > atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); > Thanks ! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] tty/serial: atmel: fix out of range clock divider handling 2019-12-13 9:57 ` Richard Genoud @ 2019-12-13 13:49 ` David Engraf -1 siblings, 0 replies; 18+ messages in thread From: David Engraf @ 2019-12-13 13:49 UTC (permalink / raw) To: Richard Genoud, gregkh, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches Cc: linux-serial, linux-arm-kernel, linux-kernel Hi, On 13.12.19 at 10:57, Richard Genoud wrote: > Hi, > > Le 11/12/2019 à 17:29, 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 writing the mode register after calculating the baudrate. >> >> Signed-off-by: David Engraf <david.engraf@sysgo.com> > > It seems that this bug was introduced by: > commit 5bf5635ac170 ("tty/serial: atmel: add fractional baud rate support") > > Could you add the "Fixes:" header ? Sure. > Ludovic, could you check if this was your intent at the time ? > >> --- >> drivers/tty/serial/atmel_serial.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c >> index a8dc8af83f39..9983e2fabbac 100644 >> --- a/drivers/tty/serial/atmel_serial.c >> +++ b/drivers/tty/serial/atmel_serial.c >> @@ -2270,9 +2270,6 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, >> mode |= ATMEL_US_USMODE_NORMAL; >> } >> > I think it's better to mo move the "Set baud rate" block here (cf bellow) > >> - /* 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 >> @@ -2315,6 +2312,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, >> } >> quot = cd | fp << ATMEL_US_FP_OFFSET; >> >> + /* set the mode, clock divisor, parity, stop bits and data size */ >> + atmel_uart_writel(port, ATMEL_US_MR, mode); >> + > I think your patch is good, but I'll be happier if instead of moving > those 2 lines here, the whole "Set the baud rate" block was moved before > "atmel_uart_writel(port, ATMEL_US_MR, mode);" > > That's because at line 2291 the ATMEL_US_CR register is set with > ATMEL_US_RTSDIS or ATMEL_US_RTSEN. > And those 2 values have a different effect depending on US_MR.USART_MODE > > Quoting from the relase manual: > RTSEN: > 1: Drives RTS pin to 1 if US_MR.USART_MODE field = 2, else drives RTS > pin to 0 if US_MR.USART_MODE field = 0. > > RTSDIS: > 1: Drives RTS pin to 0 if US_MR.USART_MODE field = 2, else drives RTS > pin to 1 if US_MR.USART_MODE field = 0. > > So, I think it's better to set the mode register before setting the > control register. I fully agree, the RTS pin configuration depends on USART_MODE. I will make a new version of the patch. Thanks - David > >> if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) >> atmel_uart_writel(port, ATMEL_US_BRGR, quot); >> atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); >> > > Thanks ! > ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] tty/serial: atmel: fix out of range clock divider handling @ 2019-12-13 13:49 ` David Engraf 0 siblings, 0 replies; 18+ messages in thread From: David Engraf @ 2019-12-13 13:49 UTC (permalink / raw) To: Richard Genoud, gregkh, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches Cc: linux-arm-kernel, linux-serial, linux-kernel Hi, On 13.12.19 at 10:57, Richard Genoud wrote: > Hi, > > Le 11/12/2019 à 17:29, 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 writing the mode register after calculating the baudrate. >> >> Signed-off-by: David Engraf <david.engraf@sysgo.com> > > It seems that this bug was introduced by: > commit 5bf5635ac170 ("tty/serial: atmel: add fractional baud rate support") > > Could you add the "Fixes:" header ? Sure. > Ludovic, could you check if this was your intent at the time ? > >> --- >> drivers/tty/serial/atmel_serial.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c >> index a8dc8af83f39..9983e2fabbac 100644 >> --- a/drivers/tty/serial/atmel_serial.c >> +++ b/drivers/tty/serial/atmel_serial.c >> @@ -2270,9 +2270,6 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, >> mode |= ATMEL_US_USMODE_NORMAL; >> } >> > I think it's better to mo move the "Set baud rate" block here (cf bellow) > >> - /* 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 >> @@ -2315,6 +2312,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, >> } >> quot = cd | fp << ATMEL_US_FP_OFFSET; >> >> + /* set the mode, clock divisor, parity, stop bits and data size */ >> + atmel_uart_writel(port, ATMEL_US_MR, mode); >> + > I think your patch is good, but I'll be happier if instead of moving > those 2 lines here, the whole "Set the baud rate" block was moved before > "atmel_uart_writel(port, ATMEL_US_MR, mode);" > > That's because at line 2291 the ATMEL_US_CR register is set with > ATMEL_US_RTSDIS or ATMEL_US_RTSEN. > And those 2 values have a different effect depending on US_MR.USART_MODE > > Quoting from the relase manual: > RTSEN: > 1: Drives RTS pin to 1 if US_MR.USART_MODE field = 2, else drives RTS > pin to 0 if US_MR.USART_MODE field = 0. > > RTSDIS: > 1: Drives RTS pin to 0 if US_MR.USART_MODE field = 2, else drives RTS > pin to 1 if US_MR.USART_MODE field = 0. > > So, I think it's better to set the mode register before setting the > control register. I fully agree, the RTS pin configuration depends on USART_MODE. I will make a new version of the patch. Thanks - David > >> if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) >> atmel_uart_writel(port, ATMEL_US_BRGR, quot); >> atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); >> > > Thanks ! > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2] tty/serial: atmel: fix out of range clock divider handling 2019-12-13 13:49 ` David Engraf @ 2019-12-13 14:03 ` David Engraf -1 siblings, 0 replies; 18+ messages in thread From: David Engraf @ 2019-12-13 14:03 UTC (permalink / raw) To: richard.genoud, gregkh, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches Cc: linux-serial, linux-arm-kernel, linux-kernel, David Engraf 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> --- 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; -- 2.17.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2] tty/serial: atmel: fix out of range clock divider handling @ 2019-12-13 14:03 ` David Engraf 0 siblings, 0 replies; 18+ messages in thread From: David Engraf @ 2019-12-13 14:03 UTC (permalink / raw) To: richard.genoud, gregkh, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches Cc: David Engraf, linux-arm-kernel, linux-serial, linux-kernel 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> --- 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; -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2] tty/serial: atmel: fix out of range clock divider handling 2019-12-13 14:03 ` David Engraf @ 2019-12-13 16:07 ` Greg KH -1 siblings, 0 replies; 18+ messages in thread From: Greg KH @ 2019-12-13 16:07 UTC (permalink / raw) To: David Engraf Cc: richard.genoud, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches, linux-serial, linux-arm-kernel, linux-kernel On Fri, Dec 13, 2019 at 03:03:01PM +0100, David Engraf wrote: > 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> > --- > drivers/tty/serial/atmel_serial.c | 43 ++++++++++++++++--------------- > 1 file changed, 22 insertions(+), 21 deletions(-) What changed from v1? Always put that below the --- line. v3 please? thanks, greg k-h ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2] tty/serial: atmel: fix out of range clock divider handling @ 2019-12-13 16:07 ` Greg KH 0 siblings, 0 replies; 18+ messages in thread From: Greg KH @ 2019-12-13 16:07 UTC (permalink / raw) To: David Engraf Cc: alexandre.belloni, richard.genoud, linux-kernel, ludovic.desroches, linux-serial, jslaby, linux-arm-kernel On Fri, Dec 13, 2019 at 03:03:01PM +0100, David Engraf wrote: > 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> > --- > drivers/tty/serial/atmel_serial.c | 43 ++++++++++++++++--------------- > 1 file changed, 22 insertions(+), 21 deletions(-) What changed from v1? Always put that below the --- line. v3 please? thanks, greg k-h _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2] tty/serial: atmel: fix out of range clock divider handling 2019-12-13 16:07 ` Greg KH @ 2019-12-16 8:34 ` David Engraf -1 siblings, 0 replies; 18+ messages in thread From: David Engraf @ 2019-12-16 8:34 UTC (permalink / raw) To: Greg KH Cc: richard.genoud, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches, linux-serial, linux-arm-kernel, linux-kernel On 13.12.19 at 17:07, Greg KH wrote: > On Fri, Dec 13, 2019 at 03:03:01PM +0100, David Engraf wrote: >> 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> >> --- >> drivers/tty/serial/atmel_serial.c | 43 ++++++++++++++++--------------- >> 1 file changed, 22 insertions(+), 21 deletions(-) > > What changed from v1? > > Always put that below the --- line. Oh sorry. > v3 please? Sure. Best regards - David > thanks, > > greg k-h > ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2] tty/serial: atmel: fix out of range clock divider handling @ 2019-12-16 8:34 ` David Engraf 0 siblings, 0 replies; 18+ messages in thread From: David Engraf @ 2019-12-16 8:34 UTC (permalink / raw) To: Greg KH Cc: alexandre.belloni, richard.genoud, linux-kernel, ludovic.desroches, linux-serial, jslaby, linux-arm-kernel On 13.12.19 at 17:07, Greg KH wrote: > On Fri, Dec 13, 2019 at 03:03:01PM +0100, David Engraf wrote: >> 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> >> --- >> drivers/tty/serial/atmel_serial.c | 43 ++++++++++++++++--------------- >> 1 file changed, 22 insertions(+), 21 deletions(-) > > What changed from v1? > > Always put that below the --- line. Oh sorry. > v3 please? Sure. Best regards - David > thanks, > > greg k-h > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3] tty/serial: atmel: fix out of range clock divider handling 2019-12-16 8:34 ` David Engraf @ 2019-12-16 8:54 ` David Engraf -1 siblings, 0 replies; 18+ messages in thread From: David Engraf @ 2019-12-16 8:54 UTC (permalink / raw) To: richard.genoud, gregkh, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches Cc: linux-serial, linux-arm-kernel, linux-kernel, David Engraf 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> --- 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; -- 2.17.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3] tty/serial: atmel: fix out of range clock divider handling @ 2019-12-16 8:54 ` David Engraf 0 siblings, 0 replies; 18+ messages in thread From: David Engraf @ 2019-12-16 8:54 UTC (permalink / raw) To: richard.genoud, gregkh, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches Cc: David Engraf, linux-arm-kernel, linux-serial, linux-kernel 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> --- 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; -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v3] tty/serial: atmel: fix out of range clock divider handling 2019-12-16 8:54 ` David Engraf @ 2019-12-16 10:03 ` Richard Genoud -1 siblings, 0 replies; 18+ messages in thread From: Richard Genoud @ 2019-12-16 10:03 UTC (permalink / raw) To: David Engraf, gregkh, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches Cc: linux-serial, linux-arm-kernel, linux-kernel 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 ! ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3] tty/serial: atmel: fix out of range clock divider handling @ 2019-12-16 10:03 ` Richard Genoud 0 siblings, 0 replies; 18+ messages in thread From: Richard Genoud @ 2019-12-16 10:03 UTC (permalink / raw) To: David Engraf, gregkh, jslaby, nicolas.ferre, alexandre.belloni, ludovic.desroches Cc: linux-arm-kernel, linux-serial, linux-kernel 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 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3] tty/serial: atmel: fix out of range clock divider handling 2019-12-16 8:54 ` David Engraf @ 2019-12-16 10:26 ` Ludovic Desroches -1 siblings, 0 replies; 18+ messages in thread From: Ludovic Desroches @ 2019-12-16 10:26 UTC (permalink / raw) To: David Engraf Cc: richard.genoud, gregkh, jslaby, nicolas.ferre, alexandre.belloni, linux-serial, linux-arm-kernel, linux-kernel On Mon, Dec 16, 2019 at 09:54:03AM +0100, David Engraf wrote: > 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: Ludovic Desroches <ludovic.desroches@microchip.com> Thanks for the fix Regards > --- > 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; > -- > 2.17.1 > ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3] tty/serial: atmel: fix out of range clock divider handling @ 2019-12-16 10:26 ` Ludovic Desroches 0 siblings, 0 replies; 18+ messages in thread From: Ludovic Desroches @ 2019-12-16 10:26 UTC (permalink / raw) To: David Engraf Cc: alexandre.belloni, richard.genoud, gregkh, linux-kernel, linux-serial, jslaby, linux-arm-kernel On Mon, Dec 16, 2019 at 09:54:03AM +0100, David Engraf wrote: > 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: Ludovic Desroches <ludovic.desroches@microchip.com> Thanks for the fix Regards > --- > 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; > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2019-12-16 10:27 UTC | newest] Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-12-11 16:29 [PATCH] tty/serial: atmel: fix out of range clock divider handling David Engraf 2019-12-11 16:29 ` David Engraf 2019-12-13 9:57 ` Richard Genoud 2019-12-13 9:57 ` Richard Genoud 2019-12-13 13:49 ` David Engraf 2019-12-13 13:49 ` David Engraf 2019-12-13 14:03 ` [PATCH v2] " David Engraf 2019-12-13 14:03 ` David Engraf 2019-12-13 16:07 ` Greg KH 2019-12-13 16:07 ` Greg KH 2019-12-16 8:34 ` David Engraf 2019-12-16 8:34 ` David Engraf 2019-12-16 8:54 ` [PATCH v3] " David Engraf 2019-12-16 8:54 ` David Engraf 2019-12-16 10:03 ` Richard Genoud 2019-12-16 10:03 ` Richard Genoud 2019-12-16 10:26 ` Ludovic Desroches 2019-12-16 10:26 ` Ludovic Desroches
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.