#define DIO200_IO_SIZE 0x20
#define DIO200_PCIE_IO_SIZE 0x4000
-/*
- * Register region.
- */
-enum dio200_regtype { no_regtype = 0, io_regtype, mmio_regtype };
-struct dio200_region {
- union {
- unsigned long iobase; /* I/O base address */
- unsigned char __iomem *membase; /* mapped MMIO base address */
- } u;
- enum dio200_regtype regtype;
-};
-
/*
* Subdevice types.
*/
* Comedi device private data.
*/
struct dio200_private {
- struct dio200_region io; /* Register region */
int intr_sd;
};
unsigned int offset)
{
const struct dio200_board *thisboard = comedi_board(dev);
- struct dio200_private *devpriv = dev->private;
offset <<= thisboard->mainshift;
- if (devpriv->io.regtype == io_regtype)
- return inb(devpriv->io.u.iobase + offset);
- return readb(devpriv->io.u.membase + offset);
+ if (dev->mmio)
+ return readb(dev->mmio + offset);
+ return inb(dev->iobase + offset);
}
/*
unsigned char val)
{
const struct dio200_board *thisboard = comedi_board(dev);
- struct dio200_private *devpriv = dev->private;
offset <<= thisboard->mainshift;
- if (devpriv->io.regtype == io_regtype)
- outb(val, devpriv->io.u.iobase + offset);
+
+ if (dev->mmio)
+ writeb(val, dev->mmio + offset);
else
- writeb(val, devpriv->io.u.membase + offset);
+ outb(val, dev->iobase + offset);
}
/*
unsigned int offset)
{
const struct dio200_board *thisboard = comedi_board(dev);
- struct dio200_private *devpriv = dev->private;
offset <<= thisboard->mainshift;
- if (devpriv->io.regtype == io_regtype)
- return inl(devpriv->io.u.iobase + offset);
- return readl(devpriv->io.u.membase + offset);
+ if (dev->mmio)
+ return readl(dev->mmio + offset);
+ return inl(dev->iobase + offset);
}
/*
unsigned int val)
{
const struct dio200_board *thisboard = comedi_board(dev);
- struct dio200_private *devpriv = dev->private;
offset <<= thisboard->mainshift;
- if (devpriv->io.regtype == io_regtype)
- outl(val, devpriv->io.u.iobase + offset);
+
+ if (dev->mmio)
+ writel(val, dev->mmio + offset);
else
- writel(val, devpriv->io.u.membase + offset);
+ outl(val, dev->iobase + offset);
}
/*
return -EINVAL;
}
if (pci_resource_flags(pci_dev, bar) & IORESOURCE_MEM) {
- devpriv->io.u.membase = pci_ioremap_bar(pci_dev, bar);
- if (!devpriv->io.u.membase) {
+ dev->mmio = pci_ioremap_bar(pci_dev, bar);
+ if (!dev->mmio) {
dev_err(dev->class_dev,
"error! cannot remap registers\n");
return -ENOMEM;
}
- devpriv->io.regtype = mmio_regtype;
} else {
- devpriv->io.u.iobase = pci_resource_start(pci_dev, bar);
- devpriv->io.regtype = io_regtype;
+ dev->iobase = pci_resource_start(pci_dev, bar);
}
switch (context_model) {
case pcie215_model:
static void dio200_pci_detach(struct comedi_device *dev)
{
- struct dio200_private *devpriv = dev->private;
-
amplc_dio200_common_detach(dev);
- if (devpriv && devpriv->io.regtype == mmio_regtype)
- iounmap(devpriv->io.u.membase);
+ if (dev->mmio)
+ iounmap(dev->mmio);
comedi_pci_disable(dev);
}