summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinda Chen <minda.chen@starfivetech.com>2023-06-25 04:40:29 +0300
committerHal Feng <hal.feng@starfivetech.com>2024-03-05 10:18:28 +0300
commit87a0010eaeeba91929dbf40608beff364ad2de70 (patch)
tree861152e45b78f6d008685ab34e46d465878263f7
parent1a3fc138b64d8887e09cdb426a5bdef8f5086b3d (diff)
downloadlinux-87a0010eaeeba91929dbf40608beff364ad2de70.tar.xz
uart: 8250: Add dw auto flow ctrl support
Add designeware 8250 auto flow ctrl support. Enable it by add auto-flow-control in dts. Signed-off-by: Minda Chen <minda.chen@starfivetech.com>
-rw-r--r--drivers/tty/serial/8250/8250_core.c2
-rw-r--r--drivers/tty/serial/8250/8250_dw.c3
-rw-r--r--drivers/tty/serial/8250/8250_port.c14
-rw-r--r--include/linux/serial_8250.h1
-rw-r--r--include/uapi/linux/serial_core.h2
5 files changed, 21 insertions, 1 deletions
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 3449f8790e46..93acba6d8fc8 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -1129,6 +1129,8 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)
uart->dl_read = up->dl_read;
if (up->dl_write)
uart->dl_write = up->dl_write;
+ if (up->probe)
+ uart->probe = up->probe;
if (uart->port.type != PORT_8250_CIR) {
if (serial8250_isa_config != NULL)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index a1f2259cc9a9..b10b51ddc3a0 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -597,6 +597,9 @@ static int dw8250_probe(struct platform_device *pdev)
/* Always ask for fixed clock rate from a property. */
device_property_read_u32(dev, "clock-frequency", &p->uartclk);
+ if (device_property_read_bool(dev, "auto-flow-control"))
+ up->probe |= UART_PROBE_AFE;
+
/* If there is separate baudclk, get the rate from it. */
data->clk = devm_clk_get_optional(dev, "baudclk");
if (data->clk == NULL)
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 141627370aab..ab351dcaee5d 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -330,6 +330,14 @@ static const struct serial8250_config uart_config[] = {
.rxtrig_bytes = {1, 8, 16, 30},
.flags = UART_CAP_FIFO | UART_CAP_AFE,
},
+ [PORT_16550A_AFE] = {
+ .name = "16550A_AFE",
+ .fifo_size = 16,
+ .tx_loadsz = 16,
+ .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
+ .rxtrig_bytes = {1, 4, 8, 14},
+ .flags = UART_CAP_FIFO | UART_CAP_AFE,
+ },
};
/* Uart divisor latch read */
@@ -1143,6 +1151,11 @@ static void autoconfig_16550a(struct uart_8250_port *up)
up->port.type = PORT_U6_16550A;
up->capabilities |= UART_CAP_AFE;
}
+
+ if ((up->port.type == PORT_16550A) && (up->probe & UART_PROBE_AFE)) {
+ up->port.type = PORT_16550A_AFE;
+ up->capabilities |= UART_CAP_AFE;
+ }
}
/*
@@ -2819,7 +2832,6 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
if (termios->c_cflag & CRTSCTS)
up->mcr |= UART_MCR_AFE;
}
-
/*
* Update the per-port timeout.
*/
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index be65de65fe61..0eaaf597889c 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -141,6 +141,7 @@ struct uart_8250_port {
unsigned char probe;
struct mctrl_gpios *gpios;
#define UART_PROBE_RSA (1 << 0)
+#define UART_PROBE_AFE (1 << 1)
/*
* Some bits in registers are cleared on a read, so they must
diff --git a/include/uapi/linux/serial_core.h b/include/uapi/linux/serial_core.h
index add349889d0a..58c5c0ac0911 100644
--- a/include/uapi/linux/serial_core.h
+++ b/include/uapi/linux/serial_core.h
@@ -245,4 +245,6 @@
/* Sunplus UART */
#define PORT_SUNPLUS 123
+#define PORT_16550A_AFE 124
+
#endif /* _UAPILINUX_SERIAL_CORE_H */