staging: comedi: aio_aio12_8: hookup 8254 counter/timer

This board has an industry-standard 8254 chip with the gate, clock,
and output pins for each counter available on the connector.

Hookup the 8254 counter as a comedi subdevice.

Provice an (*insn_config) for the user to query the clock source
for each channel.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
H Hartley Sweeten 2015-10-12 12:16:32 -07:00 committed by Greg Kroah-Hartman
parent 180480ed41
commit ffe4a31739
2 changed files with 35 additions and 2 deletions

View File

@ -410,6 +410,7 @@ config COMEDI_FL512
config COMEDI_AIO_AIO12_8 config COMEDI_AIO_AIO12_8
tristate "I/O Products PC/104 AIO12-8 Analog I/O Board support" tristate "I/O Products PC/104 AIO12-8 Analog I/O Board support"
select COMEDI_8254
select COMEDI_8255 select COMEDI_8255
---help--- ---help---
Enable support for I/O Products PC/104 AIO12-8 Analog I/O Board Enable support for I/O Products PC/104 AIO12-8 Analog I/O Board

View File

@ -32,6 +32,8 @@
#include <linux/module.h> #include <linux/module.h>
#include "../comedidev.h" #include "../comedidev.h"
#include "comedi_8254.h"
#include "8255.h" #include "8255.h"
/* /*
@ -163,6 +165,29 @@ static int aio_aio12_8_ao_insn_write(struct comedi_device *dev,
return insn->n; return insn->n;
} }
static int aio_aio12_8_counter_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
switch (data[0]) {
case INSN_CONFIG_GET_CLOCK_SRC:
/*
* Channels 0 and 2 have external clock sources.
* Channel 1 has a fixed 1 MHz clock source.
*/
data[0] = 0;
data[1] = (chan == 1) ? I8254_OSC_BASE_1MHZ : 0;
break;
default:
return -EINVAL;
}
return insn->n;
}
static const struct comedi_lrange range_aio_aio12_8 = { static const struct comedi_lrange range_aio_aio12_8 = {
4, { 4, {
UNI_RANGE(5), UNI_RANGE(5),
@ -183,6 +208,11 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
if (ret) if (ret)
return ret; return ret;
dev->pacer = comedi_8254_init(dev->iobase + AIO12_8_8254_BASE_REG,
0, I8254_IO8, 0);
if (!dev->pacer)
return -ENOMEM;
ret = comedi_alloc_subdevices(dev, 4); ret = comedi_alloc_subdevices(dev, 4);
if (ret) if (ret)
return ret; return ret;
@ -223,9 +253,11 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
if (ret) if (ret)
return ret; return ret;
/* Counter subdevice (8254) */
s = &dev->subdevices[3]; s = &dev->subdevices[3];
/* 8254 counter/timer subdevice */ comedi_8254_subdevice_init(s, dev->pacer);
s->type = COMEDI_SUBD_UNUSED;
dev->pacer->insn_config = aio_aio12_8_counter_insn_config;
return 0; return 0;
} }