1 From 9d9398944488cd3a3e1e0912b26fbc4d5921e547 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Mon, 4 Jun 2018 23:33:07 +0200
4 Subject: [PATCH] tty: serial: exar: generalize RS485 setup
6 Move the non-board-specific part of the RS485 initialization from
7 iot2040_rs485_config function to a new generic function used also for
9 This allows using TIOCGRS485 and TIOCSRS485 on boards (such as mPCIe
10 serial IO modules) which are hard-wired to RS485 or have jumpers for
13 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
14 Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17 drivers/tty/serial/8250/8250_exar.c | 38 +++++++++++++++++++----------
18 1 file changed, 25 insertions(+), 13 deletions(-)
20 --- a/drivers/tty/serial/8250/8250_exar.c
21 +++ b/drivers/tty/serial/8250/8250_exar.c
22 @@ -283,8 +283,32 @@ static int xr17v35x_register_gpio(struct
26 +static int generic_rs485_config(struct uart_port *port,
27 + struct serial_rs485 *rs485)
29 + bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED);
30 + u8 __iomem *p = port->membase;
33 + value = readb(p + UART_EXAR_FCTR);
35 + value |= UART_FCTR_EXAR_485;
37 + value &= ~UART_FCTR_EXAR_485;
39 + writeb(value, p + UART_EXAR_FCTR);
42 + writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR);
44 + port->rs485 = *rs485;
49 static const struct exar8250_platform exar8250_default_platform = {
50 .register_gpio = xr17v35x_register_gpio,
51 + .rs485_config = generic_rs485_config,
54 static int iot2040_rs485_config(struct uart_port *port,
55 @@ -317,19 +341,7 @@ static int iot2040_rs485_config(struct u
57 writeb(value, p + UART_EXAR_MPIOLVL_7_0);
59 - value = readb(p + UART_EXAR_FCTR);
61 - value |= UART_FCTR_EXAR_485;
63 - value &= ~UART_FCTR_EXAR_485;
64 - writeb(value, p + UART_EXAR_FCTR);
67 - writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR);
69 - port->rs485 = *rs485;
72 + return generic_rs485_config(port, rs485);
75 static const struct property_entry iot2040_gpio_properties[] = {