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