struct icp_multi_private {
char valid; /* card is usable */
- void __iomem *io_addr; /* Pointer to mapped io address */
unsigned int AdcCmdStatus; /* ADC Command/Status register */
unsigned int DacCmdStatus; /* DAC Command/Status register */
unsigned int IntEnable; /* Interrupt Enable register */
devpriv->AdcCmdStatus |= range;
/* Output channel, range, mode to ICP Multi */
- writew(devpriv->AdcCmdStatus,
- devpriv->io_addr + ICP_MULTI_ADC_CSR);
+ writew(devpriv->AdcCmdStatus, dev->mmio + ICP_MULTI_ADC_CSR);
}
}
struct comedi_insn *insn,
unsigned long context)
{
- struct icp_multi_private *devpriv = dev->private;
unsigned int status;
- status = readw(devpriv->io_addr + ICP_MULTI_ADC_CSR);
+ status = readw(dev->mmio + ICP_MULTI_ADC_CSR);
if ((status & ADC_BSY) == 0)
return 0;
return -EBUSY;
static int icp_multi_insn_read_ai(struct comedi_device *dev,
struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn,
+ unsigned int *data)
{
struct icp_multi_private *devpriv = dev->private;
int ret = 0;
/* Disable A/D conversion ready interrupt */
devpriv->IntEnable &= ~ADC_READY;
- writew(devpriv->IntEnable, devpriv->io_addr + ICP_MULTI_INT_EN);
+ writew(devpriv->IntEnable, dev->mmio + ICP_MULTI_INT_EN);
/* Clear interrupt status */
devpriv->IntStatus |= ADC_READY;
- writew(devpriv->IntStatus, devpriv->io_addr + ICP_MULTI_INT_STAT);
+ writew(devpriv->IntStatus, dev->mmio + ICP_MULTI_INT_STAT);
/* Set up appropriate channel, mode and range data, for specified ch */
setup_channel_list(dev, s, &insn->chanspec, 1);
for (n = 0; n < insn->n; n++) {
/* Set start ADC bit */
devpriv->AdcCmdStatus |= ADC_ST;
- writew(devpriv->AdcCmdStatus,
- devpriv->io_addr + ICP_MULTI_ADC_CSR);
+ writew(devpriv->AdcCmdStatus, dev->mmio + ICP_MULTI_ADC_CSR);
devpriv->AdcCmdStatus &= ~ADC_ST;
udelay(1);
if (ret)
break;
- data[n] =
- (readw(devpriv->io_addr + ICP_MULTI_AI) >> 4) & 0x0fff;
+ data[n] = (readw(dev->mmio + ICP_MULTI_AI) >> 4) & 0x0fff;
}
/* Disable interrupt */
devpriv->IntEnable &= ~ADC_READY;
- writew(devpriv->IntEnable, devpriv->io_addr + ICP_MULTI_INT_EN);
+ writew(devpriv->IntEnable, dev->mmio + ICP_MULTI_INT_EN);
/* Clear interrupt status */
devpriv->IntStatus |= ADC_READY;
- writew(devpriv->IntStatus, devpriv->io_addr + ICP_MULTI_INT_STAT);
+ writew(devpriv->IntStatus, dev->mmio + ICP_MULTI_INT_STAT);
return ret ? ret : n;
}
struct comedi_insn *insn,
unsigned long context)
{
- struct icp_multi_private *devpriv = dev->private;
unsigned int status;
- status = readw(devpriv->io_addr + ICP_MULTI_DAC_CSR);
+ status = readw(dev->mmio + ICP_MULTI_DAC_CSR);
if ((status & DAC_BSY) == 0)
return 0;
return -EBUSY;
static int icp_multi_insn_write_ao(struct comedi_device *dev,
struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn,
+ unsigned int *data)
{
struct icp_multi_private *devpriv = dev->private;
int n, chan, range;
/* Disable D/A conversion ready interrupt */
devpriv->IntEnable &= ~DAC_READY;
- writew(devpriv->IntEnable, devpriv->io_addr + ICP_MULTI_INT_EN);
+ writew(devpriv->IntEnable, dev->mmio + ICP_MULTI_INT_EN);
/* Clear interrupt status */
devpriv->IntStatus |= DAC_READY;
- writew(devpriv->IntStatus, devpriv->io_addr + ICP_MULTI_INT_STAT);
+ writew(devpriv->IntStatus, dev->mmio + ICP_MULTI_INT_STAT);
/* Get channel number and range */
chan = CR_CHAN(insn->chanspec);
devpriv->DacCmdStatus |= range_codes_analog[range];
devpriv->DacCmdStatus |= (chan << 8);
- writew(devpriv->DacCmdStatus, devpriv->io_addr + ICP_MULTI_DAC_CSR);
+ writew(devpriv->DacCmdStatus, dev->mmio + ICP_MULTI_DAC_CSR);
for (n = 0; n < insn->n; n++) {
/* Wait for analogue output data register to be
/* Disable interrupt */
devpriv->IntEnable &= ~DAC_READY;
writew(devpriv->IntEnable,
- devpriv->io_addr + ICP_MULTI_INT_EN);
+ dev->mmio + ICP_MULTI_INT_EN);
/* Clear interrupt status */
devpriv->IntStatus |= DAC_READY;
writew(devpriv->IntStatus,
- devpriv->io_addr + ICP_MULTI_INT_STAT);
+ dev->mmio + ICP_MULTI_INT_STAT);
/* Clear data received */
devpriv->ao_data[chan] = 0;
}
/* Write data to analogue output data register */
- writew(data[n], devpriv->io_addr + ICP_MULTI_AO);
+ writew(data[n], dev->mmio + ICP_MULTI_AO);
/* Set DAC_ST bit to write the data to selected channel */
devpriv->DacCmdStatus |= DAC_ST;
- writew(devpriv->DacCmdStatus,
- devpriv->io_addr + ICP_MULTI_DAC_CSR);
+ writew(devpriv->DacCmdStatus, dev->mmio + ICP_MULTI_DAC_CSR);
devpriv->DacCmdStatus &= ~DAC_ST;
/* Save analogue output data */
static int icp_multi_insn_bits_di(struct comedi_device *dev,
struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn,
+ unsigned int *data)
{
- struct icp_multi_private *devpriv = dev->private;
-
- data[1] = readw(devpriv->io_addr + ICP_MULTI_DI);
+ data[1] = readw(dev->mmio + ICP_MULTI_DI);
return insn->n;
}
struct comedi_insn *insn,
unsigned int *data)
{
- struct icp_multi_private *devpriv = dev->private;
-
if (comedi_dio_update_state(s, data))
- writew(s->state, devpriv->io_addr + ICP_MULTI_DO);
+ writew(s->state, dev->mmio + ICP_MULTI_DO);
- data[1] = readw(devpriv->io_addr + ICP_MULTI_DI);
+ data[1] = readw(dev->mmio + ICP_MULTI_DI);
return insn->n;
}
static irqreturn_t interrupt_service_icp_multi(int irq, void *d)
{
struct comedi_device *dev = d;
- struct icp_multi_private *devpriv = dev->private;
int int_no;
/* Is this interrupt from our board? */
- int_no = readw(devpriv->io_addr + ICP_MULTI_INT_STAT) & Status_IRQ;
+ int_no = readw(dev->mmio + ICP_MULTI_INT_STAT) & Status_IRQ;
if (!int_no)
/* No, exit */
return IRQ_NONE;
unsigned int i;
/* Clear INT enables and requests */
- writew(0, devpriv->io_addr + ICP_MULTI_INT_EN);
- writew(0x00ff, devpriv->io_addr + ICP_MULTI_INT_STAT);
+ writew(0, dev->mmio + ICP_MULTI_INT_EN);
+ writew(0x00ff, dev->mmio + ICP_MULTI_INT_STAT);
/* Set DACs to 0..5V range and 0V output */
for (i = 0; i < 4; i++) {
devpriv->DacCmdStatus |= (i << 8);
/* Output 0V */
- writew(0, devpriv->io_addr + ICP_MULTI_AO);
+ writew(0, dev->mmio + ICP_MULTI_AO);
/* Set start conversion bit */
devpriv->DacCmdStatus |= DAC_ST;
/* Output to command / status register */
- writew(devpriv->DacCmdStatus,
- devpriv->io_addr + ICP_MULTI_DAC_CSR);
+ writew(devpriv->DacCmdStatus, dev->mmio + ICP_MULTI_DAC_CSR);
/* Delay to allow DAC time to recover */
udelay(1);
}
/* Digital outputs to 0 */
- writew(0, devpriv->io_addr + ICP_MULTI_DO);
+ writew(0, dev->mmio + ICP_MULTI_DO);
return 0;
}
if (ret)
return ret;
- devpriv->io_addr = pci_ioremap_bar(pcidev, 2);
- if (!devpriv->io_addr)
+ dev->mmio = pci_ioremap_bar(pcidev, 2);
+ if (!dev->mmio)
return -ENOMEM;
ret = comedi_alloc_subdevices(dev, 5);
icp_multi_reset(dev);
if (dev->irq)
free_irq(dev->irq, dev);
- if (devpriv && devpriv->io_addr)
- iounmap(devpriv->io_addr);
+ if (dev->mmio)
+ iounmap(dev->mmio);
comedi_pci_disable(dev);
}