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

staging: comedi: 8253.h: tidy up the i8253_cascade_ns_to_timer*() users

Introduce a couple defines for the common 8254 oscillator base values
used in the comedi drivers and remove the custom defines and open
coded values.

Change the i8253_cascade_ns_to_timer_2div() calls in the drivers to
the more generic i8253_cascade_ns_to_timer(). They are identical due
to the #define in the 8253.h header.

Remove the extra mask by TRIG_ROUND_MASK of the 'round_mode' parameter
to i8253_cascade_ns_to_timer(). That function already handles the mask.

Tidy up all the calls to i8253_cascade_ns_to_timer().
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fa57560c
......@@ -21,6 +21,15 @@
#include "../comedi.h"
/*
* Common oscillator base values in nanoseconds
*/
#define I8254_OSC_BASE_10MHZ 100
#define I8254_OSC_BASE_5MHZ 200
#define I8254_OSC_BASE_4MHZ 250
#define I8254_OSC_BASE_2MHZ 500
#define I8254_OSC_BASE_1MHZ 1000
#define i8253_cascade_ns_to_timer i8253_cascade_ns_to_timer_2div
static inline void i8253_cascade_ns_to_timer_2div_old(int i8253_osc_base,
......
......@@ -86,8 +86,6 @@ a multiple of chanlist_len*convert_arg.
#define PCI9111_AI_INSTANT_READ_UDELAY_US 2
#define PCI9111_AI_INSTANT_READ_TIMEOUT 100
#define PCI9111_8254_CLOCK_PERIOD_NS 500
/*
* IO address map and bit defines
*/
......@@ -393,11 +391,10 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer_2div(PCI9111_8254_CLOCK_PERIOD_NS,
&dev_private->div1,
&dev_private->div2,
&cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ,
&dev_private->div1,
&dev_private->div2,
&cmd->convert_arg, cmd->flags);
if (tmp != cmd->convert_arg)
error++;
}
......
......@@ -792,7 +792,8 @@ static void pci9118_calc_divisors(char mode, struct comedi_device *dev,
case 4:
if (*tim2 < this_board->ai_ns_min)
*tim2 = this_board->ai_ns_min;
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, div1, div2,
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base,
div1, div2,
tim2, flags & TRIG_ROUND_NEAREST);
break;
case 2:
......@@ -1277,9 +1278,9 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
&divisor2, &cmd->scan_begin_arg,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base,
&divisor1, &divisor2,
&cmd->scan_begin_arg, cmd->flags);
if (cmd->scan_begin_arg < this_board->ai_ns_min)
cmd->scan_begin_arg = this_board->ai_ns_min;
if (tmp != cmd->scan_begin_arg)
......@@ -1288,9 +1289,9 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
if (cmd->convert_src & (TRIG_TIMER | TRIG_NOW)) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
&divisor2, &cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base,
&divisor1, &divisor2,
&cmd->convert_arg, cmd->flags);
if (cmd->convert_arg < this_board->ai_ns_min)
cmd->convert_arg = this_board->ai_ns_min;
if (tmp != cmd->convert_arg)
......@@ -2086,7 +2087,7 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq,
s->insn_bits = pci9118_insn_bits_do;
devpriv->valid = 1;
devpriv->i8254_osc_base = 250; /* 250ns=4MHz */
devpriv->i8254_osc_base = I8254_OSC_BASE_4MHZ;
devpriv->ai_maskharderr = 0x10a;
/* default measure crash condition */
if (hw_err_mask) /* disable some requested */
......
......@@ -1005,9 +1005,10 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
} else {
devpriv->ai_et = 0;
}
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
&divisor2, &devpriv->ai_timer1,
devpriv->ai_flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base,
&divisor1, &divisor2,
&devpriv->ai_timer1,
devpriv->ai_flags);
outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
if (mode != 2) {
/* start pacer */
......@@ -1086,9 +1087,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
&divisor2, &cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base,
&divisor1, &divisor2,
&cmd->convert_arg, cmd->flags);
if (cmd->convert_arg < this_board->ai_ns_min)
cmd->convert_arg = this_board->ai_ns_min;
if (tmp != cmd->convert_arg)
......@@ -1284,7 +1285,7 @@ static int pci1710_auto_attach(struct comedi_device *dev,
s->do_cmdtest = pci171x_ai_cmdtest;
s->do_cmd = pci171x_ai_cmd;
}
devpriv->i8254_osc_base = 100; /* 100ns=10MHz */
devpriv->i8254_osc_base = I8254_OSC_BASE_10MHZ;
subdev++;
}
......
......@@ -215,12 +215,6 @@ Passing a zero for an option is the same as leaving it unspecified.
#define CLK_EXT 7 /* external clock */
/* Macro to construct clock input configuration register value. */
#define CLK_CONFIG(chan, src) ((((chan) & 3) << 3) | ((src) & 7))
/* Timebases in ns. */
#define TIMEBASE_10MHZ 100
#define TIMEBASE_1MHZ 1000
#define TIMEBASE_100KHZ 10000
#define TIMEBASE_10KHZ 100000
#define TIMEBASE_1KHZ 1000000
/*
* Counter/timer gate input configuration sources.
......@@ -843,26 +837,26 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
switch (round_mode) {
case TRIG_ROUND_NEAREST:
default:
round = TIMEBASE_10MHZ / 2;
round = I8254_OSC_BASE_10MHZ / 2;
break;
case TRIG_ROUND_DOWN:
round = 0;
break;
case TRIG_ROUND_UP:
round = TIMEBASE_10MHZ - 1;
round = I8254_OSC_BASE_10MHZ - 1;
break;
}
/* Be careful to avoid overflow! */
div2 = cmd->scan_begin_arg / TIMEBASE_10MHZ;
div2 += (round + cmd->scan_begin_arg % TIMEBASE_10MHZ) /
TIMEBASE_10MHZ;
div2 = cmd->scan_begin_arg / I8254_OSC_BASE_10MHZ;
div2 += (round + cmd->scan_begin_arg % I8254_OSC_BASE_10MHZ) /
I8254_OSC_BASE_10MHZ;
if (div2 <= 0x10000) {
/* A single timer will suffice. */
if (div2 < 2)
div2 = 2;
cmd->scan_begin_arg = div2 * TIMEBASE_10MHZ;
cmd->scan_begin_arg = div2 * I8254_OSC_BASE_10MHZ;
if (cmd->scan_begin_arg < div2 ||
cmd->scan_begin_arg < TIMEBASE_10MHZ) {
cmd->scan_begin_arg < I8254_OSC_BASE_10MHZ) {
/* Overflow! */
cmd->scan_begin_arg = MAX_SCAN_PERIOD;
}
......@@ -870,7 +864,8 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
/* Use two timers. */
div1 = devpriv->cached_div1;
div2 = devpriv->cached_div2;
pci224_cascade_ns_to_timer(TIMEBASE_10MHZ, &div1, &div2,
pci224_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
&div1, &div2,
&cmd->scan_begin_arg,
round_mode);
devpriv->cached_div1 = div1;
......@@ -1002,19 +997,19 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
switch (round_mode) {
case TRIG_ROUND_NEAREST:
default:
round = TIMEBASE_10MHZ / 2;
round = I8254_OSC_BASE_10MHZ / 2;
break;
case TRIG_ROUND_DOWN:
round = 0;
break;
case TRIG_ROUND_UP:
round = TIMEBASE_10MHZ - 1;
round = I8254_OSC_BASE_10MHZ - 1;
break;
}
/* Be careful to avoid overflow! */
div2 = cmd->scan_begin_arg / TIMEBASE_10MHZ;
div2 += (round + cmd->scan_begin_arg % TIMEBASE_10MHZ) /
TIMEBASE_10MHZ;
div2 = cmd->scan_begin_arg / I8254_OSC_BASE_10MHZ;
div2 += (round + cmd->scan_begin_arg % I8254_OSC_BASE_10MHZ) /
I8254_OSC_BASE_10MHZ;
if (div2 <= 0x10000) {
/* A single timer will suffice. */
if (div2 < 2)
......@@ -1025,7 +1020,8 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* Use two timers. */
div1 = devpriv->cached_div1;
div2 = devpriv->cached_div2;
pci224_cascade_ns_to_timer(TIMEBASE_10MHZ, &div1, &div2,
pci224_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
&div1, &div2,
&ns, round_mode);
}
......
......@@ -234,9 +234,9 @@ static int das16cs_ai_cmdtest(struct comedi_device *dev,
unsigned int div1 = 0, div2 = 0;
tmp = cmd->scan_begin_arg;
i8253_cascade_ns_to_timer(100, &div1, &div2,
&cmd->scan_begin_arg,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
&div1, &div2,
&cmd->scan_begin_arg, cmd->flags);
if (tmp != cmd->scan_begin_arg)
err++;
}
......@@ -244,9 +244,9 @@ static int das16cs_ai_cmdtest(struct comedi_device *dev,
unsigned int div1 = 0, div2 = 0;
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer(100, &div1, &div2,
&cmd->scan_begin_arg,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
&div1, &div2,
&cmd->scan_begin_arg, cmd->flags);
if (tmp != cmd->convert_arg)
err++;
if (cmd->scan_begin_src == TRIG_TIMER &&
......
......@@ -73,7 +73,6 @@ analog triggering on 1602 series
#include "amcc_s5933.h"
#include "comedi_fc.h"
#define TIMER_BASE 100 /* 10MHz master clock */
#define AI_BUFFER_SIZE 1024 /* max ai fifo size */
#define AO_BUFFER_SIZE 1024 /* max ao fifo size */
#define NUM_CHANNELS_8800 8
......@@ -880,21 +879,19 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
&(devpriv->divisor1),
&(devpriv->divisor2),
&(cmd->scan_begin_arg),
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
&devpriv->divisor1,
&devpriv->divisor2,
&cmd->scan_begin_arg, cmd->flags);
if (tmp != cmd->scan_begin_arg)
err++;
}
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
&(devpriv->divisor1),
&(devpriv->divisor2),
&(cmd->convert_arg),
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
&devpriv->divisor1,
&devpriv->divisor2,
&cmd->convert_arg, cmd->flags);
if (tmp != cmd->convert_arg)
err++;
}
......@@ -932,9 +929,9 @@ static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns,
{
struct cb_pcidas_private *devpriv = dev->private;
i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
&(devpriv->divisor2), ns,
rounding_flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
&devpriv->divisor1, &devpriv->divisor2,
ns, rounding_flags);
/* Write the values of ctr1 and ctr2 into counters 1 and 2 */
i8254_load(devpriv->pacer_counter_dio + ADC8254, 0, 1,
......@@ -1084,11 +1081,10 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
&(devpriv->ao_divisor1),
&(devpriv->ao_divisor2),
&(cmd->scan_begin_arg),
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
&devpriv->ao_divisor1,
&devpriv->ao_divisor2,
&cmd->scan_begin_arg, cmd->flags);
if (tmp != cmd->scan_begin_arg)
err++;
}
......@@ -1209,11 +1205,10 @@ static int cb_pcidas_ao_cmd(struct comedi_device *dev,
/* load counters */
if (cmd->scan_begin_src == TRIG_TIMER) {
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
&(devpriv->ao_divisor1),
&(devpriv->ao_divisor2),
&(cmd->scan_begin_arg),
cmd->flags);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
&devpriv->ao_divisor1,
&devpriv->ao_divisor2,
&cmd->scan_begin_arg, cmd->flags);
/* Write the values of ctr1 and ctr2 into counters 1 and 2 */
i8254_load(devpriv->pacer_counter_dio + DAC8254, 0, 1,
......
......@@ -675,21 +675,19 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
if (cmd->scan_begin_src == TRIG_TIMER) {
unsigned int tmp = cmd->scan_begin_arg;
/* set divisors, correct timing arguments */
i8253_cascade_ns_to_timer_2div(devpriv->clockbase,
&devpriv->divisor1,
&devpriv->divisor2,
&cmd->scan_begin_arg,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(devpriv->clockbase,
&devpriv->divisor1,
&devpriv->divisor2,
&cmd->scan_begin_arg, cmd->flags);
err += (tmp != cmd->scan_begin_arg);
}
if (cmd->convert_src == TRIG_TIMER) {
unsigned int tmp = cmd->convert_arg;
/* set divisors, correct timing arguments */
i8253_cascade_ns_to_timer_2div(devpriv->clockbase,
&devpriv->divisor1,
&devpriv->divisor2,
&cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(devpriv->clockbase,
&devpriv->divisor1,
&devpriv->divisor2,
&cmd->convert_arg, cmd->flags);
err += (tmp != cmd->convert_arg);
}
if (err)
......@@ -725,11 +723,9 @@ static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
struct das16_private_struct *devpriv = dev->private;
unsigned long timer_base = dev->iobase + DAS16_TIMER_BASE_REG;
i8253_cascade_ns_to_timer_2div(devpriv->clockbase,
&devpriv->divisor1,
&devpriv->divisor2,
&ns,
rounding_flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(devpriv->clockbase,
&devpriv->divisor1, &devpriv->divisor2,
&ns, rounding_flags);
/* Write the values of ctr1 and ctr2 into counters 1 and 2 */
i8254_load(timer_base, 0, 1, devpriv->divisor1, 2);
......@@ -1036,14 +1032,15 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
status = inb(dev->iobase + DAS1600_STATUS_REG);
if (status & DAS1600_STATUS_CLK_10MHZ)
devpriv->clockbase = 100;
devpriv->clockbase = I8254_OSC_BASE_10MHZ;
else
devpriv->clockbase = 1000;
devpriv->clockbase = I8254_OSC_BASE_1MHZ;
} else {
if (it->options[3])
devpriv->clockbase = 1000 / it->options[3];
devpriv->clockbase = I8254_OSC_BASE_1MHZ /
it->options[3];
else
devpriv->clockbase = 1000; /* 1 MHz default */
devpriv->clockbase = I8254_OSC_BASE_1MHZ;
}
/* initialize dma */
......
......@@ -63,8 +63,6 @@ irq can be omitted, although the cmd interface will not work without it.
#define DAS16M1_SIZE 16
#define DAS16M1_SIZE2 8
#define DAS16M1_XTAL 100 /* 10 MHz master clock */
#define FIFO_SIZE 1024 /* 1024 sample fifo */
/*
......@@ -207,11 +205,10 @@ static int das16m1_cmd_test(struct comedi_device *dev,
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
/* calculate counter values that give desired timing */
i8253_cascade_ns_to_timer_2div(DAS16M1_XTAL,
&(devpriv->divisor1),
&(devpriv->divisor2),
&(cmd->convert_arg),
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
&devpriv->divisor1,
&devpriv->divisor2,
&cmd->convert_arg, cmd->flags);
if (tmp != cmd->convert_arg)
err++;
}
......@@ -250,9 +247,10 @@ static unsigned int das16m1_set_pacer(struct comedi_device *dev,
{
struct das16m1_private_struct *devpriv = dev->private;
i8253_cascade_ns_to_timer_2div(DAS16M1_XTAL, &(devpriv->divisor1),
&(devpriv->divisor2), &ns,
rounding_flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer_2div(I8254_OSC_BASE_10MHZ,
&devpriv->divisor1,
&devpriv->divisor2,
&ns, rounding_flags);
/* Write the values of ctr1 and ctr2 into counters 1 and 2 */
i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 1, devpriv->divisor1,
......
......@@ -108,7 +108,6 @@ Unipolar and bipolar ranges cannot be mixed in the channel/gain list.
/* misc. defines */
#define DAS1800_SIZE 16 /* uses 16 io addresses */
#define FIFO_SIZE 1024 /* 1024 sample fifo */
#define TIMER_BASE 200 /* 5 Mhz master clock */
#define UNIPOLAR 0x4 /* bit that determines whether input range is uni/bipolar */
#define DMA_BUF_SIZE 0x1ff00 /* size in bytes of dma buffers */
......@@ -839,12 +838,11 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
if (cmd->scan_begin_src == TRIG_FOLLOW) {
tmp_arg = cmd->convert_arg;
/* calculate counter values that give desired timing */
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
&(devpriv->divisor1),
&(devpriv->divisor2),
&(cmd->convert_arg),
cmd->
flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ,
&devpriv->divisor1,
&devpriv->divisor2,
&cmd->convert_arg,
cmd->flags);
if (tmp_arg != cmd->convert_arg)
err++;
}
......@@ -869,16 +867,11 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
}
tmp_arg = cmd->scan_begin_arg;
/* calculate counter values that give desired timing */
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
&(devpriv->
divisor1),
&(devpriv->
divisor2),
&(cmd->
scan_begin_arg),
cmd->
flags &
TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ,
&devpriv->divisor1,
&devpriv->divisor2,
&cmd->scan_begin_arg,
cmd->flags);
if (tmp_arg != cmd->scan_begin_arg)
err++;
}
......@@ -1010,12 +1003,10 @@ static int setup_counters(struct comedi_device *dev,
if (cmd->convert_src == TRIG_TIMER) {
/* set conversion frequency */
period = cmd->convert_arg;
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
&devpriv->divisor1,
&devpriv->divisor2,
&period,
cmd->flags &
TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ,
&devpriv->divisor1,
&devpriv->divisor2,
&period, cmd->flags);
if (das1800_set_frequency(dev) < 0)
return -1;
}
......@@ -1023,9 +1014,10 @@ static int setup_counters(struct comedi_device *dev,
case TRIG_TIMER: /* in burst mode */
/* set scan frequency */
period = cmd->scan_begin_arg;
i8253_cascade_ns_to_timer_2div(TIMER_BASE, &devpriv->divisor1,
&devpriv->divisor2, &period,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ,
&devpriv->divisor1,
&devpriv->divisor2,
&period, cmd->flags);
if (das1800_set_frequency(dev) < 0)
return -1;
break;
......
......@@ -66,7 +66,6 @@ cmd triggers supported:
#include "comedi_fc.h"
#define DAS800_SIZE 8
#define TIMER_BASE 1000
#define N_CHAN_AI 8 /* number of analog input channels */
/* Registers for the das800 */
......@@ -356,11 +355,10 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev,
int tmp = cmd->convert_arg;
/* calculate counter values that give desired timing */
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
&devpriv->divisor1,
&devpriv->divisor2,
&cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_1MHZ,
&devpriv->divisor1,
&devpriv->divisor2,
&cmd->convert_arg, cmd->flags);
if (tmp != cmd->convert_arg)
err++;
}
......
......@@ -73,7 +73,6 @@
#include "ni_labpc_isadma.h"
#define LABPC_SIZE 0x20 /* size of ISA io region */
#define LABPC_TIMER_BASE 500 /* 2 MHz master clock */
#define LABPC_ADC_TIMEOUT 1000
enum scan_mode {
......@@ -459,13 +458,13 @@ static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd,
* clock speed on convert and scan counters)
*/
devpriv->divisor_b0 = (scan_period - 1) /
(LABPC_TIMER_BASE * max_counter_value) + 1;
(I8254_OSC_BASE_2MHZ * max_counter_value) + 1;
if (devpriv->divisor_b0 < min_counter_value)
devpriv->divisor_b0 = min_counter_value;
if (devpriv->divisor_b0 > max_counter_value)
devpriv->divisor_b0 = max_counter_value;
base_period = LABPC_TIMER_BASE * devpriv->divisor_b0;
base_period = I8254_OSC_BASE_2MHZ * devpriv->divisor_b0;
/* set a0 for conversion frequency and b1 for scan frequency */
switch (cmd->flags & TRIG_ROUND_MASK) {
......@@ -510,22 +509,20 @@ static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd,
* calculate cascaded counter values
* that give desired scan timing
*/
i8253_cascade_ns_to_timer_2div(LABPC_TIMER_BASE,
&(devpriv->divisor_b1),
&(devpriv->divisor_b0),
&scan_period,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ,
&devpriv->divisor_b1,
&devpriv->divisor_b0,
&scan_period, cmd->flags);
labpc_set_ai_scan_period(cmd, mode, scan_period);
} else if (convert_period) {
/*
* calculate cascaded counter values
* that give desired conversion timing
*/
i8253_cascade_ns_to_timer_2div(LABPC_TIMER_BASE,
&(devpriv->divisor_a0),
&(devpriv->divisor_b0),
&convert_period,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ,
&devpriv->divisor_a0,
&devpriv->divisor_b0,
&convert_period, cmd->flags);
labpc_set_ai_convert_period(cmd, mode, convert_period);
}
}
......
......@@ -349,11 +349,11 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev,
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
i8253_cascade_ns_to_timer(500, /* 2 Mhz */
i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ,
&devpriv->divisor1,
&devpriv->divisor2,
&cmd->scan_begin_arg,
cmd->flags & TRIG_ROUND_MASK);
cmd->flags);
if (tmp != cmd->scan_begin_arg)
err++;
}
......
......@@ -589,9 +589,9 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev,
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer(board->i8254_osc_base, &divisor1,
&divisor2, &cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(board->i8254_osc_base,
&divisor1, &divisor2,
&cmd->convert_arg, cmd->flags);
if (cmd->convert_arg < board->ai_ns_min)
cmd->convert_arg = board->ai_ns_min;
if (tmp != cmd->convert_arg)
......@@ -637,8 +637,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
cmd->convert_arg = board->ai_ns_min;
i8253_cascade_ns_to_timer(board->i8254_osc_base,
&divisor1, &divisor2,
&cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
&cmd->convert_arg, cmd->flags);
}
start_pacer(dev, -1, 0, 0); /* stop pacer */
......@@ -1440,40 +1439,40 @@ static void pcl812_detach(struct comedi_device *dev)
static const struct pcl812_board boardtypes[] = {
{"pcl812", boardPCL812, 16, 0, 2, 16, 16, 0x0fff,
33000, 500, &range_bipolar10, &range_unipolar5,
33000, I8254_OSC_BASE_2MHZ, &range_bipolar10, &range_unipolar5,
0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"pcl812pg", boardPCL812PG, 16, 0, 2, 16, 16, 0x0fff,
33000, 500, &range_pcl812pg_ai, &range_unipolar5,
33000, I8254_OSC_BASE_2MHZ, &range_pcl812pg_ai, &range_unipolar5,
0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"acl8112pg", boardPCL812PG, 16, 0, 2, 16, 16, 0x0fff,
10000, 500, &range_pcl812pg_ai, &range_unipolar5,
10000, I8254_OSC_BASE_2MHZ, &range_pcl812pg_ai, &range_unipolar5,
0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"acl8112dg", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
10000, 500, &range_acl8112dg_ai, &range_unipolar5,
10000, I8254_OSC_BASE_2MHZ, &range_acl8112dg_ai, &range_unipolar5,
0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
{"acl8112hg", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
10000, 500, &range_acl8112hg_ai, &range_unipolar5,
10000, I8254_OSC_BASE_2MHZ, &range_acl8112hg_ai, &range_unipolar5,
0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
{"a821pgl", boardA821, 16, 8, 1, 16, 16, 0x0fff,
10000, 500, &range_pcl813b_ai, &range_unipolar5,
10000, I8254_OSC_BASE_2MHZ, &range_pcl813b_ai, &range_unipolar5,
0x000c, 0x00, PCLx1x_IORANGE, 0},
{"a821pglnda", boardA821, 16, 8, 0, 0, 0, 0x0fff,
10000, 500, &range_pcl813b_ai, NULL,
10000, I8254_OSC_BASE_2MHZ, &range_pcl813b_ai, NULL,
0x000c, 0x00, PCLx1x_IORANGE, 0},
{"a821pgh", boardA821, 16, 8, 1, 16, 16, 0x0fff,
10000, 500, &range_a821pgh_ai, &range_unipolar5,
10000, I8254_OSC_BASE_2MHZ, &range_a821pgh_ai, &range_unipolar5,
0x000c, 0x00, PCLx1x_IORANGE, 0},
{"a822pgl", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
10000, 500, &range_acl8112dg_ai, &range_unipolar5,
10000, I8254_OSC_BASE_2MHZ, &range_acl8112dg_ai, &range_unipolar5,
0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"a822pgh", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
10000, 500, &range_acl8112hg_ai, &range_unipolar5,
10000, I8254_OSC_BASE_2MHZ, &range_acl8112hg_ai, &range_unipolar5,
0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"a823pgl", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
8000, 500, &range_acl8112dg_ai, &range_unipolar5,
8000, I8254_OSC_BASE_2MHZ, &range_acl8112dg_ai, &range_unipolar5,
0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"a823pgh", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
8000, 500, &range_acl8112hg_ai, &range_unipolar5,
8000, I8254_OSC_BASE_2MHZ, &range_acl8112hg_ai, &range_unipolar5,
0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"pcl813", boardPCL813, 32, 0, 0, 0, 0, 0x0fff,
0, 0, &range_pcl813b_ai, NULL,
......@@ -1488,10 +1487,10 @@ static const struct pcl812_board boardtypes[] = {
0, 0, &range_iso813_1_ai, NULL,
0x0000, 0x00, PCLx1x_IORANGE, 0},
{"acl8216", boardACL8216, 16, 8, 2, 16, 16, 0xffff,
10000, 500, &range_pcl813b2_ai, &range_unipolar5,
10000, I8254_OSC_BASE_2MHZ, &range_pcl813b2_ai, &range_unipolar5,
0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
{"a826pg", boardACL8216, 16, 8, 2, 16, 16, 0xffff,
10000, 500, &range_pcl813b2_ai, &range_unipolar5,
10000, I8254_OSC_BASE_2MHZ, &range_pcl813b2_ai, &range_unipolar5,
0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
};
......
......@@ -481,8 +481,7 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev,
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer(board->i8254_osc_base,
&divisor1, &divisor2,
&cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
&cmd->convert_arg, cmd->flags);
if (cmd->convert_arg < board->ai_ns_min)
cmd->convert_arg = board->ai_ns_min;
if (tmp != cmd->convert_arg)
......@@ -528,9 +527,9 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (cmd->convert_arg < board->ai_ns_min)
cmd->convert_arg = board->ai_ns_min;
i8253_cascade_ns_to_timer(board->i8254_osc_base, &divisor1,
&divisor2, &cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(board->i8254_osc_base,
&divisor1, &divisor2,
&cmd->convert_arg, cmd->flags);
/* PCL816 crash if any divisor is set to 1 */
if (divisor1 == 1) {
......@@ -1105,7 +1104,7 @@ static const struct pcl816_board boardtypes[] = {
0xffff, /* D/A maxdata */
1024,
1, /* ao chan list */
100},
I8254_OSC_BASE_10MHZ},
{"pcl814b", 8, 16, 10000, 1, 16, 16, &range_pcl816,
&range_pcl816, PCLx1x_RANGE,
0x00fc,
......@@ -1114,7 +1113,7 @@ static const struct pcl816_board boardtypes[] = {
0x3fff,
1024,
1,
100},
I8254_OSC_BASE_10MHZ},
};
static struct comedi_driver pcl816_driver = {
......
......@@ -800,8 +800,9 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev,
devpriv->neverending_ai = 1; /* well, user want neverending */
if (mode == 1) {
i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, &divisor1,
&divisor2, &cmd->convert_arg,
i8253_cascade_ns_to_timer(devpriv->i8253_osc_base,
&divisor1, &divisor2,
&cmd->convert_arg,
TRIG_ROUND_NEAREST);
if (divisor1 == 1) { /* PCL718/818 crash if any divisor is set to 1 */
divisor1 = 2;
......@@ -1034,9 +1035,9 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, &divisor1,
&divisor2, &cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
i8253_cascade_ns_to_timer(devpriv->i8253_osc_base,
&divisor1, &divisor2,
&cmd->convert_arg, cmd->flags);
if (cmd->convert_arg < board->ns_min)
cmd->convert_arg = board->ns_min;
if (tmp != cmd->convert_arg)
......@@ -1432,9 +1433,9 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* select 1/10MHz oscilator */
if ((it->options[3] == 0) || (it->options[3] == 10))
devpriv->i8253_osc_base = 100;
devpriv->i8253_osc_base = I8254_OSC_BASE_10MHZ;
else
devpriv->i8253_osc_base = 1000;
devpriv->i8253_osc_base = I8254_OSC_BASE_1MHZ;
/* max sampling speed */
devpriv->ns_min = board->ns_min;
......
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