2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* This software may be used and distributed according to the terms
|
|
|
|
* of the GNU General Public License, incorporated herein by reference.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/delay.h>
|
2009-10-07 15:09:06 +02:00
|
|
|
#include <linux/sched.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 09:04:11 +01:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include "includes.h"
|
|
|
|
#include "hardware.h"
|
|
|
|
#include "card.h"
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("ISDN4Linux: Driver for Spellcaster card");
|
|
|
|
MODULE_AUTHOR("Spellcaster Telecommunications Inc.");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
board *sc_adapter[MAX_CARDS];
|
|
|
|
int cinst;
|
|
|
|
|
|
|
|
static char devname[] = "scX";
|
2005-06-25 23:58:34 +02:00
|
|
|
static const char version[] = "2.0b1";
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-06-25 23:58:34 +02:00
|
|
|
static const char *boardname[] = { "DataCommute/BRI", "DataCommute/PRI", "TeleCommute/BRI" };
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* insmod set parameters */
|
2012-02-20 04:52:38 +01:00
|
|
|
static unsigned int io[] = {0, 0, 0, 0};
|
|
|
|
static unsigned char irq[] = {0, 0, 0, 0};
|
|
|
|
static unsigned long ram[] = {0, 0, 0, 0};
|
2012-01-13 00:02:20 +01:00
|
|
|
static bool do_reset = 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
module_param_array(io, int, NULL, 0);
|
|
|
|
module_param_array(irq, int, NULL, 0);
|
|
|
|
module_param_array(ram, int, NULL, 0);
|
|
|
|
module_param(do_reset, bool, 0);
|
|
|
|
|
2005-06-25 23:58:34 +02:00
|
|
|
static int identify_board(unsigned long, unsigned int);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
static int __init sc_init(void)
|
|
|
|
{
|
|
|
|
int b = -1;
|
|
|
|
int i, j;
|
|
|
|
int status = -ENODEV;
|
|
|
|
|
|
|
|
unsigned long memsize = 0;
|
|
|
|
unsigned long features = 0;
|
|
|
|
isdn_if *interface;
|
|
|
|
unsigned char channels;
|
|
|
|
unsigned char pgport;
|
|
|
|
unsigned long magic;
|
|
|
|
int model;
|
|
|
|
int last_base = IOBASE_MIN;
|
|
|
|
int probe_exhasted = 0;
|
|
|
|
|
|
|
|
#ifdef MODULE
|
|
|
|
pr_info("SpellCaster ISA ISDN Adapter Driver rev. %s Loaded\n", version);
|
|
|
|
#else
|
|
|
|
pr_info("SpellCaster ISA ISDN Adapter Driver rev. %s\n", version);
|
|
|
|
#endif
|
|
|
|
pr_info("Copyright (C) 1996 SpellCaster Telecommunications Inc.\n");
|
|
|
|
|
2012-02-20 04:52:38 +01:00
|
|
|
while (b++ < MAX_CARDS - 1) {
|
2005-04-17 00:20:36 +02:00
|
|
|
pr_debug("Probing for adapter #%d\n", b);
|
|
|
|
/*
|
|
|
|
* Initialize reusable variables
|
|
|
|
*/
|
|
|
|
model = -1;
|
|
|
|
magic = 0;
|
|
|
|
channels = 0;
|
|
|
|
pgport = 0;
|
|
|
|
|
2012-02-20 04:52:38 +01:00
|
|
|
/*
|
|
|
|
* See if we should probe for IO base
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
pr_debug("I/O Base for board %d is 0x%x, %s probe\n", b, io[b],
|
2012-02-20 04:52:38 +01:00
|
|
|
io[b] == 0 ? "will" : "won't");
|
|
|
|
if (io[b]) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* No, I/O Base has been provided
|
|
|
|
*/
|
2012-02-20 04:52:38 +01:00
|
|
|
for (i = 0; i < MAX_IO_REGS - 1; i++) {
|
|
|
|
if (!request_region(io[b] + i * 0x400, 1, "sc test")) {
|
2005-09-13 10:25:15 +02:00
|
|
|
pr_debug("request_region for 0x%x failed\n", io[b] + i * 0x400);
|
2005-04-17 00:20:36 +02:00
|
|
|
io[b] = 0;
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
release_region(io[b] + i * 0x400, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Confirm the I/O Address with a test
|
|
|
|
*/
|
2012-02-20 04:52:38 +01:00
|
|
|
if (io[b] == 0) {
|
2006-10-11 10:22:25 +02:00
|
|
|
pr_debug("I/O Address invalid.\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
outb(0x18, io[b] + 0x400 * EXP_PAGE0);
|
2012-02-20 04:52:38 +01:00
|
|
|
if (inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) {
|
2006-10-11 10:22:25 +02:00
|
|
|
pr_debug("I/O Base 0x%x fails test\n",
|
|
|
|
io[b] + 0x400 * EXP_PAGE0);
|
2005-04-17 00:20:36 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Yes, probe for I/O Base
|
|
|
|
*/
|
2012-02-20 04:52:38 +01:00
|
|
|
if (probe_exhasted) {
|
2005-04-17 00:20:36 +02:00
|
|
|
pr_debug("All probe addresses exhasted, skipping\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
pr_debug("Probing for I/O...\n");
|
2012-02-20 04:52:38 +01:00
|
|
|
for (i = last_base; i <= IOBASE_MAX; i += IOBASE_OFFSET) {
|
2005-04-17 00:20:36 +02:00
|
|
|
int found_io = 1;
|
|
|
|
if (i == IOBASE_MAX) {
|
|
|
|
probe_exhasted = 1; /* No more addresses to probe */
|
|
|
|
pr_debug("End of Probes\n");
|
|
|
|
}
|
|
|
|
last_base = i + IOBASE_OFFSET;
|
|
|
|
pr_debug(" checking 0x%x...", i);
|
2012-02-20 04:52:38 +01:00
|
|
|
for (j = 0; j < MAX_IO_REGS - 1; j++) {
|
|
|
|
if (!request_region(i + j * 0x400, 1, "sc test")) {
|
2005-04-17 00:20:36 +02:00
|
|
|
pr_debug("Failed\n");
|
|
|
|
found_io = 0;
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
release_region(i + j * 0x400, 1);
|
2012-02-20 04:52:38 +01:00
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2012-02-20 04:52:38 +01:00
|
|
|
if (found_io) {
|
2005-04-17 00:20:36 +02:00
|
|
|
io[b] = i;
|
|
|
|
outb(0x18, io[b] + 0x400 * EXP_PAGE0);
|
2012-02-20 04:52:38 +01:00
|
|
|
if (inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) {
|
2005-04-17 00:20:36 +02:00
|
|
|
pr_debug("Failed by test\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
pr_debug("Passed\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-02-20 04:52:38 +01:00
|
|
|
if (probe_exhasted) {
|
2005-04-17 00:20:36 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if we should probe for shared RAM
|
|
|
|
*/
|
2012-02-20 04:52:38 +01:00
|
|
|
if (do_reset) {
|
2005-04-17 00:20:36 +02:00
|
|
|
pr_debug("Doing a SAFE probe reset\n");
|
|
|
|
outb(0xFF, io[b] + RESET_OFFSET);
|
|
|
|
msleep_interruptible(10000);
|
|
|
|
}
|
2006-10-11 10:22:25 +02:00
|
|
|
pr_debug("RAM Base for board %d is 0x%lx, %s probe\n", b,
|
2012-02-20 04:52:38 +01:00
|
|
|
ram[b], ram[b] == 0 ? "will" : "won't");
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2012-02-20 04:52:38 +01:00
|
|
|
if (ram[b]) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* No, the RAM base has been provided
|
|
|
|
* Just look for a signature and ID the
|
|
|
|
* board model
|
|
|
|
*/
|
2012-02-20 04:52:38 +01:00
|
|
|
if (request_region(ram[b], SRAM_PAGESIZE, "sc test")) {
|
2006-10-11 10:22:25 +02:00
|
|
|
pr_debug("request_region for RAM base 0x%lx succeeded\n", ram[b]);
|
2012-02-20 04:52:38 +01:00
|
|
|
model = identify_board(ram[b], io[b]);
|
2005-04-17 00:20:36 +02:00
|
|
|
release_region(ram[b], SRAM_PAGESIZE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Yes, probe for free RAM and look for
|
|
|
|
* a signature and id the board model
|
|
|
|
*/
|
2012-02-20 04:52:38 +01:00
|
|
|
for (i = SRAM_MIN; i < SRAM_MAX; i += SRAM_PAGESIZE) {
|
2005-04-17 00:20:36 +02:00
|
|
|
pr_debug("Checking RAM address 0x%x...\n", i);
|
2012-02-20 04:52:38 +01:00
|
|
|
if (request_region(i, SRAM_PAGESIZE, "sc test")) {
|
2005-09-13 10:25:15 +02:00
|
|
|
pr_debug(" request_region succeeded\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
model = identify_board(i, io[b]);
|
|
|
|
release_region(i, SRAM_PAGESIZE);
|
|
|
|
if (model >= 0) {
|
|
|
|
pr_debug(" Identified a %s\n",
|
2012-02-20 04:52:38 +01:00
|
|
|
boardname[model]);
|
2005-04-17 00:20:36 +02:00
|
|
|
ram[b] = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pr_debug(" Unidentifed or inaccessible\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
pr_debug(" request failed\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* See if we found free RAM and the board model
|
|
|
|
*/
|
2012-02-20 04:52:38 +01:00
|
|
|
if (!ram[b] || model < 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* Nope, there was no place in RAM for the
|
|
|
|
* board, or it couldn't be identified
|
|
|
|
*/
|
2012-02-20 04:52:38 +01:00
|
|
|
pr_debug("Failed to find an adapter at 0x%lx\n", ram[b]);
|
|
|
|
continue;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the board's magic number, memory size and page register
|
|
|
|
*/
|
2012-02-20 04:52:38 +01:00
|
|
|
switch (model) {
|
2005-04-17 00:20:36 +02:00
|
|
|
case PRI_BOARD:
|
|
|
|
channels = 23;
|
|
|
|
magic = 0x20000;
|
|
|
|
memsize = 0x100000;
|
|
|
|
features = PRI_FEATURES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BRI_BOARD:
|
|
|
|
case POTS_BOARD:
|
|
|
|
channels = 2;
|
|
|
|
magic = 0x60000;
|
|
|
|
memsize = 0x10000;
|
|
|
|
features = BRI_FEATURES;
|
|
|
|
break;
|
|
|
|
}
|
2012-02-20 04:52:38 +01:00
|
|
|
switch (ram[b] >> 12 & 0x0F) {
|
2005-04-17 00:20:36 +02:00
|
|
|
case 0x0:
|
|
|
|
pr_debug("RAM Page register set to EXP_PAGE0\n");
|
|
|
|
pgport = EXP_PAGE0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x4:
|
|
|
|
pr_debug("RAM Page register set to EXP_PAGE1\n");
|
|
|
|
pgport = EXP_PAGE1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x8:
|
|
|
|
pr_debug("RAM Page register set to EXP_PAGE2\n");
|
|
|
|
pgport = EXP_PAGE2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xC:
|
|
|
|
pr_debug("RAM Page register set to EXP_PAGE3\n");
|
|
|
|
pgport = EXP_PAGE3;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
pr_debug("RAM base address doesn't fall on 16K boundary\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-02-20 04:52:38 +01:00
|
|
|
pr_debug("current IRQ: %d b: %d\n", irq[b], b);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure we got an IRQ
|
|
|
|
*/
|
2012-02-20 04:52:38 +01:00
|
|
|
if (!irq[b]) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* No interrupt could be used
|
|
|
|
*/
|
|
|
|
pr_debug("Failed to acquire an IRQ line\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Horray! We found a board, Make sure we can register
|
|
|
|
* it with ISDN4Linux
|
|
|
|
*/
|
2006-12-08 11:39:35 +01:00
|
|
|
interface = kzalloc(sizeof(isdn_if), GFP_KERNEL);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (interface == NULL) {
|
|
|
|
/*
|
|
|
|
* Oops, can't malloc isdn_if
|
|
|
|
*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface->owner = THIS_MODULE;
|
|
|
|
interface->hl_hdrlen = 0;
|
|
|
|
interface->channels = channels;
|
|
|
|
interface->maxbufsize = BUFFER_SIZE;
|
|
|
|
interface->features = features;
|
|
|
|
interface->writebuf_skb = sndpkt;
|
|
|
|
interface->writecmd = NULL;
|
|
|
|
interface->command = command;
|
|
|
|
strcpy(interface->id, devname);
|
|
|
|
interface->id[2] = '0' + cinst;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate the board structure
|
|
|
|
*/
|
2006-12-08 11:39:35 +01:00
|
|
|
sc_adapter[cinst] = kzalloc(sizeof(board), GFP_KERNEL);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (sc_adapter[cinst] == NULL) {
|
|
|
|
/*
|
|
|
|
* Oops, can't alloc memory for the board
|
|
|
|
*/
|
|
|
|
kfree(interface);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
spin_lock_init(&sc_adapter[cinst]->lock);
|
|
|
|
|
2012-02-20 04:52:38 +01:00
|
|
|
if (!register_isdn(interface)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* Oops, couldn't register for some reason
|
|
|
|
*/
|
|
|
|
kfree(interface);
|
|
|
|
kfree(sc_adapter[cinst]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc_adapter[cinst]->card = interface;
|
|
|
|
sc_adapter[cinst]->driverId = interface->channels;
|
|
|
|
strcpy(sc_adapter[cinst]->devicename, interface->id);
|
|
|
|
sc_adapter[cinst]->nChannels = channels;
|
|
|
|
sc_adapter[cinst]->ramsize = memsize;
|
|
|
|
sc_adapter[cinst]->shmem_magic = magic;
|
|
|
|
sc_adapter[cinst]->shmem_pgport = pgport;
|
|
|
|
sc_adapter[cinst]->StartOnReset = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate channels status structures
|
|
|
|
*/
|
2006-12-08 11:39:35 +01:00
|
|
|
sc_adapter[cinst]->channel = kzalloc(sizeof(bchan) * channels, GFP_KERNEL);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (sc_adapter[cinst]->channel == NULL) {
|
|
|
|
/*
|
|
|
|
* Oops, can't alloc memory for the channels
|
|
|
|
*/
|
|
|
|
indicate_status(cinst, ISDN_STAT_UNLOAD, 0, NULL); /* Fix me */
|
|
|
|
kfree(interface);
|
|
|
|
kfree(sc_adapter[cinst]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lock down the hardware resources
|
|
|
|
*/
|
|
|
|
sc_adapter[cinst]->interrupt = irq[b];
|
|
|
|
if (request_irq(sc_adapter[cinst]->interrupt, interrupt_handler,
|
2007-10-20 01:31:27 +02:00
|
|
|
IRQF_DISABLED, interface->id,
|
|
|
|
(void *)(unsigned long) cinst))
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
kfree(sc_adapter[cinst]->channel);
|
|
|
|
indicate_status(cinst, ISDN_STAT_UNLOAD, 0, NULL); /* Fix me */
|
|
|
|
kfree(interface);
|
|
|
|
kfree(sc_adapter[cinst]);
|
|
|
|
continue;
|
2012-02-20 04:52:38 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
sc_adapter[cinst]->iobase = io[b];
|
2012-02-20 04:52:38 +01:00
|
|
|
for (i = 0; i < MAX_IO_REGS - 1; i++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
sc_adapter[cinst]->ioport[i] = io[b] + i * 0x400;
|
|
|
|
request_region(sc_adapter[cinst]->ioport[i], 1,
|
2012-02-20 04:52:38 +01:00
|
|
|
interface->id);
|
2005-04-17 00:20:36 +02:00
|
|
|
pr_debug("Requesting I/O Port %#x\n",
|
2012-02-20 04:52:38 +01:00
|
|
|
sc_adapter[cinst]->ioport[i]);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
sc_adapter[cinst]->ioport[IRQ_SELECT] = io[b] + 0x2;
|
|
|
|
request_region(sc_adapter[cinst]->ioport[IRQ_SELECT], 1,
|
2012-02-20 04:52:38 +01:00
|
|
|
interface->id);
|
2005-04-17 00:20:36 +02:00
|
|
|
pr_debug("Requesting I/O Port %#x\n",
|
2012-02-20 04:52:38 +01:00
|
|
|
sc_adapter[cinst]->ioport[IRQ_SELECT]);
|
2005-04-17 00:20:36 +02:00
|
|
|
sc_adapter[cinst]->rambase = ram[b];
|
|
|
|
request_region(sc_adapter[cinst]->rambase, SRAM_PAGESIZE,
|
2012-02-20 04:52:38 +01:00
|
|
|
interface->id);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2012-02-20 04:52:38 +01:00
|
|
|
pr_info(" %s (%d) - %s %d channels IRQ %d, I/O Base 0x%x, RAM Base 0x%lx\n",
|
2005-04-17 00:20:36 +02:00
|
|
|
sc_adapter[cinst]->devicename,
|
|
|
|
sc_adapter[cinst]->driverId,
|
|
|
|
boardname[model], channels, irq[b], io[b], ram[b]);
|
2012-02-20 04:52:38 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* reset the adapter to put things in motion
|
|
|
|
*/
|
|
|
|
reset(cinst);
|
|
|
|
|
|
|
|
cinst++;
|
|
|
|
status = 0;
|
|
|
|
}
|
2012-02-20 04:52:38 +01:00
|
|
|
if (status)
|
2005-04-17 00:20:36 +02:00
|
|
|
pr_info("Failed to find any adapters, driver unloaded\n");
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit sc_exit(void)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
2012-02-20 04:52:38 +01:00
|
|
|
for (i = 0; i < cinst; i++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
pr_debug("Cleaning up after adapter %d\n", i);
|
|
|
|
/*
|
|
|
|
* kill the timers
|
|
|
|
*/
|
|
|
|
del_timer(&(sc_adapter[i]->reset_timer));
|
|
|
|
del_timer(&(sc_adapter[i]->stat_timer));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Tell I4L we're toast
|
|
|
|
*/
|
|
|
|
indicate_status(i, ISDN_STAT_STOP, 0, NULL);
|
|
|
|
indicate_status(i, ISDN_STAT_UNLOAD, 0, NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release shared RAM
|
|
|
|
*/
|
|
|
|
release_region(sc_adapter[i]->rambase, SRAM_PAGESIZE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release the IRQ
|
|
|
|
*/
|
2007-10-19 08:39:20 +02:00
|
|
|
free_irq(sc_adapter[i]->interrupt, NULL);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset for a clean start
|
|
|
|
*/
|
|
|
|
outb(0xFF, sc_adapter[i]->ioport[SFT_RESET]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release the I/O Port regions
|
|
|
|
*/
|
2012-02-20 04:52:38 +01:00
|
|
|
for (j = 0; j < MAX_IO_REGS - 1; j++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
release_region(sc_adapter[i]->ioport[j], 1);
|
|
|
|
pr_debug("Releasing I/O Port %#x\n",
|
2012-02-20 04:52:38 +01:00
|
|
|
sc_adapter[i]->ioport[j]);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
release_region(sc_adapter[i]->ioport[IRQ_SELECT], 1);
|
|
|
|
pr_debug("Releasing I/O Port %#x\n",
|
2012-02-20 04:52:38 +01:00
|
|
|
sc_adapter[i]->ioport[IRQ_SELECT]);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Release any memory we alloced
|
|
|
|
*/
|
|
|
|
kfree(sc_adapter[i]->channel);
|
|
|
|
kfree(sc_adapter[i]->card);
|
|
|
|
kfree(sc_adapter[i]);
|
|
|
|
}
|
|
|
|
pr_info("SpellCaster ISA ISDN Adapter Driver Unloaded.\n");
|
|
|
|
}
|
|
|
|
|
2005-06-25 23:58:34 +02:00
|
|
|
static int identify_board(unsigned long rambase, unsigned int iobase)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned int pgport;
|
|
|
|
unsigned long sig;
|
|
|
|
DualPortMemory *dpm;
|
|
|
|
RspMessage rcvmsg;
|
|
|
|
ReqMessage sndmsg;
|
|
|
|
HWConfig_pl hwci;
|
|
|
|
int x;
|
|
|
|
|
2006-10-11 10:22:25 +02:00
|
|
|
pr_debug("Attempting to identify adapter @ 0x%lx io 0x%x\n",
|
2012-02-20 04:52:38 +01:00
|
|
|
rambase, iobase);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable the base pointer
|
|
|
|
*/
|
|
|
|
outb(rambase >> 12, iobase + 0x2c00);
|
|
|
|
|
2012-02-20 04:52:38 +01:00
|
|
|
switch (rambase >> 12 & 0x0F) {
|
2005-04-17 00:20:36 +02:00
|
|
|
case 0x0:
|
|
|
|
pgport = iobase + PG0_OFFSET;
|
|
|
|
pr_debug("Page Register offset is 0x%x\n", PG0_OFFSET);
|
|
|
|
break;
|
2012-02-20 04:52:38 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
case 0x4:
|
|
|
|
pgport = iobase + PG1_OFFSET;
|
|
|
|
pr_debug("Page Register offset is 0x%x\n", PG1_OFFSET);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x8:
|
|
|
|
pgport = iobase + PG2_OFFSET;
|
|
|
|
pr_debug("Page Register offset is 0x%x\n", PG2_OFFSET);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xC:
|
|
|
|
pgport = iobase + PG3_OFFSET;
|
|
|
|
pr_debug("Page Register offset is 0x%x\n", PG3_OFFSET);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pr_debug("Invalid rambase 0x%lx\n", rambase);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to identify a PRI card
|
|
|
|
*/
|
|
|
|
outb(PRI_BASEPG_VAL, pgport);
|
|
|
|
msleep_interruptible(1000);
|
|
|
|
sig = readl(rambase + SIG_OFFSET);
|
2006-10-11 10:22:25 +02:00
|
|
|
pr_debug("Looking for a signature, got 0x%lx\n", sig);
|
2012-02-20 04:52:38 +01:00
|
|
|
if (sig == SIGNATURE)
|
2005-04-17 00:20:36 +02:00
|
|
|
return PRI_BOARD;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to identify a PRI card
|
|
|
|
*/
|
|
|
|
outb(BRI_BASEPG_VAL, pgport);
|
|
|
|
msleep_interruptible(1000);
|
|
|
|
sig = readl(rambase + SIG_OFFSET);
|
2006-10-11 10:22:25 +02:00
|
|
|
pr_debug("Looking for a signature, got 0x%lx\n", sig);
|
2012-02-20 04:52:38 +01:00
|
|
|
if (sig == SIGNATURE)
|
2005-04-17 00:20:36 +02:00
|
|
|
return BRI_BOARD;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to spot a card
|
|
|
|
*/
|
|
|
|
sig = readl(rambase + SIG_OFFSET);
|
2006-10-11 10:22:25 +02:00
|
|
|
pr_debug("Looking for a signature, got 0x%lx\n", sig);
|
2012-02-20 04:52:38 +01:00
|
|
|
if (sig != SIGNATURE)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
dpm = (DualPortMemory *) rambase;
|
|
|
|
|
|
|
|
memset(&sndmsg, 0, MSG_LEN);
|
|
|
|
sndmsg.msg_byte_cnt = 3;
|
|
|
|
sndmsg.type = cmReqType1;
|
|
|
|
sndmsg.class = cmReqClass0;
|
|
|
|
sndmsg.code = cmReqHWConfig;
|
|
|
|
memcpy_toio(&(dpm->req_queue[dpm->req_head++]), &sndmsg, MSG_LEN);
|
|
|
|
outb(0, iobase + 0x400);
|
|
|
|
pr_debug("Sent HWConfig message\n");
|
|
|
|
/*
|
|
|
|
* Wait for the response
|
|
|
|
*/
|
|
|
|
x = 0;
|
2012-02-20 04:52:38 +01:00
|
|
|
while ((inb(iobase + FIFOSTAT_OFFSET) & RF_HAS_DATA) && x < 100) {
|
2005-11-07 10:01:16 +01:00
|
|
|
schedule_timeout_interruptible(1);
|
2005-04-17 00:20:36 +02:00
|
|
|
x++;
|
|
|
|
}
|
2012-02-20 04:52:38 +01:00
|
|
|
if (x == 100) {
|
2005-04-17 00:20:36 +02:00
|
|
|
pr_debug("Timeout waiting for response\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy_fromio(&rcvmsg, &(dpm->rsp_queue[dpm->rsp_tail]), MSG_LEN);
|
|
|
|
pr_debug("Got HWConfig response, status = 0x%x\n", rcvmsg.rsp_status);
|
|
|
|
memcpy(&hwci, &(rcvmsg.msg_data.HWCresponse), sizeof(HWConfig_pl));
|
2006-10-11 10:22:25 +02:00
|
|
|
pr_debug("Hardware Config: Interface: %s, RAM Size: %ld, Serial: %s\n"
|
2005-04-17 00:20:36 +02:00
|
|
|
" Part: %s, Rev: %s\n",
|
|
|
|
hwci.st_u_sense ? "S/T" : "U", hwci.ram_size,
|
|
|
|
hwci.serial_no, hwci.part_no, hwci.rev_no);
|
|
|
|
|
2012-02-20 04:52:38 +01:00
|
|
|
if (!strncmp(PRI_PARTNO, hwci.part_no, 6))
|
2005-04-17 00:20:36 +02:00
|
|
|
return PRI_BOARD;
|
2012-02-20 04:52:38 +01:00
|
|
|
if (!strncmp(BRI_PARTNO, hwci.part_no, 6))
|
2005-04-17 00:20:36 +02:00
|
|
|
return BRI_BOARD;
|
2012-02-20 04:52:38 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(sc_init);
|
|
|
|
module_exit(sc_exit);
|