]> Pileus Git - ~andy/linux/commitdiff
staging: comedi: 8255_pci: move ni_pcidio 8255 board support
authorH Hartley Sweeten <hartleys@visionengravers.com>
Thu, 13 Sep 2012 17:24:00 +0000 (10:24 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Sep 2012 03:13:03 +0000 (20:13 -0700)
The 8255 based boards in the ni_pcidio driver are all simple
memory mapped 8255 boards that don't require the dma support
provided by the mite driver.

Move the support for these boards from the ni_pcidio driver to
the generic 8255_pci driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/Kconfig
drivers/staging/comedi/drivers/8255_pci.c
drivers/staging/comedi/drivers/ni_pcidio.c

index 3f67b98f755845522aa5bf82200984307a2cd3af..2093403af2537e87e14ce18a463c92bd871fa6d1 100644 (file)
@@ -560,6 +560,8 @@ config COMEDI_8255_PCI
            ADlink - PCI-7224, PCI-7248, and PCI-7296
            Measurement Computing - PCI-DIO24, PCI-DIO24H, PCI-DIO48H and
                                    PCI-DIO96H
+           National Instruments - PCI-DIO-96, PCI-DIO-96B, PXI-6508, PCI-6503,
+                                  PCI-6503B, PCI-6503X, and PXI-6503
 
          To compile this driver as a module, choose M here: the module will
          be called 8255_pci.
@@ -1030,15 +1032,12 @@ config COMEDI_NI_LABPC
          called ni_labpc.
 
 config COMEDI_NI_PCIDIO
-       tristate "NI PCI-DIO32HS, PCI-DIO96, PCI-6533, PCI-6503 support"
+       tristate "NI PCI-DIO32HS, PCI-6533, PCI-6534 support"
        select COMEDI_MITE
        select COMEDI_8255
        ---help---
          Enable support for National Instruments PCI-DIO-32HS, PXI-6533,
-         PCI-DIO-96, PCI-DIO-96B, PXI-6508, PCI-6503, PCI-6503B, PCI-6503X,
-         PXI-6503, PCI-6533 and PCI-6534
-         The DIO-96 appears as four 8255 subdevices. See the 8255
-         driver notes for details.
+         PCI-6533 and PCI-6534
 
          To compile this driver as a module, choose M here: the module will be
          called ni_pcidio.
index 93990fabd1257a7a4021c86a0be6073c56baf751..7dff3c01dc29ef3286d5559065a1c2c9e52819d5 100644 (file)
@@ -35,6 +35,13 @@ Devices: (ADLink) PCI-7224 [adl_pci-7224] - 24 channels
         (Measurement Computing) PCI-DIO24H [cb_pci-dio24h] - 24 channels
         (Measurement Computing) PCI-DIO48H [cb_pci-dio48h] - 48 channels
         (Measurement Computing) PCI-DIO96H [cb_pci-dio96h] - 96 channels
+        (National Instruments) PCI-DIO-96 [ni_pci-dio-96] - 96 channels
+        (National Instruments) PCI-DIO-96B [ni_pci-dio-96b] - 96 channels
+        (National Instruments) PXI-6508 [ni_pxi-6508] - 96 channels
+        (National Instruments) PCI-6503 [ni_pci-6503] - 24 channels
+        (National Instruments) PCI-6503B [ni_pci-6503b] - 24 channels
+        (National Instruments) PCI-6503X [ni_pci-6503x] - 24 channels
+        (National Instruments) PXI-6503 [ni_pxi-6503] - 24 channels
 Author: H Hartley Sweeten <hsweeten@visionengravers.com>
 Updated: Wed, 12 Sep 2012 11:52:01 -0700
 Status: untested
@@ -66,6 +73,14 @@ Configuration Options: not applicable, uses PCI auto config
 #define PCI_DEVICE_ID_CB_PCIDIO96H     0x0017
 #define PCI_DEVICE_ID_CB_PCIDIO24      0x0028
 
+#define PCI_DEVICE_ID_NI_PCIDIO96      0x0160
+#define PCI_DEVICE_ID_NI_PCI6503       0x0400
+#define PCI_DEVICE_ID_NI_PCI6503B      0x1250
+#define PCI_DEVICE_ID_NI_PXI6508       0x13c0
+#define PCI_DEVICE_ID_NI_PCIDIO96B     0x1630
+#define PCI_DEVICE_ID_NI_PCI6503X      0x17d0
+#define PCI_DEVICE_ID_NI_PXI_6503      0x1800
+
 struct pci_8255_boardinfo {
        const char *name;
        unsigned short vendor;
@@ -118,6 +133,55 @@ static const struct pci_8255_boardinfo pci_8255_boards[] = {
                .device         = PCI_DEVICE_ID_CB_PCIDIO96H,
                .dio_badr       = 2,
                .n_8255         = 4,
+       }, {
+               .name           = "ni_pci-dio-96",
+               .vendor         = PCI_VENDOR_ID_NI,
+               .device         = PCI_DEVICE_ID_NI_PCIDIO96,
+               .dio_badr       = 1,
+               .is_mmio        = 1,
+               .n_8255         = 4,
+       }, {
+               .name           = "ni_pci-dio-96b",
+               .vendor         = PCI_VENDOR_ID_NI,
+               .device         = PCI_DEVICE_ID_NI_PCIDIO96B,
+               .dio_badr       = 1,
+               .is_mmio        = 1,
+               .n_8255         = 4,
+       }, {
+               .name           = "ni_pxi-6508",
+               .vendor         = PCI_VENDOR_ID_NI,
+               .device         = PCI_DEVICE_ID_NI_PXI6508,
+               .dio_badr       = 1,
+               .is_mmio        = 1,
+               .n_8255         = 4,
+       }, {
+               .name           = "ni_pci-6503",
+               .vendor         = PCI_VENDOR_ID_NI,
+               .device         = PCI_DEVICE_ID_NI_PCI6503,
+               .dio_badr       = 1,
+               .is_mmio        = 1,
+               .n_8255         = 1,
+       }, {
+               .name           = "ni_pci-6503b",
+               .vendor         = PCI_VENDOR_ID_NI,
+               .device         = PCI_DEVICE_ID_NI_PCI6503B,
+               .dio_badr       = 1,
+               .is_mmio        = 1,
+               .n_8255         = 1,
+       }, {
+               .name           = "ni_pci-6503x",
+               .vendor         = PCI_VENDOR_ID_NI,
+               .device         = PCI_DEVICE_ID_NI_PCI6503X,
+               .dio_badr       = 1,
+               .is_mmio        = 1,
+               .n_8255         = 1,
+       }, {
+               .name           = "ni_pxi-6503",
+               .vendor         = PCI_VENDOR_ID_NI,
+               .device         = PCI_DEVICE_ID_NI_PXI_6503,
+               .dio_badr       = 1,
+               .is_mmio        = 1,
+               .n_8255         = 1,
        },
 };
 
@@ -265,6 +329,13 @@ static DEFINE_PCI_DEVICE_TABLE(pci_8255_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_CB_PCIDIO24H) },
        { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_CB_PCIDIO48H) },
        { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_CB_PCIDIO96H) },
