Commit | Line | Data |
---|---|---|
f91f9bea HS |
1 | /* |
2 | * das08_pci.c | |
3 | * comedi driver for DAS08 PCI boards | |
4 | * | |
5 | * COMEDI - Linux Control and Measurement Device Interface | |
6 | * Copyright (C) 2000 David A. Schleef <ds@schleef.org> | |
7 | * Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net> | |
8 | * Copyright (C) 2004 Salvador E. Tropea <set@users.sf.net> <set@ieee.org> | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; either version 2 of the License, or | |
13 | * (at your option) any later version. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | * GNU General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License | |
21 | * along with this program; if not, write to the Free Software | |
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | */ | |
24 | ||
25 | /* | |
26 | * Driver: das08_pci | |
27 | * Description: DAS-08 PCI compatible boards | |
28 | * Devices: (ComputerBoards) PCI-DAS08 [pci-das08] | |
29 | * Author: Warren Jasper, ds, Frank Hess | |
30 | * Updated: Fri, 31 Aug 2012 19:19:06 +0100 | |
31 | * Status: works | |
32 | * | |
33 | * This is the PCI-specific support split off from the das08 driver. | |
34 | * | |
35 | * Configuration Options: not applicable, uses PCI auto config | |
36 | */ | |
37 | ||
38 | #include <linux/pci.h> | |
39 | ||
40 | #include "../comedidev.h" | |
41 | ||
42 | #include "das08.h" | |
43 | ||
44 | #define PCI_DEVICE_ID_PCIDAS08 0x0029 | |
45 | ||
46 | static const struct das08_board_struct das08_pci_boards[] = { | |
47 | { | |
48 | .name = "pci-das08", | |
f91f9bea HS |
49 | .ai_nbits = 12, |
50 | .ai_pg = das08_bipolar5, | |
51 | .ai_encoding = das08_encode12, | |
52 | .di_nchan = 3, | |
53 | .do_nchan = 4, | |
54 | .i8254_offset = 4, | |
55 | .iosize = 8, | |
56 | }, | |
57 | }; | |
58 | ||
59 | static int das08_pci_auto_attach(struct comedi_device *dev, | |
60 | unsigned long context_unused) | |
61 | { | |
62 | struct pci_dev *pdev = comedi_to_pci_dev(dev); | |
63 | struct das08_private_struct *devpriv; | |
64 | int ret; | |
65 | ||
66 | devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); | |
67 | if (!devpriv) | |
68 | return -ENOMEM; | |
69 | dev->private = devpriv; | |
70 | ||
71 | /* The das08 driver needs the board_ptr */ | |
72 | dev->board_ptr = &das08_pci_boards[0]; | |
73 | ||
818f569f | 74 | ret = comedi_pci_enable(dev); |
f91f9bea HS |
75 | if (ret) |
76 | return ret; | |
77 | dev->iobase = pci_resource_start(pdev, 2); | |
78 | ||
79 | return das08_common_attach(dev, dev->iobase); | |
80 | } | |
81 | ||
82 | static void das08_pci_detach(struct comedi_device *dev) | |
83 | { | |
f91f9bea | 84 | das08_common_detach(dev); |
7f072f54 | 85 | comedi_pci_disable(dev); |
f91f9bea HS |
86 | } |
87 | ||
88 | static struct comedi_driver das08_pci_comedi_driver = { | |
89 | .driver_name = "pci-das08", | |
90 | .module = THIS_MODULE, | |
91 | .auto_attach = das08_pci_auto_attach, | |
92 | .detach = das08_pci_detach, | |
93 | }; | |
94 | ||
95 | static int das08_pci_probe(struct pci_dev *dev, | |
b8f4ac23 | 96 | const struct pci_device_id *id) |
f91f9bea | 97 | { |
b8f4ac23 HS |
98 | return comedi_pci_auto_config(dev, &das08_pci_comedi_driver, |
99 | id->driver_data); | |
f91f9bea HS |
100 | } |
101 | ||
102 | static DEFINE_PCI_DEVICE_TABLE(das08_pci_table) = { | |
103 | { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_PCIDAS08) }, | |
104 | { 0 } | |
105 | }; | |
106 | MODULE_DEVICE_TABLE(pci, das08_pci_table); | |
107 | ||
108 | static struct pci_driver das08_pci_driver = { | |
109 | .name = "pci-das08", | |
110 | .id_table = das08_pci_table, | |
111 | .probe = das08_pci_probe, | |
112 | .remove = comedi_pci_auto_unconfig, | |
113 | }; | |
114 | module_comedi_pci_driver(das08_pci_comedi_driver, das08_pci_driver); | |
115 | ||
116 | MODULE_AUTHOR("Comedi http://www.comedi.org"); | |
117 | MODULE_DESCRIPTION("Comedi low-level driver"); | |
118 | MODULE_LICENSE("GPL"); |