kernel: modules: package module for Exar 8250 UARTs
authorDaniel Golle <daniel@makrotopia.org>
Tue, 5 Jun 2018 03:35:47 +0000 (05:35 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 5 Jun 2018 13:27:36 +0000 (15:27 +0200)
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
package/kernel/linux/modules/other.mk
target/linux/generic/pending-4.14/950-tty-serial-exar-generalize-rs485-setup.patch [new file with mode: 0644]

index eb26a8ba081e25f6db396c396f0607f31b4298b6..b33883815edf98996362d45841e841bd72ca78c6 100644 (file)
@@ -698,6 +698,22 @@ endef
 $(eval $(call KernelPackage,serial-8250))
 
 
+define KernelPackage/serial-8250-exar
+  SUBMENU:=$(OTHER_MENU)
+  TITLE:=Exar 8250 UARTs
+  KCONFIG:= CONFIG_SERIAL_8250_EXAR
+  FILES:=$(LINUX_DIR)/drivers/tty/serial/8250/8250_exar.ko
+  AUTOLOAD:=$(call AutoProbe,8250 8250_base 8250_exar)
+  DEPENDS:=+kmod-serial-8250
+endef
+
+define KernelPackage/serial-8250-exar/description
+ Kernel module for Exar serial ports
+endef
+
+$(eval $(call KernelPackage,serial-8250-exar))
+
+
 define KernelPackage/regmap
   SUBMENU:=$(OTHER_MENU)
   TITLE:=Generic register map support
diff --git a/target/linux/generic/pending-4.14/950-tty-serial-exar-generalize-rs485-setup.patch b/target/linux/generic/pending-4.14/950-tty-serial-exar-generalize-rs485-setup.patch
new file mode 100644 (file)
index 0000000..a2b740f
--- /dev/null
@@ -0,0 +1,81 @@
+From 24d5ba8ad40c3ac7903f688580c345aafa764dc7 Mon Sep 17 00:00:00 2001
+From: Daniel Golle <daniel@makrotopia.org>
+Date: Mon, 4 Jun 2018 14:51:29 +0200
+Subject: [PATCH] tty: serial: exar: generalize rs485 setup
+To: linux-serial@vger.kernel.org,
+    Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: Linus Walleij <linus.walleij@linaro.org>,
+    Jan Kiszka <jan.kiszka@siemens.com>
+
+Move the non-board-specific part of the RS485 initialization
+from iot2040_rs485_config function to a new generic function
+used also for other boards.
+This allows using PCIe boards which are hard-wired to RS485
+or have jumpers for their configurations.
+
+Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+---
+ drivers/tty/serial/8250/8250_exar.c | 38 +++++++++++++++++++----------
+ 1 file changed, 25 insertions(+), 13 deletions(-)
+
+diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
+index e0aa5f03004c..55b4d6d581f0 100644
+--- a/drivers/tty/serial/8250/8250_exar.c
++++ b/drivers/tty/serial/8250/8250_exar.c
+@@ -275,8 +275,32 @@ static int xr17v35x_register_gpio(struct pci_dev *pcidev,
+       return 0;
+ }
++static int generic_rs485_config(struct uart_port *port,
++                              struct serial_rs485 *rs485)
++{
++      bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED);
++      u8 __iomem *p = port->membase;
++      u8 value;
++
++      value = readb(p + UART_EXAR_FCTR);
++      if (is_rs485)
++              value |= UART_FCTR_EXAR_485;
++      else
++              value &= ~UART_FCTR_EXAR_485;
++
++      writeb(value, p + UART_EXAR_FCTR);
++
++      if (is_rs485)
++              writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR);
++
++      port->rs485 = *rs485;
++
++      return 0;
++}
++
+ static const struct exar8250_platform exar8250_default_platform = {
+       .register_gpio = xr17v35x_register_gpio,
++      .rs485_config = generic_rs485_config,
+ };
+ static int iot2040_rs485_config(struct uart_port *port,
+@@ -309,19 +333,7 @@ static int iot2040_rs485_config(struct uart_port *port,
+       value |= mode;
+       writeb(value, p + UART_EXAR_MPIOLVL_7_0);
+-      value = readb(p + UART_EXAR_FCTR);
+-      if (is_rs485)
+-              value |= UART_FCTR_EXAR_485;
+-      else
+-              value &= ~UART_FCTR_EXAR_485;
+-      writeb(value, p + UART_EXAR_FCTR);
+-
+-      if (is_rs485)
+-              writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR);
+-
+-      port->rs485 = *rs485;
+-
+-      return 0;
++      return generic_rs485_config(port, rs485);
+ }
+ static const struct property_entry iot2040_gpio_properties[] = {
+-- 
+2.17.1
+