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#include <linux/module.h>
26#include <linux/comedi/comedi_pci.h>
27
28#include "das08.h"
29
30static const struct das08_board_struct das08_pci_boards[] = {
31 {
32 .name = "pci-das08",
33 .ai_nbits = 12,
34 .ai_pg = das08_bipolar5,
35 .ai_encoding = das08_encode12,
36 .di_nchan = 3,
37 .do_nchan = 4,
38 .i8254_offset = 4,
39 .iosize = 8,
40 },
41};
42
43static int das08_pci_auto_attach(struct comedi_device *dev,
44 unsigned long context_unused)
45{
46 struct pci_dev *pdev = comedi_to_pci_dev(dev);
47 struct das08_private_struct *devpriv;
48 int ret;
49
50 devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
51 if (!devpriv)
52 return -ENOMEM;
53
54
55 dev->board_ptr = &das08_pci_boards[0];
56
57 ret = comedi_pci_enable(dev);
58 if (ret)
59 return ret;
60 dev->iobase = pci_resource_start(pdev, 2);
61
62 return das08_common_attach(dev, dev->iobase);
63}
64
65static struct comedi_driver das08_pci_comedi_driver = {
66 .driver_name = "pci-das08",
67 .module = THIS_MODULE,
68 .auto_attach = das08_pci_auto_attach,
69 .detach = comedi_pci_detach,
70};
71
72static int das08_pci_probe(struct pci_dev *dev,
73 const struct pci_device_id *id)
74{
75 return comedi_pci_auto_config(dev, &das08_pci_comedi_driver,
76 id->driver_data);
77}
78
79static const struct pci_device_id das08_pci_table[] = {
80 { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0029) },
81 { 0 }
82};
83MODULE_DEVICE_TABLE(pci, das08_pci_table);
84
85static struct pci_driver das08_pci_driver = {
86 .name = "pci-das08",
87 .id_table = das08_pci_table,
88 .probe = das08_pci_probe,
89 .remove = comedi_pci_auto_unconfig,
90};
91module_comedi_pci_driver(das08_pci_comedi_driver, das08_pci_driver);
92
93MODULE_AUTHOR("Comedi https://www.comedi.org");
94MODULE_DESCRIPTION("Comedi low-level driver");
95MODULE_LICENSE("GPL");
96