summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-07-29 13:57:18 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-31 17:37:49 -0700
commit96334bfebf5697dce1dba23c0abdf1683a733c52 (patch)
tree7f00b29229ac54d757832a48f40ee2a5f0061920
parent6f63840447030b32662d8d425b36e8fabd7799cf (diff)
staging: comedi: das16: add a 'can_burst' flag to the private data
If the boardinfo 'size' is > 0x400 it indicates that the board has additional registers that allow bursting of analog input data. To better indicate this add a flag to the private data. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/das16.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
index 95261a617623..009c074b664b 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -373,6 +373,7 @@ struct das16_private_struct {
short timer_running;
unsigned long extra_iobase;
+ unsigned int can_burst:1;
};
static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -389,15 +390,13 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
mask = TRIG_FOLLOW;
- /* if board supports burst mode */
- if (board->size > 0x400)
+ if (devpriv->can_burst)
mask |= TRIG_TIMER | TRIG_EXT;
err |= cfc_check_trigger_src(&cmd->scan_begin_src, mask);
tmp = cmd->convert_src;
mask = TRIG_TIMER | TRIG_EXT;
- /* if board supports burst mode */
- if (board->size > 0x400)
+ if (devpriv->can_burst)
mask |= TRIG_NOW;
err |= cfc_check_trigger_src(&cmd->convert_src, mask);
@@ -534,8 +533,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->adc_byte_count =
cmd->stop_arg * cmd->chanlist_len * sizeof(uint16_t);
- /* disable conversions for das1600 mode */
- if (board->size > 0x400)
+ if (devpriv->can_burst)
outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV);
/* set scan limits */
@@ -559,8 +557,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
/* enable counters */
byte = 0;
- /* Enable burst mode if appropriate. */
- if (board->size > 0x400) {
+ if (devpriv->can_burst) {
if (cmd->convert_src == TRIG_NOW) {
outb(DAS1600_BURST_VAL, dev->iobase + DAS1600_BURST);
/* set burst length */
@@ -598,8 +595,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->control_state |= INT_PACER;
outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
- /* Enable conversions if using das1600 mode */
- if (board->size > 0x400)
+ if (devpriv->can_burst)
outb(0, dev->iobase + DAS1600_CONV);
@@ -608,7 +604,6 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
- const struct das16_board *board = comedi_board(dev);
struct das16_private_struct *devpriv = dev->private;
unsigned long flags;
@@ -624,11 +619,9 @@ static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
del_timer(&devpriv->timer);
}
- /* disable burst mode */
- if (board->size > 0x400)
+ if (devpriv->can_burst)
outb(0, dev->iobase + DAS1600_BURST);
-
spin_unlock_irqrestore(&dev->spinlock, flags);
return 0;
@@ -955,6 +948,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (ret)
return ret;
devpriv->extra_iobase = dev->iobase + 0x400;
+ devpriv->can_burst = 1;
}
/* probe id bits to make sure they are consistent */
@@ -964,13 +958,13 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
/* get master clock speed */
- if (board->size < 0x400) {
+ if (devpriv->can_burst) {
+ das1600_mode_detect(dev);
+ } else {
if (it->options[3])
devpriv->clockbase = 1000 / it->options[3];
else
devpriv->clockbase = 1000; /* 1 MHz default */
- } else {
- das1600_mode_detect(dev);
}
/* initialize dma */
@@ -1123,8 +1117,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->control_state = DAS16_IRQ(dev->irq);
outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
- /* turn on das1600 mode if available */
- if (board->size > 0x400) {
+ if (devpriv->can_burst) {
outb(DAS1600_ENABLE_VAL, dev->iobase + DAS1600_ENABLE);
outb(0, dev->iobase + DAS1600_CONV);
outb(0, dev->iobase + DAS1600_BURST);