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

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: 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 180480ed
...@@ -410,6 +410,7 @@ config COMEDI_FL512 ...@@ -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
......
...@@ -32,6 +32,8 @@ ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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;
} }
......
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