Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 324459
b: refs/heads/master
c: 270809a
h: refs/heads/master
i:
  324457: b9e6459
  324455: 6a74f7f
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Aug 14, 2012
1 parent 8defd1c commit 3c6a083
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0a1e6c1fdbdcdbbf9457bc812e145062d59a68c2
refs/heads/master: 270809a80fb610b54de5ee792a607dc37a71195c
78 changes: 44 additions & 34 deletions trunk/drivers/staging/comedi/drivers/adl_pci6208.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,46 +125,41 @@ static int pci6208_ao_rinsn(struct comedi_device *dev,
return insn->n;
}

static int pci6208_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
static int pci6208_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0] & PCI6208_DIO_DO_MASK;
unsigned int val;

val = inw(dev->iobase + PCI6208_DIO);
val = (val & PCI6208_DIO_DI_MASK) >> PCI6208_DIO_DI_SHIFT;

data[1] = val;

return insn->n;
}

static int pci6208_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0];
unsigned int bits = data[1];

if (mask) {
s->state &= ~mask;
s->state |= bits & mask;
s->state |= (bits & mask);

outw(s->state, dev->iobase + PCI6208_DIO);
}

s->state = inw(dev->iobase + PCI6208_DIO);
data[1] = s->state;

return insn->n;
}

static int pci6208_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
unsigned int mask = 1 << chan;

switch (data[0]) {
case INSN_CONFIG_DIO_QUERY:
data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT;
break;
default:
return -EINVAL;
}

return insn->n;
}

static const void *pci6208_find_boardinfo(struct comedi_device *dev,
struct pci_dev *pcidev)
{
Expand All @@ -185,6 +180,7 @@ static int pci6208_attach_pci(struct comedi_device *dev,
const struct pci6208_board *boardinfo;
struct pci6208_private *devpriv;
struct comedi_subdevice *s;
unsigned int val;
int ret;

comedi_set_hw_dev(dev, &pcidev->dev);
Expand All @@ -208,7 +204,7 @@ static int pci6208_attach_pci(struct comedi_device *dev,
}
dev->iobase = pci_resource_start(pcidev, 2);

ret = comedi_alloc_subdevices(dev, 2);
ret = comedi_alloc_subdevices(dev, 3);
if (ret)
return ret;

Expand All @@ -223,17 +219,31 @@ static int pci6208_attach_pci(struct comedi_device *dev,
s->insn_read = pci6208_ao_rinsn;

s = dev->subdevices + 1;
/* digital i/o subdevice */
s->type = COMEDI_SUBD_DIO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 8;
/* digital input subdevice */
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE;
s->n_chan = 4;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = pci6208_dio_insn_bits;
s->insn_config = pci6208_dio_insn_config;
s->insn_bits = pci6208_di_insn_bits;

s = dev->subdevices + 2;
/* digital output subdevice */
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE;
s->n_chan = 4;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = pci6208_do_insn_bits;

/*
* Get the read back signals from the digital outputs
* and save it as the initial state for the subdevice.
*/
val = inw(dev->iobase + PCI6208_DIO);
val = (val & PCI6208_DIO_DO_MASK) >> PCI6208_DIO_DO_SHIFT;
s->state = val;
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->driver->driver_name, dev->board_name, dev->iobase);
Expand Down

0 comments on commit 3c6a083

Please sign in to comment.