These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / comedi / drivers / pcl816.c
index 1ccb2f1..c00a71f 100644 (file)
@@ -1,36 +1,33 @@
 /*
-   comedi/drivers/pcl816.c
-
-   Author:  Juan Grigera <juan@grigera.com.ar>
-           based on pcl818 by Michal Dobes <dobes@tesnet.cz> and bits of pcl812
+ * pcl816.c
+ * Comedi driver for Advantech PCL-816 cards
+ *
+ * Author:  Juan Grigera <juan@grigera.com.ar>
+ * based on pcl818 by Michal Dobes <dobes@tesnet.cz> and bits of pcl812
+ */
 
-   hardware driver for Advantech cards:
-    card:   PCL-816, PCL814B
-    driver: pcl816
-*/
 /*
-Driver: pcl816
-Description: Advantech PCL-816 cards, PCL-814
-Author: Juan Grigera <juan@grigera.com.ar>
-Devices: [Advantech] PCL-816 (pcl816), PCL-814B (pcl814b)
-Status: works
-Updated: Tue,  2 Apr 2002 23:15:21 -0800
-
-PCL 816 and 814B have 16 SE/DIFF ADCs, 16 DACs, 16 DI and 16 DO.
-Differences are at resolution (16 vs 12 bits).
-
-The driver support AI command mode, other subdevices not written.
-
-Analog output and digital input and output are not supported.
-
-Configuration Options:
-  [0] - IO Base
-  [1] - IRQ    (0=disable, 2, 3, 4, 5, 6, 7)
-  [2] - DMA    (0=disable, 1, 3)
-  [3] - 0, 10=10MHz clock for 8254
-           1= 1MHz clock for 8254
-
-*/
+ * Driver: pcl816
+ * Description: Advantech PCL-816 cards, PCL-814
+ * Devices: [Advantech] PCL-816 (pcl816), PCL-814B (pcl814b)
+ * Author: Juan Grigera <juan@grigera.com.ar>
+ * Status: works
+ * Updated: Tue,  2 Apr 2002 23:15:21 -0800
+ *
+ * PCL 816 and 814B have 16 SE/DIFF ADCs, 16 DACs, 16 DI and 16 DO.
+ * Differences are at resolution (16 vs 12 bits).
+ *
+ * The driver support AI command mode, other subdevices not written.
+ *
+ * Analog output and digital input and output are not supported.
+ *
+ * Configuration Options:
+ *   [0] - IO Base
+ *   [1] - IRQ (0=disable, 2, 3, 4, 5, 6, 7)
+ *   [2] - DMA (0=disable, 1, 3)
+ *   [3] - 0, 10=10MHz clock for 8254
+ *            1= 1MHz clock for 8254
+ */
 
 #include <linux/module.h>
 #include <linux/gfp.h>
@@ -56,25 +53,20 @@ Configuration Options:
 #define PCL816_MUX_REG                         0x0b
 #define PCL816_MUX_SCAN(_first, _last)         (((_last) << 4) | (_first))
 #define PCL816_CTRL_REG                                0x0c
-#define PCL816_CTRL_DISABLE_TRIG               (0 << 0)
-#define PCL816_CTRL_SOFT_TRIG                  (1 << 0)
-#define PCL816_CTRL_PACER_TRIG                 (1 << 1)
-#define PCL816_CTRL_EXT_TRIG                   (1 << 2)
-#define PCL816_CTRL_POE                                (1 << 3)
-#define PCL816_CTRL_DMAEN                      (1 << 4)
-#define PCL816_CTRL_INTEN                      (1 << 5)
-#define PCL816_CTRL_DMASRC_SLOT0               (0 << 6)
-#define PCL816_CTRL_DMASRC_SLOT1               (1 << 6)
-#define PCL816_CTRL_DMASRC_SLOT2               (2 << 6)
+#define PCL816_CTRL_SOFT_TRIG                  BIT(0)
+#define PCL816_CTRL_PACER_TRIG                 BIT(1)
+#define PCL816_CTRL_EXT_TRIG                   BIT(2)
+#define PCL816_CTRL_POE                                BIT(3)
+#define PCL816_CTRL_DMAEN                      BIT(4)
+#define PCL816_CTRL_INTEN                      BIT(5)
+#define PCL816_CTRL_DMASRC_SLOT(x)             (((x) & 0x3) << 6)
 #define PCL816_STATUS_REG                      0x0d
 #define PCL816_STATUS_NEXT_CHAN_MASK           (0xf << 0)
