openwrt/target/linux/bcm27xx/patches-5.15/950-0231-sc16is7xx-Fix-for-hardware-flow-control.patch
John Audia 67d998e25d
kernel: bump 5.15 to 5.15.145
Changelog: https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.15.145

No patches needed a rebase.

 23.05 backport:

    Rebased patch mediatek/100-dts-update-mt7622-rfb1.patch due to
    changes introduced in commit e37aa926447f ("arm64: dts: mediatek:
    mt7622: fix memory node warning check") in version v5.15.143 and we
    jumped over from v5.15.139 directly to v5.15.145.

Build system: x86_64
Build-tested: ramips/tplink_archer-a6-v3
Run-tested: ramips/tplink_archer-a6-v3

 23.05 backport:

  Stijn:
   Compile-tested: ath79/generic, ipq40xx/generic, mvebu/cortexa72, ramips/mt{7621,7620,76x8}, realtek/rtl{838x,930x}, 86/64.
   Run-tested: cortexa72 (RB5009UG+S+IN), mt7621 (EAP615-Wall v1), rtl838x (GS1900-10HP, GS1900-8HP, GS108T v3).

  Petr:
   Compile-tested: ipq807x, mvebu/cortexa9
   Run-tested: turris-omnia, prpl-haze

Tested-by: Stijn Segers <foss@volatilesystems.org> [23.05 testing]
Signed-off-by: John Audia <therealgraysky@proton.me>
Signed-off-by: Petr Štetiar <ynezz@true.cz> [23.05 refresh]
(cherry picked from commit 8de4cc77a6)
2024-01-07 12:57:30 +00:00

71 lines
2.5 KiB
Diff

From e37d08d5cc0eece55a886f52ef35ac148acabe08 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Wed, 13 May 2020 20:10:15 +0100
Subject: [PATCH] sc16is7xx: Fix for hardware flow control
The SC16IS7XX hardware flow control is mishandled by the driver in
a number of ways:
1. The set_baud method accidentally clears it when setting EFR bit.
2. Even though hardware flow control is enabled, it isn't indicated
back to the serial framework.
3. Applying the flow control clears the EFR bit.
4. The CTS support is not indicated in the return from
sc16is7xx_get_mctrl.
Address all of those issues using a mixture of patches found on the
linked pages.
See: https://github.com/raspberrypi/linux/issues/2542
See: https://www.spinics.net/lists/linux-serial/msg21794.html
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
drivers/tty/serial/sc16is7xx.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -523,8 +523,9 @@ static int sc16is7xx_set_baud(struct uar
/* Enable enhanced features */
regcache_cache_bypass(s->regmap, true);
- sc16is7xx_port_write(port, SC16IS7XX_EFR_REG,
- SC16IS7XX_EFR_ENABLE_BIT);
+ sc16is7xx_port_update(port, SC16IS7XX_EFR_REG,
+ SC16IS7XX_EFR_ENABLE_BIT,
+ SC16IS7XX_EFR_ENABLE_BIT);
regcache_cache_bypass(s->regmap, false);
/* Put LCR back to the normal mode */
@@ -854,7 +855,7 @@ static unsigned int sc16is7xx_get_mctrl(
/* DCD and DSR are not wired and CTS/RTS is handled automatically
* so just indicate DSR and CAR asserted
*/
- return TIOCM_DSR | TIOCM_CAR;
+ return TIOCM_DSR | TIOCM_CAR | TIOCM_RI | TIOCM_CTS;
}
static void sc16is7xx_set_mctrl(struct uart_port *port, unsigned int mctrl)
@@ -941,14 +942,19 @@ static void sc16is7xx_set_termios(struct
regcache_cache_bypass(s->regmap, true);
sc16is7xx_port_write(port, SC16IS7XX_XON1_REG, termios->c_cc[VSTART]);
sc16is7xx_port_write(port, SC16IS7XX_XOFF1_REG, termios->c_cc[VSTOP]);
- if (termios->c_cflag & CRTSCTS)
+ if (termios->c_cflag & CRTSCTS) {
flow |= SC16IS7XX_EFR_AUTOCTS_BIT |
SC16IS7XX_EFR_AUTORTS_BIT;
+ port->status |= UPSTAT_AUTOCTS;
+ };
if (termios->c_iflag & IXON)
flow |= SC16IS7XX_EFR_SWFLOW3_BIT;
if (termios->c_iflag & IXOFF)
flow |= SC16IS7XX_EFR_SWFLOW1_BIT;
+ /* Always set enable enhanced */
+ flow |= SC16IS7XX_EFR_ENABLE_BIT;
+
sc16is7xx_port_write(port, SC16IS7XX_EFR_REG, flow);
regcache_cache_bypass(s->regmap, false);