2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* PCBIT-D module support
|
|
|
|
*
|
|
|
|
* Copyright (C) 1996 Universidade de Lisboa
|
2012-02-19 20:52:38 -07:00
|
|
|
*
|
2005-04-16 16:20:36 -06:00
|
|
|
* Written by Pedro Roque Marques (roque@di.fc.ul.pt)
|
|
|
|
*
|
2012-02-19 20:52:38 -07:00
|
|
|
* This software may be used and distributed according to the terms of
|
2005-04-16 16:20:36 -06:00
|
|
|
* the GNU General Public License, incorporated herein by reference.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
|
|
|
|
#include <linux/isdnif.h>
|
|
|
|
#include "pcbit.h"
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("ISDN4Linux: Driver for PCBIT-T card");
|
|
|
|
MODULE_AUTHOR("Pedro Roque Marques");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
static int mem[MAX_PCBIT_CARDS];
|
|
|
|
static int irq[MAX_PCBIT_CARDS];
|
|
|
|
|
|
|
|
module_param_array(mem, int, NULL, 0);
|
|
|
|
module_param_array(irq, int, NULL, 0);
|
|
|
|
|
|
|
|
static int num_boards;
|
2012-02-19 20:52:38 -07:00
|
|
|
struct pcbit_dev *dev_pcbit[MAX_PCBIT_CARDS];
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
static int __init pcbit_init(void)
|
|
|
|
{
|
|
|
|
int board;
|
|
|
|
|
|
|
|
num_boards = 0;
|
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
printk(KERN_NOTICE
|
2005-04-16 16:20:36 -06:00
|
|
|
"PCBIT-D device driver v 0.5-fjpc0 19991204 - "
|
|
|
|
"Copyright (C) 1996 Universidade de Lisboa\n");
|
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
if (mem[0] || irq[0])
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2012-02-19 20:52:38 -07:00
|
|
|
for (board = 0; board < MAX_PCBIT_CARDS && mem[board] && irq[board]; board++)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
if (!mem[board])
|
|
|
|
mem[board] = 0xD0000;
|
|
|
|
if (!irq[board])
|
|
|
|
irq[board] = 5;
|
2012-02-19 20:52:38 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
if (pcbit_init_dev(board, mem[board], irq[board]) == 0)
|
|
|
|
num_boards++;
|
2012-02-19 20:52:38 -07:00
|
|
|
|
|
|
|
else
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2012-02-19 20:52:38 -07:00
|
|
|
printk(KERN_WARNING
|
|
|
|
"pcbit_init failed for dev %d",
|
2005-04-16 16:20:36 -06:00
|
|
|
board + 1);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hardcoded default settings detection */
|
|
|
|
|
|
|
|
if (!num_boards)
|
|
|
|
{
|
2012-02-19 20:52:38 -07:00
|
|
|
printk(KERN_INFO
|
2005-04-16 16:20:36 -06:00
|
|
|
"Trying to detect board using default settings\n");
|
|
|
|
if (pcbit_init_dev(0, 0xD0000, 5) == 0)
|
|
|
|
num_boards++;
|
|
|
|
else
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit pcbit_exit(void)
|
|
|
|
{
|
|
|
|
#ifdef MODULE
|
|
|
|
int board;
|
|
|
|
|
|
|
|
for (board = 0; board < num_boards; board++)
|
|
|
|
pcbit_terminate(board);
|
2012-02-19 20:52:38 -07:00
|
|
|
printk(KERN_NOTICE
|
2005-04-16 16:20:36 -06:00
|
|
|
"PCBIT-D module unloaded\n");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef MODULE
|
|
|
|
#define MAX_PARA (MAX_PCBIT_CARDS * 2)
|
|
|
|
static int __init pcbit_setup(char *line)
|
|
|
|
{
|
|
|
|
int i, j, argc;
|
|
|
|
char *str;
|
2012-02-19 20:52:38 -07:00
|
|
|
int ints[MAX_PARA + 1];
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
str = get_options(line, MAX_PARA, ints);
|
|
|
|
argc = ints[0];
|
|
|
|
i = 0;
|
|
|
|
j = 1;
|
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
while (argc && (i < MAX_PCBIT_CARDS)) {
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (argc) {
|
|
|
|
mem[i] = ints[j];
|
|
|
|
j++; argc--;
|
|
|
|
}
|
2012-02-19 20:52:38 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
if (argc) {
|
|
|
|
irq[i] = ints[j];
|
|
|
|
j++; argc--;
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
2012-02-19 20:52:38 -07:00
|
|
|
return (1);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
__setup("pcbit=", pcbit_setup);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
module_init(pcbit_init);
|
|
|
|
module_exit(pcbit_exit);
|