+       { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PCIDIO96) },
+       { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PCIDIO96B) },
+       { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PXI6508) },
+       { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PCI6503) },
+       { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PCI6503B) },
+       { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PCI6503X) },
+       { PCI_DEVICE(PCI_VENDOR_ID_NI, PCI_DEVICE_ID_NI_PXI_6503) },
        { 0 }
 };
 MODULE_DEVICE_TABLE(pci, pci_8255_pci_table);
index a83f52517567a2d486264eed62ac7cfaf08410ff..0f8650681ee9325e5347feeefa300bc2dbbbf4a1 100644 (file)
@@ -1,8 +1,6 @@
 /*
     comedi/drivers/ni_pcidio.c
-    driver for National Instruments PCI-DIO-96/PCI-6508
-               National Instruments PCI-DIO-32HS
-               National Instruments PCI-6503
+    driver for National Instruments PCI-DIO-32HS
 
     COMEDI - Linux Control and Measurement Device Interface
     Copyright (C) 1999,2002 David A. Schleef <ds@schleef.org>
 */
 /*
 Driver: ni_pcidio
-Description: National Instruments PCI-DIO32HS, PCI-DIO96, PCI-6533, PCI-6503
+Description: National Instruments PCI-DIO32HS, PCI-6533
 Author: ds
 Status: works
-Devices: [National Instruments] PCI-DIO-32HS (ni_pcidio), PXI-6533,
-  PCI-DIO-96, PCI-DIO-96B, PXI-6508, PCI-6503, PCI-6503B, PCI-6503X,
-  PXI-6503, PCI-6533, PCI-6534
+Devices: [National Instruments] PCI-DIO-32HS (ni_pcidio)
+        [National Instruments] PXI-6533, PCI-6533 (pxi-6533)
+        [National Instruments] PCI-6534 (pci-6534)
 Updated: Mon, 09 Jan 2012 14:27:23 +0000
 
-The DIO-96 appears as four 8255 subdevices.  See the 8255
-driver notes for details.
-
 The DIO32HS board appears as one subdevice, with 32 channels.
 Each channel is individually I/O configurable.  The channel order
 is 0=A0, 1=A1, 2=A2, ... 8=B0, 16=C0, 24=D0.  The driver only
@@ -56,20 +51,6 @@ it are contained in the
 comedi_nonfree_firmware tarball available from http://www.comedi.org
 */
 
