ath79: add support for COMFAST CF-E130N v2
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-4.19 / 950-0795-tty-amba-pl011-Add-un-throttle-support.patch
1 From d4f4b57c667141ca98711cfcb30ae2b8deb1a034 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Fri, 24 Jan 2020 11:38:28 +0000
4 Subject: [PATCH] tty: amba-pl011: Add un/throttle support
5
6 The PL011 driver lacks throttle and unthrottle methods. As a result,
7 sending more data to the Pi than it can immediately sink while CRTSCTS
8 is enabled causes a NULL pointer to be followed.
9
10 Add a throttle handler that disables the RX interrupts, and an
11 unthrottle handler that reenables them.
12
13 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
14 ---
15 drivers/tty/serial/amba-pl011.c | 28 ++++++++++++++++++++++++++++
16 1 file changed, 28 insertions(+)
17
18 --- a/drivers/tty/serial/amba-pl011.c
19 +++ b/drivers/tty/serial/amba-pl011.c
20 @@ -1323,6 +1323,32 @@ static void pl011_start_tx(struct uart_p
21 pl011_start_tx_pio(uap);
22 }
23
24 +static void pl011_throttle(struct uart_port *port)
25 +{
26 + struct uart_amba_port *uap =
27 + container_of(port, struct uart_amba_port, port);
28 + unsigned long flags;
29 +
30 + spin_lock_irqsave(&uap->port.lock, flags);
31 + uap->im &= ~(UART011_RTIM | UART011_RXIM);
32 + pl011_write(uap->im, uap, REG_IMSC);
33 + spin_unlock_irqrestore(&uap->port.lock, flags);
34 +}
35 +
36 +static void pl011_unthrottle(struct uart_port *port)
37 +{
38 + struct uart_amba_port *uap =
39 + container_of(port, struct uart_amba_port, port);
40 + unsigned long flags;
41 +
42 + spin_lock_irqsave(&uap->port.lock, flags);
43 + uap->im |= UART011_RTIM;
44 + if (!pl011_dma_rx_running(uap))
45 + uap->im |= UART011_RXIM;
46 + pl011_write(uap->im, uap, REG_IMSC);
47 + spin_unlock_irqrestore(&uap->port.lock, flags);
48 +}
49 +
50 static void pl011_stop_rx(struct uart_port *port)
51 {
52 struct uart_amba_port *uap =
53 @@ -2165,6 +2191,8 @@ static const struct uart_ops amba_pl011_
54 .stop_tx = pl011_stop_tx,
55 .start_tx = pl011_start_tx,
56 .stop_rx = pl011_stop_rx,
57 + .throttle = pl011_throttle,
58 + .unthrottle = pl011_unthrottle,
59 .enable_ms = pl011_enable_ms,
60 .break_ctl = pl011_break_ctl,
61 .startup = pl011_startup,