serial: 8250: Fold EndRun device support into OxSemi Tornado code
[linux-2.6-microblaze.git] / drivers / tty / serial / 8250 / 8250_pci.c
index e17e97e..e8be1b3 100644 (file)
@@ -994,41 +994,29 @@ static void pci_ite887x_exit(struct pci_dev *dev)
 }
 
 /*
- * EndRun Technologies.
- * Determine the number of ports available on the device.
+ * Oxford Semiconductor Inc.
+ * Check if an OxSemi device is part of the Tornado range of devices.
  */
 #define PCI_VENDOR_ID_ENDRUN                   0x7401
 #define PCI_DEVICE_ID_ENDRUN_1588      0xe100
 
-static int pci_endrun_init(struct pci_dev *dev)
+static bool pci_oxsemi_tornado_p(struct pci_dev *dev)
 {
-       u8 __iomem *p;
-       unsigned long deviceID;
-       unsigned int  number_uarts = 0;
+       /* OxSemi Tornado devices are all 0xCxxx */
+       if (dev->vendor == PCI_VENDOR_ID_OXSEMI &&
+           (dev->device & 0xf000) != 0xc000)
+               return false;
 
-       /* EndRun device is all 0xexxx */
+       /* EndRun devices are all 0xExxx */
        if (dev->vendor == PCI_VENDOR_ID_ENDRUN &&
-               (dev->device & 0xf000) != 0xe000)
-               return 0;
-
-       p = pci_iomap(dev, 0, 5);
-       if (p == NULL)
-               return -ENOMEM;
+           (dev->device & 0xf000) != 0xe000)
+               return false;
 
