Merge tag 'gpio-v4.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw...
[linux-2.6-microblaze.git] / drivers / tty / serial / 8250 / 8250_exar.c
index b105f4c..b5c98e5 100644 (file)
@@ -154,7 +154,6 @@ pci_fastcom335_setup(struct exar8250 *priv, struct pci_dev *pcidev,
        u8 __iomem *p;
        int err;
 
-       port->port.flags |= UPF_EXAR_EFR;
        port->port.uartclk = baud * 16;
 
        err = default_setup(priv, pcidev, idx, offset, port);
@@ -216,19 +215,26 @@ pci_xr17c154_setup(struct exar8250 *priv, struct pci_dev *pcidev,
        return default_setup(priv, pcidev, idx, offset, port);
 }
 
-static void setup_gpio(u8 __iomem *p)
+static void setup_gpio(struct pci_dev *pcidev, u8 __iomem *p)
 {
+       /*
+        * The Commtech adapters required the MPIOs to be driven low. The Exar
+        * devices will export them as GPIOs, so we pre-configure them safely
+        * as inputs.
+        */
+       u8 dir = pcidev->vendor == PCI_VENDOR_ID_EXAR ? 0xff : 0x00;
+
        writeb(0x00, p + UART_EXAR_MPIOINT_7_0);
        writeb(0x00, p + UART_EXAR_MPIOLVL_7_0);
        writeb(0x00, p + UART_EXAR_MPIO3T_7_0);
        writeb(0x00, p + UART_EXAR_MPIOINV_7_0);
-       writeb(0x00, p + UART_EXAR_MPIOSEL_7_0);
+       writeb(dir,  p + UART_EXAR_MPIOSEL_7_0);
        writeb(0x00, p + UART_EXAR_MPIOOD_7_0);
        writeb(0x00, p + UART_EXAR_MPIOINT_15_8);
        writeb(0x00, p + UART_EXAR_MPIOLVL_15_8);
        writeb(0x00, p + UART_EXAR_MPIO3T_15_8);
        writeb(0x00, p + UART_EXAR_MPIOINV_15_8);
-       writeb(0x00, p + UART_EXAR_MPIOSEL_15_8);
+       writeb(dir,  p + UART_EXAR_MPIOSEL_15_8);
        writeb(0x00, p + UART_EXAR_MPIOOD_15_8);
 }
 
@@ -399,7 +405,7 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
 
        if (idx == 0) {
                /* Setup Multipurpose Input/Output pins. */
-               setup_gpio(p);
+               setup_gpio(pcidev, p);
 
                ret = platform->register_gpio(pcidev, port);
        }