-/*
-   This driver is for both the NI PCI-DIO-32HS and the PCI-DIO-96,
-   which have very different architectures.  But, since the '96 is
-   so simple, it is included here.
-
-   Manuals (available from ftp://ftp.natinst.com/support/manuals)
-
-       320938c.pdf     PCI-DIO-96/PXI-6508/PCI-6503 User Manual
-       321464b.pdf     AT/PCI-DIO-32HS User Manual
-       341329A.pdf     PCI-6533 Register-Level Programmer Manual
-       341330A.pdf     DAQ-DIO Technical Reference Manual
-
- */
-
 #define USE_DMA
 /* #define DEBUG 1 */
 /* #define DEBUG_FLAGS */
@@ -79,7 +60,6 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org
 #include "../comedidev.h"
 
 #include "mite.h"
-#include "8255.h"
 
 #undef DPRINTK
 #ifdef DEBUG
@@ -91,14 +71,6 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org
 #define PCI_DIO_SIZE 4096
 #define PCI_MITE_SIZE 4096
 
-/* defines for the PCI-DIO-96 */
-
-#define NIDIO_8255_BASE(x)     ((x)*4)
-#define NIDIO_A 0
-#define NIDIO_B 4
-#define NIDIO_C 8
-#define NIDIO_D 12
-
 /* defines for the PCI-DIO-32HS */
 
 #define Window_Address                 4       /* W */