-       deviceID = ioread32(p);
-       /* EndRun device */
-       if (deviceID == 0x07000200) {
-               number_uarts = ioread8(p + 4);
-               pci_dbg(dev, "%d ports detected on EndRun PCI Express device\n", number_uarts);
-       }
-       pci_iounmap(dev, p);
-       return number_uarts;
+       return true;
 }
 
 /*
- * Oxford Semiconductor Inc.
- * Check that device is part of the Tornado range of devices, then determine
- * the number of ports available on the device.
+ * Determine the number of ports available on a Tornado device.
  */
 static int pci_oxsemi_tornado_init(struct pci_dev *dev)
 {
@@ -1036,9 +1024,7 @@ static int pci_oxsemi_tornado_init(struct pci_dev *dev)
        unsigned long deviceID;
        unsigned int  number_uarts = 0;
 
-       /* OxSemi Tornado devices are all 0xCxxx */
-       if (dev->vendor == PCI_VENDOR_ID_OXSEMI &&
-           (dev->device & 0xF000) != 0xC000)
+       if (!pci_oxsemi_tornado_p(dev))
                return 0;
 
        p = pci_iomap(dev, 0, 5);
@@ -1049,7 +1035,10 @@ static int pci_oxsemi_tornado_init(struct pci_dev *dev)
        /* Tornado device */
        if (deviceID == 0x07000200) {
                number_uarts = ioread8(p + 4);
-               pci_dbg(dev, "%d ports detected on Oxford PCI Express device\n", number_uarts);
+               pci_dbg(dev, "%d ports detected on %s PCI Express device\n",
+                       number_uarts,
+                       dev->vendor == PCI_VENDOR_ID_ENDRUN ?
+                       "EndRun" : "Oxford");
        }
        pci_iounmap(dev, p);
        return number_uarts;
@@ -2244,7 +2233,7 @@ static struct pci_serial_quirk pci_serial_quirks[] = {
                .device         = PCI_ANY_ID,
                .subvendor      = PCI_ANY_ID,
                .subdevice      = PCI_ANY_ID,
-               .init           = pci_endrun_init,
+               .init           = pci_oxsemi_tornado_init,
                .setup          = pci_default_setup,
        },
        /*
@@ -2667,7 +2656,6 @@ enum pci_board_num_t {
        pbn_panacom2,
        pbn_panacom4,
        pbn_plx_romulus,
-       pbn_endrun_2_4000000,
        pbn_oxsemi,
        pbn_oxsemi_1_3906250,
        pbn_oxsemi_2_3906250,
@@ -3189,20 +3177,6 @@ static struct pciserial_board pci_boards[] = {
                .first_offset   = 0x03,
        },
 
-       /*
-        * EndRun Technologies
-       * Uses the size of PCI Base region 0 to
-       * signal now many ports are available
-       * 2 port 952 Uart support
-       */
-       [pbn_endrun_2_4000000] = {
-               .flags          = FL_BASE0,
-               .num_ports      = 2,
-               .base_baud      = 4000000,
-               .uart_offset    = 0x200,
-               .first_offset   = 0x1000,
-       },
-
        /*
         * This board uses the size of PCI Base region 0 to
         * signal now many ports are available
@@ -3518,6 +3492,12 @@ static struct pciserial_board pci_boards[] = {
        },
 };
 
+#define REPORT_CONFIG(option) \
+       (IS_ENABLED(CONFIG_##option) ? 0 : (kernel_ulong_t)&#option)
+#define REPORT_8250_CONFIG(option) \
+       (IS_ENABLED(CONFIG_SERIAL_8250_##option) ? \
+        0 : (kernel_ulong_t)&"SERIAL_8250_"#option)
+
 static const struct pci_device_id blacklist[] = {
        /* softmodems */
        { PCI_VDEVICE(AL, 0x5457), }, /* ALi Corporation M5457 AC'97 Modem */
@@ -3525,40 +3505,43 @@ static const struct pci_device_id blacklist[] = {
        { PCI_DEVICE(0x1543, 0x3052), }, /* Si3052-based modem, default IDs */
 
        /* multi-io cards handled by parport_serial */
-       { PCI_DEVICE(0x4348, 0x7053), }, /* WCH CH353 2S1P */
-       { PCI_DEVICE(0x4348, 0x5053), }, /* WCH CH353 1S1P */
-       { PCI_DEVICE(0x1c00, 0x3250), }, /* WCH CH382 2S1P */
+       /* WCH CH353 2S1P */
+       { PCI_DEVICE(0x4348, 0x7053), 0, 0, REPORT_CONFIG(PARPORT_SERIAL), },
+       /* WCH CH353 1S1P */
+       { PCI_DEVICE(0x4348, 0x5053), 0, 0, REPORT_CONFIG(PARPORT_SERIAL), },
+       /* WCH CH382 2S1P */
+       { PCI_DEVICE(0x1c00, 0x3250), 0, 0, REPORT_CONFIG(PARPORT_SERIAL), },
 
        /* Intel platforms with MID UART */
-       { PCI_VDEVICE(INTEL, 0x081b), },
-       { PCI_VDEVICE(INTEL, 0x081c), },
-       { PCI_VDEVICE(INTEL, 0x081d), },
-       { PCI_VDEVICE(INTEL, 0x1191), },
-       { PCI_VDEVICE(INTEL, 0x18d8), },
-       { PCI_VDEVICE(INTEL, 0x19d8), },
+       { PCI_VDEVICE(INTEL, 0x081b), REPORT_8250_CONFIG(MID), },
+       { PCI_VDEVICE(INTEL, 0x081c), REPORT_8250_CONFIG(MID), },
+       { PCI_VDEVICE(INTEL, 0x081d), REPORT_8250_CONFIG(MID), },
+       { PCI_VDEVICE(INTEL, 0x1191), REPORT_8250_CONFIG(MID), },
+       { PCI_VDEVICE(INTEL, 0x18d8), REPORT_8250_CONFIG(MID), },
+       { PCI_VDEVICE(INTEL, 0x19d8), REPORT_8250_CONFIG(MID), },
 
        /* Intel platforms with DesignWare UART */
-       { PCI_VDEVICE(INTEL, 0x0936), },
-       { PCI_VDEVICE(INTEL, 0x0f0a), },
-       { PCI_VDEVICE(INTEL, 0x0f0c), },
-       { PCI_VDEVICE(INTEL, 0x228a), },
-       { PCI_VDEVICE(INTEL, 0x228c), },
-       { PCI_VDEVICE(INTEL, 0x4b96), },
-       { PCI_VDEVICE(INTEL, 0x4b97), },
-       { PCI_VDEVICE(INTEL, 0x4b98), },
-       { PCI_VDEVICE(INTEL, 0x4b99), },
-       { PCI_VDEVICE(INTEL, 0x4b9a), },
-       { PCI_VDEVICE(INTEL, 0x4b9b), },
-       { PCI_VDEVICE(INTEL, 0x9ce3), },
-       { PCI_VDEVICE(INTEL, 0x9ce4), },
+       { PCI_VDEVICE(INTEL, 0x0936), REPORT_8250_CONFIG(LPSS), },
+       { PCI_VDEVICE(INTEL, 0x0f0a), REPORT_8250_CONFIG(LPSS), },
+       { PCI_VDEVICE(INTEL, 0x0f0c), REPORT_8250_CONFIG(LPSS), },
+       { PCI_VDEVICE(INTEL, 0x228a), REPORT_8250_CONFIG(LPSS), },
+       { PCI_VDEVICE(INTEL, 0x228c), REPORT_8250_CONFIG(LPSS), },
+       { PCI_VDEVICE(INTEL, 0x4b96), REPORT_8250_CONFIG(LPSS), },
+       { PCI_VDEVICE(INTEL, 0x4b97), REPORT_8250_CONFIG(LPSS), },
+       { PCI_VDEVICE(INTEL, 0x4b98), REPORT_8250_CONFIG(LPSS), },
+       { PCI_VDEVICE(INTEL, 0x4b99), REPORT_8250_CONFIG(LPSS), },
+       { PCI_VDEVICE(INTEL, 0x4b9a), REPORT_8250_CONFIG(LPSS), },
+       { PCI_VDEVICE(INTEL, 0x4b9b), REPORT_8250_CONFIG(LPSS), },
+       { PCI_VDEVICE(INTEL, 0x9ce3), REPORT_8250_CONFIG(LPSS), },
+       { PCI_VDEVICE(INTEL, 0x9ce4), REPORT_8250_CONFIG(LPSS), },
 
        /* Exar devices */
-       { PCI_VDEVICE(EXAR, PCI_ANY_ID), },
-       { PCI_VDEVICE(COMMTECH, PCI_ANY_ID), },
+       { PCI_VDEVICE(EXAR, PCI_ANY_ID), REPORT_8250_CONFIG(EXAR), },
+       { PCI_VDEVICE(COMMTECH, PCI_ANY_ID), REPORT_8250_CONFIG(EXAR), },
 
        /* Pericom devices */
-       { PCI_VDEVICE(PERICOM, PCI_ANY_ID), },
-       { PCI_VDEVICE(ACCESSIO, PCI_ANY_ID), },
+       { PCI_VDEVICE(PERICOM, PCI_ANY_ID), REPORT_8250_CONFIG(PERICOM), },
+       { PCI_VDEVICE(ACCESSIO, PCI_ANY_ID), REPORT_8250_CONFIG(PERICOM), },
 
        /* End of the black list */
        { }
@@ -3840,8 +3823,12 @@ pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
        board = &pci_boards[ent->driver_data];
 
        exclude = pci_match_id(blacklist, dev);
-       if (exclude)
+       if (exclude) {
+               if (exclude->driver_data)
+                       pci_warn(dev, "ignoring port, enable %s to handle\n",
+                                (const char *)exclude->driver_data);
                return -ENODEV;
+       }
 
        rc = pcim_enable_device(dev);
        pci_save_state(dev);
@@ -4109,13 +4096,6 @@ static const struct pci_device_id serial_pci_tbl[] = {
        {       PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_ROMULUS,
                0x10b5, 0x106a, 0, 0,
                pbn_plx_romulus },
-       /*
-       * EndRun Technologies. PCI express device range.
-       *    EndRun PTP/1588 has 2 Native UARTs.
-       */
-       {       PCI_VENDOR_ID_ENDRUN, PCI_DEVICE_ID_ENDRUN_1588,
-               PCI_ANY_ID, PCI_ANY_ID, 0, 0,
-               pbn_endrun_2_4000000 },
        /*
         * Quatech cards. These actually have configurable clocks but for
         * now we just use the default.
@@ -4377,6 +4357,13 @@ static const struct pci_device_id serial_pci_tbl[] = {
        {       PCI_VENDOR_ID_DIGI, PCIE_DEVICE_ID_NEO_2_OX_IBM,
                PCI_SUBVENDOR_ID_IBM, PCI_ANY_ID, 0, 0,
                pbn_oxsemi_2_3906250 },
+       /*
+        * EndRun Technologies. PCI express device range.
+        * EndRun PTP/1588 has 2 Native UARTs utilizing OxSemi 952.
+        */
+       {       PCI_VENDOR_ID_ENDRUN, PCI_DEVICE_ID_ENDRUN_1588,
+               PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+               pbn_oxsemi_2_3906250 },
 
        /*
         * SBS Technologies, Inc. P-Octal and PMC-OCTPRO cards,