staging: comedi: addi_apci_3xxx: use the comedi_device 'mmio' member
Use the new 'mmio' member in the comedi_device for the ioremap'ed base address. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a3e6328810
commit
24a4461279
@ -353,7 +353,6 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||
};
|
||||
|
||||
struct apci3xxx_private {
|
||||
void __iomem *mmio;
|
||||
unsigned int ai_timer;
|
||||
unsigned char ai_time_base;
|
||||
};
|
||||
@ -361,18 +360,17 @@ struct apci3xxx_private {
|
||||
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;
|
||||
@ -385,9 +383,7 @@ static irqreturn_t apci3xxx_irq_handler(int irq, void *d)
|
||||
|
||||
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;
|
||||
@ -395,7 +391,6 @@ static int apci3xxx_ai_started(struct comedi_device *dev)
|
||||
|
||||
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);
|
||||
@ -406,29 +401,29 @@ static int apci3xxx_ai_setup(struct comedi_device *dev, unsigned int 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;
|
||||
}
|
||||
@ -438,10 +433,9 @@ static int apci3xxx_ai_eoc(struct comedi_device *dev,
|
||||
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;
|
||||
@ -452,7 +446,6 @@ static int apci3xxx_ai_insn_read(struct comedi_device *dev,
|
||||
struct comedi_insn *insn,
|
||||
unsigned int *data)
|
||||
{
|
||||
struct apci3xxx_private *devpriv = dev->private;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
@ -462,7 +455,7 @@ static int apci3xxx_ai_insn_read(struct comedi_device *dev,
|
||||
|
||||
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);
|
||||
@ -470,7 +463,7 @@ static int apci3xxx_ai_insn_read(struct comedi_device *dev,
|
||||
return ret;
|
||||
|
||||
/* Read the analog value */
|
||||
data[i] = readl(devpriv->mmio + 28);
|
||||
data[i] = readl(dev->mmio + 28);
|
||||
}
|
||||
|
||||
return insn->n;
|
||||
@ -594,13 +587,13 @@ static int apci3xxx_ai_cmd(struct comedi_device *dev,
|
||||
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;
|
||||
}
|
||||
@ -616,10 +609,9 @@ static int apci3xxx_ao_eoc(struct comedi_device *dev,
|
||||
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;
|
||||
@ -630,7 +622,6 @@ static int apci3xxx_ao_insn_write(struct comedi_device *dev,
|
||||
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;
|
||||
@ -638,10 +629,10 @@ static int apci3xxx_ao_insn_write(struct comedi_device *dev,
|
||||
|
||||
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);
|
||||
@ -740,7 +731,6 @@ static int apci3xxx_dio_insn_bits(struct comedi_device *dev,
|
||||
|
||||
static int apci3xxx_reset(struct comedi_device *dev)
|
||||
{
|
||||
struct apci3xxx_private *devpriv = dev->private;
|
||||
unsigned int val;
|
||||
int i;
|
||||
|
||||
@ -748,18 +738,18 @@ static int apci3xxx_reset(struct comedi_device *dev)
|
||||
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);
|
||||
@ -794,7 +784,7 @@ static int apci3xxx_auto_attach(struct comedi_device *dev,
|
||||
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,
|
||||
@ -918,8 +908,8 @@ static void apci3xxx_detach(struct comedi_device *dev)
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user