2 * comedi/drivers/ni_labpc_pci.c
3 * Driver for National Instruments Lab-PC PCI-1200
4 * Copyright (C) 2001, 2002, 2003 Frank Mori Hess <fmhess@users.sourceforge.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
18 * Driver: ni_labpc_pci
19 * Description: National Instruments Lab-PC PCI-1200
20 * Devices: (National Instruments) PCI-1200 [ni_pci-1200]
21 * Author: Frank Mori Hess <fmhess@users.sourceforge.net>
24 * This is the PCI-specific support split off from the ni_labpc driver.
26 * Configuration Options: not applicable, uses PCI auto config
32 #include <linux/interrupt.h>
33 #include <linux/slab.h>
34 #include <linux/pci.h>
36 #include "../comedidev.h"
41 enum labpc_pci_boardid {
45 static const struct labpc_boardinfo labpc_pci_boards[] = {
46 [BOARD_NI_PCI1200] = {
47 .name = "ni_pci-1200",
56 static int labpc_pci_auto_attach(struct comedi_device *dev,
57 unsigned long context)
59 struct pci_dev *pcidev = comedi_to_pci_dev(dev);
60 const struct labpc_boardinfo *board = NULL;
61 struct labpc_private *devpriv;
64 if (context < ARRAY_SIZE(labpc_pci_boards))
65 board = &labpc_pci_boards[context];
68 dev->board_ptr = board;
69 dev->board_name = board->name;
71 ret = comedi_pci_enable(dev);
75 devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
78 dev->private = devpriv;
80 devpriv->mite = mite_alloc(pcidev);
83 ret = mite_setup(devpriv->mite);
86 dev->iobase = (unsigned long)devpriv->mite->daq_io_addr;
88 return labpc_common_attach(dev, mite_irq(devpriv->mite), IRQF_SHARED);
91 static void labpc_pci_detach(struct comedi_device *dev)
93 struct labpc_private *devpriv = dev->private;
95 if (devpriv && devpriv->mite) {
96 mite_unsetup(devpriv->mite);
97 mite_free(devpriv->mite);
100 free_irq(dev->irq, dev);
101 comedi_pci_disable(dev);
104 static struct comedi_driver labpc_pci_comedi_driver = {
105 .driver_name = "labpc_pci",
106 .module = THIS_MODULE,
107 .auto_attach = labpc_pci_auto_attach,
108 .detach = labpc_pci_detach,
111 static DEFINE_PCI_DEVICE_TABLE(labpc_pci_table) = {
112 { PCI_VDEVICE(NI, 0x161), BOARD_NI_PCI1200 },
115 MODULE_DEVICE_TABLE(pci, labpc_pci_table);
117 static int labpc_pci_probe(struct pci_dev *dev,
118 const struct pci_device_id *id)
120 return comedi_pci_auto_config(dev, &labpc_pci_comedi_driver,
124 static struct pci_driver labpc_pci_driver = {
126 .id_table = labpc_pci_table,
127 .probe = labpc_pci_probe,
128 .remove = comedi_pci_auto_unconfig,
130 module_comedi_pci_driver(labpc_pci_comedi_driver, labpc_pci_driver);
132 MODULE_DESCRIPTION("Comedi: National Instruments Lab-PC PCI-1200 driver");
133 MODULE_AUTHOR("Comedi http://www.comedi.org");
134 MODULE_LICENSE("GPL");