1
2
3
4
5
6
7
8
9
10
11
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <asm/uaccess.h>
16#include <asm/io.h>
17#include <linux/ioport.h>
18#include <linux/workqueue.h>
19#include <linux/pci.h>
20#include <linux/interrupt.h>
21#include <linux/list.h>
22#include <linux/poll.h>
23#include <linux/kmod.h>
24
25#include "platform.h"
26#undef ID_MASK
27#undef N_DATA
28#include "pc.h"
29#include "di_defs.h"
30#include "divasync.h"
31#include "diva.h"
32#include "di.h"
33#include "io.h"
34#include "xdi_msg.h"
35#include "xdi_adapter.h"
36#include "xdi_vers.h"
37#include "diva_dma.h"
38#include "diva_pci.h"
39
40static char *main_revision = "$Revision: 1.55.4.6 $";
41
42static int major;
43
44static int dbgmask;
45
46MODULE_DESCRIPTION("Kernel driver for Eicon DIVA Server cards");
47MODULE_AUTHOR("Cytronics & Melware, Eicon Networks");
48MODULE_LICENSE("GPL");
49
50module_param(dbgmask, int, 0);
51MODULE_PARM_DESC(dbgmask, "initial debug mask");
52
53static char *DRIVERNAME =
54 "Eicon DIVA Server driver (http://www.melware.net)";
55static char *DRIVERLNAME = "divas";
56static char *DEVNAME = "Divas";
57char *DRIVERRELEASE_DIVAS = "2.0";
58
59extern irqreturn_t diva_os_irq_wrapper(int irq, void *context);
60extern int create_divas_proc(void);
61extern void remove_divas_proc(void);
62extern void diva_get_vserial_number(PISDN_ADAPTER IoAdapter, char *buf);
63extern int divasfunc_init(int dbgmask);
64extern void divasfunc_exit(void);
65
66typedef struct _diva_os_thread_dpc {
67 struct tasklet_struct divas_task;
68 diva_os_soft_isr_t *psoft_isr;
69} diva_os_thread_dpc_t;
70
71
72
73
74
75
76
77
78
79
80
81
82
83#if !defined(PCI_DEVICE_ID_EICON_MAESTRAP_2)
84#define PCI_DEVICE_ID_EICON_MAESTRAP_2 0xE015
85#endif
86
87#if !defined(PCI_DEVICE_ID_EICON_4BRI_VOIP)
88#define PCI_DEVICE_ID_EICON_4BRI_VOIP 0xE016
89#endif
90
91#if !defined(PCI_DEVICE_ID_EICON_4BRI_2_VOIP)
92#define PCI_DEVICE_ID_EICON_4BRI_2_VOIP 0xE017
93#endif
94
95#if !defined(PCI_DEVICE_ID_EICON_BRI2M_2)
96#define PCI_DEVICE_ID_EICON_BRI2M_2 0xE018
97#endif
98
99#if !defined(PCI_DEVICE_ID_EICON_MAESTRAP_2_VOIP)
100#define PCI_DEVICE_ID_EICON_MAESTRAP_2_VOIP 0xE019
101#endif
102
103#if !defined(PCI_DEVICE_ID_EICON_2F)
104#define PCI_DEVICE_ID_EICON_2F 0xE01A
105#endif
106
107#if !defined(PCI_DEVICE_ID_EICON_BRI2M_2_VOIP)
108#define PCI_DEVICE_ID_EICON_BRI2M_2_VOIP 0xE01B
109#endif
110
111
112
113
114static struct pci_device_id divas_pci_tbl[] = {
115
116 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_MAESTRA,
117 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CARDTYPE_MAESTRA_PCI},
118
119 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_MAESTRAQ,
120 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CARDTYPE_DIVASRV_Q_8M_PCI},
121
122 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_MAESTRAQ_U,
123 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CARDTYPE_DIVASRV_Q_8M_V2_PCI},
124
125 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_MAESTRAP,
126 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CARDTYPE_DIVASRV_P_30M_PCI},
127
128 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_MAESTRAP_2,
129 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CARDTYPE_DIVASRV_P_30M_V2_PCI},
130
131 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_4BRI_VOIP,
132 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CARDTYPE_DIVASRV_VOICE_Q_8M_PCI},
133
134 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_4BRI_2_VOIP,
135 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CARDTYPE_DIVASRV_VOICE_Q_8M_V2_PCI},
136
137 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_BRI2M_2,
138 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CARDTYPE_DIVASRV_B_2M_V2_PCI},
139
140 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_MAESTRAP_2_VOIP,
141 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
142 CARDTYPE_DIVASRV_VOICE_P_30M_V2_PCI},
143
144 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_2F,
145 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CARDTYPE_DIVASRV_B_2F_PCI},
146
147 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_BRI2M_2_VOIP,
148 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CARDTYPE_DIVASRV_VOICE_B_2M_V2_PCI},
149 {0,}
150};
151MODULE_DEVICE_TABLE(pci, divas_pci_tbl);
152
153static int divas_init_one(struct pci_dev *pdev,
154 const struct pci_device_id *ent);
155static void __devexit divas_remove_one(struct pci_dev *pdev);
156
157static struct pci_driver diva_pci_driver = {
158 .name = "divas",
159 .probe = divas_init_one,
160 .remove = __devexit_p(divas_remove_one),
161 .id_table = divas_pci_tbl,
162};
163
164
165
166
167static char *getrev(const char *revision)
168{
169 char *rev;
170 char *p;
171 if ((p = strchr(revision, ':'))) {
172 rev = p + 2;
173 p = strchr(rev, '$');
174 *--p = 0;
175 } else
176 rev = "1.0";
177 return rev;
178}
179
180void diva_log_info(unsigned char *format, ...)
181{
182 va_list args;
183 unsigned char line[160];
184
185 va_start(args, format);
186 vsnprintf(line, sizeof(line), format, args);
187 va_end(args);
188
189 printk(KERN_INFO "%s: %s\n", DRIVERLNAME, line);
190}
191
192void divas_get_version(char *p)
193{
194 char tmprev[32];
195
196 strcpy(tmprev, main_revision);
197 sprintf(p, "%s: %s(%s) %s(%s) major=%d\n", DRIVERLNAME, DRIVERRELEASE_DIVAS,
198 getrev(tmprev), diva_xdi_common_code_build, DIVA_BUILD, major);
199}
200
201
202
203
204byte diva_os_get_pci_bus(void *pci_dev_handle)
205{
206 struct pci_dev *pdev = (struct pci_dev *) pci_dev_handle;
207 return ((byte) pdev->bus->number);
208}
209
210byte diva_os_get_pci_func(void *pci_dev_handle)
211{
212 struct pci_dev *pdev = (struct pci_dev *) pci_dev_handle;
213 return ((byte) pdev->devfn);
214}
215
216unsigned long divasa_get_pci_irq(unsigned char bus, unsigned char func,
217 void *pci_dev_handle)
218{
219 unsigned char irq = 0;
220 struct pci_dev *dev = (struct pci_dev *) pci_dev_handle;
221
222 irq = dev->irq;
223
224 return ((unsigned long) irq);
225}
226
227unsigned long divasa_get_pci_bar(unsigned char bus, unsigned char func,
228 int bar, void *pci_dev_handle)
229{
230 unsigned long ret = 0;
231 struct pci_dev *dev = (struct pci_dev *) pci_dev_handle;
232
233 if (bar < 6) {
234 ret = dev->resource[bar].start;
235 }
236
237 DBG_TRC(("GOT BAR[%d]=%08x", bar, ret));
238
239 {
240 unsigned long type = (ret & 0x00000001);
241 if (type & PCI_BASE_ADDRESS_SPACE_IO) {
242 DBG_TRC((" I/O"));
243 ret &= PCI_BASE_ADDRESS_IO_MASK;
244 } else {
245 DBG_TRC((" memory"));
246 ret &= PCI_BASE_ADDRESS_MEM_MASK;
247 }
248 DBG_TRC((" final=%08x", ret));
249 }
250
251 return (ret);
252}
253
254void PCIwrite(byte bus, byte func, int offset, void *data, int length,
255 void *pci_dev_handle)
256{
257 struct pci_dev *dev = (struct pci_dev *) pci_dev_handle;
258
259 switch (length) {
260 case 1:
261 pci_write_config_byte(dev, offset,
262 *(unsigned char *) data);
263 break;
264 case 2:
265 pci_write_config_word(dev, offset,
266 *(unsigned short *) data);
267 break;
268 case 4:
269 pci_write_config_dword(dev, offset,
270 *(unsigned int *) data);
271 break;
272
273 default:
274 if (!(length % 4) && !(length & 0x03)) {
275 dword *p = (dword *) data;
276 length /= 4;
277
278 while (length--) {
279 pci_write_config_dword(dev, offset,
280 *(unsigned int *)
281 p++);
282 }
283 } else {
284 byte *p = (byte *) data;
285
286 while (length--) {
287 pci_write_config_byte(dev, offset,
288 *(unsigned char *)
289 p++);
290 }
291 }
292 }
293}
294
295void PCIread(byte bus, byte func, int offset, void *data, int length,
296 void *pci_dev_handle)
297{
298 struct pci_dev *dev = (struct pci_dev *) pci_dev_handle;
299
300 switch (length) {
301 case 1:
302 pci_read_config_byte(dev, offset, (unsigned char *) data);
303 break;
304 case 2:
305 pci_read_config_word(dev, offset, (unsigned short *) data);
306 break;
307 case 4:
308 pci_read_config_dword(dev, offset, (unsigned int *) data);
309 break;
310
311 default:
312 if (!(length % 4) && !(length & 0x03)) {
313 dword *p = (dword *) data;
314 length /= 4;
315
316 while (length--) {
317 pci_read_config_dword(dev, offset,
318 (unsigned int *)
319 p++);
320 }
321 } else {
322 byte *p = (byte *) data;
323
324 while (length--) {
325 pci_read_config_byte(dev, offset,
326 (unsigned char *)
327 p++);
328 }
329 }
330 }
331}
332
333
334
335
336
337
338static void *diva_pci_alloc_consistent(struct pci_dev *hwdev,
339 size_t size,
340 dma_addr_t * dma_handle,
341 void **addr_handle)
342{
343 void *addr = pci_alloc_consistent(hwdev, size, dma_handle);
344
345 *addr_handle = addr;
346
347 return (addr);
348}
349
350void diva_init_dma_map(void *hdev,
351 struct _diva_dma_map_entry **ppmap, int nentries)
352{
353 struct pci_dev *pdev = (struct pci_dev *) hdev;
354 struct _diva_dma_map_entry *pmap =
355 diva_alloc_dma_map(hdev, nentries);
356
357 if (pmap) {
358 int i;
359 dma_addr_t dma_handle;
360 void *cpu_addr;
361 void *addr_handle;
362
363 for (i = 0; i < nentries; i++) {
364 if (!(cpu_addr = diva_pci_alloc_consistent(pdev,
365 PAGE_SIZE,
366 &dma_handle,
367 &addr_handle)))
368 {
369 break;
370 }
371 diva_init_dma_map_entry(pmap, i, cpu_addr,
372 (dword) dma_handle,
373 addr_handle);
374 DBG_TRC(("dma map alloc [%d]=(%08lx:%08x:%08lx)",
375 i, (unsigned long) cpu_addr,
376 (dword) dma_handle,
377 (unsigned long) addr_handle))}
378 }
379
380 *ppmap = pmap;
381}
382
383
384
385
386
387void diva_free_dma_map(void *hdev, struct _diva_dma_map_entry *pmap)
388{
389 struct pci_dev *pdev = (struct pci_dev *) hdev;
390 int i;
391 dword phys_addr;
392 void *cpu_addr;
393 dma_addr_t dma_handle;
394 void *addr_handle;
395
396 for (i = 0; (pmap != 0); i++) {
397 diva_get_dma_map_entry(pmap, i, &cpu_addr, &phys_addr);
398 if (!cpu_addr) {
399 break;
400 }
401 addr_handle = diva_get_entry_handle(pmap, i);
402 dma_handle = (dma_addr_t) phys_addr;
403 pci_free_consistent(pdev, PAGE_SIZE, addr_handle,
404 dma_handle);
405 DBG_TRC(("dma map free [%d]=(%08lx:%08x:%08lx)", i,
406 (unsigned long) cpu_addr, (dword) dma_handle,
407 (unsigned long) addr_handle))
408 }
409
410 diva_free_dma_mapping(pmap);
411}
412
413
414
415
416
417
418int
419diva_os_register_io_port(void *adapter, int on, unsigned long port,
420 unsigned long length, const char *name, int id)
421{
422 if (on) {
423 if (!request_region(port, length, name)) {
424 DBG_ERR(("A: I/O: can't register port=%08x", port))
425 return (-1);
426 }
427 } else {
428 release_region(port, length);
429 }
430 return (0);
431}
432
433void __iomem *divasa_remap_pci_bar(diva_os_xdi_adapter_t *a, int id, unsigned long bar, unsigned long area_length)
434{
435 void __iomem *ret = ioremap(bar, area_length);
436 DBG_TRC(("remap(%08x)->%p", bar, ret));
437 return (ret);
438}
439
440void divasa_unmap_pci_bar(void __iomem *bar)
441{
442 if (bar) {
443 iounmap(bar);
444 }
445}
446
447
448
449
450byte __inline__ inpp(void __iomem *addr)
451{
452 return (inb((unsigned long) addr));
453}
454
455word __inline__ inppw(void __iomem *addr)
456{
457 return (inw((unsigned long) addr));
458}
459
460void __inline__ inppw_buffer(void __iomem *addr, void *P, int length)
461{
462 insw((unsigned long) addr, (word *) P, length >> 1);
463}
464
465void __inline__ outppw_buffer(void __iomem *addr, void *P, int length)
466{
467 outsw((unsigned long) addr, (word *) P, length >> 1);
468}
469
470void __inline__ outppw(void __iomem *addr, word w)
471{
472 outw(w, (unsigned long) addr);
473}
474
475void __inline__ outpp(void __iomem *addr, word p)
476{
477 outb(p, (unsigned long) addr);
478}
479
480
481
482
483int diva_os_register_irq(void *context, byte irq, const char *name)
484{
485 int result = request_irq(irq, diva_os_irq_wrapper,
486 IRQF_DISABLED | IRQF_SHARED, name, context);
487 return (result);
488}
489
490void diva_os_remove_irq(void *context, byte irq)
491{
492 free_irq(irq, context);
493}
494
495
496
497
498static void diva_os_dpc_proc(unsigned long context)
499{
500 diva_os_thread_dpc_t *psoft_isr = (diva_os_thread_dpc_t *) context;
501 diva_os_soft_isr_t *pisr = psoft_isr->psoft_isr;
502
503 (*(pisr->callback)) (pisr, pisr->callback_context);
504}
505
506int diva_os_initialize_soft_isr(diva_os_soft_isr_t * psoft_isr,
507 diva_os_soft_isr_callback_t callback,
508 void *callback_context)
509{
510 diva_os_thread_dpc_t *pdpc;
511
512 pdpc = (diva_os_thread_dpc_t *) diva_os_malloc(0, sizeof(*pdpc));
513 if (!(psoft_isr->object = pdpc)) {
514 return (-1);
515 }
516 memset(pdpc, 0x00, sizeof(*pdpc));
517 psoft_isr->callback = callback;
518 psoft_isr->callback_context = callback_context;
519 pdpc->psoft_isr = psoft_isr;
520 tasklet_init(&pdpc->divas_task, diva_os_dpc_proc, (unsigned long)pdpc);
521
522 return (0);
523}
524
525int diva_os_schedule_soft_isr(diva_os_soft_isr_t * psoft_isr)
526{
527 if (psoft_isr && psoft_isr->object) {
528 diva_os_thread_dpc_t *pdpc =
529 (diva_os_thread_dpc_t *) psoft_isr->object;
530
531 tasklet_schedule(&pdpc->divas_task);
532 }
533
534 return (1);
535}
536
537int diva_os_cancel_soft_isr(diva_os_soft_isr_t * psoft_isr)
538{
539 return (0);
540}
541
542void diva_os_remove_soft_isr(diva_os_soft_isr_t * psoft_isr)
543{
544 if (psoft_isr && psoft_isr->object) {
545 diva_os_thread_dpc_t *pdpc =
546 (diva_os_thread_dpc_t *) psoft_isr->object;
547 void *mem;
548
549 tasklet_kill(&pdpc->divas_task);
550 flush_scheduled_work();
551 mem = psoft_isr->object;
552 psoft_isr->object = NULL;
553 diva_os_free(0, mem);
554 }
555}
556
557
558
559
560static int
561xdi_copy_to_user(void *os_handle, void __user *dst, const void *src, int length)
562{
563 if (copy_to_user(dst, src, length)) {
564 return (-EFAULT);
565 }
566 return (length);
567}
568
569static int
570xdi_copy_from_user(void *os_handle, void *dst, const void __user *src, int length)
571{
572 if (copy_from_user(dst, src, length)) {
573 return (-EFAULT);
574 }
575 return (length);
576}
577
578
579
580
581static int divas_open(struct inode *inode, struct file *file)
582{
583 return (0);
584}
585
586static int divas_release(struct inode *inode, struct file *file)
587{
588 if (file->private_data) {
589 diva_xdi_close_adapter(file->private_data, file);
590 }
591 return (0);
592}
593
594static ssize_t divas_write(struct file *file, const char __user *buf,
595 size_t count, loff_t * ppos)
596{
597 int ret = -EINVAL;
598
599 if (!file->private_data) {
600 file->private_data = diva_xdi_open_adapter(file, buf,
601 count,
602 xdi_copy_from_user);
603 }
604 if (!file->private_data) {
605 return (-ENODEV);
606 }
607
608 ret = diva_xdi_write(file->private_data, file,
609 buf, count, xdi_copy_from_user);
610 switch (ret) {
611 case -1:
612 ret = -EBUSY;
613 break;
614 case -2:
615 ret = -ENOMEM;
616 break;
617 case -3:
618 ret = -ENXIO;
619 break;
620 }
621 DBG_TRC(("write: ret %d", ret));
622 return (ret);
623}
624
625static ssize_t divas_read(struct file *file, char __user *buf,
626 size_t count, loff_t * ppos)
627{
628 int ret = -EINVAL;
629
630 if (!file->private_data) {
631 file->private_data = diva_xdi_open_adapter(file, buf,
632 count,
633 xdi_copy_from_user);
634 }
635 if (!file->private_data) {
636 return (-ENODEV);
637 }
638
639 ret = diva_xdi_read(file->private_data, file,
640 buf, count, xdi_copy_to_user);
641 switch (ret) {
642 case -1:
643 ret = -EAGAIN;
644 break;
645 case -2:
646 ret = -ENOMEM;
647 break;
648 case -3:
649 ret = -EFAULT;
650 break;
651 }
652 DBG_TRC(("read: ret %d", ret));
653 return (ret);
654}
655
656static unsigned int divas_poll(struct file *file, poll_table * wait)
657{
658 if (!file->private_data) {
659 return (POLLERR);
660 }
661 return (POLLIN | POLLRDNORM);
662}
663
664static const struct file_operations divas_fops = {
665 .owner = THIS_MODULE,
666 .llseek = no_llseek,
667 .read = divas_read,
668 .write = divas_write,
669 .poll = divas_poll,
670 .open = divas_open,
671 .release = divas_release
672};
673
674static void divas_unregister_chrdev(void)
675{
676 unregister_chrdev(major, DEVNAME);
677}
678
679static int DIVA_INIT_FUNCTION divas_register_chrdev(void)
680{
681 if ((major = register_chrdev(0, DEVNAME, &divas_fops)) < 0)
682 {
683 printk(KERN_ERR "%s: failed to create /dev entry.\n",
684 DRIVERLNAME);
685 return (0);
686 }
687
688 return (1);
689}
690
691
692
693
694static int __devinit divas_init_one(struct pci_dev *pdev,
695 const struct pci_device_id *ent)
696{
697 void *pdiva = NULL;
698 u8 pci_latency;
699 u8 new_latency = 32;
700
701 DBG_TRC(("%s bus: %08x fn: %08x insertion.\n",
702 CardProperties[ent->driver_data].Name,
703 pdev->bus->number, pdev->devfn))
704 printk(KERN_INFO "%s: %s bus: %08x fn: %08x insertion.\n",
705 DRIVERLNAME, CardProperties[ent->driver_data].Name,
706 pdev->bus->number, pdev->devfn);
707
708 if (pci_enable_device(pdev)) {
709 DBG_TRC(("%s: %s bus: %08x fn: %08x device init failed.\n",
710 DRIVERLNAME,
711 CardProperties[ent->driver_data].Name,
712 pdev->bus->number,
713 pdev->devfn))
714 printk(KERN_ERR
715 "%s: %s bus: %08x fn: %08x device init failed.\n",
716 DRIVERLNAME,
717 CardProperties[ent->driver_data].
718 Name, pdev->bus->number,
719 pdev->devfn);
720 return (-EIO);
721 }
722
723 pci_set_master(pdev);
724
725 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &pci_latency);
726 if (!pci_latency) {
727 DBG_TRC(("%s: bus: %08x fn: %08x fix latency.\n",
728 DRIVERLNAME, pdev->bus->number, pdev->devfn))
729 printk(KERN_INFO
730 "%s: bus: %08x fn: %08x fix latency.\n",
731 DRIVERLNAME, pdev->bus->number, pdev->devfn);
732 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, new_latency);
733 }
734
735 if (!(pdiva = diva_driver_add_card(pdev, ent->driver_data))) {
736 DBG_TRC(("%s: %s bus: %08x fn: %08x card init failed.\n",
737 DRIVERLNAME,
738 CardProperties[ent->driver_data].Name,
739 pdev->bus->number,
740 pdev->devfn))
741 printk(KERN_ERR
742 "%s: %s bus: %08x fn: %08x card init failed.\n",
743 DRIVERLNAME,
744 CardProperties[ent->driver_data].
745 Name, pdev->bus->number,
746 pdev->devfn);
747 return (-EIO);
748 }
749
750 pci_set_drvdata(pdev, pdiva);
751
752 return (0);
753}
754
755static void __devexit divas_remove_one(struct pci_dev *pdev)
756{
757 void *pdiva = pci_get_drvdata(pdev);
758
759 DBG_TRC(("bus: %08x fn: %08x removal.\n",
760 pdev->bus->number, pdev->devfn))
761 printk(KERN_INFO "%s: bus: %08x fn: %08x removal.\n",
762 DRIVERLNAME, pdev->bus->number, pdev->devfn);
763
764 if (pdiva) {
765 diva_driver_remove_card(pdiva);
766 }
767
768}
769
770
771
772
773static int DIVA_INIT_FUNCTION divas_init(void)
774{
775 char tmprev[50];
776 int ret = 0;
777
778 printk(KERN_INFO "%s\n", DRIVERNAME);
779 printk(KERN_INFO "%s: Rel:%s Rev:", DRIVERLNAME, DRIVERRELEASE_DIVAS);
780 strcpy(tmprev, main_revision);
781 printk("%s Build: %s(%s)\n", getrev(tmprev),
782 diva_xdi_common_code_build, DIVA_BUILD);
783 printk(KERN_INFO "%s: support for: ", DRIVERLNAME);
784#ifdef CONFIG_ISDN_DIVAS_BRIPCI
785 printk("BRI/PCI ");
786#endif
787#ifdef CONFIG_ISDN_DIVAS_PRIPCI
788 printk("PRI/PCI ");
789#endif
790 printk("adapters\n");
791
792 if (!divasfunc_init(dbgmask)) {
793 printk(KERN_ERR "%s: failed to connect to DIDD.\n",
794 DRIVERLNAME);
795 ret = -EIO;
796 goto out;
797 }
798
799 if (!divas_register_chrdev()) {
800#ifdef MODULE
801 divasfunc_exit();
802#endif
803 ret = -EIO;
804 goto out;
805 }
806
807 if (!create_divas_proc()) {
808#ifdef MODULE
809 remove_divas_proc();
810 divas_unregister_chrdev();
811 divasfunc_exit();
812#endif
813 printk(KERN_ERR "%s: failed to create proc entry.\n",
814 DRIVERLNAME);
815 ret = -EIO;
816 goto out;
817 }
818
819 if ((ret = pci_register_driver(&diva_pci_driver))) {
820#ifdef MODULE
821 remove_divas_proc();
822 divas_unregister_chrdev();
823 divasfunc_exit();
824#endif
825 printk(KERN_ERR "%s: failed to init pci driver.\n",
826 DRIVERLNAME);
827 goto out;
828 }
829 printk(KERN_INFO "%s: started with major %d\n", DRIVERLNAME, major);
830
831 out:
832 return (ret);
833}
834
835
836
837
838static void DIVA_EXIT_FUNCTION divas_exit(void)
839{
840 pci_unregister_driver(&diva_pci_driver);
841 remove_divas_proc();
842 divas_unregister_chrdev();
843 divasfunc_exit();
844
845 printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME);
846}
847
848module_init(divas_init);
849module_exit(divas_exit);
850