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

staging: comedi: adl_pci6208: fix the digital i/o subdevice

The PCI-6208 board has 4 digital outputs and 4 digital inputs.

The support for the digital i/o subdevice was commented out and
the code was just cut-and-paste from the skel driver. Enable
the digital i/o subdevice by uncommenting the code and fixing
the insn_bits and insn_config functions.
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 b4dda059
...@@ -137,54 +137,45 @@ static int pci6208_ao_rinsn(struct comedi_device *dev, ...@@ -137,54 +137,45 @@ static int pci6208_ao_rinsn(struct comedi_device *dev,
return i; return i;
} }
/* DIO devices are slightly special. Although it is possible to static int pci6208_dio_insn_bits(struct comedi_device *dev,
* implement the insn_read/insn_write interface, it is much more struct comedi_subdevice *s,
* useful to applications if you implement the insn_bits interface. struct comedi_insn *insn,
* This allows packed reading/writing of the DIO channels. The unsigned int *data)
* comedi core can convert between insn_bits and insn_read/write */ {
/* static int pci6208_dio_insn_bits(struct comedi_device *dev, unsigned int mask = data[0] & PCI6208_DIO_DO_MASK;
* struct comedi_subdevice *s, */ unsigned int bits = data[1];
/* struct comedi_insn *insn,unsigned int *data) */
/* { */ if (mask) {
/* The insn data is a mask in data[0] and the new data s->state &= ~mask;
* in data[1], each channel cooresponding to a bit. */ s->state |= bits & mask;
/* if(data[0]){ */
/* s->state &= ~data[0]; */ outw(s->state, dev->iobase + PCI6208_DIO);
/* s->state |= data[0]&data[1]; */ }
/* Write out the new digital output lines */
/* outw(s->state,dev->iobase + SKEL_DIO); */ s->state = inw(dev->iobase + PCI6208_DIO);
/* } */ data[1] = s->state;
/* on return, data[1] contains the value of the digital return insn->n;
* input and output lines. */ }
/* data[1]=inw(dev->iobase + SKEL_DIO); */
/* or we could just return the software copy of the output values if static int pci6208_dio_insn_config(struct comedi_device *dev,
* it was a purely digital output subdevice */ struct comedi_subdevice *s,
/* data[1]=s->state; */ struct comedi_insn *insn,
unsigned int *data)
/* return insn->n; */ {
/* } */ int chan = CR_CHAN(insn->chanspec);
unsigned int mask = 1 << chan;
/* static int pci6208_dio_insn_config(struct comedi_device *dev,
* struct comedi_subdevice *s, */ switch (data[0]) {
/* struct comedi_insn *insn,unsigned int *data) */ case INSN_CONFIG_DIO_QUERY:
/* { */ data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT;
/* int chan=CR_CHAN(insn->chanspec); */ break;
default:
/* The input or output configuration of each digital line is return -EINVAL;
* configured by a special insn_config instruction. chanspec }
* contains the channel to be changed, and data[0] contains the
* value COMEDI_INPUT or COMEDI_OUTPUT. */ return insn->n;
}
/* if(data[0]==COMEDI_OUTPUT){ */
/* s->io_bits |= 1<<chan; */
/* }else{ */
/* s->io_bits &= ~(1<<chan); */
/* } */
/* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */
/* return 1; */
/* } */
static struct pci_dev *pci6208_find_device(struct comedi_device *dev, static struct pci_dev *pci6208_find_device(struct comedi_device *dev,
struct comedi_devconfig *it) struct comedi_devconfig *it)
...@@ -268,15 +259,18 @@ static int pci6208_attach(struct comedi_device *dev, ...@@ -268,15 +259,18 @@ static int pci6208_attach(struct comedi_device *dev,
s->insn_write = pci6208_ao_winsn; s->insn_write = pci6208_ao_winsn;
s->insn_read = pci6208_ao_rinsn; s->insn_read = pci6208_ao_rinsn;
/* s=dev->subdevices+1; */ s = dev->subdevices + 1;
/* digital i/o subdevice */ /* digital i/o subdevice */
/* s->type=COMEDI_SUBD_DIO; */ s->type = COMEDI_SUBD_DIO;
/* s->subdev_flags=SDF_READABLE|SDF_WRITABLE; */ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
/* s->n_chan=16; */ s->n_chan = 8;
/* s->maxdata=1; */ s->maxdata = 1;
/* s->range_table=&range_digital; */ s->range_table = &range_digital;
/* s->insn_bits = pci6208_dio_insn_bits; */ s->insn_bits = pci6208_dio_insn_bits;
/* s->insn_config = pci6208_dio_insn_config; */ s->insn_config = pci6208_dio_insn_config;
s->io_bits = 0x0f;
s->state = inw(dev->iobase + PCI6208_DIO);
dev_info(dev->class_dev, "%s: %s, I/O base=0x%04lx\n", dev_info(dev->class_dev, "%s: %s, I/O base=0x%04lx\n",
dev->driver->driver_name, dev->board_name, dev->iobase); dev->driver->driver_name, dev->board_name, dev->iobase);
......
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