Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 324623
b: refs/heads/master
c: c8d3739
h: refs/heads/master
i:
  324621: 9597554
  324619: 8b3dd0d
  324615: c9f7c52
  324607: 3e275cd
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Sep 4, 2012
1 parent 6b33ad3 commit a3d6b89
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 98 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: 11d853f955eca03218fe71f6911d02163013fa4d
refs/heads/master: c8d3739dd30c0b1cdc34608bf292249f7fa34ed6
139 changes: 42 additions & 97 deletions trunk/drivers/staging/comedi/drivers/adv_pci1723.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ configures all channels in the same group.

#define PCI_VENDOR_ID_ADVANTECH 0x13fe /* Advantech PCI vendor ID */

/* hardware types of the cards */
#define TYPE_PCI1723 0

#define IORANGE_1723 0x2A

/* all the registers for the pci1723 board */
#define PCI1723_DA(N) ((N)<<1) /* W: D/A register N (0 to 7) */

Expand Down Expand Up @@ -112,37 +107,6 @@ configures all channels in the same group.

#define PCI1723_SELECT_CALIBRATION 0x28 /* Select the calibration Ref_V */

/* static unsigned short pci_list_builded=0; =1 list of card is know */

/*
* Board descriptions for pci1723 boards.
*/
struct pci1723_board {
const char *name;
int vendor_id; /* PCI vendor a device ID of card */
int device_id;
int iorange;
char cardtype;
int n_aochan; /* num of D/A chans */
int n_diochan; /* num of DIO chans */
int ao_maxdata; /* resolution of D/A */
const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */
};

static const struct pci1723_board boardtypes[] = {
{
.name = "pci1723",
.vendor_id = PCI_VENDOR_ID_ADVANTECH,
.device_id = 0x1723,
.iorange = IORANGE_1723,
.cardtype = TYPE_PCI1723,
.n_aochan = 8,
.n_diochan = 16,
.ao_maxdata = 0xffff,
.rangelist_ao = &range_bipolar10,
},
};

/* This structure is for data unique to this hardware driver. */
struct pci1723_private {
int valid; /* card is usable; */
Expand Down Expand Up @@ -289,7 +253,8 @@ static struct pci_dev *pci1723_find_pci_dev(struct comedi_device *dev,
}
if (pcidev->vendor != PCI_VENDOR_ID_ADVANTECH)
continue;
dev->board_ptr = &boardtypes[0];
if (pcidev->device != 0x1723)
continue;
return pcidev;
}
dev_err(dev->class_dev,
Expand All @@ -301,11 +266,10 @@ static struct pci_dev *pci1723_find_pci_dev(struct comedi_device *dev,
static int pci1723_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
const struct pci1723_board *this_board;
struct pci1723_private *devpriv;
struct pci_dev *pcidev;
struct comedi_subdevice *s;
int ret, subdev, n_subdevices;
int ret;

ret = alloc_private(dev, sizeof(*devpriv));
if (ret < 0)
Expand All @@ -316,76 +280,57 @@ static int pci1723_attach(struct comedi_device *dev,
if (!pcidev)
return -EIO;
comedi_set_hw_dev(dev, &pcidev->dev);
this_board = comedi_board(dev);
dev->board_name = this_board->name;
dev->board_name = dev->driver->driver_name;

ret = comedi_pci_enable(pcidev, dev->board_name);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 2);

n_subdevices = 0;

if (this_board->n_aochan)
n_subdevices++;
if (this_board->n_diochan)
n_subdevices++;

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

pci1723_reset(dev);
subdev = 0;
if (this_board->n_aochan) {
s = dev->subdevices + subdev;
dev->write_subdev = s;
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = this_board->n_aochan;
s->maxdata = this_board->ao_maxdata;
s->len_chanlist = this_board->n_aochan;
s->range_table = this_board->rangelist_ao;

s->insn_write = pci1723_ao_write_winsn;
s->insn_read = pci1723_insn_read_ao;

subdev++;
}

if (this_board->n_diochan) {
s = dev->subdevices + subdev;
s->type = COMEDI_SUBD_DIO;
s->subdev_flags =
SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = this_board->n_diochan;
s->maxdata = 1;
s->len_chanlist = this_board->n_diochan;
s->range_table = &range_digital;
s->insn_config = pci1723_dio_insn_config;
s->insn_bits = pci1723_dio_insn_bits;

/* read DIO config */
switch (inw(dev->iobase + PCI1723_DIGITAL_IO_PORT_MODE)
& 0x03) {
case 0x00: /* low byte output, high byte output */
s->io_bits = 0xFFFF;
break;
case 0x01: /* low byte input, high byte output */
s->io_bits = 0xFF00;
break;
case 0x02: /* low byte output, high byte input */
s->io_bits = 0x00FF;
break;
case 0x03: /* low byte input, high byte input */
s->io_bits = 0x0000;
break;
}
/* read DIO port state */
s->state = inw(dev->iobase + PCI1723_READ_DIGITAL_INPUT_DATA);

subdev++;
s = dev->subdevices + 0;
dev->write_subdev = s;
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 8;
s->maxdata = 0xffff;
s->len_chanlist = 8;
s->range_table = &range_bipolar10;
s->insn_write = pci1723_ao_write_winsn;
s->insn_read = pci1723_insn_read_ao;

s = dev->subdevices + 1;
s->type = COMEDI_SUBD_DIO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 16;
s->maxdata = 1;
s->len_chanlist = 16;
s->range_table = &range_digital;
s->insn_config = pci1723_dio_insn_config;
s->insn_bits = pci1723_dio_insn_bits;

/* read DIO config */
switch (inw(dev->iobase + PCI1723_DIGITAL_IO_PORT_MODE) & 0x03) {
case 0x00: /* low byte output, high byte output */
s->io_bits = 0xFFFF;
break;
case 0x01: /* low byte input, high byte output */
s->io_bits = 0xFF00;
break;
case 0x02: /* low byte output, high byte input */
s->io_bits = 0x00FF;
break;
case 0x03: /* low byte input, high byte input */
s->io_bits = 0x0000;
break;
}
/* read DIO port state */
s->state = inw(dev->iobase + PCI1723_READ_DIGITAL_INPUT_DATA);

devpriv->valid = 1;

Expand Down

0 comments on commit a3d6b89

Please sign in to comment.