2 * $Id: b1isa.c,v 1.4 1999/08/22 20:26:24 calle Exp $
4 * Module for AVM B1 ISA-card.
6 * (c) Copyright 1999 by Carsten Paeth (calle@calle.in-berlin.de)
9 * Revision 1.4 1999/08/22 20:26:24 calle
10 * backported changes from kernel 2.3.14:
11 * - several #include "config.h" gone, others come.
12 * - "struct device" changed to "struct net_device" in 2.3.14, added a
13 * define in isdn_compat.h for older kernel versions.
15 * Revision 1.3 1999/07/09 15:05:40 keil
16 * compat.h is now isdn_compat.h
18 * Revision 1.2 1999/07/05 15:09:49 calle
19 * - renamed "appl_release" to "appl_released".
20 * - version und profile data now cleared on controller reset
21 * - extended /proc interface, to allow driver and controller specific
22 * informations to include by driver hackers.
24 * Revision 1.1 1999/07/01 15:26:27 calle
25 * complete new version (I love it):
26 * + new hardware independed "capi_driver" interface that will make it easy to:
27 * - support other controllers with CAPI-2.0 (i.e. USB Controller)
28 * - write a CAPI-2.0 for the passive cards
29 * - support serial link CAPI-2.0 boxes.
30 * + wrote "capi_driver" for all supported cards.
31 * + "capi_driver" (supported cards) now have to be configured with
32 * make menuconfig, in the past all supported cards where included
34 * + new and better informations in /proc/capi/
35 * + new ioctl to switch trace of capi messages per controller
36 * using "avmcapictrl trace [contr] on|off|...."
37 * + complete testcircle with all supported cards and also the
38 * PCMCIA cards (now patch for pcmcia-cs-3.0.13 needed) done.
43 #include <linux/module.h>
44 #include <linux/kernel.h>
45 #include <linux/skbuff.h>
46 #include <linux/delay.h>
48 #include <linux/interrupt.h>
49 #include <linux/ioport.h>
50 #include <linux/capi.h>
52 #include <linux/isdn_compat.h>
58 static char *revision
= "$Revision: 1.4 $";
60 /* ------------------------------------------------------------- */
62 MODULE_AUTHOR("Carsten Paeth <calle@calle.in-berlin.de>");
64 /* ------------------------------------------------------------- */
66 static struct capi_driver_interface
*di
;
68 /* ------------------------------------------------------------- */
70 static void b1isa_interrupt(int interrupt
, void *devptr
, struct pt_regs
*regs
)
74 card
= (avmcard
*) devptr
;
77 printk(KERN_WARNING
"b1_interrupt: wrong device\n");
80 if (card
->interrupt
) {
81 printk(KERN_ERR
"b1_interrupt: reentering interrupt hander (%s)\n", card
->name
);
87 b1_handle_interrupt(card
);
91 /* ------------------------------------------------------------- */
93 static void b1isa_remove_ctr(struct capi_ctr
*ctrl
)
95 avmcard
*card
= (avmcard
*)(ctrl
->driverdata
);
96 unsigned int port
= card
->port
;
101 di
->detach_ctr(ctrl
);
102 free_irq(card
->irq
, card
);
103 release_region(card
->port
, AVMB1_PORTLEN
);
109 /* ------------------------------------------------------------- */
111 static int b1isa_add_card(struct capi_driver
*driver
, struct capicardparams
*p
)
116 card
= (avmcard
*) kmalloc(sizeof(avmcard
), GFP_ATOMIC
);
119 printk(KERN_WARNING
"b1isa: no memory.\n");
122 memset(card
, 0, sizeof(avmcard
));
123 sprintf(card
->name
, "b1isa-%x", p
->port
);
124 card
->port
= p
->port
;
126 card
->cardtype
= avm_b1isa
;
128 if (check_region(card
->port
, AVMB1_PORTLEN
)) {
130 "b1isa: ports 0x%03x-0x%03x in use.\n",
131 card
->port
, card
->port
+ AVMB1_PORTLEN
);
135 if (b1_irq_table
[card
->irq
& 0xf] == 0) {
136 printk(KERN_WARNING
"b1isa: irq %d not valid.\n", card
->irq
);
140 if ( card
->port
!= 0x150 && card
->port
!= 0x250
141 && card
->port
!= 0x300 && card
->port
!= 0x340) {
142 printk(KERN_WARNING
"b1isa: illegal port 0x%x.\n", card
->port
);
146 b1_reset(card
->port
);
147 if ((retval
= b1_detect(card
->port
, card
->cardtype
)) != 0) {
148 printk(KERN_NOTICE
"b1isa: NO card at 0x%x (%d)\n",
153 b1_reset(card
->port
);
155 request_region(p
->port
, AVMB1_PORTLEN
, card
->name
);
157 retval
= request_irq(card
->irq
, b1isa_interrupt
, 0, card
->name
, card
);
159 printk(KERN_ERR
"b1isa: unable to get IRQ %d.\n", card
->irq
);
160 release_region(card
->port
, AVMB1_PORTLEN
);
165 card
->ctrl
= di
->attach_ctr(driver
, card
->name
, card
);
167 printk(KERN_ERR
"b1isa: attach controller failed.\n");
168 free_irq(card
->irq
, card
);
169 release_region(card
->port
, AVMB1_PORTLEN
);
178 static char *b1isa_procinfo(struct capi_ctr
*ctrl
)
180 avmcard
*card
= (avmcard
*)(ctrl
->driverdata
);
183 sprintf(card
->infobuf
, "%s %s 0x%x %d",
184 card
->cardname
[0] ? card
->cardname
: "-",
185 card
->version
[VER_DRIVER
] ? card
->version
[VER_DRIVER
] : "-",
186 card
->port
, card
->irq
188 return card
->infobuf
;
191 /* ------------------------------------------------------------- */
193 static struct capi_driver b1isa_driver
= {
205 0, /* use standard driver_read_proc */
211 #define b1isa_init init_module
212 void cleanup_module(void);
217 struct capi_driver
*driver
= &b1isa_driver
;
220 if ((p
= strchr(revision
, ':'))) {
221 strncpy(driver
->revision
, p
+ 1, sizeof(driver
->revision
));
222 p
= strchr(driver
->revision
, '$');
226 printk(KERN_INFO
"%s: revision %s\n", driver
->name
, driver
->revision
);
228 di
= attach_capi_driver(driver
);
231 printk(KERN_ERR
"%s: failed to attach capi_driver\n",
239 void cleanup_module(void)
241 detach_capi_driver(&b1isa_driver
);