OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | From 24d5ba8ad40c3ac7903f688580c345aafa764dc7 Mon Sep 17 00:00:00 2001 |
2 | From: Daniel Golle <daniel@makrotopia.org> |
||
3 | Date: Mon, 4 Jun 2018 14:51:29 +0200 |
||
4 | Subject: [PATCH] tty: serial: exar: generalize rs485 setup |
||
5 | To: linux-serial@vger.kernel.org, |
||
6 | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
||
7 | Cc: Linus Walleij <linus.walleij@linaro.org>, |
||
8 | Jan Kiszka <jan.kiszka@siemens.com> |
||
9 | |||
10 | Move the non-board-specific part of the RS485 initialization |
||
11 | from iot2040_rs485_config function to a new generic function |
||
12 | used also for other boards. |
||
13 | This allows using PCIe boards which are hard-wired to RS485 |
||
14 | or have jumpers for their configurations. |
||
15 | |||
16 | Signed-off-by: Daniel Golle <daniel@makrotopia.org> |
||
17 | --- |
||
18 | drivers/tty/serial/8250/8250_exar.c | 38 +++++++++++++++++++---------- |
||
19 | 1 file changed, 25 insertions(+), 13 deletions(-) |
||
20 | |||
21 | --- a/drivers/tty/serial/8250/8250_exar.c |
||
22 | +++ b/drivers/tty/serial/8250/8250_exar.c |
||
23 | @@ -275,8 +275,32 @@ static int xr17v35x_register_gpio(struct |
||
24 | return 0; |
||
25 | } |
||
26 | |||
27 | +static int generic_rs485_config(struct uart_port *port, |
||
28 | + struct serial_rs485 *rs485) |
||
29 | +{ |
||
30 | + bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED); |
||
31 | + u8 __iomem *p = port->membase; |
||
32 | + u8 value; |
||
33 | + |
||
34 | + value = readb(p + UART_EXAR_FCTR); |
||
35 | + if (is_rs485) |
||
36 | + value |= UART_FCTR_EXAR_485; |
||
37 | + else |
||
38 | + value &= ~UART_FCTR_EXAR_485; |
||
39 | + |
||
40 | + writeb(value, p + UART_EXAR_FCTR); |
||
41 | + |
||
42 | + if (is_rs485) |
||
43 | + writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR); |
||
44 | + |
||
45 | + port->rs485 = *rs485; |
||
46 | + |
||
47 | + return 0; |
||
48 | +} |
||
49 | + |
||
50 | static const struct exar8250_platform exar8250_default_platform = { |
||
51 | .register_gpio = xr17v35x_register_gpio, |
||
52 | + .rs485_config = generic_rs485_config, |
||
53 | }; |
||
54 | |||
55 | static int iot2040_rs485_config(struct uart_port *port, |
||
56 | @@ -309,19 +333,7 @@ static int iot2040_rs485_config(struct u |
||
57 | value |= mode; |
||
58 | writeb(value, p + UART_EXAR_MPIOLVL_7_0); |
||
59 | |||
60 | - value = readb(p + UART_EXAR_FCTR); |
||
61 | - if (is_rs485) |
||
62 | - value |= UART_FCTR_EXAR_485; |
||
63 | - else |
||
64 | - value &= ~UART_FCTR_EXAR_485; |
||
65 | - writeb(value, p + UART_EXAR_FCTR); |
||
66 | - |
||
67 | - if (is_rs485) |
||
68 | - writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR); |
||
69 | - |
||
70 | - port->rs485 = *rs485; |
||
71 | - |
||
72 | - return 0; |
||
73 | + return generic_rs485_config(port, rs485); |
||
74 | } |
||
75 | |||
76 | static const struct property_entry iot2040_gpio_properties[] = { |