Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: exar: Leave MPIOs as output for Commtech adapters

Commtech adapters apparently need the original setting as outputs, see
https://marc.info/?l=linux-gpio&m=149557425201323&w=2. Account for that.

Fixes: 7dea8165f1d6 ("serial: exar: Preconfigure xr17v35x MPIOs as output")
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jan Kiszka and committed by
Greg Kroah-Hartman
bea8be65 72ce5732

+11 -4
+11 -4
drivers/tty/serial/8250/8250_exar.c
··· 170 170 return default_setup(priv, pcidev, idx, offset, port); 171 171 } 172 172 173 - static void setup_gpio(u8 __iomem *p) 173 + static void setup_gpio(struct pci_dev *pcidev, u8 __iomem *p) 174 174 { 175 + /* 176 + * The Commtech adapters required the MPIOs to be driven low. The Exar 177 + * devices will export them as GPIOs, so we pre-configure them safely 178 + * as inputs. 179 + */ 180 + u8 dir = pcidev->vendor == PCI_VENDOR_ID_EXAR ? 0xff : 0x00; 181 + 175 182 writeb(0x00, p + UART_EXAR_MPIOINT_7_0); 176 183 writeb(0x00, p + UART_EXAR_MPIOLVL_7_0); 177 184 writeb(0x00, p + UART_EXAR_MPIO3T_7_0); 178 185 writeb(0x00, p + UART_EXAR_MPIOINV_7_0); 179 - writeb(0xff, p + UART_EXAR_MPIOSEL_7_0); 186 + writeb(dir, p + UART_EXAR_MPIOSEL_7_0); 180 187 writeb(0x00, p + UART_EXAR_MPIOOD_7_0); 181 188 writeb(0x00, p + UART_EXAR_MPIOINT_15_8); 182 189 writeb(0x00, p + UART_EXAR_MPIOLVL_15_8); 183 190 writeb(0x00, p + UART_EXAR_MPIO3T_15_8); 184 191 writeb(0x00, p + UART_EXAR_MPIOINV_15_8); 185 - writeb(0xff, p + UART_EXAR_MPIOSEL_15_8); 192 + writeb(dir, p + UART_EXAR_MPIOSEL_15_8); 186 193 writeb(0x00, p + UART_EXAR_MPIOOD_15_8); 187 194 } 188 195 ··· 242 235 243 236 if (idx == 0) { 244 237 /* Setup Multipurpose Input/Output pins. */ 245 - setup_gpio(p); 238 + setup_gpio(pcidev, p); 246 239 247 240 port->port.private_data = xr17v35x_register_gpio(pcidev); 248 241 }