Skip to content

Commit

Permalink
Merge branch 'rcar-3.9.8/sh-sci.rc1' into v4.14.75-ltsi/rcar-3.9.9
Browse files Browse the repository at this point in the history
* rcar-3.9.8/sh-sci.rc1:
  serial: sh-sci: Make sure status register SCxSR is read in correct sequence
  serial: sh-sci: Fix HSCIF RX sampling point calculation
  serial: sh-sci: Fix HSCIF RX sampling point adjustment
  • Loading branch information
r-kataok committed May 22, 2020
2 parents 5b8611d + 94b4a7a commit c37ab32
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions drivers/tty/serial/sh-sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,9 +854,16 @@ static void sci_receive_chars(struct uart_port *port)
tty_insert_flip_char(tport, c, TTY_NORMAL);
} else {
for (i = 0; i < count; i++) {
char c = serial_port_in(port, SCxRDR);

status = serial_port_in(port, SCxSR);
char c;

if (port->type == PORT_SCIF ||
port->type == PORT_HSCIF) {
status = serial_port_in(port, SCxSR);
c = serial_port_in(port, SCxRDR);
} else {
c = serial_port_in(port, SCxRDR);
status = serial_port_in(port, SCxSR);
}
if (uart_handle_sysrq_char(port, c)) {
count--; i--;
continue;
Expand Down Expand Up @@ -2439,14 +2446,16 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
* center of the last stop bit in sampling clocks.
*/
int last_stop = bits * 2 - 1;
int deviation = min_err * srr * last_stop / 2 / baud;
int deviation = DIV_ROUND_CLOSEST(min_err * last_stop *
(int)(srr + 1),
2 * (int)baud);

if (abs(deviation) >= 2) {
/* At least two sampling clocks off at the
* last stop bit; we can increase the error
* margin by shifting the sampling point.
*/
int shift = min(-8, max(7, deviation / 2));
int shift = clamp(deviation / 2, -8, 7);

hssrr |= (shift << HSCIF_SRHP_SHIFT) &
HSCIF_SRHP_MASK;
Expand Down

0 comments on commit c37ab32

Please sign in to comment.