]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.0.45/serial-pl011-handle-corruption-at-high-clock-speeds.patch
Linux 4.14.112
[thirdparty/kernel/stable-queue.git] / releases / 3.0.45 / serial-pl011-handle-corruption-at-high-clock-speeds.patch
1 From c5dd553b9fd069892c9e2de734f4f604e280fa7a Mon Sep 17 00:00:00 2001
2 From: Linus Walleij <linus.walleij@linaro.org>
3 Date: Wed, 26 Sep 2012 17:21:36 +0200
4 Subject: serial: pl011: handle corruption at high clock speeds
5
6 From: Linus Walleij <linus.walleij@linaro.org>
7
8 commit c5dd553b9fd069892c9e2de734f4f604e280fa7a upstream.
9
10 This works around a few glitches in the ST version of the PL011
11 serial driver when using very high baud rates, as we do in the
12 Ux500: 3, 3.25, 4 and 4.05 Mbps.
13
14 Problem Observed/rootcause:
15
16 When using high baud-rates, and the baudrate*8 is getting close to
17 the provided clock frequency (so a division factor close to 1), when
18 using bursts of characters (so they are abutted), then it seems as if
19 there is not enough time to detect the beginning of the start-bit which
20 is a timing reference for the entire character, and thus the sampling
21 moment of character bits is moving towards the end of each bit, instead
22 of the middle.
23
24 Fix:
25 Increase slightly the RX baud rate of the UART above the theoretical
26 baudrate by 5%. This will definitely give more margin time to the
27 UART_RX to correctly sample the data at the middle of the bit period.
28
29 Also fix the ages old copy-paste error in the very stressed comment,
30 it's referencing the registers used in the PL010 driver rather than
31 the PL011 ones.
32
33 Signed-off-by: Guillaume Jaunet <guillaume.jaunet@stericsson.com>
34 Signed-off-by: Christophe Arnal <christophe.arnal@stericsson.com>
35 Signed-off-by: Matthias Locher <matthias.locher@stericsson.com>
36 Signed-off-by: Rajanikanth HV <rajanikanth.hv@stericsson.com>
37 Cc: Bibek Basu <bibek.basu@stericsson.com>
38 Cc: Par-Gunnar Hjalmdahl <par-gunnar.hjalmdahl@stericsson.com>
39 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
40 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
41
42 ---
43 drivers/tty/serial/amba-pl011.c | 15 ++++++++++++++-
44 1 file changed, 14 insertions(+), 1 deletion(-)
45
46 --- a/drivers/tty/serial/amba-pl011.c
47 +++ b/drivers/tty/serial/amba-pl011.c
48 @@ -1620,13 +1620,26 @@ pl011_set_termios(struct uart_port *port
49 old_cr &= ~ST_UART011_CR_OVSFACT;
50 }
51
52 + /*
53 + * Workaround for the ST Micro oversampling variants to
54 + * increase the bitrate slightly, by lowering the divisor,
55 + * to avoid delayed sampling of start bit at high speeds,
56 + * else we see data corruption.
57 + */
58 + if (uap->vendor->oversampling) {
59 + if ((baud >= 3000000) && (baud < 3250000) && (quot > 1))
60 + quot -= 1;
61 + else if ((baud > 3250000) && (quot > 2))
62 + quot -= 2;
63 + }
64 /* Set baud rate */
65 writew(quot & 0x3f, port->membase + UART011_FBRD);
66 writew(quot >> 6, port->membase + UART011_IBRD);
67
68 /*
69 * ----------v----------v----------v----------v-----
70 - * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L
71 + * NOTE: lcrh_tx and lcrh_rx MUST BE WRITTEN AFTER
72 + * UART011_FBRD & UART011_IBRD.
73 * ----------^----------^----------^----------^-----
74 */
75 writew(lcr_h, port->membase + uap->lcrh_rx);