]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
staging: comedi: ni_pcidio: Support trailing edge external trigger
authorIan Abbott <abbotti@mev.co.uk>
Mon, 9 Jan 2012 15:47:33 +0000 (15:47 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2012 18:02:21 +0000 (10:02 -0800)
This patch is ported over by me (Ian Abbott) from the out-of-tree Comedi
git repository at "git://comedi.org/git/comedi/comedi.git".

The original patch is by Nicholas Nell.

The patch adds support for trailing (falling) edge external triggers for
scans in asynchronous command support in the ni_pcidio driver.  This is
supported at least on the PCI-DIO_32HS and PCI-6533 boards; not sure
about the other boards.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: Nicholas Nell <nicholas.nell@colorado.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/ni_pcidio.c

index 88728bdf2c654ec8e00e93ac5f33543cb05810b9..1df8fcbcd108bbd807cc1eab39e26b844e98ec37 100644 (file)
@@ -30,7 +30,7 @@ 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
-Updated: Sun, 21 Apr 2002 21:03:38 -0700
+Updated: Mon, 09 Jan 2012 14:27:23 +0000
 
 The DIO-96 appears as four 8255 subdevices.  See the 8255
 driver notes for details.
@@ -42,6 +42,11 @@ supports simple digital I/O; no handshaking is supported.
 
 DMA mostly works for the PCI-DIO32HS, but only in timed input mode.
 
+The PCI-DIO-32HS/PCI-6533 has a configurable external trigger. Setting
+scan_begin_arg to 0 or CR_EDGE triggers on the leading edge. Setting
+scan_begin_arg to CR_INVERT or (CR_EDGE | CR_INVERT) triggers on the
+trailing edge.
+
 This driver could be easily modified to support AT-MIO32HS and
 AT-MIO96.
 
@@ -845,8 +850,8 @@ static int ni_pcidio_cmdtest(struct comedi_device *dev,
        } else {
                /* TRIG_EXT */
                /* should be level/edge, hi/lo specification here */
-               if (cmd->scan_begin_arg != 0) {
-                       cmd->scan_begin_arg = 0;
+               if ((cmd->scan_begin_arg & ~(CR_EDGE | CR_INVERT)) != 0) {
+                       cmd->scan_begin_arg &= (CR_EDGE | CR_INVERT);
                        err++;
                }
        }
@@ -961,7 +966,13 @@ static int ni_pcidio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                writeb(0, devpriv->mite->daq_io_addr + Sequence);
                writeb(0x00, devpriv->mite->daq_io_addr + ReqReg);
                writeb(4, devpriv->mite->daq_io_addr + BlockMode);
-               writeb(0, devpriv->mite->daq_io_addr + LinePolarities);
+               if (!(cmd->scan_begin_arg & CR_INVERT)) {
+                       /* Leading Edge pulse mode */
+                       writeb(0, devpriv->mite->daq_io_addr + LinePolarities);
+               } else {
+                       /* Trailing Edge pulse mode */
+                       writeb(2, devpriv->mite->daq_io_addr + LinePolarities);
+               }
                writeb(0x00, devpriv->mite->daq_io_addr + AckSer);
                writel(1, devpriv->mite->daq_io_addr + StartDelay);
                writeb(1, devpriv->mite->daq_io_addr + ReqDelay);