diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2014-11-10 16:20:16 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-26 15:31:33 -0800 |
commit | 0658d6de9c9750201a5728f25dd3037a73941077 (patch) | |
tree | d3ae0ad25279365d87cc51b1f08f8c0506ebdfec /drivers/staging/comedi/drivers/addi_apci_1564.c | |
parent | staging: comedi: addi_apci_1564: move counter register defines to driver (diff) | |
download | linux-dev-0658d6de9c9750201a5728f25dd3037a73941077.tar.xz linux-dev-0658d6de9c9750201a5728f25dd3037a73941077.zip |
staging: comedi: addi_apci_1564: split timer and counter subdevices
The timer subdevice is currently broken in this driver.
The Rev 1.0 and 2.x versions of the board both have a 12-bit timer. But only
the Rev 2.x boards have the 3 32-bit counters.
Split the current timer subdevice into two separate subdevices:
1) A single channel 12-bit timer subdevice
2) A three channel 32-bit counter subdevice
This represents the hardware correctly and the counters can be disabled on
the Rev 1.0 boards.
Split up the current (*insn_config), (*insn_write), and (*insn_read) so they
only deal with the hardware associated with the subdevice.
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>
Diffstat (limited to 'drivers/staging/comedi/drivers/addi_apci_1564.c')
-rw-r--r-- | drivers/staging/comedi/drivers/addi_apci_1564.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 958eb7d29be2..359880d422f2 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -127,7 +127,6 @@ struct apci1564_private { unsigned int mode1; /* riding-edge/high level channels */ unsigned int mode2; /* falling-edge/low level channels */ unsigned int ctrl; /* interrupt mode OR (edge) . AND (level) */ - unsigned char timer_select_mode; struct task_struct *tsk_current; }; @@ -486,7 +485,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, dev->irq = pcidev->irq; } - ret = comedi_alloc_subdevices(dev, 6); + ret = comedi_alloc_subdevices(dev, 7); if (ret) return ret; @@ -527,25 +526,40 @@ static int apci1564_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - /* Allocate and Initialise Timer Subdevice Structures */ + /* Timer subdevice */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = 3; - s->maxdata = 0; + s->subdev_flags = SDF_WRITABLE | SDF_READABLE; + s->n_chan = 1; + s->maxdata = 0x0fff; s->range_table = &range_digital; - s->insn_write = apci1564_timer_write; - s->insn_read = apci1564_timer_read; - s->insn_config = apci1564_timer_config; + s->insn_config = apci1564_timer_insn_config; + s->insn_write = apci1564_timer_insn_write; + s->insn_read = apci1564_timer_insn_read; - /* Initialize the watchdog subdevice */ + /* Counter subdevice */ s = &dev->subdevices[4]; + if (devpriv->counters) { + s->type = COMEDI_SUBD_COUNTER; + s->subdev_flags = SDF_WRITABLE | SDF_READABLE | SDF_LSAMPL; + s->n_chan = 3; + s->maxdata = 0xffffffff; + s->range_table = &range_digital; + s->insn_config = apci1564_counter_insn_config; + s->insn_write = apci1564_counter_insn_write; + s->insn_read = apci1564_counter_insn_read; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + /* Initialize the watchdog subdevice */ + s = &dev->subdevices[5]; ret = addi_watchdog_init(s, dev->iobase + APCI1564_WDOG_REG); if (ret) return ret; /* Initialize the diagnostic status subdevice */ - s = &dev->subdevices[5]; + s = &dev->subdevices[6]; s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE; s->n_chan = 2; |