const struct pcl818_board *board = dev->board_ptr;
struct pcl818_private *devpriv;
struct comedi_subdevice *s;
+ unsigned int io_base = it->options[0];
+ bool fifo_is_supported = board->has_fifo && !(io_base & 0x10);
+ bool fifo_is_wanted = board->has_fifo && it->options[2] == -1;
+ unsigned int io_len = fifo_is_supported ? 0x20 : 0x10;
unsigned int osc_base;
int ret;
if (!devpriv)
return -ENOMEM;
- ret = comedi_request_region(dev, it->options[0],
- board->has_fifo ? 0x20 : 0x10);
+ ret = comedi_check_request_region(dev, io_base, io_len,
+ 0, 0x3ff, io_len);
if (ret)
return ret;
+ if (board->has_fifo) {
+ /* let user know about any required JP6 setting */
+ if (fifo_is_supported) {
+ if (fifo_is_wanted) {
+ dev_info(dev->class_dev,
+ "Assuming JP6 is in \"Enabled\" (default) position to use the FIFO.\n");
+ }
+ } else {
+ dev_info(dev->class_dev,
+ "JP6 needs to be in \"Disabled\" position for correct operation at this base address\n");
+ if (fifo_is_wanted) {
+ dev_warn(dev->class_dev,
+ "FIFO cannot be used at this base address\n");
+ }
+ }
+ }
+
/* we can use IRQ 2-7 for async command support */
if (it->options[1] >= 2 && it->options[1] <= 7) {
ret = request_irq(it->options[1], pcl818_interrupt, 0,
}
/* should we use the FIFO? */
- if (dev->irq && board->has_fifo && it->options[2] == -1)
+ if (dev->irq && fifo_is_supported && fifo_is_wanted)
devpriv->usefifo = 1;
/* we need an IRQ to do DMA on channel 3 or 1 */