Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 324966
b: refs/heads/master
c: 4b2f15f
h: refs/heads/master
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Sep 8, 2012
1 parent 35ebd03 commit 5801e58
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 132 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: 4683f9f8010523701d87eb56643a85bec947939f
refs/heads/master: 4b2f15f138f75c15f42015110af111a95f30ed22
252 changes: 121 additions & 131 deletions trunk/drivers/staging/comedi/drivers/me4000.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,6 @@ static const struct me4000_board me4000_boards[] = {
},
};

/*-----------------------------------------------------------------------------
Meilhaus function prototypes
---------------------------------------------------------------------------*/
static int xilinx_download(struct comedi_device *dev);
static int reset_board(struct comedi_device *dev);

static int ai_write_chanlist(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd);

static const struct comedi_lrange me4000_ai_range = {
4,
{
Expand All @@ -232,91 +222,6 @@ static const struct comedi_lrange me4000_ai_range = {
}
};

static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct me4000_info *info;
struct pci_dev *pci_device = NULL;
int result, i;
const struct me4000_board *board;

/* Allocate private memory */
result = alloc_private(dev, sizeof(*info));
if (result)
return result;
info = dev->private;

/*
* Probe the device to determine what device in the series it is.
*/
for_each_pci_dev(pci_device) {
if (pci_device->vendor == PCI_VENDOR_ID_MEILHAUS) {
for (i = 0; i < ARRAY_SIZE(me4000_boards); i++) {
if (me4000_boards[i].device_id ==
pci_device->device) {
/*
* Was a particular
* bus/slot requested?
*/
if ((it->options[0] != 0)
|| (it->options[1] != 0)) {
/*
* Are we on the wrong
* bus/slot?
*/
if (pci_device->bus->number !=
it->options[0]
||
PCI_SLOT(pci_device->devfn)
!= it->options[1]) {
continue;
}
}
dev->board_ptr = me4000_boards + i;
board = comedi_board(dev);
info->pci_dev_p = pci_device;
goto found;
}
}
}
}
return -ENODEV;

found:
dev->board_name = board->name;

result = comedi_pci_enable(pci_device, dev->board_name);
if (result)
return result;

info->plx_regbase = pci_resource_start(pci_device, 1);
if (!info->plx_regbase)
return -ENODEV;

dev->iobase = pci_resource_start(pci_device, 2);
if (!dev->iobase)
return -ENODEV;

info->timer_regbase = pci_resource_start(pci_device, 3);
if (!info->timer_regbase)
return -ENODEV;

info->program_regbase = pci_resource_start(pci_device, 5);
if (!info->program_regbase)
return -ENODEV;

dev->irq = pci_device->irq;

result = xilinx_download(dev);
if (result)
return result;

result = reset_board(dev);
if (result)
return result;

return 0;
}

#define FIRMWARE_NOT_AVAILABLE 1
#if FIRMWARE_NOT_AVAILABLE
extern unsigned char *xilinx_firm;
Expand Down Expand Up @@ -744,6 +649,42 @@ static void ai_write_timer(struct comedi_device *dev,
outl(chan_ticks - 1, dev->iobase + ME4000_AI_CHAN_TIMER_REG);
}

static int ai_write_chanlist(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
unsigned int entry;
unsigned int chan;
unsigned int rang;
unsigned int aref;
int i;

for (i = 0; i < cmd->chanlist_len; i++) {
chan = CR_CHAN(cmd->chanlist[i]);
rang = CR_RANGE(cmd->chanlist[i]);
aref = CR_AREF(cmd->chanlist[i]);

entry = chan;

if (rang == 0)
entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_2_5;
else if (rang == 1)
entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_10;
else if (rang == 2)
entry |= ME4000_AI_LIST_RANGE_BIPOLAR_2_5;
else
entry |= ME4000_AI_LIST_RANGE_BIPOLAR_10;

if (aref == SDF_DIFF)
entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL;
else
entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED;

outl(entry, dev->iobase + ME4000_AI_CHANNEL_LIST_REG);
}

return 0;
}

static int ai_prepare(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd,
Expand Down Expand Up @@ -811,42 +752,6 @@ static int ai_prepare(struct comedi_device *dev,
return 0;
}

static int ai_write_chanlist(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
unsigned int entry;
unsigned int chan;
unsigned int rang;
unsigned int aref;
int i;

for (i = 0; i < cmd->chanlist_len; i++) {
chan = CR_CHAN(cmd->chanlist[i]);
rang = CR_RANGE(cmd->chanlist[i]);
aref = CR_AREF(cmd->chanlist[i]);

entry = chan;

if (rang == 0)
entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_2_5;
else if (rang == 1)
entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_10;
else if (rang == 2)
entry |= ME4000_AI_LIST_RANGE_BIPOLAR_2_5;
else
entry |= ME4000_AI_LIST_RANGE_BIPOLAR_10;

if (aref == SDF_DIFF)
entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL;
else
entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED;

outl(entry, dev->iobase + ME4000_AI_CHANNEL_LIST_REG);
}

return 0;
}

static int me4000_ai_do_cmd(struct comedi_device *dev,
struct comedi_subdevice *s)
{
Expand Down Expand Up @@ -1832,6 +1737,91 @@ static int me4000_cnt_insn_write(struct comedi_device *dev,
return 1;
}

static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct me4000_info *info;
struct pci_dev *pci_device = NULL;
int result, i;
const struct me4000_board *board;

/* Allocate private memory */
result = alloc_private(dev, sizeof(*info));
if (result)
return result;
info = dev->private;

/*
* Probe the device to determine what device in the series it is.
*/
for_each_pci_dev(pci_device) {
if (pci_device->vendor == PCI_VENDOR_ID_MEILHAUS) {
for (i = 0; i < ARRAY_SIZE(me4000_boards); i++) {
if (me4000_boards[i].device_id ==
pci_device->device) {
/*
* Was a particular
* bus/slot requested?
*/
if ((it->options[0] != 0)
|| (it->options[1] != 0)) {
/*
* Are we on the wrong
* bus/slot?
*/
if (pci_device->bus->number !=
it->options[0]
||
PCI_SLOT(pci_device->devfn)
!= it->options[1]) {
continue;
}
}
dev->board_ptr = me4000_boards + i;
board = comedi_board(dev);
info->pci_dev_p = pci_device;
goto found;
}
}
}
}
return -ENODEV;

found:
dev->board_name = board->name;

result = comedi_pci_enable(pci_device, dev->board_name);
if (result)
return result;

info->plx_regbase = pci_resource_start(pci_device, 1);
if (!info->plx_regbase)
return -ENODEV;

dev->iobase = pci_resource_start(pci_device, 2);
if (!dev->iobase)
return -ENODEV;

info->timer_regbase = pci_resource_start(pci_device, 3);
if (!info->timer_regbase)
return -ENODEV;

info->program_regbase = pci_resource_start(pci_device, 5);
if (!info->program_regbase)
return -ENODEV;

dev->irq = pci_device->irq;

result = xilinx_download(dev);
if (result)
return result;

result = reset_board(dev);
if (result)
return result;

return 0;
}

static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct me4000_board *thisboard;
Expand Down

0 comments on commit 5801e58

Please sign in to comment.