7 #include <linux/module.h>
11 #include <linux/sched.h>
12 #include <linux/slab.h>
24 static char devname[] =
"scX";
25 static const char version[] =
"2.0b1";
27 static const char *boardname[] = {
"DataCommute/BRI",
"DataCommute/PRI",
"TeleCommute/BRI" };
30 static unsigned int io[] = {0, 0, 0, 0};
31 static unsigned char irq[] = {0, 0, 0, 0};
32 static unsigned long ram[] = {0, 0, 0, 0};
40 static int identify_board(
unsigned long,
unsigned int);
42 static int __init sc_init(
void)
56 int probe_exhasted = 0;
59 pr_info(
"SpellCaster ISA ISDN Adapter Driver rev. %s Loaded\n",
version);
63 pr_info(
"Copyright (C) 1996 SpellCaster Telecommunications Inc.\n");
66 pr_debug(
"Probing for adapter #%d\n", b);
78 pr_debug(
"I/O Base for board %d is 0x%x, %s probe\n", b,
io[b],
79 io[b] == 0 ?
"will" :
"won't");
86 pr_debug(
"request_region for 0x%x failed\n",
io[b] + i * 0x400);
103 pr_debug(
"I/O Base 0x%x fails test\n",
104 io[b] + 0x400 * EXP_PAGE0);
112 if (probe_exhasted) {
113 pr_debug(
"All probe addresses exhasted, skipping\n");
125 for (j = 0; j < MAX_IO_REGS - 1; j++) {
145 if (probe_exhasted) {
154 pr_debug(
"Doing a SAFE probe reset\n");
158 pr_debug(
"RAM Base for board %d is 0x%lx, %s probe\n", b,
159 ram[b], ram[b] == 0 ?
"will" :
"won't");
168 pr_debug(
"request_region for RAM base 0x%lx succeeded\n", ram[b]);
169 model = identify_board(ram[b],
io[b]);
179 pr_debug(
"Checking RAM address 0x%x...\n", i);
181 pr_debug(
" request_region succeeded\n");
182 model = identify_board(i,
io[b]);
190 pr_debug(
" Unidentifed or inaccessible\n");
199 if (!ram[b] || model < 0) {
204 pr_debug(
"Failed to find an adapter at 0x%lx\n", ram[b]);
227 switch (ram[b] >> 12 & 0x0F) {
229 pr_debug(
"RAM Page register set to EXP_PAGE0\n");
234 pr_debug(
"RAM Page register set to EXP_PAGE1\n");
239 pr_debug(
"RAM Page register set to EXP_PAGE2\n");
244 pr_debug(
"RAM Page register set to EXP_PAGE3\n");
249 pr_debug(
"RAM base address doesn't fall on 16K boundary\n");
253 pr_debug(
"current IRQ: %d b: %d\n", irq[b], b);
262 pr_debug(
"Failed to acquire an IRQ line\n");
271 if (interface ==
NULL) {
287 interface->
id[2] =
'0' +
cinst;
340 (
void *)(
unsigned long)
cinst))
345 kfree(sc_adapter[cinst]);
350 for (i = 0; i < MAX_IO_REGS - 1; i++) {
354 pr_debug(
"Requesting I/O Port %#x\n",
355 sc_adapter[cinst]->
ioport[i]);
360 pr_debug(
"Requesting I/O Port %#x\n",
366 pr_info(
" %s (%d) - %s %d channels IRQ %d, I/O Base 0x%x, RAM Base 0x%lx\n",
367 sc_adapter[cinst]->devicename,
368 sc_adapter[cinst]->driverId,
369 boardname[model], channels, irq[b],
io[b], ram[b]);
380 pr_info(
"Failed to find any adapters, driver unloaded\n");
384 static void __exit sc_exit(
void)
388 for (i = 0; i <
cinst; i++) {
389 pr_debug(
"Cleaning up after adapter %d\n", i);
420 for (j = 0; j < MAX_IO_REGS - 1; j++) {
422 pr_debug(
"Releasing I/O Port %#x\n",
423 sc_adapter[i]->
ioport[j]);
426 pr_debug(
"Releasing I/O Port %#x\n",
434 kfree(sc_adapter[i]);
436 pr_info(
"SpellCaster ISA ISDN Adapter Driver Unloaded.\n");
439 static int identify_board(
unsigned long rambase,
unsigned int iobase)
449 pr_debug(
"Attempting to identify adapter @ 0x%lx io 0x%x\n",
455 outb(rambase >> 12, iobase + 0x2c00);
457 switch (rambase >> 12 & 0x0F) {
460 pr_debug(
"Page Register offset is 0x%x\n", PG0_OFFSET);
465 pr_debug(
"Page Register offset is 0x%x\n", PG1_OFFSET);
470 pr_debug(
"Page Register offset is 0x%x\n", PG2_OFFSET);
475 pr_debug(
"Page Register offset is 0x%x\n", PG3_OFFSET);
478 pr_debug(
"Invalid rambase 0x%lx\n", rambase);
488 pr_debug(
"Looking for a signature, got 0x%lx\n", sig);
498 pr_debug(
"Looking for a signature, got 0x%lx\n", sig);
508 pr_debug(
"Looking for a signature, got 0x%lx\n", sig);
520 outb(0, iobase + 0x400);
521 pr_debug(
"Sent HWConfig message\n");
531 pr_debug(
"Timeout waiting for response\n");
538 pr_debug(
"Hardware Config: Interface: %s, RAM Size: %ld, Serial: %s\n"
539 " Part: %s, Rev: %s\n",