#include "comedi_isadma.h"
#include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
#include "8255.h"
#define DAS16_DMA_SIZE 0xff00 /* size in bytes of allocated dma buffer */
/* step 4: fix up arguments */
if (cmd->scan_begin_src == TRIG_TIMER) {
arg = cmd->scan_begin_arg;
- i8253_cascade_ns_to_timer(devpriv->clockbase,
- &devpriv->divisor1,
- &devpriv->divisor2,
- &arg, cmd->flags);
+ comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
}
if (cmd->convert_src == TRIG_TIMER) {
arg = cmd->convert_arg;
- i8253_cascade_ns_to_timer(devpriv->clockbase,
- &devpriv->divisor1,
- &devpriv->divisor2,
- &arg, cmd->flags);
+ comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
}
if (err)
static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
unsigned int flags)
{
- struct das16_private_struct *devpriv = dev->private;
- unsigned long timer_base = dev->iobase + DAS16_TIMER_BASE_REG;
-
- i8253_cascade_ns_to_timer(devpriv->clockbase,
- &devpriv->divisor1, &devpriv->divisor2,
- &ns, flags);
-
- i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
- i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
- i8254_write(timer_base, 0, 1, devpriv->divisor1);
- i8254_write(timer_base, 0, 2, devpriv->divisor2);
+ comedi_8254_cascade_ns_to_timer(dev->pacer, &ns, flags);
+ comedi_8254_update_divisors(dev->pacer);
+ comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
return ns;
}
outb(0, dev->iobase + DAS16_STATUS_REG);
outb(0, dev->iobase + DAS16_CTRL_REG);
outb(0, dev->iobase + DAS16_PACER_REG);
- outb(0, dev->iobase + DAS16_TIMER_BASE_REG + i8254_control_reg);
}
static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
const struct das16_board *board = dev->board_ptr;
struct das16_private_struct *devpriv;
struct comedi_subdevice *s;
+ unsigned int osc_base;
unsigned int status;
int ret;
return -EINVAL;
/* get master clock speed */
+ osc_base = I8254_OSC_BASE_1MHZ;
if (devpriv->can_burst) {
status = inb(dev->iobase + DAS1600_STATUS_REG);
-
if (status & DAS1600_STATUS_CLK_10MHZ)
- devpriv->clockbase = I8254_OSC_BASE_10MHZ;
- else
- devpriv->clockbase = I8254_OSC_BASE_1MHZ;
+ osc_base = I8254_OSC_BASE_10MHZ;
} else {
if (it->options[3])
- devpriv->clockbase = I8254_OSC_BASE_1MHZ /
- it->options[3];
- else
- devpriv->clockbase = I8254_OSC_BASE_1MHZ;
+ osc_base = I8254_OSC_BASE_1MHZ / it->options[3];
}
+ dev->pacer = comedi_8254_init(dev->iobase + DAS16_TIMER_BASE_REG,
+ osc_base, I8254_IO8, 0);
+ if (!dev->pacer)
+ return -ENOMEM;
+
das16_alloc_dma(dev, it->options[2]);
ret = comedi_alloc_subdevices(dev, 4 + board->has_8255);