summaryrefslogtreecommitdiffstats
path: root/drivers/comedi/drivers/das08_isa.c
blob: 3d43b77cc9f40281523c9cb8c26059c0feab005f (plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// SPDX-License-Identifier: GPL-2.0+
/*
 *  das08_isa.c
 *  comedi driver for DAS08 ISA/PC-104 boards
 *
 *  COMEDI - Linux Control and Measurement Device Interface
 *  Copyright (C) 2000 David A. Schleef <ds@schleef.org>
 *  Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net>
 *  Copyright (C) 2004 Salvador E. Tropea <set@users.sf.net> <set@ieee.org>
 */

/*
 * Driver: das08_isa
 * Description: DAS-08 ISA/PC-104 compatible boards
 * Devices: [Keithley Metrabyte] DAS08 (isa-das08),
 *   [ComputerBoards] DAS08 (isa-das08), DAS08-PGM (das08-pgm),
 *   DAS08-PGH (das08-pgh), DAS08-PGL (das08-pgl), DAS08-AOH (das08-aoh),
 *   DAS08-AOL (das08-aol), DAS08-AOM (das08-aom), DAS08/JR-AO (das08/jr-ao),
 *   DAS08/JR-16-AO (das08jr-16-ao), PC104-DAS08 (pc104-das08),
 *   DAS08/JR/16 (das08jr/16)
 * Author: Warren Jasper, ds, Frank Hess
 * Updated: Fri, 31 Aug 2012 19:19:06 +0100
 * Status: works
 *
 * This is the ISA/PC-104-specific support split off from the das08 driver.
 *
 * Configuration Options:
 *	[0] - base io address
 */

#include <linux/module.h>
#include <linux/comedi/comedidev.h>

#include "das08.h"

static const struct das08_board_struct das08_isa_boards[] = {
	{
		/* cio-das08.pdf */
		.name		= "isa-das08",
		.ai_nbits	= 12,
		.ai_pg		= das08_pg_none,
		.ai_encoding	= das08_encode12,
		.di_nchan	= 3,
		.do_nchan	= 4,
		.i8255_offset	= 8,
		.i8254_offset	= 4,
		.iosize		= 16,		/* unchecked */
	}, {
		/* cio-das08pgx.pdf */
		.name		= "das08-pgm",
		.ai_nbits	= 12,
		.ai_pg		= das08_pgm,
		.ai_encoding	= das08_encode12,
		.di_nchan	= 3,
		.do_nchan	= 4,
		.i8255_offset	= 0,
		.i8254_offset	= 0x04,
		.iosize		= 16,		/* unchecked */
	}, {
		/* cio-das08pgx.pdf */
		.name		= "das08-pgh",
		.ai_nbits	= 12,
		.ai_pg		= das08_pgh,
		.ai_encoding	= das08_encode12,
		.di_nchan	= 3,
		.do_nchan	= 4,
		.i8254_offset	= 0x04,
		.iosize		= 16,		/* unchecked */
	}, {
		/* cio-das08pgx.pdf */
		.name		= "das08-pgl",
		.ai_nbits	= 12,
		.ai_pg		= das08_pgl,
		.ai_encoding	= das08_encode12,
		.di_nchan	= 3,
		.do_nchan	= 4,
		.i8254_offset	= 0x04,
		.iosize		= 16,		/* unchecked */
	}, {
		/* cio-das08_aox.pdf */
		.name		= "das08-aoh",
		.ai_nbits	= 12,
		.ai_pg		= das08_pgh,
		.ai_encoding	= das08_encode12,
		.ao_nbits	= 12,
		.di_nchan	= 3,
		.do_nchan	= 4,
		.i8255_offset	= 0x0c,
		.i8254_offset	= 0x04,
		.iosize		= 16,		/* unchecked */
	}, {
		/* cio-das08_aox.pdf */
		.name		= "das08-aol",
		.ai_nbits	= 12,
		.ai_pg		= das08_pgl,
		.ai_encoding	= das08_encode12,
		.ao_nbits	= 12,
		.di_nchan	= 3,
		.do_nchan	= 4,
		.i8255_offset	= 0x0c,
		.i8254_offset	= 0x04,
		.iosize		= 16,		/* unchecked */
	}, {
		/* cio-das08_aox.pdf */
		.name		= "das08-aom",
		.ai_nbits	= 12,
		.ai_pg		= das08_pgm,
		.ai_encoding	= das08_encode12,
		.ao_nbits	= 12,
		.di_nchan	= 3,
		.do_nchan	= 4,
		.i8255_offset	= 0x0c,
		.i8254_offset	= 0x04,
		.iosize		= 16,		/* unchecked */
	}, {
		/* cio-das08-jr-ao.pdf */
		.name		= "das08/jr-ao",
		.is_jr		= true,
		.ai_nbits	= 12,
		.ai_pg		= das08_pg_none,
		.ai_encoding	= das08_encode12,
		.ao_nbits	= 12,
		.di_nchan	= 8,
		.do_nchan	= 8,
		.iosize		= 16,		/* unchecked */
	}, {
		/* cio-das08jr-16-ao.pdf */
		.name		= "das08jr-16-ao",
		.is_jr		= true,
		.ai_nbits	= 16,
		.ai_pg		= das08_pg_none,
		.ai_encoding	= das08_encode16,
		.ao_nbits	= 16,
		.di_nchan	= 8,
		.do_nchan	= 8,
		.i8254_offset	= 0x04,
		.iosize		= 16,		/* unchecked */
	}, {
		.name		= "pc104-das08",
		.ai_nbits	= 12,
		.ai_pg		= das08_pg_none,
		.ai_encoding	= das08_encode12,
		.di_nchan	= 3,
		.do_nchan	= 4,
		.i8254_offset	= 4,
		.iosize		= 16,		/* unchecked */
	}, {
		.name		= "das08jr/16",
		.is_jr		= true,
		.ai_nbits	= 16,
		.ai_pg		= das08_pg_none,
		.ai_encoding	= das08_encode16,
		.di_nchan	= 8,
		.do_nchan	= 8,
		.iosize		= 16,		/* unchecked */
	},
};

static int das08_isa_attach(struct comedi_device *dev,
			    struct comedi_devconfig *it)
{
	const struct das08_board_struct *board = dev->board_ptr;
	struct das08_private_struct *devpriv;
	int ret;

	devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
	if (!devpriv)
		return -ENOMEM;

	ret = comedi_request_region(dev, it->options[0], board->iosize);
	if (ret)
		return ret;

	return das08_common_attach(dev, dev->iobase);
}

static struct comedi_driver das08_isa_driver = {
	.driver_name	= "isa-das08",
	.module		= THIS_MODULE,
	.attach		= das08_isa_attach,
	.detach		= comedi_legacy_detach,
	.board_name	= &das08_isa_boards[0].name,
	.num_names	= ARRAY_SIZE(das08_isa_boards),
	.offset		= sizeof(das08_isa_boards[0]),
};
module_comedi_driver(das08_isa_driver);

MODULE_AUTHOR("Comedi https://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");