-#define PCL816_STATUS_INTSRC_MASK              (3 << 4)
-#define PCL816_STATUS_INTSRC_SLOT0             (0 << 4)
-#define PCL816_STATUS_INTSRC_SLOT1             (1 << 4)
-#define PCL816_STATUS_INTSRC_SLOT2             (2 << 4)
-#define PCL816_STATUS_INTSRC_DMA               (3 << 4)
-#define PCL816_STATUS_INTACT                   (1 << 6)
-#define PCL816_STATUS_DRDY                     (1 << 7)
+#define PCL816_STATUS_INTSRC_SLOT(x)           (((x) & 0x3) << 4)
+#define PCL816_STATUS_INTSRC_DMA               PCL816_STATUS_INTSRC_SLOT(3)
+#define PCL816_STATUS_INTSRC_MASK              PCL816_STATUS_INTSRC_SLOT(3)
+#define PCL816_STATUS_INTACT                   BIT(6)
+#define PCL816_STATUS_DRDY                     BIT(7)
 
 #define MAGIC_DMA_WORD 0x5a5a
 
@@ -94,7 +86,6 @@ static const struct comedi_lrange range_pcl816 = {
 struct pcl816_board {
        const char *name;
        int ai_maxdata;
-       int ao_maxdata;
        int ai_chanlist;
 };
 
@@ -102,12 +93,10 @@ static const struct pcl816_board boardtypes[] = {
        {
                .name           = "pcl816",
                .ai_maxdata     = 0xffff,
-               .ao_maxdata     = 0xffff,
                .ai_chanlist    = 1024,
        }, {
                .name           = "pcl814b",
                .ai_maxdata     = 0x3fff,
-               .ao_maxdata     = 0x3fff,
                .ai_chanlist    = 1024,
        },
 };
@@ -305,7 +294,7 @@ static int check_channel_list(struct comedi_device *dev,
                chansegment[0] = chanlist[0];
                for (i = 1, seglen = 1; i < chanlen; i++, seglen++) {
                        /*  we detect loop, this must by finish */
-                           if (chanlist[0] == chanlist[i])
+                       if (chanlist[0] == chanlist[i])
                                break;
                        nowmustbechan =
                            (CR_CHAN(chansegment[i - 1]) + 1) % chanlen;
@@ -323,7 +312,7 @@ static int check_channel_list(struct comedi_device *dev,
 
                /*  check whole chanlist */
                for (i = 0, segpos = 0; i < chanlen; i++) {
-                           if (chanlist[i] != chansegment[i % seglen]) {
+                       if (chanlist[i] != chansegment[i % seglen]) {
                                dev_dbg(dev->class_dev,
                                        "bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n",
                                        i, CR_CHAN(chansegment[i]),
@@ -443,7 +432,8 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        comedi_8254_update_divisors(dev->pacer);
        comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
 
-       ctrl = PCL816_CTRL_INTEN | PCL816_CTRL_DMAEN | PCL816_CTRL_DMASRC_SLOT0;
+       ctrl = PCL816_CTRL_INTEN | PCL816_CTRL_DMAEN |
+              PCL816_CTRL_DMASRC_SLOT(0);
        if (cmd->convert_src == TRIG_TIMER)
                ctrl |= PCL816_CTRL_PACER_TRIG;
        else    /* TRIG_EXT */
@@ -497,7 +487,7 @@ static int pcl816_ai_cancel(struct comedi_device *dev,
        if (!devpriv->ai_cmd_running)
                return 0;
 
-       outb(PCL816_CTRL_DISABLE_TRIG, dev->iobase + PCL816_CTRL_REG);
+       outb(0, dev->iobase + PCL816_CTRL_REG);
        pcl816_ai_clear_eoc(dev);
 
        comedi_8254_pacer_enable(dev->pacer, 1, 2, false);
@@ -533,7 +523,7 @@ static int pcl816_ai_insn_read(struct comedi_device *dev,
 
                data[i] = pcl816_ai_get_sample(dev, s);
        }
-       outb(PCL816_CTRL_DISABLE_TRIG, dev->iobase + PCL816_CTRL_REG);
+       outb(0, dev->iobase + PCL816_CTRL_REG);
        pcl816_ai_clear_eoc(dev);
 
        return ret ? ret : insn->n;
@@ -567,7 +557,7 @@ static int pcl816_do_insn_bits(struct comedi_device *dev,
 
 static void pcl816_reset(struct comedi_device *dev)
 {
-       outb(PCL816_CTRL_DISABLE_TRIG, dev->iobase + PCL816_CTRL_REG);
+       outb(0, dev->iobase + PCL816_CTRL_REG);
        pcl816_ai_set_chan_range(dev, 0, 0);
        pcl816_ai_clear_eoc(dev);
 
@@ -652,16 +642,9 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                s->cancel       = pcl816_ai_cancel;
        }
 
-       /* Analog OUtput subdevice */
-       s = &dev->subdevices[2];
+       /* Piggyback Slot1 subdevice */
+       s = &dev->subdevices[1];
        s->type         = COMEDI_SUBD_UNUSED;
-#if 0
-       subdevs[1] = COMEDI_SUBD_AO;
-       s->subdev_flags = SDF_WRITABLE | SDF_GROUND;
-       s->n_chan = 1;
-       s->maxdata = board->ao_maxdata;
-       s->range_table = &range_pcl816;
-#endif
 
        /* Digital Input subdevice */
        s = &dev->subdevices[2];