aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-03-03 16:47:41 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-03-04 16:40:27 -0800
commit661b9dbbc32021ddba5a291ef3ccd86686c35373 (patch)
tree64e7e4c59142dd6524454e8d8068110b5eaaf754
parent7556dc373153f0fb7c069159eb815949148c6cf2 (diff)
staging: comedi: ke_counter: add digital output support
The hardware has three digital output channels. Add the subdevice support for these channels. 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>
-rw-r--r--drivers/staging/comedi/drivers/ke_counter.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c
index aab72ab3434..3b57a52e0d3 100644
--- a/drivers/staging/comedi/drivers/ke_counter.c
+++ b/drivers/staging/comedi/drivers/ke_counter.c
@@ -95,6 +95,19 @@ static int ke_counter_insn_read(struct comedi_device *dev,
return insn->n;
}
+static int ke_counter_do_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
+{
+ if (comedi_dio_update_state(s, data))
+ outb(s->state, dev->iobase + KE_DO_REG);
+
+ data[1] = s->state;
+
+ return insn->n;
+}
+
static int ke_counter_auto_attach(struct comedi_device *dev,
unsigned long context_unused)
{
@@ -107,7 +120,7 @@ static int ke_counter_auto_attach(struct comedi_device *dev,
return ret;
dev->iobase = pci_resource_start(pcidev, 0);
- ret = comedi_alloc_subdevices(dev, 1);
+ ret = comedi_alloc_subdevices(dev, 2);
if (ret)
return ret;
@@ -120,6 +133,14 @@ static int ke_counter_auto_attach(struct comedi_device *dev,
s->insn_read = ke_counter_insn_read;
s->insn_write = ke_counter_insn_write;
+ s = &dev->subdevices[1];
+ s->type = COMEDI_SUBD_DO;
+ s->subdev_flags = SDF_WRITABLE;
+ s->n_chan = 3;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = ke_counter_do_insn_bits;
+
outb(KE_OSC_SEL_20MHZ, dev->iobase + KE_OSC_SEL_REG);
outb(0, dev->iobase + KE_RESET_REG(0));