1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
46static const struct das08_board_struct das08_pci_boards[] = {
47 {
48 .name = "pci-das08",
49 .id = PCI_DEVICE_ID_PCIDAS08,
50 .ai_nbits = 12,
51 .ai_pg = das08_bipolar5,
52 .ai_encoding = das08_encode12,
53 .di_nchan = 3,
54 .do_nchan = 4,
55 .i8254_offset = 4,
56 .iosize = 8,
57 },
58};
59
60static int das08_pci_auto_attach(struct comedi_device *dev,
61 unsigned long context_unused)
62{
63 struct pci_dev *pdev = comedi_to_pci_dev(dev);
64 struct das08_private_struct *devpriv;
65 int ret;
66
67 devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
68 if (!devpriv)
69 return -ENOMEM;
70 dev->private = devpriv;
71
72
73 dev->board_ptr = &das08_pci_boards[0];
74
75 ret = comedi_pci_enable(pdev, dev->driver->driver_name);
76 if (ret)
77 return ret;
78 dev->iobase = pci_resource_start(pdev, 2);
79
80 return das08_common_attach(dev, dev->iobase);
81}
82
83static void das08_pci_detach(struct comedi_device *dev)
84{
85 struct pci_dev *pdev = comedi_to_pci_dev(dev);
86
87 das08_common_detach(dev);
88 if (dev->iobase)
89 comedi_pci_disable(pdev);
90}
91
92static struct comedi_driver das08_pci_comedi_driver = {
93 .driver_name = "pci-das08",
94 .module = THIS_MODULE,
95 .auto_attach = das08_pci_auto_attach,
96 .detach = das08_pci_detach,
97};
98
99static int das08_pci_probe(struct pci_dev *dev,
100 const struct pci_device_id *ent)
101{
102 return comedi_pci_auto_config(dev, &das08_pci_comedi_driver);
103}
104
105static DEFINE_PCI_DEVICE_TABLE(das08_pci_table) = {
106 { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_PCIDAS08) },
107 { 0 }
108};
109MODULE_DEVICE_TABLE(pci, das08_pci_table);
110
111static struct pci_driver das08_pci_driver = {
112 .name = "pci-das08",
113 .id_table = das08_pci_table,
114 .probe = das08_pci_probe,
115 .remove = comedi_pci_auto_unconfig,
116};
117module_comedi_pci_driver(das08_pci_comedi_driver, das08_pci_driver);
118
119MODULE_AUTHOR("Comedi http://www.comedi.org");
120MODULE_DESCRIPTION("Comedi low-level driver");
121MODULE_LICENSE("GPL");
122