Commit a6b7dbb2 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: das1800: allow setting the external trigger polarity

The external pin TGIN can be used to start and/or stop the analog input
command. Currently the driver only supports negative edge polarity for
this signal.

Add support to allow the user to select positive edge polarity using
the CR_INVERT flag.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a2706b09
...@@ -60,6 +60,9 @@ ...@@ -60,6 +60,9 @@
* If TRIG_EXT is used for both the start_src and stop_src, the first TGIN * If TRIG_EXT is used for both the start_src and stop_src, the first TGIN
* trigger starts the command, and the second trigger will stop it. If only * trigger starts the command, and the second trigger will stop it. If only
* one is TRIG_EXT, the first trigger will either stop or start the command. * one is TRIG_EXT, the first trigger will either stop or start the command.
* The external pin TGIN is normally set for negative edge triggering. It
* can be set to positive edge with the CR_INVERT flag. If TRIG_EXT is used
* for both the start_src and stop_src they must have the same polarity.
* *
* Minimum conversion speed is limited to 64 microseconds (convert_arg <= 64000) * Minimum conversion speed is limited to 64 microseconds (convert_arg <= 64000)
* for 'burst' scans. This limitation does not apply for 'paced' scans. The * for 'burst' scans. This limitation does not apply for 'paced' scans. The
...@@ -105,6 +108,7 @@ ...@@ -105,6 +108,7 @@
#define CGSL 0x8 #define CGSL 0x8
#define TGEN 0x10 #define TGEN 0x10
#define TGSL 0x20 #define TGSL 0x20
#define TGPL 0x40
#define ATEN 0x80 #define ATEN 0x80
#define DAS1800_CONTROL_B 0x5 #define DAS1800_CONTROL_B 0x5
#define DMA_CH5 0x1 #define DMA_CH5 0x1
...@@ -671,11 +675,17 @@ static int das1800_ai_cmdtest(struct comedi_device *dev, ...@@ -671,11 +675,17 @@ static int das1800_ai_cmdtest(struct comedi_device *dev,
cmd->convert_src != TRIG_TIMER) cmd->convert_src != TRIG_TIMER)
err |= -EINVAL; err |= -EINVAL;
/* the external pin TGIN must use the same polarity */
if (cmd->start_src == TRIG_EXT && cmd->stop_src == TRIG_EXT)
err |= comedi_check_trigger_arg_is(&cmd->start_arg,
cmd->stop_arg);
if (err) if (err)
return 2; return 2;
/* Step 3: check if arguments are trivially valid */ /* Step 3: check if arguments are trivially valid */
if (cmd->start_arg == TRIG_NOW)
err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0); err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
if (cmd->convert_src == TRIG_TIMER) { if (cmd->convert_src == TRIG_TIMER) {
...@@ -868,6 +878,10 @@ static int das1800_ai_cmd(struct comedi_device *dev, ...@@ -868,6 +878,10 @@ static int das1800_ai_cmd(struct comedi_device *dev,
control_a |= TGEN | CGSL; control_a |= TGEN | CGSL;
else /* TRIG_NOW */ else /* TRIG_NOW */
control_a |= CGEN; control_a |= CGEN;
if (control_a & (ATEN | TGEN)) {
if ((cmd->start_arg & CR_INVERT) || (cmd->stop_arg & CR_INVERT))
control_a |= TGPL;
}
control_c = das1800_ai_chanspec_bits(s, cmd->chanlist[0]); control_c = das1800_ai_chanspec_bits(s, cmd->chanlist[0]);
/* set clock source to internal or external */ /* set clock source to internal or external */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment