#include "../comedidev.h"
-#include "mite.h"
#include "ni_labpc.h"
enum labpc_pci_boardid {
},
};
+/* ripped from mite.h and mite_setup2() to avoid mite dependancy */
+#define MITE_IODWBSR 0xc0 /* IO Device Window Base Size Register */
+#define WENAB (1 << 7) /* window enable */
+
+static int labpc_pci_mite_init(struct pci_dev *pcidev)
+{
+ void __iomem *mite_base;
+ u32 main_phys_addr;
+
+ /* ioremap the MITE registers (BAR 0) temporarily */
+ mite_base = pci_ioremap_bar(pcidev, 0);
+ if (!mite_base)
+ return -ENOMEM;
+
+ /* set data window to main registers (BAR 1) */
+ main_phys_addr = pci_resource_start(pcidev, 1);
+ writel(main_phys_addr | WENAB, mite_base + MITE_IODWBSR);
+
+ /* finished with MITE registers */
+ iounmap(mite_base);
+ return 0;
+}
+
static int labpc_pci_auto_attach(struct comedi_device *dev,
unsigned long context)
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
const struct labpc_boardinfo *board = NULL;
struct labpc_private *devpriv;
+ void __iomem *mmio;
int ret;
if (context < ARRAY_SIZE(labpc_pci_boards))
if (ret)
return ret;
- devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
- if (!devpriv)
+ ret = labpc_pci_mite_init(pcidev);
+ if (ret)
+ return ret;
+
+ mmio = pci_ioremap_bar(pcidev, 1);
+ if (!mmio)
return -ENOMEM;
+ dev->iobase = (unsigned long)mmio;
- devpriv->mite = mite_alloc(pcidev);
- if (!devpriv->mite)
+ devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
+ if (!devpriv)
return -ENOMEM;
- ret = mite_setup(devpriv->mite);
- if (ret < 0)
- return ret;
- dev->iobase = (unsigned long)devpriv->mite->daq_io_addr;
return labpc_common_attach(dev, pcidev->irq, IRQF_SHARED);
}
static void labpc_pci_detach(struct comedi_device *dev)
{
- struct labpc_private *devpriv = dev->private;
-
- if (devpriv)
- mite_detach(devpriv->mite);
+ if (dev->iobase)
+ iounmap((void __iomem *)dev->iobase);
if (dev->irq)
free_irq(dev->irq, dev);
comedi_pci_disable(dev);