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