Staging: heci: add TODO file
[linux-2.6] / drivers / staging / meilhaus / medevice.h
1 /*
2  * Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
3  *
4  * Source File : medevice.h
5  * Author      : GG (Guenter Gebhardt)  <support@meilhaus.de>
6  */
7
8 #ifndef _MEDEVICE_H_
9 #define _MEDEVICE_H_
10
11 #ifndef KBUILD_MODNAME
12 #  define KBUILD_MODNAME KBUILD_STR(memain)
13 #endif
14
15 #include <linux/pci.h>
16 //#include <linux/usb.h>
17 #include <linux/fs.h>
18 #include <linux/spinlock.h>
19
20 #include "metypes.h"
21 #include "meslist.h"
22 #include "medlock.h"
23
24 #ifdef __KERNEL__
25
26 /**
27  * @brief Defines a pointer type to a PCI constructor function.
28  */
29 typedef struct me_device *(*me_pci_constructor_t) (struct pci_dev *);
30
31 /**
32  * @brief Defines a pointer type to a ME-4000 PCI constructor function.
33  */
34 #ifdef BOSCH
35 typedef struct me_device *(*me_bosch_constructor_t) (struct pci_dev *,
36                                                      int me_bosch_fw);
37 #endif
38
39 /**
40  * @brief Defines a pointer type to a USB constructor function.
41  */
42 //typedef struct me_device *(*me_usb_constructor_t)(struct usb_interface *);
43
44 /**
45  * @brief Defines a pointer type to the dummy constructor function.
46  */
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);
53
54 //extern me_usb_constructor_t mephisto_s1_constructor __attribute__ ((weak));
55
56 /**
57  * @brief Holds the PCI device information.
58  */
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. */
63
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. */
67
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;
73
74 /**
75  * @brief Holds the USB device information.
76  */
77 //typedef struct me_usb_info {
78 //} me_usb_info_t;
79
80 /**
81  * @brief The Meilhaus device base class structure.
82  */
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. */
87
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. */
93
94         int irq;                                                        /**< The irq assigned to this device. */
95
96         me_dlock_t dlock;                                       /**< The device locking structure. */
97         me_slist_t slist;                                       /**< The container holding all subdevices belonging to this device. */
98
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. */
102
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);
110
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);
117
118         int (*me_device_io_irq_stop) (struct me_device * device,
119                                       struct file * filep,
120                                       int subdevice, int channel, int flags);
121
122         int (*me_device_io_reset_device) (struct me_device * device,
123                                           struct file * filep, int flags);
124
125         int (*me_device_io_reset_subdevice) (struct me_device * device,
126                                              struct file * filep,
127                                              int subdevice, int flags);
128
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);
138
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);
144
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);
150
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);
158
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);
164
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);
170
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);
176
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);
182
183         int (*me_device_io_stream_stop) (struct me_device * device,
184                                          struct file * filep,
185                                          int subdevice,
186                                          int stop_mode, int flags);
187
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);
193
194         int (*me_device_lock_device) (struct me_device * device,
195                                       struct file * filep, int lock, int flags);
196
197         int (*me_device_lock_subdevice) (struct me_device * device,
198                                          struct file * filep,
199                                          int subdevice, int lock, int flags);
200
201         int (*me_device_query_description_device) (struct me_device * device,
202                                                    char **description);
203
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);
212
213         int (*me_device_query_name_device) (struct me_device * device,
214                                             char **name);
215
216         int (*me_device_query_name_device_driver) (struct me_device * device,
217                                                    char **name);
218
219         int (*me_device_query_number_subdevices) (struct me_device * device,
220                                                   int *number);
221
222         int (*me_device_query_number_channels) (struct me_device * device,
223                                                 int subdevice, int *number);
224
225         int (*me_device_query_number_ranges) (struct me_device * device,
226                                               int subdevice,
227                                               int unit, int *count);
228
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);
235
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);
241
242         int (*me_device_query_subdevice_by_type) (struct me_device * device,
243                                                   int start_subdevice,
244                                                   int type,
245                                                   int subtype, int *subdevice);
246
247         int (*me_device_query_subdevice_type) (struct me_device * device,
248                                                int subdevice,
249                                                int *type, int *subtype);
250
251         int (*me_device_query_subdevice_caps) (struct me_device * device,
252                                                int subdevice, int *caps);
253
254         int (*me_device_query_subdevice_caps_args) (struct me_device * device,
255                                                     int subdevice,
256                                                     int cap,
257                                                     int *args, int count);
258
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);
265
266         int (*me_device_query_version_device_driver) (struct me_device * device,
267                                                       int *version);
268
269         int (*me_device_config_load) (struct me_device * device,
270                                       struct file * filep,
271                                       me_cfg_device_entry_t * config);
272
273         void (*me_device_destructor) (struct me_device * device);
274 } me_device_t;
275
276 /**
277  * @brief Initializes a PCI device base class structure.
278  *
279  * @param pci_device The PCI device context as handed over by kernel.
280  *
281  * @return 0 on success.
282  */
283 int me_device_pci_init(me_device_t * me_device, struct pci_dev *pci_device);
284
285 /**
286  * @brief Initializes a USB device base class structure.
287  *
288  * @param usb_interface The USB device interface as handed over by kernel.
289  *
290  * @return 0 on success.
291  */
292 //int me_device_usb_init(me_device_t *me_device, struct usb_interface *interface);
293
294 /**
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.
298   *
299   * @param me_device The device class to deinitialize.
300   */
301 void me_device_deinit(me_device_t * me_device);
302
303 #endif
304 #endif