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

staging: comedi: adl_pci9111: convert driver to use the comedi_8254 module

This driver uses an 8254 timer to generate the pacer clock used for analog
input data acquisition. Convert it to use the comedi_8254 module to provide
support for the 8254 timer.
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 9ef02dea
...@@ -719,6 +719,7 @@ config COMEDI_ADL_PCI8164 ...@@ -719,6 +719,7 @@ config COMEDI_ADL_PCI8164
config COMEDI_ADL_PCI9111 config COMEDI_ADL_PCI9111
tristate "ADLink PCI-9111HR support" tristate "ADLink PCI-9111HR support"
select COMEDI_8254
---help--- ---help---
Enable support for ADlink PCI9111 cards Enable support for ADlink PCI9111 cards
......
...@@ -71,9 +71,9 @@ a multiple of chanlist_len*convert_arg. ...@@ -71,9 +71,9 @@ a multiple of chanlist_len*convert_arg.
#include "../comedidev.h" #include "../comedidev.h"
#include "8253.h"
#include "plx9052.h" #include "plx9052.h"
#include "comedi_fc.h" #include "comedi_fc.h"
#include "comedi_8254.h"
#define PCI9111_FIFO_HALF_SIZE 512 #define PCI9111_FIFO_HALF_SIZE 512
...@@ -137,9 +137,6 @@ struct pci9111_private_data { ...@@ -137,9 +137,6 @@ struct pci9111_private_data {
unsigned int chunk_counter; unsigned int chunk_counter;
unsigned int chunk_num_samples; unsigned int chunk_num_samples;
unsigned int div1;
unsigned int div2;
unsigned short ai_bounce_buffer[2 * PCI9111_FIFO_HALF_SIZE]; unsigned short ai_bounce_buffer[2 * PCI9111_FIFO_HALF_SIZE];
}; };
...@@ -167,21 +164,6 @@ static void plx9050_interrupt_control(unsigned long io_base, ...@@ -167,21 +164,6 @@ static void plx9050_interrupt_control(unsigned long io_base,
outb(flags, io_base + PLX9052_INTCSR); outb(flags, io_base + PLX9052_INTCSR);
} }
static void pci9111_timer_set(struct comedi_device *dev)
{
struct pci9111_private_data *dev_private = dev->private;
unsigned long timer_base = dev->iobase + PCI9111_8254_BASE_REG;
i8254_set_mode(timer_base, 1, 0, I8254_MODE0 | I8254_BINARY);
i8254_set_mode(timer_base, 1, 1, I8254_MODE2 | I8254_BINARY);
i8254_set_mode(timer_base, 1, 2, I8254_MODE2 | I8254_BINARY);
udelay(1);
i8254_write(timer_base, 1, 2, dev_private->div2);
i8254_write(timer_base, 1, 1, dev_private->div1);
}
enum pci9111_ISC0_sources { enum pci9111_ISC0_sources {
irq_on_eoc, irq_on_eoc,
irq_on_fifo_half_full irq_on_fifo_half_full
...@@ -281,7 +263,6 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, ...@@ -281,7 +263,6 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_cmd *cmd) struct comedi_cmd *cmd)
{ {
struct pci9111_private_data *dev_private = dev->private;
int err = 0; int err = 0;
unsigned int arg; unsigned int arg;
...@@ -345,10 +326,7 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, ...@@ -345,10 +326,7 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
if (cmd->convert_src == TRIG_TIMER) { if (cmd->convert_src == TRIG_TIMER) {
arg = cmd->convert_arg; arg = cmd->convert_arg;
i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ, comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
&dev_private->div1,
&dev_private->div2,
&arg, cmd->flags);
err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
} }
...@@ -406,7 +384,8 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, ...@@ -406,7 +384,8 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev,
dev_private->scan_delay = 0; dev_private->scan_delay = 0;
if (cmd->convert_src == TRIG_TIMER) { if (cmd->convert_src == TRIG_TIMER) {
trig |= PCI9111_AI_TRIG_CTRL_TPST; trig |= PCI9111_AI_TRIG_CTRL_TPST;
pci9111_timer_set(dev); comedi_8254_update_divisors(dev->pacer);
comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
pci9111_fifo_reset(dev); pci9111_fifo_reset(dev);
pci9111_interrupt_source_set(dev, irq_on_fifo_half_full, pci9111_interrupt_source_set(dev, irq_on_fifo_half_full,
irq_on_timer_tick); irq_on_timer_tick);
...@@ -667,11 +646,6 @@ static int pci9111_reset(struct comedi_device *dev) ...@@ -667,11 +646,6 @@ static int pci9111_reset(struct comedi_device *dev)
/* disable A/D triggers (software trigger mode) and auto scan off */ /* disable A/D triggers (software trigger mode) and auto scan off */
outb(0, dev->iobase + PCI9111_AI_TRIG_CTRL_REG); outb(0, dev->iobase + PCI9111_AI_TRIG_CTRL_REG);
/* Reset 8254 chip */
dev_private->div1 = 0;
dev_private->div2 = 0;
pci9111_timer_set(dev);
return 0; return 0;
} }
...@@ -702,6 +676,11 @@ static int pci9111_auto_attach(struct comedi_device *dev, ...@@ -702,6 +676,11 @@ static int pci9111_auto_attach(struct comedi_device *dev,
dev->irq = pcidev->irq; dev->irq = pcidev->irq;
} }
dev->pacer = comedi_8254_init(dev->iobase + PCI9111_8254_BASE_REG,
I8254_OSC_BASE_2MHZ, I8254_IO16, 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;
......
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