@@ -297,76 +269,23 @@ static int ni_pcidio_cancel(struct comedi_device *dev,
                            struct comedi_subdevice *s);
 
 struct nidio_board {
-
        int dev_id;
        const char *name;
-       int n_8255;
-       unsigned int is_diodaq:1;
        unsigned int uses_firmware:1;
 };
 
 static const struct nidio_board nidio_boards[] = {
        {
-        .dev_id = 0x1150,
-        .name = "pci-dio-32hs",
-        .n_8255 = 0,
-        .is_diodaq = 1,
-        },
-       {
-        .dev_id = 0x1320,
-        .name = "pxi-6533",
-        .n_8255 = 0,
-        .is_diodaq = 1,
-        },
-       {
-        .dev_id = 0x12b0,
-        .name = "pci-6534",
-        .n_8255 = 0,
-        .is_diodaq = 1,
-        .uses_firmware = 1,
-        },
-       {
-        .dev_id = 0x0160,
-        .name = "pci-dio-96",
-        .n_8255 = 4,
-        .is_diodaq = 0,
-        },
-       {
-        .dev_id = 0x1630,
-        .name = "pci-dio-96b",
-        .n_8255 = 4,
-        .is_diodaq = 0,
-        },
-       {
-        .dev_id = 0x13c0,
-        .name = "pxi-6508",
-        .n_8255 = 4,
-        .is_diodaq = 0,
-        },
-       {
-        .dev_id = 0x0400,
-        .name = "pci-6503",
-        .n_8255 = 1,
-        .is_diodaq = 0,
-        },
-       {
-        .dev_id = 0x1250,
-        .name = "pci-6503b",
-        .n_8255 = 1,
-        .is_diodaq = 0,
-        },
-       {
-        .dev_id = 0x17d0,
-        .name = "pci-6503x",
-        .n_8255 = 1,
-        .is_diodaq = 0,
-        },
-       {
-        .dev_id = 0x1800,
-        .name = "pxi-6503",
-        .n_8255 = 1,
-        .is_diodaq = 0,
-        },
+               .dev_id         = 0x1150,
+               .name           = "pci-dio-32hs",
+       }, {
+               .dev_id         = 0x1320,
+               .name           = "pxi-6533",
+       }, {
+               .dev_id         = 0x12b0,
+               .name           = "pci-6534",
+               .uses_firmware  = 1,
+       },
 };
 
 #define n_nidio_boards ARRAY_SIZE(nidio_boards)
@@ -442,16 +361,6 @@ static void ni_pcidio_release_di_mite_channel(struct comedi_device *dev)
        spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
 }
 
