1 /* $Id: b1isa.c,v 1.1.2.3 2004/02/10 01:07:12 keil Exp $
3 * Module for AVM B1 ISA-card.
5 * Copyright 1999 by Carsten Paeth <calle@calle.de>
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/skbuff.h>
15 #include <linux/delay.h>
17 #include <linux/interrupt.h>
18 #include <linux/ioport.h>
19 #include <linux/capi.h>
20 #include <linux/init.h>
21 #include <linux/pci.h>
23 #include <linux/isdn/capicmd.h>
24 #include <linux/isdn/capiutil.h>
25 #include <linux/isdn/capilli.h>
28 /* ------------------------------------------------------------- */
30 static char *revision
= "$Revision: 1.1.2.3 $";
32 /* ------------------------------------------------------------- */
34 MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM B1 ISA card");
35 MODULE_AUTHOR("Carsten Paeth");
36 MODULE_LICENSE("GPL");
38 /* ------------------------------------------------------------- */
40 static void b1isa_remove(struct pci_dev
*pdev
)
42 avmctrl_info
*cinfo
= pci_get_drvdata(pdev
);
53 detach_capi_ctr(&cinfo
->capi_ctrl
);
54 free_irq(card
->irq
, card
);
55 release_region(card
->port
, AVMB1_PORTLEN
);
59 /* ------------------------------------------------------------- */
61 static char *b1isa_procinfo(struct capi_ctr
*ctrl
);
63 static int b1isa_probe(struct pci_dev
*pdev
)
69 card
= b1_alloc_card(1);
71 printk(KERN_WARNING
"b1isa: no memory.\n");
76 cinfo
= card
->ctrlinfo
;
78 card
->port
= pci_resource_start(pdev
, 0);
79 card
->irq
= pdev
->irq
;
80 card
->cardtype
= avm_b1isa
;
81 sprintf(card
->name
, "b1isa-%x", card
->port
);
83 if (card
->port
!= 0x150 && card
->port
!= 0x250
84 && card
->port
!= 0x300 && card
->port
!= 0x340) {
85 printk(KERN_WARNING
"b1isa: invalid port 0x%x.\n", card
->port
);
89 if (b1_irq_table
[card
->irq
& 0xf] == 0) {
90 printk(KERN_WARNING
"b1isa: irq %d not valid.\n", card
->irq
);
94 if (!request_region(card
->port
, AVMB1_PORTLEN
, card
->name
)) {
95 printk(KERN_WARNING
"b1isa: ports 0x%03x-0x%03x in use.\n",
96 card
->port
, card
->port
+ AVMB1_PORTLEN
);
100 retval
= request_irq(card
->irq
, b1_interrupt
, 0, card
->name
, card
);
102 printk(KERN_ERR
"b1isa: unable to get IRQ %d.\n", card
->irq
);
103 goto err_release_region
;
105 b1_reset(card
->port
);
106 if ((retval
= b1_detect(card
->port
, card
->cardtype
)) != 0) {
107 printk(KERN_NOTICE
"b1isa: NO card at 0x%x (%d)\n",
112 b1_reset(card
->port
);
113 b1_getrevision(card
);
115 cinfo
->capi_ctrl
.owner
= THIS_MODULE
;
116 cinfo
->capi_ctrl
.driver_name
= "b1isa";
117 cinfo
->capi_ctrl
.driverdata
= cinfo
;
118 cinfo
->capi_ctrl
.register_appl
= b1_register_appl
;
119 cinfo
->capi_ctrl
.release_appl
= b1_release_appl
;
120 cinfo
->capi_ctrl
.send_message
= b1_send_message
;
121 cinfo
->capi_ctrl
.load_firmware
= b1_load_firmware
;
122 cinfo
->capi_ctrl
.reset_ctr
= b1_reset_ctr
;
123 cinfo
->capi_ctrl
.procinfo
= b1isa_procinfo
;
124 cinfo
->capi_ctrl
.proc_show
= b1_proc_show
;
125 strcpy(cinfo
->capi_ctrl
.name
, card
->name
);
127 retval
= attach_capi_ctr(&cinfo
->capi_ctrl
);
129 printk(KERN_ERR
"b1isa: attach controller failed.\n");
133 printk(KERN_INFO
"b1isa: AVM B1 ISA at i/o %#x, irq %d, revision %d\n",
134 card
->port
, card
->irq
, card
->revision
);
136 pci_set_drvdata(pdev
, cinfo
);
140 free_irq(card
->irq
, card
);
142 release_region(card
->port
, AVMB1_PORTLEN
);
149 static char *b1isa_procinfo(struct capi_ctr
*ctrl
)
151 avmctrl_info
*cinfo
= (avmctrl_info
*)(ctrl
->driverdata
);
155 sprintf(cinfo
->infobuf
, "%s %s 0x%x %d r%d",
156 cinfo
->cardname
[0] ? cinfo
->cardname
: "-",
157 cinfo
->version
[VER_DRIVER
] ? cinfo
->version
[VER_DRIVER
] : "-",
158 cinfo
->card
? cinfo
->card
->port
: 0x0,
159 cinfo
->card
? cinfo
->card
->irq
: 0,
160 cinfo
->card
? cinfo
->card
->revision
: 0
162 return cinfo
->infobuf
;
165 /* ------------------------------------------------------------- */
168 static struct pci_dev isa_dev
[MAX_CARDS
];
169 static int io
[MAX_CARDS
];
170 static int irq
[MAX_CARDS
];
172 module_param_hw_array(io
, int, ioport
, NULL
, 0);
173 module_param_hw_array(irq
, int, irq
, NULL
, 0);
174 MODULE_PARM_DESC(io
, "I/O base address(es)");
175 MODULE_PARM_DESC(irq
, "IRQ number(s) (assigned)");
177 static int b1isa_add_card(struct capi_driver
*driver
, capicardparams
*data
)
181 for (i
= 0; i
< MAX_CARDS
; i
++) {
182 if (isa_dev
[i
].resource
[0].start
)
185 isa_dev
[i
].resource
[0].start
= data
->port
;
186 isa_dev
[i
].irq
= data
->irq
;
188 if (b1isa_probe(&isa_dev
[i
]) == 0)
194 static struct capi_driver capi_driver_b1isa
= {
197 .add_card
= b1isa_add_card
,
200 static int __init
b1isa_init(void)
206 if ((p
= strchr(revision
, ':')) != NULL
&& p
[1]) {
207 strlcpy(rev
, p
+ 2, 32);
208 if ((p
= strchr(rev
, '$')) != NULL
&& p
> rev
)
213 for (i
= 0; i
< MAX_CARDS
; i
++) {
217 isa_dev
[i
].resource
[0].start
= io
[i
];
218 isa_dev
[i
].irq
= irq
[i
];
220 if (b1isa_probe(&isa_dev
[i
]) != 0)
224 strlcpy(capi_driver_b1isa
.revision
, rev
, 32);
225 register_capi_driver(&capi_driver_b1isa
);
226 printk(KERN_INFO
"b1isa: revision %s\n", rev
);
231 static void __exit
b1isa_exit(void)
235 for (i
= 0; i
< MAX_CARDS
; i
++) {
236 if (isa_dev
[i
].resource
[0].start
)
237 b1isa_remove(&isa_dev
[i
]);
239 unregister_capi_driver(&capi_driver_b1isa
);
242 module_init(b1isa_init
);
243 module_exit(b1isa_exit
);