};
struct apci3xxx_private {
- void __iomem *mmio;
unsigned int ai_timer;
unsigned char ai_time_base;
};
static irqreturn_t apci3xxx_irq_handler(int irq, void *d)
{
struct comedi_device *dev = d;
- struct apci3xxx_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
unsigned int status;
unsigned int val;
/* Test if interrupt occur */
- status = readl(devpriv->mmio + 16);
+ status = readl(dev->mmio + 16);
if ((status & 0x2) == 0x2) {
/* Reset the interrupt */
- writel(status, devpriv->mmio + 16);
+ writel(status, dev->mmio + 16);
- val = readl(devpriv->mmio + 28);
+ val = readl(dev->mmio + 28);
comedi_buf_put(s, val);
s->async->events |= COMEDI_CB_EOA;
static int apci3xxx_ai_started(struct comedi_device *dev)
{
- struct apci3xxx_private *devpriv = dev->private;
-
- if ((readl(devpriv->mmio + 8) & 0x80000) == 0x80000)
+ if ((readl(dev->mmio + 8) & 0x80000) == 0x80000)
return 1;
return 0;
static int apci3xxx_ai_setup(struct comedi_device *dev, unsigned int chanspec)
{
- struct apci3xxx_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(chanspec);
unsigned int range = CR_RANGE(chanspec);
unsigned int aref = CR_AREF(chanspec);
return -EBUSY;
/* Clear the FIFO */
- writel(0x10000, devpriv->mmio + 12);
+ writel(0x10000, dev->mmio + 12);
/* Get and save the delay mode */
- delay_mode = readl(devpriv->mmio + 4);
+ delay_mode = readl(dev->mmio + 4);
delay_mode &= 0xfffffef0;
/* Channel configuration selection */
- writel(delay_mode, devpriv->mmio + 4);
+ writel(delay_mode, dev->mmio + 4);
/* Make the configuration */
val = (range & 3) | ((range >> 2) << 6) |
((aref == AREF_DIFF) << 7);
- writel(val, devpriv->mmio + 0);
+ writel(val, dev->mmio + 0);
/* Channel selection */
- writel(delay_mode | 0x100, devpriv->mmio + 4);
- writel(chan, devpriv->mmio + 0);
+ writel(delay_mode | 0x100, dev->mmio + 4);
+ writel(chan, dev->mmio + 0);
/* Restore delay mode */
- writel(delay_mode, devpriv->mmio + 4);
+ writel(delay_mode, dev->mmio + 4);
/* Set the number of sequence to 1 */
- writel(1, devpriv->mmio + 48);
+ writel(1, dev->mmio + 48);
return 0;
}
struct comedi_insn *insn,
unsigned long context)
{
- struct apci3xxx_private *devpriv = dev->private;
unsigned int status;
- status = readl(devpriv->mmio + 20);
+ status = readl(dev->mmio + 20);
if (status & 0x1)
return 0;
return -EBUSY;
struct comedi_insn *insn,
unsigned int *data)
{
- struct apci3xxx_private *devpriv = dev->private;
int ret;
int i;
for (i = 0; i < insn->n; i++) {
/* Start the conversion */
- writel(0x80000, devpriv->mmio + 8);
+ writel(0x80000, dev->mmio + 8);
/* Wait the EOS */
ret = comedi_timeout(dev, s, insn, apci3xxx_ai_eoc, 0);
return ret;
/* Read the analog value */
- data[i] = readl(devpriv->mmio + 28);
+ data[i] = readl(dev->mmio + 28);
}
return insn->n;
return ret;
/* Set the convert timing unit */
- writel(devpriv->ai_time_base, devpriv->mmio + 36);
+ writel(devpriv->ai_time_base, dev->mmio + 36);
/* Set the convert timing */
- writel(devpriv->ai_timer, devpriv->mmio + 32);
+ writel(devpriv->ai_timer, dev->mmio + 32);
/* Start the conversion */
- writel(0x180000, devpriv->mmio + 8);
+ writel(0x180000, dev->mmio + 8);
return 0;
}
struct comedi_insn *insn,
unsigned long context)
{
- struct apci3xxx_private *devpriv = dev->private;
unsigned int status;
- status = readl(devpriv->mmio + 96);
+ status = readl(dev->mmio + 96);
if (status & 0x100)
return 0;
return -EBUSY;
struct comedi_insn *insn,
unsigned int *data)
{
- struct apci3xxx_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int range = CR_RANGE(insn->chanspec);
int ret;
for (i = 0; i < insn->n; i++) {
/* Set the range selection */
- writel(range, devpriv->mmio + 96);
+ writel(range, dev->mmio + 96);
/* Write the analog value to the selected channel */
- writel((data[i] << 8) | chan, devpriv->mmio + 100);
+ writel((data[i] << 8) | chan, dev->mmio + 100);
/* Wait the end of transfer */
ret = comedi_timeout(dev, s, insn, apci3xxx_ao_eoc, 0);
static int apci3xxx_reset(struct comedi_device *dev)
{
- struct apci3xxx_private *devpriv = dev->private;
unsigned int val;
int i;
disable_irq(dev->irq);
/* Clear the start command */
- writel(0, devpriv->mmio + 8);
+ writel(0, dev->mmio + 8);
/* Reset the interrupt flags */
- val = readl(devpriv->mmio + 16);
- writel(val, devpriv->mmio + 16);
+ val = readl(dev->mmio + 16);
+ writel(val, dev->mmio + 16);
/* clear the EOS */
- readl(devpriv->mmio + 20);
+ readl(dev->mmio + 20);
/* Clear the FIFO */
for (i = 0; i < 16; i++)
- val = readl(devpriv->mmio + 28);
+ val = readl(dev->mmio + 28);
/* Enable the interrupt */
enable_irq(dev->irq);
return ret;
dev->iobase = pci_resource_start(pcidev, 2);
- devpriv->mmio = pci_ioremap_bar(pcidev, 3);
+ dev->mmio = pci_ioremap_bar(pcidev, 3);
if (pcidev->irq > 0) {
ret = request_irq(pcidev->irq, apci3xxx_irq_handler,
apci3xxx_reset(dev);
if (dev->irq)
free_irq(dev->irq, dev);
- if (devpriv->mmio)
- iounmap(devpriv->mmio);
+ if (dev->mmio)
+ iounmap(dev->mmio);
}
comedi_pci_disable(dev);
}