Staging: sxg: Add support to download the firmware using request_firmware()
[linux-2.6] / drivers / staging / meilhaus / medummy.c
1 /* Device driver for Meilhaus ME-DUMMY devices.
2  * ===========================================
3  *
4  *    Copyright (C) 2005 Meilhaus Electronic GmbH (support@meilhaus.de)
5  *
6  *    This file is free software; you can redistribute it and/or modify
7  *    it under the terms of the GNU General Public License as published by
8  *    the Free Software Foundation; either version 2 of the License, or
9  *    (at your option) any later version.
10  *
11  *    This program is distributed in the hope that it will be useful,
12  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *    GNU General Public License for more details.
15  *
16  *    You should have received a copy of the GNU General Public License
17  *    along with this program; if not, write to the Free Software
18  *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 /*
22  * User application could also include the kernel header files. But the
23  * real kernel functions are protected by #ifdef __KERNEL__.
24  */
25 #ifndef __KERNEL__
26 #  define __KERNEL__
27 #endif
28
29 /*
30  * This must be defined before module.h is included. Not needed, when
31  * it is a built in driver.
32  */
33 #ifndef MODULE
34 #  define MODULE
35 #endif
36
37 #include <linux/module.h>
38 #include <linux/slab.h>
39
40 #include "meerror.h"
41 #include "meinternal.h"
42
43 #include "meids.h"
44 #include "mecommon.h"
45 #include "medevice.h"
46 #include "medebug.h"
47
48 #include "medummy.h"
49
50 static int medummy_io_irq_start(me_device_t * device,
51                                 struct file *filep,
52                                 int subdevice,
53                                 int channel,
54                                 int irq_source,
55                                 int irq_edge, int irq_arg, int flags)
56 {
57         PDEBUG("executed.\n");
58         return ME_ERRNO_DEVICE_UNPLUGGED;
59 }
60
61 static int medummy_io_irq_wait(me_device_t * device,
62                                struct file *filep,
63                                int subdevice,
64                                int channel,
65                                int *irq_count,
66                                int *value, int timeout, int flags)
67 {
68         PDEBUG("executed.\n");
69         return ME_ERRNO_DEVICE_UNPLUGGED;
70 }
71
72 static int medummy_io_irq_stop(me_device_t * device,
73                                struct file *filep,
74                                int subdevice, int channel, int flags)
75 {
76         PDEBUG("executed.\n");
77         return ME_ERRNO_DEVICE_UNPLUGGED;
78 }
79
80 static int medummy_io_reset_device(me_device_t * device,
81                                    struct file *filep, int flags)
82 {
83         PDEBUG("executed.\n");
84         return ME_ERRNO_DEVICE_UNPLUGGED;
85 }
86
87 static int medummy_io_reset_subdevice(me_device_t * device,
88                                       struct file *filep,
89                                       int subdevice, int flags)
90 {
91         PDEBUG("executed.\n");
92         return ME_ERRNO_DEVICE_UNPLUGGED;
93 }
94
95 static int medummy_io_single_config(me_device_t * device,
96                                     struct file *filep,
97                                     int subdevice,
98                                     int channel,
99                                     int single_config,
100                                     int ref,
101                                     int trig_chan,
102                                     int trig_type, int trig_edge, int flags)
103 {
104         PDEBUG("executed.\n");
105         return ME_ERRNO_DEVICE_UNPLUGGED;
106 }
107
108 static int medummy_io_single_read(me_device_t * device,
109                                   struct file *filep,
110                                   int subdevice,
111                                   int channel,
112                                   int *value, int time_out, int flags)
113 {
114         PDEBUG("executed.\n");
115         return ME_ERRNO_DEVICE_UNPLUGGED;
116 }
117
118 static int medummy_io_single_write(me_device_t * device,
119                                    struct file *filep,
120                                    int subdevice,
121                                    int channel,
122                                    int value, int time_out, int flags)
123 {
124         PDEBUG("executed.\n");
125         return ME_ERRNO_DEVICE_UNPLUGGED;
126 }
127
128 static int medummy_io_stream_config(me_device_t * device,
129                                     struct file *filep,
130                                     int subdevice,
131                                     meIOStreamConfig_t * config_list,
132                                     int count,
133                                     meIOStreamTrigger_t * trigger,
134                                     int fifo_irq_threshold, int flags)
135 {
136         PDEBUG("executed.\n");
137         return ME_ERRNO_DEVICE_UNPLUGGED;
138 }
139
140 static int medummy_io_stream_new_values(me_device_t * device,
141                                         struct file *filep,
142                                         int subdevice,
143                                         int timeout, int *count, int flags)
144 {
145         PDEBUG("executed.\n");
146         return ME_ERRNO_DEVICE_UNPLUGGED;
147 }
148
149 static int medummy_io_stream_read(me_device_t * device,
150                                   struct file *filep,
151                                   int subdevice,
152                                   int read_mode,
153                                   int *values, int *count, int flags)
154 {
155         PDEBUG("executed.\n");
156         return ME_ERRNO_DEVICE_UNPLUGGED;
157 }
158
159 static int medummy_io_stream_start(me_device_t * device,
160                                    struct file *filep,
161                                    int subdevice,
162                                    int start_mode, int time_out, int flags)
163 {
164         PDEBUG("executed.\n");
165         return ME_ERRNO_DEVICE_UNPLUGGED;
166 }
167
168 static int medummy_io_stream_status(me_device_t * device,
169                                     struct file *filep,
170                                     int subdevice,
171                                     int wait,
172                                     int *status, int *values, int flags)
173 {
174         PDEBUG("executed.\n");
175         return ME_ERRNO_DEVICE_UNPLUGGED;
176 }
177
178 static int medummy_io_stream_stop(me_device_t * device,
179                                   struct file *filep,
180                                   int subdevice, int stop_mode, int flags)
181 {
182         PDEBUG("executed.\n");
183         return ME_ERRNO_DEVICE_UNPLUGGED;
184 }
185
186 static int medummy_io_stream_write(me_device_t * device,
187                                    struct file *filep,
188                                    int subdevice,
189                                    int write_mode,
190                                    int *values, int *count, int flags)
191 {
192         PDEBUG("executed.\n");
193         return ME_ERRNO_DEVICE_UNPLUGGED;
194 }
195
196 static int medummy_lock_device(me_device_t * device,
197                                struct file *filep, int lock, int flags)
198 {
199         PDEBUG("executed.\n");
200         return ME_ERRNO_DEVICE_UNPLUGGED;
201 }
202
203 static int medummy_lock_subdevice(me_device_t * device,
204                                   struct file *filep,
205                                   int subdevice, int lock, int flags)
206 {
207         PDEBUG("executed.\n");
208         return ME_ERRNO_DEVICE_UNPLUGGED;
209 }
210
211 static int medummy_query_description_device(me_device_t * device,
212                                             char **description)
213 {
214         medummy_device_t *instance = (medummy_device_t *) device;
215
216         PDEBUG("executed.\n");
217
218 //      if (instance->magic != MEDUMMY_MAGIC_NUMBER)
219 //      {
220 //              PERROR("Wrong magic number.\n");
221 //              return ME_ERRNO_INTERNAL;
222 //      }
223
224         switch (instance->device_id) {
225
226         case PCI_DEVICE_ID_MEILHAUS_ME1000:
227
228         case PCI_DEVICE_ID_MEILHAUS_ME1000_A:
229
230         case PCI_DEVICE_ID_MEILHAUS_ME1000_B:
231                 *description = ME1000_DESCRIPTION_DEVICE_ME1000;
232
233                 break;
234
235         case PCI_DEVICE_ID_MEILHAUS_ME1400:
236                 *description = ME1400_DESCRIPTION_DEVICE_ME1400;
237
238                 break;
239
240         case PCI_DEVICE_ID_MEILHAUS_ME140A:
241                 *description = ME1400_DESCRIPTION_DEVICE_ME1400A;
242
243                 break;
244
245         case PCI_DEVICE_ID_MEILHAUS_ME140B:
246                 *description = ME1400_DESCRIPTION_DEVICE_ME1400B;
247
248                 break;
249
250         case PCI_DEVICE_ID_MEILHAUS_ME14E0:
251                 *description = ME1400_DESCRIPTION_DEVICE_ME1400E;
252
253                 break;
254
255         case PCI_DEVICE_ID_MEILHAUS_ME14EA:
256                 *description = ME1400_DESCRIPTION_DEVICE_ME1400EA;
257
258                 break;
259
260         case PCI_DEVICE_ID_MEILHAUS_ME14EB:
261                 *description = ME1400_DESCRIPTION_DEVICE_ME1400EB;
262
263                 break;
264
265         case PCI_DEVICE_ID_MEILHAUS_ME140C:
266                 *description = ME1400_DESCRIPTION_DEVICE_ME1400C;
267
268                 break;
269
270         case PCI_DEVICE_ID_MEILHAUS_ME140D:
271                 *description = ME1400_DESCRIPTION_DEVICE_ME1400D;
272
273                 break;
274
275         case PCI_DEVICE_ID_MEILHAUS_ME1600_4U:
276                 *description = ME1600_DESCRIPTION_DEVICE_ME16004U;
277
278                 break;
279
280         case PCI_DEVICE_ID_MEILHAUS_ME1600_8U:
281                 *description = ME1600_DESCRIPTION_DEVICE_ME16008U;
282
283                 break;
284
285         case PCI_DEVICE_ID_MEILHAUS_ME1600_12U:
286                 *description = ME1600_DESCRIPTION_DEVICE_ME160012U;
287
288                 break;
289
290         case PCI_DEVICE_ID_MEILHAUS_ME1600_16U:
291                 *description = ME1600_DESCRIPTION_DEVICE_ME160016U;
292
293                 break;
294
295         case PCI_DEVICE_ID_MEILHAUS_ME1600_16U_8I:
296                 *description = ME1600_DESCRIPTION_DEVICE_ME160016U8I;
297
298                 break;
299
300         case PCI_DEVICE_ID_MEILHAUS_ME4610:
301                 *description = ME4600_DESCRIPTION_DEVICE_ME4610;
302
303                 break;
304
305         case PCI_DEVICE_ID_MEILHAUS_ME4650:
306                 *description = ME4600_DESCRIPTION_DEVICE_ME4650;
307
308                 break;
309
310         case PCI_DEVICE_ID_MEILHAUS_ME4660:
311                 *description = ME4600_DESCRIPTION_DEVICE_ME4660;
312
313                 break;
314
315         case PCI_DEVICE_ID_MEILHAUS_ME4660I:
316                 *description = ME4600_DESCRIPTION_DEVICE_ME4660I;
317
318                 break;
319
320         case PCI_DEVICE_ID_MEILHAUS_ME4660S:
321                 *description = ME4600_DESCRIPTION_DEVICE_ME4660S;
322
323                 break;
324
325         case PCI_DEVICE_ID_MEILHAUS_ME4660IS:
326                 *description = ME4600_DESCRIPTION_DEVICE_ME4660IS;
327
328                 break;
329
330         case PCI_DEVICE_ID_MEILHAUS_ME4670:
331                 *description = ME4600_DESCRIPTION_DEVICE_ME4670;
332
333                 break;
334
335         case PCI_DEVICE_ID_MEILHAUS_ME4670I:
336                 *description = ME4600_DESCRIPTION_DEVICE_ME4670I;
337
338                 break;
339
340         case PCI_DEVICE_ID_MEILHAUS_ME4670S:
341                 *description = ME4600_DESCRIPTION_DEVICE_ME4670S;
342
343                 break;
344
345         case PCI_DEVICE_ID_MEILHAUS_ME4670IS:
346                 *description = ME4600_DESCRIPTION_DEVICE_ME4670IS;
347
348                 break;
349
350         case PCI_DEVICE_ID_MEILHAUS_ME4680:
351                 *description = ME4600_DESCRIPTION_DEVICE_ME4680;
352
353                 break;
354
355         case PCI_DEVICE_ID_MEILHAUS_ME4680I:
356                 *description = ME4600_DESCRIPTION_DEVICE_ME4680I;
357
358                 break;
359
360         case PCI_DEVICE_ID_MEILHAUS_ME4680S:
361                 *description = ME4600_DESCRIPTION_DEVICE_ME4680S;
362
363                 break;
364
365         case PCI_DEVICE_ID_MEILHAUS_ME4680IS:
366                 *description = ME4600_DESCRIPTION_DEVICE_ME4680IS;
367
368                 break;
369
370         case PCI_DEVICE_ID_MEILHAUS_ME6004:
371                 *description = ME6000_DESCRIPTION_DEVICE_ME60004;
372
373                 break;
374
375         case PCI_DEVICE_ID_MEILHAUS_ME6008:
376                 *description = ME6000_DESCRIPTION_DEVICE_ME60008;
377
378                 break;
379
380         case PCI_DEVICE_ID_MEILHAUS_ME600F:
381                 *description = ME6000_DESCRIPTION_DEVICE_ME600016;
382
383                 break;
384
385         case PCI_DEVICE_ID_MEILHAUS_ME6014:
386                 *description = ME6000_DESCRIPTION_DEVICE_ME6000I4;
387
388                 break;
389
390         case PCI_DEVICE_ID_MEILHAUS_ME6018:
391                 *description = ME6000_DESCRIPTION_DEVICE_ME6000I8;
392
393                 break;
394
395         case PCI_DEVICE_ID_MEILHAUS_ME601F:
396                 *description = ME6000_DESCRIPTION_DEVICE_ME6000I16;
397
398                 break;
399
400         case PCI_DEVICE_ID_MEILHAUS_ME6034:
401                 *description = ME6000_DESCRIPTION_DEVICE_ME6000ISLE4;
402
403                 break;
404
405         case PCI_DEVICE_ID_MEILHAUS_ME6038:
406                 *description = ME6000_DESCRIPTION_DEVICE_ME6000ISLE8;
407
408                 break;
409
410         case PCI_DEVICE_ID_MEILHAUS_ME603F:
411                 *description = ME6000_DESCRIPTION_DEVICE_ME6000ISLE16;
412
413                 break;
414
415         case PCI_DEVICE_ID_MEILHAUS_ME6104:
416                 *description = ME6000_DESCRIPTION_DEVICE_ME61004;
417
418                 break;
419
420         case PCI_DEVICE_ID_MEILHAUS_ME6108:
421                 *description = ME6000_DESCRIPTION_DEVICE_ME61008;
422
423                 break;
424
425         case PCI_DEVICE_ID_MEILHAUS_ME610F:
426                 *description = ME6000_DESCRIPTION_DEVICE_ME610016;
427
428                 break;
429
430         case PCI_DEVICE_ID_MEILHAUS_ME6114:
431                 *description = ME6000_DESCRIPTION_DEVICE_ME6100I4;
432
433                 break;
434
435         case PCI_DEVICE_ID_MEILHAUS_ME6118:
436                 *description = ME6000_DESCRIPTION_DEVICE_ME6100I8;
437
438                 break;
439
440         case PCI_DEVICE_ID_MEILHAUS_ME611F:
441                 *description = ME6000_DESCRIPTION_DEVICE_ME6100I16;
442
443                 break;
444
445         case PCI_DEVICE_ID_MEILHAUS_ME6134:
446                 *description = ME6000_DESCRIPTION_DEVICE_ME6100ISLE4;
447
448                 break;
449
450         case PCI_DEVICE_ID_MEILHAUS_ME6138:
451                 *description = ME6000_DESCRIPTION_DEVICE_ME6100ISLE8;
452
453                 break;
454
455         case PCI_DEVICE_ID_MEILHAUS_ME613F:
456                 *description = ME6000_DESCRIPTION_DEVICE_ME6100ISLE16;
457
458                 break;
459
460         case PCI_DEVICE_ID_MEILHAUS_ME6044:
461                 *description = ME6000_DESCRIPTION_DEVICE_ME60004DIO;
462
463                 break;
464
465         case PCI_DEVICE_ID_MEILHAUS_ME6048:
466                 *description = ME6000_DESCRIPTION_DEVICE_ME60008DIO;
467
468                 break;
469
470         case PCI_DEVICE_ID_MEILHAUS_ME604F:
471                 *description = ME6000_DESCRIPTION_DEVICE_ME600016DIO;
472
473                 break;
474
475         case PCI_DEVICE_ID_MEILHAUS_ME6054:
476                 *description = ME6000_DESCRIPTION_DEVICE_ME6000I4DIO;
477
478                 break;
479
480         case PCI_DEVICE_ID_MEILHAUS_ME6058:
481                 *description = ME6000_DESCRIPTION_DEVICE_ME6000I8DIO;
482
483                 break;
484
485         case PCI_DEVICE_ID_MEILHAUS_ME605F:
486                 *description = ME6000_DESCRIPTION_DEVICE_ME6000I16DIO;
487
488                 break;
489
490         case PCI_DEVICE_ID_MEILHAUS_ME6074:
491                 *description = ME6000_DESCRIPTION_DEVICE_ME6000ISLE4DIO;
492
493                 break;
494
495         case PCI_DEVICE_ID_MEILHAUS_ME6078:
496                 *description = ME6000_DESCRIPTION_DEVICE_ME6000ISLE8DIO;
497
498                 break;
499
500         case PCI_DEVICE_ID_MEILHAUS_ME607F:
501                 *description = ME6000_DESCRIPTION_DEVICE_ME6000ISLE16DIO;
502
503                 break;
504
505         case PCI_DEVICE_ID_MEILHAUS_ME6144:
506                 *description = ME6000_DESCRIPTION_DEVICE_ME61004DIO;
507
508                 break;
509
510         case PCI_DEVICE_ID_MEILHAUS_ME6148:
511                 *description = ME6000_DESCRIPTION_DEVICE_ME61008DIO;
512
513                 break;
514
515         case PCI_DEVICE_ID_MEILHAUS_ME614F:
516                 *description = ME6000_DESCRIPTION_DEVICE_ME610016DIO;
517
518                 break;
519
520         case PCI_DEVICE_ID_MEILHAUS_ME6154:
521                 *description = ME6000_DESCRIPTION_DEVICE_ME6100I4DIO;
522
523                 break;
524
525         case PCI_DEVICE_ID_MEILHAUS_ME6158:
526                 *description = ME6000_DESCRIPTION_DEVICE_ME6100I8DIO;
527
528                 break;
529
530         case PCI_DEVICE_ID_MEILHAUS_ME615F:
531                 *description = ME6000_DESCRIPTION_DEVICE_ME6100I16DIO;
532
533                 break;
534
535         case PCI_DEVICE_ID_MEILHAUS_ME6174:
536                 *description = ME6000_DESCRIPTION_DEVICE_ME6100ISLE4DIO;
537
538                 break;
539
540         case PCI_DEVICE_ID_MEILHAUS_ME6178:
541                 *description = ME6000_DESCRIPTION_DEVICE_ME6100ISLE8DIO;
542
543                 break;
544
545         case PCI_DEVICE_ID_MEILHAUS_ME617F:
546                 *description = ME6000_DESCRIPTION_DEVICE_ME6100ISLE16DIO;
547
548                 break;
549
550         case PCI_DEVICE_ID_MEILHAUS_ME6259:
551                 *description = ME6000_DESCRIPTION_DEVICE_ME6200I9DIO;
552
553                 break;
554
555         case PCI_DEVICE_ID_MEILHAUS_ME6359:
556                 *description = ME6000_DESCRIPTION_DEVICE_ME6300I9DIO;
557
558                 break;
559
560         case PCI_DEVICE_ID_MEILHAUS_ME0630:
561                 *description = ME0600_DESCRIPTION_DEVICE_ME0630;
562
563                 break;
564
565         case PCI_DEVICE_ID_MEILHAUS_ME8100_A:
566                 *description = ME8100_DESCRIPTION_DEVICE_ME8100A;
567
568                 break;
569
570         case PCI_DEVICE_ID_MEILHAUS_ME8100_B:
571                 *description = ME8100_DESCRIPTION_DEVICE_ME8100B;
572
573                 break;
574
575         case PCI_DEVICE_ID_MEILHAUS_ME0940:
576                 *description = ME0900_DESCRIPTION_DEVICE_ME0940;
577
578                 break;
579
580         case PCI_DEVICE_ID_MEILHAUS_ME0950:
581                 *description = ME0900_DESCRIPTION_DEVICE_ME0950;
582
583                 break;
584
585         case PCI_DEVICE_ID_MEILHAUS_ME0960:
586                 *description = ME0900_DESCRIPTION_DEVICE_ME0960;
587
588                 break;
589 /*
590                 case USB_DEVICE_ID_MEPHISTO_S1:
591                         *description = MEPHISTO_S1_DESCRIPTION_DEVICE;
592
593                         break;
594 */
595         default:
596                 *description = EMPTY_DESCRIPTION_DEVICE;
597                 PERROR("Invalid device id in device info.\n");
598
599                 return ME_ERRNO_INTERNAL;
600         }
601
602         return ME_ERRNO_DEVICE_UNPLUGGED;
603 }
604
605 static int medummy_query_info_device(me_device_t * device,
606                                      int *vendor_id,
607                                      int *device_id,
608                                      int *serial_no,
609                                      int *bus_type,
610                                      int *bus_no,
611                                      int *dev_no, int *func_no, int *plugged)
612 {
613         medummy_device_t *instance = (medummy_device_t *) device;
614
615         PDEBUG("executed.\n");
616
617 //      if (instance->magic != MEDUMMY_MAGIC_NUMBER)
618 //      {
619 //              PERROR("Wrong magic number.\n");
620 //              return ME_ERRNO_INTERNAL;
621 //      }
622
623         *vendor_id = instance->vendor_id;
624         *device_id = instance->device_id;
625         *serial_no = instance->serial_no;
626         *bus_type = instance->bus_type;
627         *bus_no = instance->bus_no;
628         *dev_no = instance->dev_no;
629         *func_no = instance->func_no;
630         *plugged = ME_PLUGGED_OUT;
631
632         return ME_ERRNO_SUCCESS;
633 }
634
635 static int medummy_query_name_device_driver(me_device_t * device, char **name)
636 {
637         PDEBUG("executed.\n");
638         *name = MEDUMMY_NAME_DRIVER;
639         return ME_ERRNO_SUCCESS;
640 }
641
642 static int medummy_query_name_device(me_device_t * device, char **name)
643 {
644         medummy_device_t *instance = (medummy_device_t *) device;
645
646         PDEBUG("executed.\n");
647
648 // // //        if (instance->magic != MEDUMMY_MAGIC_NUMBER)
649 // // //        {
650 // // //                PERROR("Wrong magic number.\n");
651 // // //                return ME_ERRNO_INTERNAL;
652 // // //        }
653
654         switch (instance->device_id) {
655
656         case PCI_DEVICE_ID_MEILHAUS_ME1000:
657
658         case PCI_DEVICE_ID_MEILHAUS_ME1000_A:
659
660         case PCI_DEVICE_ID_MEILHAUS_ME1000_B:
661                 *name = ME1000_NAME_DEVICE_ME1000;
662
663                 break;
664
665         case PCI_DEVICE_ID_MEILHAUS_ME1400:
666                 *name = ME1400_NAME_DEVICE_ME1400;
667
668                 break;
669
670         case PCI_DEVICE_ID_MEILHAUS_ME140A:
671                 *name = ME1400_NAME_DEVICE_ME1400A;
672
673                 break;
674
675         case PCI_DEVICE_ID_MEILHAUS_ME140B:
676                 *name = ME1400_NAME_DEVICE_ME1400B;
677
678                 break;
679
680         case PCI_DEVICE_ID_MEILHAUS_ME14E0:
681                 *name = ME1400_NAME_DEVICE_ME1400E;
682
683                 break;
684
685         case PCI_DEVICE_ID_MEILHAUS_ME14EA:
686                 *name = ME1400_NAME_DEVICE_ME1400EA;
687
688                 break;
689
690         case PCI_DEVICE_ID_MEILHAUS_ME14EB:
691                 *name = ME1400_NAME_DEVICE_ME1400EB;
692
693                 break;
694
695         case PCI_DEVICE_ID_MEILHAUS_ME140C:
696                 *name = ME1400_NAME_DEVICE_ME1400C;
697
698                 break;
699
700         case PCI_DEVICE_ID_MEILHAUS_ME140D:
701                 *name = ME1400_NAME_DEVICE_ME1400D;
702
703                 break;
704
705         case PCI_DEVICE_ID_MEILHAUS_ME1600_4U:
706                 *name = ME1600_NAME_DEVICE_ME16004U;
707
708                 break;
709
710         case PCI_DEVICE_ID_MEILHAUS_ME1600_8U:
711                 *name = ME1600_NAME_DEVICE_ME16008U;
712
713                 break;
714
715         case PCI_DEVICE_ID_MEILHAUS_ME1600_12U:
716                 *name = ME1600_NAME_DEVICE_ME160012U;
717
718                 break;
719
720         case PCI_DEVICE_ID_MEILHAUS_ME1600_16U:
721                 *name = ME1600_NAME_DEVICE_ME160016U;
722
723                 break;
724
725         case PCI_DEVICE_ID_MEILHAUS_ME1600_16U_8I:
726                 *name = ME1600_NAME_DEVICE_ME160016U8I;
727
728                 break;
729
730         case PCI_DEVICE_ID_MEILHAUS_ME4610:
731                 *name = ME4600_NAME_DEVICE_ME4610;
732
733                 break;
734
735         case PCI_DEVICE_ID_MEILHAUS_ME4650:
736                 *name = ME4600_NAME_DEVICE_ME4650;
737
738                 break;
739
740         case PCI_DEVICE_ID_MEILHAUS_ME4660:
741                 *name = ME4600_NAME_DEVICE_ME4660;
742
743                 break;
744
745         case PCI_DEVICE_ID_MEILHAUS_ME4660I:
746                 *name = ME4600_NAME_DEVICE_ME4660I;
747
748                 break;
749
750         case PCI_DEVICE_ID_MEILHAUS_ME4670:
751                 *name = ME4600_NAME_DEVICE_ME4670;
752
753                 break;
754
755         case PCI_DEVICE_ID_MEILHAUS_ME4670I:
756                 *name = ME4600_NAME_DEVICE_ME4670I;
757
758                 break;
759
760         case PCI_DEVICE_ID_MEILHAUS_ME4670S:
761                 *name = ME4600_NAME_DEVICE_ME4670S;
762
763                 break;
764
765         case PCI_DEVICE_ID_MEILHAUS_ME4670IS:
766                 *name = ME4600_NAME_DEVICE_ME4670IS;
767
768                 break;
769
770         case PCI_DEVICE_ID_MEILHAUS_ME4680:
771                 *name = ME4600_NAME_DEVICE_ME4680;
772
773                 break;
774
775         case PCI_DEVICE_ID_MEILHAUS_ME4680I:
776                 *name = ME4600_NAME_DEVICE_ME4680I;
777
778                 break;
779
780         case PCI_DEVICE_ID_MEILHAUS_ME4680S:
781                 *name = ME4600_NAME_DEVICE_ME4680S;
782
783                 break;
784
785         case PCI_DEVICE_ID_MEILHAUS_ME4680IS:
786                 *name = ME4600_NAME_DEVICE_ME4680IS;
787
788                 break;
789
790         case PCI_DEVICE_ID_MEILHAUS_ME6004:
791                 *name = ME6000_NAME_DEVICE_ME60004;
792
793                 break;
794
795         case PCI_DEVICE_ID_MEILHAUS_ME6008:
796                 *name = ME6000_NAME_DEVICE_ME60008;
797
798                 break;
799
800         case PCI_DEVICE_ID_MEILHAUS_ME600F:
801                 *name = ME6000_NAME_DEVICE_ME600016;
802
803                 break;
804
805         case PCI_DEVICE_ID_MEILHAUS_ME6014:
806                 *name = ME6000_NAME_DEVICE_ME6000I4;
807
808                 break;
809
810         case PCI_DEVICE_ID_MEILHAUS_ME6018:
811                 *name = ME6000_NAME_DEVICE_ME6000I8;
812
813                 break;
814
815         case PCI_DEVICE_ID_MEILHAUS_ME601F:
816                 *name = ME6000_NAME_DEVICE_ME6000I16;
817
818                 break;
819
820         case PCI_DEVICE_ID_MEILHAUS_ME6034:
821                 *name = ME6000_NAME_DEVICE_ME6000ISLE4;
822
823                 break;
824
825         case PCI_DEVICE_ID_MEILHAUS_ME6038:
826                 *name = ME6000_NAME_DEVICE_ME6000ISLE8;
827
828                 break;
829
830         case PCI_DEVICE_ID_MEILHAUS_ME603F:
831                 *name = ME6000_NAME_DEVICE_ME6000ISLE16;
832
833                 break;
834
835         case PCI_DEVICE_ID_MEILHAUS_ME6104:
836                 *name = ME6000_NAME_DEVICE_ME61004;
837
838                 break;
839
840         case PCI_DEVICE_ID_MEILHAUS_ME6108:
841                 *name = ME6000_NAME_DEVICE_ME61008;
842
843                 break;
844
845         case PCI_DEVICE_ID_MEILHAUS_ME610F:
846                 *name = ME6000_NAME_DEVICE_ME610016;
847
848                 break;
849
850         case PCI_DEVICE_ID_MEILHAUS_ME6114:
851                 *name = ME6000_NAME_DEVICE_ME6100I4;
852
853                 break;
854
855         case PCI_DEVICE_ID_MEILHAUS_ME6118:
856                 *name = ME6000_NAME_DEVICE_ME6100I8;
857
858                 break;
859
860         case PCI_DEVICE_ID_MEILHAUS_ME611F:
861                 *name = ME6000_NAME_DEVICE_ME6100I16;
862
863                 break;
864
865         case PCI_DEVICE_ID_MEILHAUS_ME6134:
866                 *name = ME6000_NAME_DEVICE_ME6100ISLE4;
867
868                 break;
869
870         case PCI_DEVICE_ID_MEILHAUS_ME6138:
871                 *name = ME6000_NAME_DEVICE_ME6100ISLE8;
872
873                 break;
874
875         case PCI_DEVICE_ID_MEILHAUS_ME613F:
876                 *name = ME6000_NAME_DEVICE_ME6100ISLE16;
877
878                 break;
879
880         case PCI_DEVICE_ID_MEILHAUS_ME6044:
881                 *name = ME6000_NAME_DEVICE_ME60004DIO;
882
883                 break;
884
885         case PCI_DEVICE_ID_MEILHAUS_ME6048:
886                 *name = ME6000_NAME_DEVICE_ME60008DIO;
887
888                 break;
889
890         case PCI_DEVICE_ID_MEILHAUS_ME604F:
891                 *name = ME6000_NAME_DEVICE_ME600016DIO;
892
893                 break;
894
895         case PCI_DEVICE_ID_MEILHAUS_ME6054:
896                 *name = ME6000_NAME_DEVICE_ME6000I4DIO;
897
898                 break;
899
900         case PCI_DEVICE_ID_MEILHAUS_ME6058:
901                 *name = ME6000_NAME_DEVICE_ME6000I8DIO;
902
903                 break;
904
905         case PCI_DEVICE_ID_MEILHAUS_ME605F:
906                 *name = ME6000_NAME_DEVICE_ME6000I16DIO;
907
908                 break;
909
910         case PCI_DEVICE_ID_MEILHAUS_ME6074:
911                 *name = ME6000_NAME_DEVICE_ME6000ISLE4DIO;
912
913                 break;
914
915         case PCI_DEVICE_ID_MEILHAUS_ME6078:
916                 *name = ME6000_NAME_DEVICE_ME6000ISLE8DIO;
917
918                 break;
919
920         case PCI_DEVICE_ID_MEILHAUS_ME607F:
921                 *name = ME6000_NAME_DEVICE_ME6000ISLE16DIO;
922
923                 break;
924
925         case PCI_DEVICE_ID_MEILHAUS_ME6144:
926                 *name = ME6000_NAME_DEVICE_ME61004DIO;
927
928                 break;
929
930         case PCI_DEVICE_ID_MEILHAUS_ME6148:
931                 *name = ME6000_NAME_DEVICE_ME61008DIO;
932
933                 break;
934
935         case PCI_DEVICE_ID_MEILHAUS_ME614F:
936                 *name = ME6000_NAME_DEVICE_ME610016DIO;
937
938                 break;
939
940         case PCI_DEVICE_ID_MEILHAUS_ME6154:
941                 *name = ME6000_NAME_DEVICE_ME6100I4DIO;
942
943                 break;
944
945         case PCI_DEVICE_ID_MEILHAUS_ME6158:
946                 *name = ME6000_NAME_DEVICE_ME6100I8DIO;
947
948                 break;
949
950         case PCI_DEVICE_ID_MEILHAUS_ME615F:
951                 *name = ME6000_NAME_DEVICE_ME6100I16DIO;
952
953                 break;
954
955         case PCI_DEVICE_ID_MEILHAUS_ME6174:
956                 *name = ME6000_NAME_DEVICE_ME6100ISLE4DIO;
957
958                 break;
959
960         case PCI_DEVICE_ID_MEILHAUS_ME6178:
961                 *name = ME6000_NAME_DEVICE_ME6100ISLE8DIO;
962
963                 break;
964
965         case PCI_DEVICE_ID_MEILHAUS_ME617F:
966                 *name = ME6000_NAME_DEVICE_ME6100ISLE16DIO;
967
968                 break;
969
970         case PCI_DEVICE_ID_MEILHAUS_ME0630:
971                 *name = ME0600_NAME_DEVICE_ME0630;
972
973                 break;
974
975         case PCI_DEVICE_ID_MEILHAUS_ME8100_A:
976                 *name = ME8100_NAME_DEVICE_ME8100A;
977
978                 break;
979
980         case PCI_DEVICE_ID_MEILHAUS_ME8100_B:
981                 *name = ME8100_NAME_DEVICE_ME8100B;
982
983                 break;
984
985         case PCI_DEVICE_ID_MEILHAUS_ME0940:
986                 *name = ME0900_NAME_DEVICE_ME0940;
987
988                 break;
989
990         case PCI_DEVICE_ID_MEILHAUS_ME0950:
991                 *name = ME0900_NAME_DEVICE_ME0950;
992
993                 break;
994
995         case PCI_DEVICE_ID_MEILHAUS_ME0960:
996                 *name = ME0900_NAME_DEVICE_ME0960;
997
998                 break;
999 /*
1000                 case USB_DEVICE_ID_MEPHISTO_S1:
1001                         *name = MEPHISTO_S1_NAME_DEVICE;
1002
1003                         break;
1004 */
1005         default:
1006                 *name = EMPTY_NAME_DEVICE;
1007                 PERROR("Invalid PCI device id.\n");
1008
1009                 return ME_ERRNO_INTERNAL;
1010         }
1011
1012         return ME_ERRNO_SUCCESS;
1013 }
1014
1015 static int medummy_query_number_subdevices(me_device_t * device, int *number)
1016 {
1017         PDEBUG("executed.\n");
1018         return ME_ERRNO_DEVICE_UNPLUGGED;
1019 }
1020
1021 static int medummy_query_number_channels(me_device_t * device,
1022                                          int subdevice, int *number)
1023 {
1024         PDEBUG("executed.\n");
1025         return ME_ERRNO_DEVICE_UNPLUGGED;
1026 }
1027
1028 static int medummy_query_number_ranges(me_device_t * device,
1029                                        int subdevice, int unit, int *count)
1030 {
1031         PDEBUG("executed.\n");
1032         return ME_ERRNO_DEVICE_UNPLUGGED;
1033 }
1034
1035 static int medummy_query_subdevice_type(me_device_t * device,
1036                                         int subdevice, int *type, int *subtype)
1037 {
1038         PDEBUG("executed.\n");
1039         return ME_ERRNO_DEVICE_UNPLUGGED;
1040 }
1041
1042 static int medummy_query_subdevice_caps(me_device_t * device,
1043                                         int subdevice, int *caps)
1044 {
1045         PDEBUG("executed.\n");
1046         return ME_ERRNO_DEVICE_UNPLUGGED;
1047 }
1048
1049 static int medummy_query_subdevice_caps_args(me_device_t * device,
1050                                              int subdevice,
1051                                              int cap, int *args, int count)
1052 {
1053         PDEBUG("executed.\n");
1054         return ME_ERRNO_NOT_SUPPORTED;
1055 }
1056
1057 static int medummy_query_subdevice_by_type(me_device_t * device,
1058                                            int start_subdevice,
1059                                            int type,
1060                                            int subtype, int *subdevice)
1061 {
1062         PDEBUG("executed.\n");
1063         return ME_ERRNO_DEVICE_UNPLUGGED;
1064 }
1065
1066 static int medummy_query_range_by_min_max(me_device_t * device,
1067                                           int subdevice,
1068                                           int unit,
1069                                           int *min,
1070                                           int *max, int *maxdata, int *range)
1071 {
1072         PDEBUG("executed.\n");
1073         return ME_ERRNO_DEVICE_UNPLUGGED;
1074 }
1075
1076 static int medummy_query_range_info(me_device_t * device,
1077                                     int subdevice,
1078                                     int range,
1079                                     int *unit, int *min, int *max, int *maxdata)
1080 {
1081         PDEBUG("executed.\n");
1082         return ME_ERRNO_DEVICE_UNPLUGGED;
1083 }
1084
1085 int medummy_query_timer(me_device_t * device,
1086                         int subdevice,
1087                         int timer,
1088                         int *base_frequency,
1089                         uint64_t * min_ticks, uint64_t * max_ticks)
1090 {
1091         PDEBUG("executed.\n");
1092         return ME_ERRNO_DEVICE_UNPLUGGED;
1093 }
1094
1095 static int medummy_query_version_device_driver(me_device_t * device,
1096                                                int *version)
1097 {
1098         PDEBUG("executed.\n");
1099
1100         *version = ME_VERSION_DRIVER;
1101         return ME_ERRNO_SUCCESS;
1102 }
1103
1104 static void medummy_destructor(me_device_t * device)
1105 {
1106         PDEBUG("executed.\n");
1107         kfree(device);
1108 }
1109
1110 static int init_device_info(unsigned short vendor_id,
1111                             unsigned short device_id,
1112                             unsigned int serial_no,
1113                             int bus_type,
1114                             int bus_no,
1115                             int dev_no,
1116                             int func_no, medummy_device_t * instance)
1117 {
1118         PDEBUG("executed.\n");
1119
1120 //      instance->magic = MEDUMMY_MAGIC_NUMBER;
1121         instance->vendor_id = vendor_id;
1122         instance->device_id = device_id;
1123         instance->serial_no = serial_no;
1124         instance->bus_type = bus_type;
1125         instance->bus_no = bus_no;
1126         instance->dev_no = dev_no;
1127         instance->func_no = func_no;
1128
1129         return 0;
1130 }
1131
1132 static int medummy_config_load(me_device_t * device, struct file *filep,
1133                                me_cfg_device_entry_t * config)
1134 {
1135         PDEBUG("executed.\n");
1136         return ME_ERRNO_SUCCESS;
1137 }
1138
1139 static int init_device_instance(me_device_t * device)
1140 {
1141         PDEBUG("executed.\n");
1142
1143         INIT_LIST_HEAD(&device->list);
1144
1145         device->me_device_io_irq_start = medummy_io_irq_start;
1146         device->me_device_io_irq_wait = medummy_io_irq_wait;
1147         device->me_device_io_irq_stop = medummy_io_irq_stop;
1148         device->me_device_io_reset_device = medummy_io_reset_device;
1149         device->me_device_io_reset_subdevice = medummy_io_reset_subdevice;
1150         device->me_device_io_single_config = medummy_io_single_config;
1151         device->me_device_io_single_read = medummy_io_single_read;
1152         device->me_device_io_single_write = medummy_io_single_write;
1153         device->me_device_io_stream_config = medummy_io_stream_config;
1154         device->me_device_io_stream_new_values = medummy_io_stream_new_values;
1155         device->me_device_io_stream_read = medummy_io_stream_read;
1156         device->me_device_io_stream_start = medummy_io_stream_start;
1157         device->me_device_io_stream_status = medummy_io_stream_status;
1158         device->me_device_io_stream_stop = medummy_io_stream_stop;
1159         device->me_device_io_stream_write = medummy_io_stream_write;
1160
1161         device->me_device_lock_device = medummy_lock_device;
1162         device->me_device_lock_subdevice = medummy_lock_subdevice;
1163
1164         device->me_device_query_description_device =
1165             medummy_query_description_device;
1166         device->me_device_query_info_device = medummy_query_info_device;
1167         device->me_device_query_name_device_driver =
1168             medummy_query_name_device_driver;
1169         device->me_device_query_name_device = medummy_query_name_device;
1170
1171         device->me_device_query_number_subdevices =
1172             medummy_query_number_subdevices;
1173         device->me_device_query_number_channels = medummy_query_number_channels;
1174         device->me_device_query_number_ranges = medummy_query_number_ranges;
1175
1176         device->me_device_query_range_by_min_max =
1177             medummy_query_range_by_min_max;
1178         device->me_device_query_range_info = medummy_query_range_info;
1179
1180         device->me_device_query_subdevice_type = medummy_query_subdevice_type;
1181         device->me_device_query_subdevice_by_type =
1182             medummy_query_subdevice_by_type;
1183         device->me_device_query_subdevice_caps = medummy_query_subdevice_caps;
1184         device->me_device_query_subdevice_caps_args =
1185             medummy_query_subdevice_caps_args;
1186
1187         device->me_device_query_timer = medummy_query_timer;
1188
1189         device->me_device_query_version_device_driver =
1190             medummy_query_version_device_driver;
1191
1192         device->me_device_destructor = medummy_destructor;
1193         device->me_device_config_load = medummy_config_load;
1194         return 0;
1195 }
1196
1197 me_device_t *medummy_constructor(unsigned short vendor_id,
1198                                  unsigned short device_id,
1199                                  unsigned int serial_no,
1200                                  int bus_type,
1201                                  int bus_no, int dev_no, int func_no)
1202 {
1203         int result = 0;
1204         medummy_device_t *instance;
1205
1206         PDEBUG("executed.\n");
1207
1208         /* Allocate structure for device attributes */
1209         instance = kmalloc(sizeof(medummy_device_t), GFP_KERNEL);
1210
1211         if (!instance) {
1212                 PERROR("Can't get memory for device instance.\n");
1213                 return NULL;
1214         }
1215
1216         memset(instance, 0, sizeof(medummy_device_t));
1217
1218         /* Initialize device info */
1219         result = init_device_info(vendor_id,
1220                                   device_id,
1221                                   serial_no,
1222                                   bus_type, bus_no, dev_no, func_no, instance);
1223
1224         if (result) {
1225                 PERROR("Cannot init baord info.\n");
1226                 kfree(instance);
1227                 return NULL;
1228         }
1229
1230         /* Initialize device instance */
1231         result = init_device_instance((me_device_t *) instance);
1232
1233         if (result) {
1234                 PERROR("Cannot init baord info.\n");
1235                 kfree(instance);
1236                 return NULL;
1237         }
1238
1239         return (me_device_t *) instance;
1240 }
1241
1242 // Init and exit of module.
1243
1244 static int __init dummy_init(void)
1245 {
1246         PDEBUG("executed.\n");
1247         return 0;
1248 }
1249
1250 static void __exit dummy_exit(void)
1251 {
1252         PDEBUG("executed.\n");
1253 }
1254
1255 module_init(dummy_init);
1256
1257 module_exit(dummy_exit);
1258
1259 // Administrative stuff for modinfo.
1260 MODULE_AUTHOR("Guenter Gebhardt <g.gebhardt@meilhaus.de>");
1261 MODULE_DESCRIPTION("Device Driver Module for Meilhaus ME-DUMMY Devices");
1262 MODULE_SUPPORTED_DEVICE("Meilhaus ME-DUMMY Devices");
1263 MODULE_LICENSE("GPL");
1264
1265 // Export the constructor.
1266 EXPORT_SYMBOL(medummy_constructor);