blob: 329b1d7bc45e4ef5546c3a5bba5ee0a0c8eba8ee [file] [log] [blame]
David Schleefed9eccb2008-11-04 20:29:31 -08001/*
2 include/linux/comedidev.h
3 header file for kernel-only structures, variables, and constants
4
5 COMEDI - Linux Control and Measurement Device Interface
6 Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
22*/
23
24#ifndef _COMEDIDEV_H
25#define _COMEDIDEV_H
26
27#include <linux/kernel.h>
28#include <linux/module.h>
David Schleefed9eccb2008-11-04 20:29:31 -080029#include <linux/kdev_t.h>
30#include <linux/slab.h>
Randy Dunlapf9c51372009-06-05 11:10:42 -070031#include <linux/delay.h>
David Schleefed9eccb2008-11-04 20:29:31 -080032#include <linux/errno.h>
33#include <linux/spinlock.h>
34#include <linux/mutex.h>
35#include <linux/wait.h>
36#include <linux/mm.h>
37#include <linux/init.h>
38#include <linux/vmalloc.h>
David Schleefed9eccb2008-11-04 20:29:31 -080039#include <linux/dma-mapping.h>
Greg Kroah-Hartmane0dcef72008-11-13 16:36:22 -080040#include <linux/uaccess.h>
41#include <linux/io.h>
Greg Kroah-Hartmanc7a5d702009-06-19 11:04:32 -070042#include <linux/timer.h>
David Schleefed9eccb2008-11-04 20:29:31 -080043
44#include "comedi.h"
45
Greg Kroah-Hartmane0dcef72008-11-13 16:36:22 -080046#define DPRINTK(format, args...) do { \
47 if (comedi_debug) \
Ian Abbott4f870fe2012-08-16 14:38:05 +010048 pr_debug("comedi: " format, ## args); \
Greg Kroah-Hartmane0dcef72008-11-13 16:36:22 -080049} while (0)
David Schleefed9eccb2008-11-04 20:29:31 -080050
Greg Kroah-Hartmane0dcef72008-11-13 16:36:22 -080051#define COMEDI_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
Shane Warden62eeae92009-09-22 16:13:04 -070052#define COMEDI_VERSION_CODE COMEDI_VERSION(COMEDI_MAJORVERSION, \
53 COMEDI_MINORVERSION, COMEDI_MICROVERSION)
David Schleefed9eccb2008-11-04 20:29:31 -080054#define COMEDI_RELEASE VERSION
55
David Schleefed9eccb2008-11-04 20:29:31 -080056#define COMEDI_NUM_MINORS 0x100
David Schleefed9eccb2008-11-04 20:29:31 -080057#define COMEDI_NUM_BOARD_MINORS 0x30
58#define COMEDI_FIRST_SUBDEVICE_MINOR COMEDI_NUM_BOARD_MINORS
59
Bill Pemberton34c43922009-03-16 22:05:14 -040060struct comedi_subdevice {
Bill Pemberton71b5f4f2009-03-16 22:05:08 -040061 struct comedi_device *device;
H Hartley Sweeten90a35c12012-12-19 17:27:02 -070062 int index;
David Schleefed9eccb2008-11-04 20:29:31 -080063 int type;
64 int n_chan;
Greg Kroah-Hartmanbaf22b62010-04-30 15:26:54 -070065 int subdev_flags;
David Schleefed9eccb2008-11-04 20:29:31 -080066 int len_chanlist; /* maximum length of channel/gain list */
67
68 void *private;
69
Bill Pembertond1636792009-03-16 22:05:20 -040070 struct comedi_async *async;
David Schleefed9eccb2008-11-04 20:29:31 -080071
72 void *lock;
73 void *busy;
74 unsigned runflags;
75 spinlock_t spin_lock;
76
H Hartley Sweetend4a7dc82012-06-18 14:45:42 -070077 unsigned int io_bits;
David Schleefed9eccb2008-11-04 20:29:31 -080078
Bill Pemberton790c5542009-03-16 22:05:02 -040079 unsigned int maxdata; /* if maxdata==0, use list */
80 const unsigned int *maxdata_list; /* list is channel specific */
David Schleefed9eccb2008-11-04 20:29:31 -080081
82 unsigned int flags;
83 const unsigned int *flaglist;
84
85 unsigned int settling_time_0;
86
Bill Pemberton9ced1de2009-03-16 22:05:31 -040087 const struct comedi_lrange *range_table;
88 const struct comedi_lrange *const *range_table_list;
David Schleefed9eccb2008-11-04 20:29:31 -080089
90 unsigned int *chanlist; /* driver-owned chanlist (not used) */
91
Mithlesh Thukral0a85b6f2009-06-08 21:04:41 +053092 int (*insn_read) (struct comedi_device *, struct comedi_subdevice *,
93 struct comedi_insn *, unsigned int *);
94 int (*insn_write) (struct comedi_device *, struct comedi_subdevice *,
95 struct comedi_insn *, unsigned int *);
96 int (*insn_bits) (struct comedi_device *, struct comedi_subdevice *,
97 struct comedi_insn *, unsigned int *);
98 int (*insn_config) (struct comedi_device *, struct comedi_subdevice *,
99 struct comedi_insn *, unsigned int *);
David Schleefed9eccb2008-11-04 20:29:31 -0800100
Bill Pemberton34c43922009-03-16 22:05:14 -0400101 int (*do_cmd) (struct comedi_device *, struct comedi_subdevice *);
Mithlesh Thukral0a85b6f2009-06-08 21:04:41 +0530102 int (*do_cmdtest) (struct comedi_device *, struct comedi_subdevice *,
103 struct comedi_cmd *);
Bill Pemberton34c43922009-03-16 22:05:14 -0400104 int (*poll) (struct comedi_device *, struct comedi_subdevice *);
105 int (*cancel) (struct comedi_device *, struct comedi_subdevice *);
Shane Warden62eeae92009-09-22 16:13:04 -0700106 /* int (*do_lock)(struct comedi_device *, struct comedi_subdevice *); */
107 /* int (*do_unlock)(struct comedi_device *, \
108 struct comedi_subdevice *); */
David Schleefed9eccb2008-11-04 20:29:31 -0800109
110 /* called when the buffer changes */
Shane Warden62eeae92009-09-22 16:13:04 -0700111 int (*buf_change) (struct comedi_device *dev,
112 struct comedi_subdevice *s, unsigned long new_size);
David Schleefed9eccb2008-11-04 20:29:31 -0800113
Shane Warden62eeae92009-09-22 16:13:04 -0700114 void (*munge) (struct comedi_device *dev, struct comedi_subdevice *s,
Mithlesh Thukral0a85b6f2009-06-08 21:04:41 +0530115 void *data, unsigned int num_bytes,
116 unsigned int start_chan_index);
David Schleefed9eccb2008-11-04 20:29:31 -0800117 enum dma_data_direction async_dma_dir;
118
119 unsigned int state;
120
Bill Pemberton0bfbbe82009-03-16 22:05:36 -0400121 struct device *class_dev;
David Schleefed9eccb2008-11-04 20:29:31 -0800122 int minor;
123};
124
125struct comedi_buf_page {
126 void *virt_addr;
127 dma_addr_t dma_addr;
128};
129
Bill Pembertond1636792009-03-16 22:05:20 -0400130struct comedi_async {
Bill Pemberton34c43922009-03-16 22:05:14 -0400131 struct comedi_subdevice *subdevice;
David Schleefed9eccb2008-11-04 20:29:31 -0800132
133 void *prealloc_buf; /* pre-allocated buffer */
134 unsigned int prealloc_bufsz; /* buffer size, in bytes */
Shane Warden62eeae92009-09-22 16:13:04 -0700135 /* virtual and dma address of each page */
136 struct comedi_buf_page *buf_page_list;
David Schleefed9eccb2008-11-04 20:29:31 -0800137 unsigned n_buf_pages; /* num elements in buf_page_list */
138
139 unsigned int max_bufsize; /* maximum buffer size, bytes */
Shane Warden62eeae92009-09-22 16:13:04 -0700140 /* current number of mmaps of prealloc_buf */
141 unsigned int mmap_count;
David Schleefed9eccb2008-11-04 20:29:31 -0800142
Shane Warden62eeae92009-09-22 16:13:04 -0700143 /* byte count for writer (write completed) */
144 unsigned int buf_write_count;
145 /* byte count for writer (allocated for writing) */
146 unsigned int buf_write_alloc_count;
147 /* byte count for reader (read completed) */
148 unsigned int buf_read_count;
149 /* byte count for reader (allocated for reading) */
150 unsigned int buf_read_alloc_count;
David Schleefed9eccb2008-11-04 20:29:31 -0800151
152 unsigned int buf_write_ptr; /* buffer marker for writer */
153 unsigned int buf_read_ptr; /* buffer marker for reader */
154
155 unsigned int cur_chan; /* useless channel marker for interrupt */
156 /* number of bytes that have been received for current scan */
157 unsigned int scan_progress;
158 /* keeps track of where we are in chanlist as for munging */
159 unsigned int munge_chan;
160 /* number of bytes that have been munged */
161 unsigned int munge_count;
162 /* buffer marker for munging */
163 unsigned int munge_ptr;
164
165 unsigned int events; /* events that have occurred */
166
Bill Pembertonea6d0d42009-03-16 22:05:47 -0400167 struct comedi_cmd cmd;
David Schleefed9eccb2008-11-04 20:29:31 -0800168
169 wait_queue_head_t wait_head;
170
Greg Kroah-Hartmane0dcef72008-11-13 16:36:22 -0800171 /* callback stuff */
David Schleefed9eccb2008-11-04 20:29:31 -0800172 unsigned int cb_mask;
173 int (*cb_func) (unsigned int flags, void *);
174 void *cb_arg;
175
Shane Warden62eeae92009-09-22 16:13:04 -0700176 int (*inttrig) (struct comedi_device *dev, struct comedi_subdevice *s,
Greg Kroah-Hartmane0dcef72008-11-13 16:36:22 -0800177 unsigned int x);
David Schleefed9eccb2008-11-04 20:29:31 -0800178};
179
Bill Pemberton139dfbd2009-03-16 22:05:25 -0400180struct comedi_driver {
181 struct comedi_driver *next;
David Schleefed9eccb2008-11-04 20:29:31 -0800182
183 const char *driver_name;
184 struct module *module;
Bill Pemberton0707bb02009-03-16 22:06:20 -0400185 int (*attach) (struct comedi_device *, struct comedi_devconfig *);
H Hartley Sweeten484ecc92012-05-17 17:11:14 -0700186 void (*detach) (struct comedi_device *);
Ian Abbott8ed705a2012-10-27 21:44:14 +0100187 int (*auto_attach) (struct comedi_device *, unsigned long);
David Schleefed9eccb2008-11-04 20:29:31 -0800188
189 /* number of elements in board_name and board_id arrays */
190 unsigned int num_names;
191 const char *const *board_name;
192 /* offset in bytes from one board name pointer to the next */
193 int offset;
194};
195
Bill Pemberton71b5f4f2009-03-16 22:05:08 -0400196struct comedi_device {
David Schleefed9eccb2008-11-04 20:29:31 -0800197 int use_count;
Bill Pemberton139dfbd2009-03-16 22:05:25 -0400198 struct comedi_driver *driver;
David Schleefed9eccb2008-11-04 20:29:31 -0800199 void *private;
200
Bill Pemberton0bfbbe82009-03-16 22:05:36 -0400201 struct device *class_dev;
David Schleefed9eccb2008-11-04 20:29:31 -0800202 int minor;
Greg Kroah-Hartmane0dcef72008-11-13 16:36:22 -0800203 /* hw_dev is passed to dma_alloc_coherent when allocating async buffers
204 * for subdevices that have async_dma_dir set to something other than
205 * DMA_NONE */
David Schleefed9eccb2008-11-04 20:29:31 -0800206 struct device *hw_dev;
207
208 const char *board_name;
209 const void *board_ptr;
210 int attached;
David Schleefed9eccb2008-11-04 20:29:31 -0800211 spinlock_t spinlock;
212 struct mutex mutex;
213 int in_request_module;
214
215 int n_subdevices;
Bill Pemberton34c43922009-03-16 22:05:14 -0400216 struct comedi_subdevice *subdevices;
David Schleefed9eccb2008-11-04 20:29:31 -0800217
218 /* dumb */
219 unsigned long iobase;
220 unsigned int irq;
221
Bill Pemberton34c43922009-03-16 22:05:14 -0400222 struct comedi_subdevice *read_subdev;
223 struct comedi_subdevice *write_subdev;
David Schleefed9eccb2008-11-04 20:29:31 -0800224
225 struct fasync_struct *async_queue;
226
Ian Abbott3c17ba072010-05-19 14:10:00 +0100227 int (*open) (struct comedi_device *dev);
Shane Warden62eeae92009-09-22 16:13:04 -0700228 void (*close) (struct comedi_device *dev);
David Schleefed9eccb2008-11-04 20:29:31 -0800229};
230
Ian Abbott4dba6c02012-11-02 19:18:00 +0000231static inline const void *comedi_board(const struct comedi_device *dev)
H Hartley Sweeten37859f82012-04-27 14:10:15 -0700232{
233 return dev->board_ptr;
234}
235
David Schleefed9eccb2008-11-04 20:29:31 -0800236#ifdef CONFIG_COMEDI_DEBUG
237extern int comedi_debug;
238#else
Greg Kroah-Hartmane0dcef72008-11-13 16:36:22 -0800239static const int comedi_debug;
David Schleefed9eccb2008-11-04 20:29:31 -0800240#endif
241
242/*
243 * function prototypes
244 */
245
Bill Pemberton34c43922009-03-16 22:05:14 -0400246void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s);
Bill Pemberton71b5f4f2009-03-16 22:05:08 -0400247void comedi_error(const struct comedi_device *dev, const char *s);
David Schleefed9eccb2008-11-04 20:29:31 -0800248
249/* we can expand the number of bits used to encode devices/subdevices into
250 the minor number soon, after more distros support > 8 bit minor numbers
251 (like after Debian Etch gets released) */
252enum comedi_minor_bits {
253 COMEDI_DEVICE_MINOR_MASK = 0xf,
254 COMEDI_SUBDEVICE_MINOR_MASK = 0xf0
255};
256static const unsigned COMEDI_SUBDEVICE_MINOR_SHIFT = 4;
257static const unsigned COMEDI_SUBDEVICE_MINOR_OFFSET = 1;
258
H Hartley Sweeten85104e92012-12-19 15:34:40 -0700259struct comedi_device *comedi_dev_from_minor(unsigned minor);
260
H Hartley Sweeten8b9ba6e2012-06-12 11:57:27 -0700261int comedi_alloc_subdevices(struct comedi_device *, int);
H Hartley Sweeten2f0b9d02012-06-11 17:45:15 -0700262
Bill Pemberton71b5f4f2009-03-16 22:05:08 -0400263void comedi_device_detach(struct comedi_device *dev);
Mithlesh Thukral0a85b6f2009-06-08 21:04:41 +0530264int comedi_device_attach(struct comedi_device *dev,
265 struct comedi_devconfig *it);
Bill Pemberton139dfbd2009-03-16 22:05:25 -0400266int comedi_driver_register(struct comedi_driver *);
267int comedi_driver_unregister(struct comedi_driver *);
David Schleefed9eccb2008-11-04 20:29:31 -0800268
H Hartley Sweeten20416252012-05-01 17:20:04 -0700269/**
270 * module_comedi_driver() - Helper macro for registering a comedi driver
271 * @__comedi_driver: comedi_driver struct
272 *
273 * Helper macro for comedi drivers which do not do anything special in module
274 * init/exit. This eliminates a lot of boilerplate. Each module may only use
275 * this macro once, and calling it replaces module_init() and module_exit().
276 */
277#define module_comedi_driver(__comedi_driver) \
278 module_driver(__comedi_driver, comedi_driver_register, \
279 comedi_driver_unregister)
280
David Schleefed9eccb2008-11-04 20:29:31 -0800281void init_polling(void);
282void cleanup_polling(void);
Bill Pemberton71b5f4f2009-03-16 22:05:08 -0400283void start_polling(struct comedi_device *);
284void stop_polling(struct comedi_device *);
David Schleefed9eccb2008-11-04 20:29:31 -0800285
David Schleefed9eccb2008-11-04 20:29:31 -0800286#ifdef CONFIG_PROC_FS
287void comedi_proc_init(void);
288void comedi_proc_cleanup(void);
289#else
290static inline void comedi_proc_init(void)
291{
292}
Mithlesh Thukral0a85b6f2009-06-08 21:04:41 +0530293
David Schleefed9eccb2008-11-04 20:29:31 -0800294static inline void comedi_proc_cleanup(void)
295{
296}
297#endif
298
299/* subdevice runflags */
300enum subdevice_runflags {
301 SRF_USER = 0x00000001,
302 SRF_RT = 0x00000002,
Greg Kroah-Hartmane0dcef72008-11-13 16:36:22 -0800303 /* indicates an COMEDI_CB_ERROR event has occurred since the last
304 * command was started */
David Schleefed9eccb2008-11-04 20:29:31 -0800305 SRF_ERROR = 0x00000004,
306 SRF_RUNNING = 0x08000000
307};
308
H Hartley Sweetene0dac312012-12-19 15:42:47 -0700309bool comedi_is_subdevice_running(struct comedi_subdevice *s);
310
Mark Rankilor5e220112010-05-06 17:49:37 +0800311int comedi_check_chanlist(struct comedi_subdevice *s,
312 int n,
313 unsigned int *chanlist);
David Schleefed9eccb2008-11-04 20:29:31 -0800314
315/* range stuff */
316
Greg Kroah-Hartmane0dcef72008-11-13 16:36:22 -0800317#define RANGE(a, b) {(a)*1e6, (b)*1e6, 0}
318#define RANGE_ext(a, b) {(a)*1e6, (b)*1e6, RF_EXTERNAL}
319#define RANGE_mA(a, b) {(a)*1e6, (b)*1e6, UNIT_mA}
Greg Kroah-Hartmanbaf22b62010-04-30 15:26:54 -0700320#define RANGE_unitless(a, b) {(a)*1e6, (b)*1e6, 0}
Greg Kroah-Hartmane0dcef72008-11-13 16:36:22 -0800321#define BIP_RANGE(a) {-(a)*1e6, (a)*1e6, 0}
322#define UNI_RANGE(a) {0, (a)*1e6, 0}
David Schleefed9eccb2008-11-04 20:29:31 -0800323
Bill Pemberton9ced1de2009-03-16 22:05:31 -0400324extern const struct comedi_lrange range_bipolar10;
325extern const struct comedi_lrange range_bipolar5;
326extern const struct comedi_lrange range_bipolar2_5;
327extern const struct comedi_lrange range_unipolar10;
328extern const struct comedi_lrange range_unipolar5;
329extern const struct comedi_lrange range_unknown;
David Schleefed9eccb2008-11-04 20:29:31 -0800330
331#define range_digital range_unipolar5
332
333#if __GNUC__ >= 3
334#define GCC_ZERO_LENGTH_ARRAY
335#else
336#define GCC_ZERO_LENGTH_ARRAY 0
337#endif
338
Bill Pemberton9ced1de2009-03-16 22:05:31 -0400339struct comedi_lrange {
David Schleefed9eccb2008-11-04 20:29:31 -0800340 int length;
Bill Pemberton1f6325d2009-03-16 22:06:31 -0400341 struct comedi_krange range[GCC_ZERO_LENGTH_ARRAY];
David Schleefed9eccb2008-11-04 20:29:31 -0800342};
343
344/* some silly little inline functions */
345
Bill Pemberton34c43922009-03-16 22:05:14 -0400346static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd)
David Schleefed9eccb2008-11-04 20:29:31 -0800347{
348 if (subd->subdev_flags & SDF_LSAMPL)
Bill Pemberton790c5542009-03-16 22:05:02 -0400349 return sizeof(unsigned int);
David Schleefed9eccb2008-11-04 20:29:31 -0800350 else
Bill Pemberton790c5542009-03-16 22:05:02 -0400351 return sizeof(short);
David Schleefed9eccb2008-11-04 20:29:31 -0800352}
353
Ian Abbottbc3954b2013-01-29 16:20:17 +0000354/*
355 * Must set dev->hw_dev if you wish to dma directly into comedi's buffer.
356 * Also useful for retrieving a previously configured hardware device of
357 * known bus type. Set automatically for auto-configured devices.
358 * Automatically set to NULL when detaching hardware device.
359 */
Mithlesh Thukral0a85b6f2009-06-08 21:04:41 +0530360static inline void comedi_set_hw_dev(struct comedi_device *dev,
361 struct device *hw_dev)
David Schleefed9eccb2008-11-04 20:29:31 -0800362{
Ian Abbottbc3954b2013-01-29 16:20:17 +0000363 struct device *old_hw_dev = dev->hw_dev;
364
365 dev->hw_dev = get_device(hw_dev);
366 put_device(old_hw_dev);
David Schleefed9eccb2008-11-04 20:29:31 -0800367}
368
H Hartley Sweeten8ae560a2013-01-09 13:32:56 -0700369unsigned int comedi_buf_write_alloc(struct comedi_async *, unsigned int);
370unsigned int comedi_buf_write_free(struct comedi_async *, unsigned int);
David Schleefed9eccb2008-11-04 20:29:31 -0800371
H Hartley Sweeten8ae560a2013-01-09 13:32:56 -0700372unsigned int comedi_buf_read_n_available(struct comedi_async *);
373unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int);
374unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int);
375
376int comedi_buf_put(struct comedi_async *, short);
377int comedi_buf_get(struct comedi_async *, short *);
378
Bill Pembertond1636792009-03-16 22:05:20 -0400379void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
Mithlesh Thukral0a85b6f2009-06-08 21:04:41 +0530380 const void *source, unsigned int num_bytes);
Bill Pembertond1636792009-03-16 22:05:20 -0400381void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
Mithlesh Thukral0a85b6f2009-06-08 21:04:41 +0530382 void *destination, unsigned int num_bytes);
Mithlesh Thukral0a85b6f2009-06-08 21:04:41 +0530383
Mithlesh Thukral0a85b6f2009-06-08 21:04:41 +0530384int comedi_alloc_subdevice_minor(struct comedi_device *dev,
385 struct comedi_subdevice *s);
Bill Pemberton34c43922009-03-16 22:05:14 -0400386void comedi_free_subdevice_minor(struct comedi_subdevice *s);
Ian Abbott8ed705a2012-10-27 21:44:14 +0100387int comedi_auto_config(struct device *hardware_device,
388 struct comedi_driver *driver, unsigned long context);
389void comedi_auto_unconfig(struct device *hardware_device);
Ian Abbott581a7dd2012-11-14 13:10:40 +0000390
H Hartley Sweeten33782dd2013-01-30 15:22:21 -0700391#ifdef CONFIG_COMEDI_PCI_DRIVERS
392
393/* comedi_pci.c - comedi PCI driver specific functions */
394
395/*
396 * PCI Vendor IDs not in <linux/pci_ids.h>
397 */
398#define PCI_VENDOR_ID_KOLTER 0x1001
399#define PCI_VENDOR_ID_ICP 0x104c
400#define PCI_VENDOR_ID_AMCC 0x10e8
401#define PCI_VENDOR_ID_DT 0x1116
402#define PCI_VENDOR_ID_IOTECH 0x1616
403#define PCI_VENDOR_ID_CONTEC 0x1221
404#define PCI_VENDOR_ID_CB 0x1307 /* Measurement Computing */
405#define PCI_VENDOR_ID_ADVANTECH 0x13fe
406#define PCI_VENDOR_ID_MEILHAUS 0x1402
407#define PCI_VENDOR_ID_RTD 0x1435
408#define PCI_VENDOR_ID_ADLINK 0x144a
409#define PCI_VENDOR_ID_AMPLICON 0x14dc
410
411struct pci_dev;
412struct pci_driver;
413
414struct pci_dev *comedi_to_pci_dev(struct comedi_device *);
415
416int comedi_pci_enable(struct pci_dev *, const char *);
417void comedi_pci_disable(struct pci_dev *);
418
419int comedi_pci_auto_config(struct pci_dev *, struct comedi_driver *);
420void comedi_pci_auto_unconfig(struct pci_dev *);
421
422int comedi_pci_driver_register(struct comedi_driver *, struct pci_driver *);
423void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *);
424
425/**
426 * module_comedi_pci_driver() - Helper macro for registering a comedi PCI driver
427 * @__comedi_driver: comedi_driver struct
428 * @__pci_driver: pci_driver struct
429 *
430 * Helper macro for comedi PCI drivers which do not do anything special
431 * in module init/exit. This eliminates a lot of boilerplate. Each
432 * module may only use this macro once, and calling it replaces
433 * module_init() and module_exit()
434 */
435#define module_comedi_pci_driver(__comedi_driver, __pci_driver) \
436 module_driver(__comedi_driver, comedi_pci_driver_register, \
437 comedi_pci_driver_unregister, &(__pci_driver))
438
439#else
440
441/*
442 * Some of the comedi mixed ISA/PCI drivers call the PCI specific
443 * functions. Provide some dummy functions if CONFIG_COMEDI_PCI_DRIVERS
444 * is not enabled.
445 */
446
447static inline struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev)
Ian Abbott581a7dd2012-11-14 13:10:40 +0000448{
H Hartley Sweeten33782dd2013-01-30 15:22:21 -0700449 return NULL;
Ian Abbott581a7dd2012-11-14 13:10:40 +0000450}
451
H Hartley Sweeten33782dd2013-01-30 15:22:21 -0700452static inline int comedi_pci_enable(struct pci_dev *dev, const char *name)
453{
454 return -ENOSYS;
455}
456
457static inline void comedi_pci_disable(struct pci_dev *dev)
458{
459}
460
461#endif /* CONFIG_COMEDI_PCI_DRIVERS */
Ian Abbott581a7dd2012-11-14 13:10:40 +0000462
H Hartley Sweeten309231d2013-01-30 15:22:44 -0700463#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS
464
465/* comedi_pcmcia.c - comedi PCMCIA driver specific functions */
466
467struct pcmcia_driver;
468
469int comedi_pcmcia_driver_register(struct comedi_driver *,
470 struct pcmcia_driver *);
471void comedi_pcmcia_driver_unregister(struct comedi_driver *,
472 struct pcmcia_driver *);
473
474/**
475 * module_comedi_pcmcia_driver() - Helper macro for registering a comedi PCMCIA driver
476 * @__comedi_driver: comedi_driver struct
477 * @__pcmcia_driver: pcmcia_driver struct
478 *
479 * Helper macro for comedi PCMCIA drivers which do not do anything special
480 * in module init/exit. This eliminates a lot of boilerplate. Each
481 * module may only use this macro once, and calling it replaces
482 * module_init() and module_exit()
483 */
484#define module_comedi_pcmcia_driver(__comedi_driver, __pcmcia_driver) \
485 module_driver(__comedi_driver, comedi_pcmcia_driver_register, \
486 comedi_pcmcia_driver_unregister, &(__pcmcia_driver))
487
488#endif /* CONFIG_COMEDI_PCMCIA_DRIVERS */
489
H Hartley Sweetenabac8b52013-01-30 15:21:49 -0700490#ifdef CONFIG_COMEDI_USB_DRIVERS
Ian Abbott581a7dd2012-11-14 13:10:40 +0000491
H Hartley Sweetenabac8b52013-01-30 15:21:49 -0700492/* comedi_usb.c - comedi USB driver specific functions */
493
494struct usb_driver;
495struct usb_interface;
496
497struct usb_interface *comedi_to_usb_interface(struct comedi_device *);
498
499int comedi_usb_auto_config(struct usb_interface *, struct comedi_driver *);
500void comedi_usb_auto_unconfig(struct usb_interface *);
501
502int comedi_usb_driver_register(struct comedi_driver *, struct usb_driver *);
503void comedi_usb_driver_unregister(struct comedi_driver *, struct usb_driver *);
504
505/**
506 * module_comedi_usb_driver() - Helper macro for registering a comedi USB driver
507 * @__comedi_driver: comedi_driver struct
508 * @__usb_driver: usb_driver struct
509 *
510 * Helper macro for comedi USB drivers which do not do anything special
511 * in module init/exit. This eliminates a lot of boilerplate. Each
512 * module may only use this macro once, and calling it replaces
513 * module_init() and module_exit()
514 */
515#define module_comedi_usb_driver(__comedi_driver, __usb_driver) \
516 module_driver(__comedi_driver, comedi_usb_driver_register, \
517 comedi_usb_driver_unregister, &(__usb_driver))
518
519#endif /* CONFIG_COMEDI_USB_DRIVERS */
David Schleefed9eccb2008-11-04 20:29:31 -0800520
David Schleefed9eccb2008-11-04 20:29:31 -0800521#endif /* _COMEDIDEV_H */