-static int nidio96_8255_cb(int dir, int port, int data, unsigned long iobase)
-{
-       if (dir) {
-               writeb(data, (void *)(iobase + port));
-               return 0;
-       } else {
-               return readb((void *)(iobase + port));
-       }
-}
-
 void ni_pcidio_event(struct comedi_device *dev, struct comedi_subdevice *s)
 {
        if (s->
@@ -1207,9 +1116,7 @@ static int nidio_find_device(struct comedi_device *dev, int bus, int slot)
 static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
        struct comedi_subdevice *s;
-       int i;
        int ret;
-       int n_subdevices;
        unsigned int irq;
 
        printk(KERN_INFO "comedi%d: nidio:", dev->minor);
@@ -1241,64 +1148,49 @@ static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                if (ret < 0)
                        return ret;
        }
-       if (!this_board->is_diodaq)
-               n_subdevices = this_board->n_8255;
-       else
-               n_subdevices = 1;
 
-       ret = comedi_alloc_subdevices(dev, n_subdevices);
+       ret = comedi_alloc_subdevices(dev, 1);
        if (ret)
                return ret;
 
-       if (!this_board->is_diodaq) {
-               for (i = 0; i < this_board->n_8255; i++) {
-                       s = &dev->subdevices[i];
-                       subdev_8255_init(dev, s, nidio96_8255_cb,
-                                        (unsigned long)(devpriv->mite->
-                                                        daq_io_addr +
-                                                        NIDIO_8255_BASE(i)));
-               }
-       } else {
-
-               printk(KERN_INFO " rev=%d",
-                      readb(devpriv->mite->daq_io_addr + Chip_Version));
-
-               s = &dev->subdevices[0];
-
-               dev->read_subdev = s;
-               s->type = COMEDI_SUBD_DIO;
-               s->subdev_flags =
-                   SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL | SDF_PACKED |
-                   SDF_CMD_READ;
-               s->n_chan = 32;
-               s->range_table = &range_digital;
-               s->maxdata = 1;
-               s->insn_config = &ni_pcidio_insn_config;
-               s->insn_bits = &ni_pcidio_insn_bits;
-               s->do_cmd = &ni_pcidio_cmd;
-               s->do_cmdtest = &ni_pcidio_cmdtest;
-               s->cancel = &ni_pcidio_cancel;
-               s->len_chanlist = 32;   /* XXX */
-               s->buf_change = &ni_pcidio_change;
-               s->async_dma_dir = DMA_BIDIRECTIONAL;
-               s->poll = &ni_pcidio_poll;
-
-               writel(0, devpriv->mite->daq_io_addr + Port_IO(0));
-               writel(0, devpriv->mite->daq_io_addr + Port_Pin_Directions(0));
-               writel(0, devpriv->mite->daq_io_addr + Port_Pin_Mask(0));
-
-               /* disable interrupts on board */
-               writeb(0x00,
-                      devpriv->mite->daq_io_addr +
-                      Master_DMA_And_Interrupt_Control);
+       printk(KERN_INFO " rev=%d",
+               readb(devpriv->mite->daq_io_addr + Chip_Version));
+
+       s = &dev->subdevices[0];
+
+       dev->read_subdev = s;
+       s->type = COMEDI_SUBD_DIO;
+       s->subdev_flags =
+               SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL | SDF_PACKED |
+               SDF_CMD_READ;
+       s->n_chan = 32;
+       s->range_table = &range_digital;
+       s->maxdata = 1;
+       s->insn_config = &ni_pcidio_insn_config;
+       s->insn_bits = &ni_pcidio_insn_bits;
+       s->do_cmd = &ni_pcidio_cmd;
+       s->do_cmdtest = &ni_pcidio_cmdtest;
+       s->cancel = &ni_pcidio_cancel;
+       s->len_chanlist = 32;   /* XXX */
+       s->buf_change = &ni_pcidio_change;
+       s->async_dma_dir = DMA_BIDIRECTIONAL;
+       s->poll = &ni_pcidio_poll;
+
+       writel(0, devpriv->mite->daq_io_addr + Port_IO(0));
+       writel(0, devpriv->mite->daq_io_addr + Port_Pin_Directions(0));
+       writel(0, devpriv->mite->daq_io_addr + Port_Pin_Mask(0));
+
+       /* disable interrupts on board */
+       writeb(0x00,
+               devpriv->mite->daq_io_addr +
+               Master_DMA_And_Interrupt_Control);
 
-               ret = request_irq(irq, nidio_interrupt, IRQF_SHARED,
-                                 "ni_pcidio", dev);
-               if (ret < 0)
-                       printk(KERN_WARNING " irq not available");
+       ret = request_irq(irq, nidio_interrupt, IRQF_SHARED,
+                               "ni_pcidio", dev);
+       if (ret < 0)
+               printk(KERN_WARNING " irq not available");
 
-               dev->irq = irq;
-       }
+       dev->irq = irq;
 
        printk("\n");
 
@@ -1307,15 +1199,6 @@ static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
 static void nidio_detach(struct comedi_device *dev)
 {
-       struct comedi_subdevice *s;
-       int i;
-
-       if (this_board && !this_board->is_diodaq) {
-               for (i = 0; i < this_board->n_8255; i++) {
-                       s = &dev->subdevices[i];
-                       subdev_8255_cleanup(dev, s);
-               }
-       }
        if (dev->irq)
                free_irq(dev->irq, dev);
        if (devpriv) {
@@ -1350,13 +1233,6 @@ static DEFINE_PCI_DEVICE_TABLE(ni_pcidio_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1150) },
        { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1320) },
        { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x12b0) },
-       { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0160) },
-       { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1630) },
-       { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x13c0) },
-       { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0400) },
-       { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1250) },
-       { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x17d0) },
-       { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1800) },
        { 0 }
 };
 MODULE_DEVICE_TABLE(pci, ni_pcidio_pci_table);