#include "comedi_isadma.h"
#include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
/* boards constants */
struct comedi_isadma *dma;
/* manimal allowed delay between samples (in us) for actual card */
unsigned int ns_min;
- int i8253_osc_base; /* 1/frequency of on board oscilator in ns */
/* MUX setting for actual AI operations */
unsigned int act_chanlist[16];
unsigned int act_chanlist_len; /* how long is actual MUX list */
unsigned int act_chanlist_pos; /* actual position in MUX list */
- unsigned int divisor1;
- unsigned int divisor2;
unsigned int usefifo:1;
unsigned int ai_cmd_running:1;
unsigned int ai_cmd_canceled:1;
};
-static void pcl818_start_pacer(struct comedi_device *dev, bool load_counters)
-{
- struct pcl818_private *devpriv = dev->private;
- unsigned long timer_base = dev->iobase + PCL818_TIMER_BASE;
-
- i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
- i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
- udelay(1);
-
- if (load_counters) {
- i8254_write(timer_base, 0, 2, devpriv->divisor2);
- i8254_write(timer_base, 0, 1, devpriv->divisor1);
- }
-}
-
static void pcl818_ai_setup_dma(struct comedi_device *dev,
struct comedi_subdevice *s,
unsigned int unread_samples)
struct comedi_cmd *cmd)
{
const struct pcl818_board *board = dev->board_ptr;
- struct pcl818_private *devpriv = dev->private;
int err = 0;
- unsigned int arg;
/* Step 1 : check if triggers are trivially valid */
/* step 4: fix up any arguments */
if (cmd->convert_src == TRIG_TIMER) {
- arg = cmd->convert_arg;
- i8253_cascade_ns_to_timer(devpriv->i8253_osc_base,
- &devpriv->divisor1,
- &devpriv->divisor2,
- &arg, cmd->flags);
+ unsigned int arg = cmd->convert_arg;
+
+ comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
}
if (devpriv->ai_cmd_running)
return -EBUSY;
- pcl818_start_pacer(dev, false);
-
seglen = check_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len);
if (seglen < 1)
return -EINVAL;
}
outb(ctrl, dev->iobase + PCL818_CTRL_REG);
- if (cmd->convert_src == TRIG_TIMER)
- pcl818_start_pacer(dev, true);
+ if (cmd->convert_src == TRIG_TIMER) {
+ comedi_8254_update_divisors(dev->pacer);
+ comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
+ }
return 0;
}
}
outb(PCL818_CTRL_DISABLE_TRIG, dev->iobase + PCL818_CTRL_REG);
- pcl818_start_pacer(dev, false);
+ comedi_8254_pacer_enable(dev->pacer, 1, 2, false);
pcl818_ai_clear_eoc(dev);
if (devpriv->usefifo) { /* FIFO shutdown */
static void pcl818_reset(struct comedi_device *dev)
{
const struct pcl818_board *board = dev->board_ptr;
- unsigned long timer_base = dev->iobase + PCL818_TIMER_BASE;
unsigned int chan;
/* flush and disable the FIFO */
/* stop pacer */
outb(PCL818_CNTENABLE_PACER_ENA, dev->iobase + PCL818_CNTENABLE_REG);
- i8254_set_mode(timer_base, 0, 2, I8254_MODE0 | I8254_BINARY);
- i8254_set_mode(timer_base, 0, 1, I8254_MODE0 | I8254_BINARY);
- i8254_set_mode(timer_base, 0, 0, I8254_MODE0 | I8254_BINARY);
/* set analog output channels to 0V */
for (chan = 0; chan < board->n_aochan; chan++) {
const struct pcl818_board *board = dev->board_ptr;
struct pcl818_private *devpriv;
struct comedi_subdevice *s;
+ unsigned int osc_base;
int ret;
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (dev->irq && board->has_dma)
pcl818_alloc_dma(dev, it->options[2]);
+ /* use 1MHz or 10MHz oscilator */
+ if ((it->options[3] == 0) || (it->options[3] == 10))
+ osc_base = I8254_OSC_BASE_10MHZ;
+ else
+ osc_base = I8254_OSC_BASE_1MHZ;
+
+ dev->pacer = comedi_8254_init(dev->iobase + PCL818_TIMER_BASE,
+ osc_base, I8254_IO8, 0);
+ if (!dev->pacer)
+ return -ENOMEM;
+
+ /* max sampling speed */
+ devpriv->ns_min = board->ns_min;
+ if (!board->is_818) {
+ /* extended PCL718 to 100kHz DAC */
+ if ((it->options[6] == 1) || (it->options[6] == 100))
+ devpriv->ns_min = 10000;
+ }
+
ret = comedi_alloc_subdevices(dev, 4);
if (ret)
return ret;
s->range_table = &range_digital;
s->insn_bits = pcl818_do_insn_bits;
- /* select 1/10MHz oscilator */
- if ((it->options[3] == 0) || (it->options[3] == 10))
- devpriv->i8253_osc_base = I8254_OSC_BASE_10MHZ;
- else
- devpriv->i8253_osc_base = I8254_OSC_BASE_1MHZ;
-
- /* max sampling speed */
- devpriv->ns_min = board->ns_min;
-
- if (!board->is_818) {
- if ((it->options[6] == 1) || (it->options[6] == 100)) {
- /* extended PCL718 to 100kHz DAC */
- devpriv->ns_min = 10000;
- }
- }
-
pcl818_reset(dev);
return 0;