Staging: Add the Meilhaus ME-IDS driver package
[linux-2.6/mini2440.git] / drivers / staging / meilhaus / medevice.h
blob25da82883e1fd2d7a8c815c845c74391a5f6ea01
1 /*
2 * Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
4 * Source File : medevice.h
5 * Author : GG (Guenter Gebhardt) <support@meilhaus.de>
6 */
8 #ifndef _MEDEVICE_H_
9 #define _MEDEVICE_H_
11 #ifndef KBUILD_MODNAME
12 # define KBUILD_MODNAME KBUILD_STR(memain)
13 #endif
15 #include <linux/pci.h>
16 //#include <linux/usb.h>
17 #include <linux/fs.h>
18 #include <linux/spinlock.h>
20 #include "metypes.h"
21 #include "meslist.h"
22 #include "medlock.h"
24 #ifdef __KERNEL__
26 /**
27 * @brief Defines a pointer type to a PCI constructor function.
29 typedef struct me_device *(*me_pci_constructor_t) (struct pci_dev *);
31 /**
32 * @brief Defines a pointer type to a ME-4000 PCI constructor function.
34 #ifdef BOSCH
35 typedef struct me_device *(*me_bosch_constructor_t) (struct pci_dev *,
36 int me_bosch_fw);
37 #endif
39 /**
40 * @brief Defines a pointer type to a USB constructor function.
42 //typedef struct me_device *(*me_usb_constructor_t)(struct usb_interface *);
44 /**
45 * @brief Defines a pointer type to the dummy constructor function.
47 typedef struct me_device *(*me_dummy_constructor_t) (unsigned short vendor_id,
48 unsigned short device_id,
49 unsigned int serial_no,
50 int bus_type,
51 int bus_no,
52 int dev_no, int func_no);
54 //extern me_usb_constructor_t mephisto_s1_constructor __attribute__ ((weak));
56 /**
57 * @brief Holds the PCI device information.
59 typedef struct me_pci_info {
60 struct pci_dev *pci_device; /**< Kernel PCI device structure. */
61 uint32_t reg_bases[6]; /**< The base adresses of the PCI bars. */
62 uint32_t reg_sizes[6]; /**< The sizes of the PCI bars. */
64 uint32_t pci_bus_no; /**< PCI bus number. */
65 uint32_t pci_dev_no; /**< PCI device number. */
66 uint32_t pci_func_no; /**< PCI function number. */
68 uint16_t vendor_id; /**< Meilhaus PCI vendor id. */
69 uint16_t device_id; /**< Meilhaus device id. */
70 uint8_t hw_revision; /**< Hardware revision of the device. */
71 uint32_t serial_no; /**< Serial number of the device. */
72 } me_pci_info_t;
74 /**
75 * @brief Holds the USB device information.
77 //typedef struct me_usb_info {
78 //} me_usb_info_t;
80 /**
81 * @brief The Meilhaus device base class structure.
83 typedef struct me_device {
84 /* Attributes */
85 struct list_head list; /**< Enables the device to be added to a dynamic list. */
86 // int magic; /**< The magic number of the structure. */
88 int bus_type; /**< The descriminator for the union. */
89 union {
90 me_pci_info_t pci; /**< PCI specific device information. */
91 // me_usb_info_t usb; /**< USB specific device information. */
92 } info; /**< Holds the device information. */
94 int irq; /**< The irq assigned to this device. */
96 me_dlock_t dlock; /**< The device locking structure. */
97 me_slist_t slist; /**< The container holding all subdevices belonging to this device. */
99 char *device_name; /**< The name of the Meilhaus device. */
100 char *device_description; /**< The description of the Meilhaus device. */
101 char *driver_name; /**< The name of the device driver module supporting the device family. */
103 /* Methods */
104 int (*me_device_io_irq_start) (struct me_device * device,
105 struct file * filep,
106 int subdevice,
107 int channel,
108 int irq_source,
109 int irq_edge, int irq_arg, int flags);
111 int (*me_device_io_irq_wait) (struct me_device * device,
112 struct file * filep,
113 int subdevice,
114 int channel,
115 int *irq_count,
116 int *value, int time_out, int flags);
118 int (*me_device_io_irq_stop) (struct me_device * device,
119 struct file * filep,
120 int subdevice, int channel, int flags);
122 int (*me_device_io_reset_device) (struct me_device * device,
123 struct file * filep, int flags);
125 int (*me_device_io_reset_subdevice) (struct me_device * device,
126 struct file * filep,
127 int subdevice, int flags);
129 int (*me_device_io_single_config) (struct me_device * device,
130 struct file * filep,
131 int subdevice,
132 int channel,
133 int single_config,
134 int ref,
135 int trig_chan,
136 int trig_type,
137 int trig_edge, int flags);
139 int (*me_device_io_single_read) (struct me_device * device,
140 struct file * filep,
141 int subdevice,
142 int channel,
143 int *value, int time_out, int flags);
145 int (*me_device_io_single_write) (struct me_device * device,
146 struct file * filep,
147 int subdevice,
148 int channel,
149 int value, int time_out, int flags);
151 int (*me_device_io_stream_config) (struct me_device * device,
152 struct file * filep,
153 int subdevice,
154 meIOStreamConfig_t * config_list,
155 int count,
156 meIOStreamTrigger_t * trigger,
157 int fifo_irq_threshold, int flags);
159 int (*me_device_io_stream_new_values) (struct me_device * device,
160 struct file * filep,
161 int subdevice,
162 int time_out,
163 int *count, int flags);
165 int (*me_device_io_stream_read) (struct me_device * device,
166 struct file * filep,
167 int subdevice,
168 int read_mode,
169 int *values, int *count, int flags);
171 int (*me_device_io_stream_start) (struct me_device * device,
172 struct file * filep,
173 int subdevice,
174 int start_mode,
175 int time_out, int flags);
177 int (*me_device_io_stream_status) (struct me_device * device,
178 struct file * filep,
179 int subdevice,
180 int wait,
181 int *status, int *count, int flags);
183 int (*me_device_io_stream_stop) (struct me_device * device,
184 struct file * filep,
185 int subdevice,
186 int stop_mode, int flags);
188 int (*me_device_io_stream_write) (struct me_device * device,
189 struct file * filep,
190 int subdevice,
191 int write_mode,
192 int *values, int *count, int flags);
194 int (*me_device_lock_device) (struct me_device * device,
195 struct file * filep, int lock, int flags);
197 int (*me_device_lock_subdevice) (struct me_device * device,
198 struct file * filep,
199 int subdevice, int lock, int flags);
201 int (*me_device_query_description_device) (struct me_device * device,
202 char **description);
204 int (*me_device_query_info_device) (struct me_device * device,
205 int *vendor_id,
206 int *device_id,
207 int *serial_no,
208 int *bus_type,
209 int *bus_no,
210 int *dev_no,
211 int *func_no, int *plugged);
213 int (*me_device_query_name_device) (struct me_device * device,
214 char **name);
216 int (*me_device_query_name_device_driver) (struct me_device * device,
217 char **name);
219 int (*me_device_query_number_subdevices) (struct me_device * device,
220 int *number);
222 int (*me_device_query_number_channels) (struct me_device * device,
223 int subdevice, int *number);
225 int (*me_device_query_number_ranges) (struct me_device * device,
226 int subdevice,
227 int unit, int *count);
229 int (*me_device_query_range_by_min_max) (struct me_device * device,
230 int subdevice,
231 int unit,
232 int *min,
233 int *max,
234 int *maxdata, int *range);
236 int (*me_device_query_range_info) (struct me_device * device,
237 int subdevice,
238 int range,
239 int *unit,
240 int *min, int *max, int *maxdata);
242 int (*me_device_query_subdevice_by_type) (struct me_device * device,
243 int start_subdevice,
244 int type,
245 int subtype, int *subdevice);
247 int (*me_device_query_subdevice_type) (struct me_device * device,
248 int subdevice,
249 int *type, int *subtype);
251 int (*me_device_query_subdevice_caps) (struct me_device * device,
252 int subdevice, int *caps);
254 int (*me_device_query_subdevice_caps_args) (struct me_device * device,
255 int subdevice,
256 int cap,
257 int *args, int count);
259 int (*me_device_query_timer) (struct me_device * device,
260 int subdevice,
261 int timer,
262 int *base_frequency,
263 uint64_t * min_ticks,
264 uint64_t * max_ticks);
266 int (*me_device_query_version_device_driver) (struct me_device * device,
267 int *version);
269 int (*me_device_config_load) (struct me_device * device,
270 struct file * filep,
271 me_cfg_device_entry_t * config);
273 void (*me_device_destructor) (struct me_device * device);
274 } me_device_t;
277 * @brief Initializes a PCI device base class structure.
279 * @param pci_device The PCI device context as handed over by kernel.
281 * @return 0 on success.
283 int me_device_pci_init(me_device_t * me_device, struct pci_dev *pci_device);
286 * @brief Initializes a USB device base class structure.
288 * @param usb_interface The USB device interface as handed over by kernel.
290 * @return 0 on success.
292 //int me_device_usb_init(me_device_t *me_device, struct usb_interface *interface);
295 * @brief Deinitializes a device base class structure and frees any previously
296 * requested resources related with this structure. It also frees any subdevice
297 * instance hold by the subdevice list.
299 * @param me_device The device class to deinitialize.
301 void me_device_deinit(me_device_t * me_device);
303 #endif
304 #endif