From 319a883bfdfe163094ba32c8ab7815a109ba3bcc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 14 Jul 2014 11:54:27 -0700 Subject: [PATCH] staging: comedi: ni_labpc_pci: remove COMEDI_MITE and HAS_DMA dependancy The mite module provides the DMA interface for the PCI MITE ASIC used on many National Instruments DAQ boards. This driver does not use DMA and only depends on the mite module to initialize the MITE ASIC. Handle the initialization localy and remove the unnecessary dependancies. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 2 - drivers/staging/comedi/drivers/ni_labpc.h | 1 - drivers/staging/comedi/drivers/ni_labpc_pci.c | 48 ++++++++++++++----- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 8d992a87d3c4..0c079d29053b 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -1049,9 +1049,7 @@ config COMEDI_NI_670X config COMEDI_NI_LABPC_PCI tristate "NI Lab-PC PCI-1200 support" - depends on HAS_DMA select COMEDI_NI_LABPC - select COMEDI_MITE ---help--- Enable support for National Instruments Lab-PC PCI-1200. diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h index 486589fa6fd8..0fb431137c76 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.h +++ b/drivers/staging/comedi/drivers/ni_labpc.h @@ -36,7 +36,6 @@ struct labpc_boardinfo { }; struct labpc_private { - struct mite_struct *mite; /* for mite chip on pci-1200 */ /* number of data points left to be taken */ unsigned long long count; /* software copy of analog output values */ diff --git a/drivers/staging/comedi/drivers/ni_labpc_pci.c b/drivers/staging/comedi/drivers/ni_labpc_pci.c index 358c4af3e174..5b59be3350ad 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_pci.c +++ b/drivers/staging/comedi/drivers/ni_labpc_pci.c @@ -35,7 +35,6 @@ #include "../comedidev.h" -#include "mite.h" #include "ni_labpc.h" enum labpc_pci_boardid { @@ -53,12 +52,36 @@ static const struct labpc_boardinfo labpc_pci_boards[] = { }, }; +/* 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)) @@ -72,27 +95,26 @@ static int labpc_pci_auto_attach(struct comedi_device *dev, 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); -- 2.30.2