This source file includes following definitions.
- pc263_do_insn_bits
- pc263_attach
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 #include <linux/module.h>
28 #include "../comedidev.h"
29
30
31 #define PC263_DO_0_7_REG 0x00
32 #define PC263_DO_8_15_REG 0x01
33
34 struct pc263_board {
35 const char *name;
36 };
37
38 static const struct pc263_board pc263_boards[] = {
39 {
40 .name = "pc263",
41 },
42 };
43
44 static int pc263_do_insn_bits(struct comedi_device *dev,
45 struct comedi_subdevice *s,
46 struct comedi_insn *insn,
47 unsigned int *data)
48 {
49 if (comedi_dio_update_state(s, data)) {
50 outb(s->state & 0xff, dev->iobase + PC263_DO_0_7_REG);
51 outb((s->state >> 8) & 0xff, dev->iobase + PC263_DO_8_15_REG);
52 }
53
54 data[1] = s->state;
55
56 return insn->n;
57 }
58
59 static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
60 {
61 struct comedi_subdevice *s;
62 int ret;
63
64 ret = comedi_request_region(dev, it->options[0], 0x2);
65 if (ret)
66 return ret;
67
68 ret = comedi_alloc_subdevices(dev, 1);
69 if (ret)
70 return ret;
71
72
73 s = &dev->subdevices[0];
74 s->type = COMEDI_SUBD_DO;
75 s->subdev_flags = SDF_WRITABLE;
76 s->n_chan = 16;
77 s->maxdata = 1;
78 s->range_table = &range_digital;
79 s->insn_bits = pc263_do_insn_bits;
80
81
82 s->state = inb(dev->iobase + PC263_DO_0_7_REG) |
83 (inb(dev->iobase + PC263_DO_8_15_REG) << 8);
84
85 return 0;
86 }
87
88 static struct comedi_driver amplc_pc263_driver = {
89 .driver_name = "amplc_pc263",
90 .module = THIS_MODULE,
91 .attach = pc263_attach,
92 .detach = comedi_legacy_detach,
93 .board_name = &pc263_boards[0].name,
94 .offset = sizeof(struct pc263_board),
95 .num_names = ARRAY_SIZE(pc263_boards),
96 };
97
98 module_comedi_driver(amplc_pc263_driver);
99
100 MODULE_AUTHOR("Comedi http://www.comedi.org");
101 MODULE_DESCRIPTION("Comedi driver for Amplicon PC263 relay board");
102 MODULE_LICENSE("GPL");