[PATCH 7/8] staging: comedi: adv_pci1710: disable synchronous mode after pci1720 reset

H Hartley Sweeten hsweeten at visionengravers.com
Fri Jun 20 19:01:59 UTC 2014


The PCI-1720 board can be configured to store the value for the analog channels
then simultaneously update each of the channels by writing to a 'sync output'
register. This mode is enabled in the reset function so that the four channels
are reset to 0V at the same time. This mode is never cleared so the (*insn_write)
has to write to the 'sync output' register for each write to a channel.

Simplify the (*insn_write) a bit by disabling the synchronous output mode after
the channels are reset. The analog outputs are then updated immediately after
writing to the data registers.

For aesthetics, redefine the register map for the effected registers.

Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Cc: Ian Abbott <abbotti at mev.co.uk>
Cc: Greg Kroah-Hartman <gregk at linuxfoundation.org>
---
 drivers/staging/comedi/drivers/adv_pci1710.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c
index 6229983..63f643b 100644
--- a/drivers/staging/comedi/drivers/adv_pci1710.c
+++ b/drivers/staging/comedi/drivers/adv_pci1710.c
@@ -107,11 +107,9 @@ Configuration options:
 
 #define PCI1720_AO_REG(x)	(0x00 + ((x) * 2))
 #define PCI1720_RANGE	 8	/* R/W: D/A range register */
-#define PCI1720_SYNCOUT	 9	/* W:   D/A synchronized output register */
-#define PCI1720_SYNCONT	15	/* R/W: D/A synchronized control */
-
-/* D/A synchronized control (PCI1720_SYNCONT) */
-#define Syncont_SC0	 1	/* set synchronous output mode */
+#define PCI1720_AO_SYNC_REG	0x09
+#define PCI1720_AO_CTRL_REG	0x0f
+#define PCI1720_AO_CTRL_SC0	(1 << 0)
 
 static const struct comedi_lrange range_pci1710_3 = {
 	9, {
@@ -700,7 +698,6 @@ static int pci1720_insn_write_ao(struct comedi_device *dev,
 			val = comedi_offset_munge(s, val);
 
 		outw(val, dev->iobase + PCI1720_AO_REG(chan));
-		outb(0, dev->iobase + PCI1720_SYNCOUT);	/*  update outputs */
 	}
 
 	return n;
@@ -1071,7 +1068,8 @@ static int pci1720_reset(struct comedi_device *dev)
 	struct pci1710_private *devpriv = dev->private;
 	int i;
 
-	outb(Syncont_SC0, dev->iobase + PCI1720_SYNCONT);	/*  set synchronous output mode */
+	/* set synchronous output mode so all outputs are synchronized */
+	outb(PCI1720_AO_CTRL_SC0, dev->iobase + PCI1720_AO_CTRL_REG);
 
 	/* set all ranges to unipolar 5V */
 	devpriv->da_ranges = 0;
@@ -1081,7 +1079,12 @@ static int pci1720_reset(struct comedi_device *dev)
 		devpriv->ao_data[i] = 0;
 		outw(devpriv->ao_data[i], dev->iobase + PCI1720_AO_REG(i));
 	}
-	outb(0, dev->iobase + PCI1720_SYNCOUT);	/*  update outputs */
+
+	/* update all outputs synchronously */
+	outb(0, dev->iobase + PCI1720_AO_SYNC_REG);
+
+	/* disable synchronous output mode so (*insn_write) works normally */
+	outb(0, dev->iobase + PCI1720_AO_CTRL_REG);
 
 	return 0;
 }
-- 
1.9.3



More information about the devel mailing list