2005-04-16 16:20:36 -06:00
|
|
|
/* $Id: b1.c,v 1.1.2.2 2004/01/16 21:09:27 keil Exp $
|
2012-02-19 20:52:38 -07:00
|
|
|
*
|
2005-04-16 16:20:36 -06:00
|
|
|
* Common module for AVM B1 cards.
|
2012-02-19 20:52:38 -07:00
|
|
|
*
|
2005-04-16 16:20:36 -06:00
|
|
|
* Copyright 1999 by Carsten Paeth <calle@calle.de>
|
|
|
|
*
|
|
|
|
* 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/kernel.h>
|
|
|
|
#include <linux/pci.h>
|
2010-01-14 04:10:54 -07:00
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/seq_file.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/capi.h>
|
|
|
|
#include <linux/kernelcapi.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 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/isdn/capilli.h>
|
|
|
|
#include "avmcard.h"
|
|
|
|
#include <linux/isdn/capicmd.h>
|
|
|
|
#include <linux/isdn/capiutil.h>
|
|
|
|
|
|
|
|
static char *revision = "$Revision: 1.1.2.2 $";
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("CAPI4Linux: Common support for active AVM cards");
|
|
|
|
MODULE_AUTHOR("Carsten Paeth");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
int b1_irq_table[16] =
|
|
|
|
{0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
192, /* irq 3 */
|
|
|
|
32, /* irq 4 */
|
|
|
|
160, /* irq 5 */
|
|
|
|
96, /* irq 6 */
|
|
|
|
224, /* irq 7 */
|
|
|
|
0,
|
|
|
|
64, /* irq 9 */
|
|
|
|
80, /* irq 10 */
|
|
|
|
208, /* irq 11 */
|
|
|
|
48, /* irq 12 */
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
112, /* irq 15 */
|
|
|
|
};
|
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
/* ------------------------------------------------------------- */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
avmcard *b1_alloc_card(int nr_controllers)
|
|
|
|
{
|
|
|
|
avmcard *card;
|
|
|
|
avmctrl_info *cinfo;
|
|
|
|
int i;
|
|
|
|
|
2006-12-08 03:39:35 -07:00
|
|
|
card = kzalloc(sizeof(*card), GFP_KERNEL);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!card)
|
|
|
|
return NULL;
|
|
|
|
|
2006-12-08 03:39:35 -07:00
|
|
|
cinfo = kzalloc(sizeof(*cinfo) * nr_controllers, GFP_KERNEL);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!cinfo) {
|
|
|
|
kfree(card);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
card->ctrlinfo = cinfo;
|
|
|
|
for (i = 0; i < nr_controllers; i++) {
|
|
|
|
INIT_LIST_HEAD(&cinfo[i].ncci_head);
|
|
|
|
cinfo[i].card = card;
|
|
|
|
}
|
|
|
|
spin_lock_init(&card->lock);
|
|
|
|
card->nr_controllers = nr_controllers;
|
|
|
|
|
|
|
|
return card;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void b1_free_card(avmcard *card)
|
|
|
|
{
|
|
|
|
kfree(card->ctrlinfo);
|
|
|
|
kfree(card);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
int b1_detect(unsigned int base, enum avmcardtype cardtype)
|
|
|
|
{
|
|
|
|
int onoff, i;
|
|
|
|
|
|
|
|
/*
|
2012-02-19 20:52:38 -07:00
|
|
|
* Statusregister 0000 00xx
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
if ((inb(base + B1_INSTAT) & 0xfc)
|
|
|
|
|| (inb(base + B1_OUTSTAT) & 0xfc))
|
|
|
|
return 1;
|
|
|
|
/*
|
2012-02-19 20:52:38 -07:00
|
|
|
* Statusregister 0000 001x
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
b1outp(base, B1_INSTAT, 0x2); /* enable irq */
|
|
|
|
/* b1outp(base, B1_OUTSTAT, 0x2); */
|
|
|
|
if ((inb(base + B1_INSTAT) & 0xfe) != 0x2
|
|
|
|
/* || (inb(base + B1_OUTSTAT) & 0xfe) != 0x2 */)
|
|
|
|
return 2;
|
|
|
|
/*
|
2012-02-19 20:52:38 -07:00
|
|
|
* Statusregister 0000 000x
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
b1outp(base, B1_INSTAT, 0x0); /* disable irq */
|
|
|
|
b1outp(base, B1_OUTSTAT, 0x0);
|
|
|
|
if ((inb(base + B1_INSTAT) & 0xfe)
|
|
|
|
|| (inb(base + B1_OUTSTAT) & 0xfe))
|
|
|
|
return 3;
|
2012-02-19 20:52:38 -07:00
|
|
|
|
|
|
|
for (onoff = !0, i = 0; i < 10; i++) {
|
2005-04-16 16:20:36 -06:00
|
|
|
b1_set_test_bit(base, cardtype, onoff);
|
|
|
|
if (b1_get_test_bit(base, cardtype) != onoff)
|
2012-02-19 20:52:38 -07:00
|
|
|
return 4;
|
2005-04-16 16:20:36 -06:00
|
|
|
onoff = !onoff;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cardtype == avm_m1)
|
2012-02-19 20:52:38 -07:00
|
|
|
return 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
if ((b1_rd_reg(base, B1_STAT1(cardtype)) & 0x0f) != 0x01)
|
|
|
|
return 5;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void b1_getrevision(avmcard *card)
|
|
|
|
{
|
2012-02-19 20:52:38 -07:00
|
|
|
card->class = inb(card->port + B1_ANALYSE);
|
|
|
|
card->revision = inb(card->port + B1_REVISION);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#define FWBUF_SIZE 256
|
2012-02-19 20:52:38 -07:00
|
|
|
int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
unsigned char buf[FWBUF_SIZE];
|
|
|
|
unsigned char *dp;
|
|
|
|
int i, left;
|
|
|
|
unsigned int base = card->port;
|
|
|
|
|
|
|
|
dp = t4file->data;
|
|
|
|
left = t4file->len;
|
|
|
|
while (left > FWBUF_SIZE) {
|
|
|
|
if (t4file->user) {
|
|
|
|
if (copy_from_user(buf, dp, FWBUF_SIZE))
|
|
|
|
return -EFAULT;
|
|
|
|
} else {
|
|
|
|
memcpy(buf, dp, FWBUF_SIZE);
|
|
|
|
}
|
|
|
|
for (i = 0; i < FWBUF_SIZE; i++)
|
|
|
|
if (b1_save_put_byte(base, buf[i]) < 0) {
|
|
|
|
printk(KERN_ERR "%s: corrupted firmware file ?\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
card->name);
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
left -= FWBUF_SIZE;
|
|
|
|
dp += FWBUF_SIZE;
|
|
|
|
}
|
|
|
|
if (left) {
|
|
|
|
if (t4file->user) {
|
|
|
|
if (copy_from_user(buf, dp, left))
|
|
|
|
return -EFAULT;
|
|
|
|
} else {
|
|
|
|
memcpy(buf, dp, left);
|
|
|
|
}
|
|
|
|
for (i = 0; i < left; i++)
|
|
|
|
if (b1_save_put_byte(base, buf[i]) < 0) {
|
|
|
|
printk(KERN_ERR "%s: corrupted firmware file ?\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
card->name);
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
int b1_load_config(avmcard *card, capiloaddatapart *config)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
unsigned char buf[FWBUF_SIZE];
|
|
|
|
unsigned char *dp;
|
|
|
|
unsigned int base = card->port;
|
|
|
|
int i, j, left;
|
|
|
|
|
|
|
|
dp = config->data;
|
|
|
|
left = config->len;
|
|
|
|
if (left) {
|
|
|
|
b1_put_byte(base, SEND_CONFIG);
|
2012-02-19 20:52:38 -07:00
|
|
|
b1_put_word(base, 1);
|
2005-04-16 16:20:36 -06:00
|
|
|
b1_put_byte(base, SEND_CONFIG);
|
2012-02-19 20:52:38 -07:00
|
|
|
b1_put_word(base, left);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
while (left > FWBUF_SIZE) {
|
|
|
|
if (config->user) {
|
|
|
|
if (copy_from_user(buf, dp, FWBUF_SIZE))
|
|
|
|
return -EFAULT;
|
|
|
|
} else {
|
|
|
|
memcpy(buf, dp, FWBUF_SIZE);
|
|
|
|
}
|
|
|
|
for (i = 0; i < FWBUF_SIZE; ) {
|
|
|
|
b1_put_byte(base, SEND_CONFIG);
|
2012-02-19 20:52:38 -07:00
|
|
|
for (j = 0; j < 4; j++) {
|
2005-04-16 16:20:36 -06:00
|
|
|
b1_put_byte(base, buf[i++]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
left -= FWBUF_SIZE;
|
|
|
|
dp += FWBUF_SIZE;
|
|
|
|
}
|
|
|
|
if (left) {
|
|
|
|
if (config->user) {
|
|
|
|
if (copy_from_user(buf, dp, left))
|
|
|
|
return -EFAULT;
|
|
|
|
} else {
|
|
|
|
memcpy(buf, dp, left);
|
|
|
|
}
|
|
|
|
for (i = 0; i < left; ) {
|
|
|
|
b1_put_byte(base, SEND_CONFIG);
|
2012-02-19 20:52:38 -07:00
|
|
|
for (j = 0; j < 4; j++) {
|
2005-04-16 16:20:36 -06:00
|
|
|
if (i < left)
|
|
|
|
b1_put_byte(base, buf[i++]);
|
|
|
|
else
|
|
|
|
b1_put_byte(base, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int b1_loaded(avmcard *card)
|
|
|
|
{
|
|
|
|
unsigned int base = card->port;
|
|
|
|
unsigned long stop;
|
|
|
|
unsigned char ans;
|
|
|
|
unsigned long tout = 2;
|
|
|
|
|
|
|
|
for (stop = jiffies + tout * HZ; time_before(jiffies, stop);) {
|
|
|
|
if (b1_tx_empty(base))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!b1_tx_empty(base)) {
|
|
|
|
printk(KERN_ERR "%s: b1_loaded: tx err, corrupted t4 file ?\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
card->name);
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
b1_put_byte(base, SEND_POLL);
|
|
|
|
for (stop = jiffies + tout * HZ; time_before(jiffies, stop);) {
|
|
|
|
if (b1_rx_full(base)) {
|
|
|
|
if ((ans = b1_get_byte(base)) == RECEIVE_POLL) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
printk(KERN_ERR "%s: b1_loaded: got 0x%x, firmware not running\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
card->name, ans);
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printk(KERN_ERR "%s: b1_loaded: firmware not running\n", card->name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
int b1_load_firmware(struct capi_ctr *ctrl, capiloaddata *data)
|
|
|
|
{
|
|
|
|
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
|
|
|
|
avmcard *card = cinfo->card;
|
|
|
|
unsigned int port = card->port;
|
|
|
|
unsigned long flags;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
b1_reset(port);
|
|
|
|
|
|
|
|
if ((retval = b1_load_t4file(card, &data->firmware))) {
|
|
|
|
b1_reset(port);
|
|
|
|
printk(KERN_ERR "%s: failed to load t4file!!\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
card->name);
|
2005-04-16 16:20:36 -06:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
b1_disable_irq(port);
|
|
|
|
|
|
|
|
if (data->configuration.len > 0 && data->configuration.data) {
|
|
|
|
if ((retval = b1_load_config(card, &data->configuration))) {
|
|
|
|
b1_reset(port);
|
|
|
|
printk(KERN_ERR "%s: failed to load config!!\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
card->name);
|
2005-04-16 16:20:36 -06:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!b1_loaded(card)) {
|
|
|
|
printk(KERN_ERR "%s: failed to load t4file.\n", card->name);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&card->lock, flags);
|
|
|
|
b1_setinterrupt(port, card->irq, card->cardtype);
|
|
|
|
b1_put_byte(port, SEND_INIT);
|
|
|
|
b1_put_word(port, CAPI_MAXAPPL);
|
2012-02-19 20:52:38 -07:00
|
|
|
b1_put_word(port, AVM_NCCI_PER_CHANNEL * 2);
|
2005-04-16 16:20:36 -06:00
|
|
|
b1_put_word(port, ctrl->cnr - 1);
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void b1_reset_ctr(struct capi_ctr *ctrl)
|
|
|
|
{
|
|
|
|
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
|
|
|
|
avmcard *card = cinfo->card;
|
|
|
|
unsigned int port = card->port;
|
2007-10-18 04:04:31 -06:00
|
|
|
unsigned long flags;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
b1_reset(port);
|
|
|
|
b1_reset(port);
|
|
|
|
|
|
|
|
memset(cinfo->version, 0, sizeof(cinfo->version));
|
2007-10-18 04:04:31 -06:00
|
|
|
spin_lock_irqsave(&card->lock, flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
capilib_release(&cinfo->ncci_head);
|
2007-10-18 04:04:31 -06:00
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
2009-06-07 03:09:23 -06:00
|
|
|
capi_ctr_down(ctrl);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void b1_register_appl(struct capi_ctr *ctrl,
|
2012-02-19 20:52:38 -07:00
|
|
|
u16 appl,
|
|
|
|
capi_register_params *rp)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
|
|
|
|
avmcard *card = cinfo->card;
|
|
|
|
unsigned int port = card->port;
|
|
|
|
unsigned long flags;
|
|
|
|
int nconn, want = rp->level3cnt;
|
|
|
|
|
|
|
|
if (want > 0) nconn = want;
|
|
|
|
else nconn = ctrl->profile.nbchannel * -want;
|
|
|
|
if (nconn == 0) nconn = ctrl->profile.nbchannel;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&card->lock, flags);
|
|
|
|
b1_put_byte(port, SEND_REGISTER);
|
|
|
|
b1_put_word(port, appl);
|
2012-02-19 20:52:38 -07:00
|
|
|
b1_put_word(port, 1024 * (nconn + 1));
|
2005-04-16 16:20:36 -06:00
|
|
|
b1_put_word(port, nconn);
|
|
|
|
b1_put_word(port, rp->datablkcnt);
|
|
|
|
b1_put_word(port, rp->datablklen);
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void b1_release_appl(struct capi_ctr *ctrl, u16 appl)
|
|
|
|
{
|
|
|
|
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
|
|
|
|
avmcard *card = cinfo->card;
|
|
|
|
unsigned int port = card->port;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&card->lock, flags);
|
2007-10-18 04:04:31 -06:00
|
|
|
capilib_release_appl(&cinfo->ncci_head, appl);
|
2005-04-16 16:20:36 -06:00
|
|
|
b1_put_byte(port, SEND_RELEASE);
|
|
|
|
b1_put_word(port, appl);
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 b1_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
|
|
|
|
avmcard *card = cinfo->card;
|
|
|
|
unsigned int port = card->port;
|
|
|
|
unsigned long flags;
|
|
|
|
u16 len = CAPIMSG_LEN(skb->data);
|
|
|
|
u8 cmd = CAPIMSG_COMMAND(skb->data);
|
|
|
|
u8 subcmd = CAPIMSG_SUBCOMMAND(skb->data);
|
|
|
|
u16 dlen, retval;
|
|
|
|
|
2007-10-18 04:04:31 -06:00
|
|
|
spin_lock_irqsave(&card->lock, flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (CAPICMD(cmd, subcmd) == CAPI_DATA_B3_REQ) {
|
|
|
|
retval = capilib_data_b3_req(&cinfo->ncci_head,
|
|
|
|
CAPIMSG_APPID(skb->data),
|
|
|
|
CAPIMSG_NCCI(skb->data),
|
|
|
|
CAPIMSG_MSGID(skb->data));
|
2007-10-18 04:04:31 -06:00
|
|
|
if (retval != CAPI_NOERROR) {
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
return retval;
|
2007-10-18 04:04:31 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
dlen = CAPIMSG_DATALEN(skb->data);
|
|
|
|
|
|
|
|
b1_put_byte(port, SEND_DATA_B3_REQ);
|
|
|
|
b1_put_slice(port, skb->data, len);
|
|
|
|
b1_put_slice(port, skb->data + len, dlen);
|
|
|
|
} else {
|
|
|
|
b1_put_byte(port, SEND_MESSAGE);
|
|
|
|
b1_put_slice(port, skb->data, len);
|
|
|
|
}
|
2007-10-18 04:04:31 -06:00
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
return CAPI_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void b1_parse_version(avmctrl_info *cinfo)
|
|
|
|
{
|
|
|
|
struct capi_ctr *ctrl = &cinfo->capi_ctrl;
|
|
|
|
avmcard *card = cinfo->card;
|
|
|
|
capi_profile *profp;
|
|
|
|
u8 *dversion;
|
|
|
|
u8 flag;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (j = 0; j < AVM_MAXVERSION; j++)
|
|
|
|
cinfo->version[j] = "\0\0" + 1;
|
|
|
|
for (i = 0, j = 0;
|
|
|
|
j < AVM_MAXVERSION && i < cinfo->versionlen;
|
|
|
|
j++, i += cinfo->versionbuf[i] + 1)
|
|
|
|
cinfo->version[j] = &cinfo->versionbuf[i + 1];
|
|
|
|
|
|
|
|
strlcpy(ctrl->serial, cinfo->version[VER_SERIAL], sizeof(ctrl->serial));
|
2012-02-19 20:52:38 -07:00
|
|
|
memcpy(&ctrl->profile, cinfo->version[VER_PROFILE], sizeof(capi_profile));
|
2005-04-16 16:20:36 -06:00
|
|
|
strlcpy(ctrl->manu, "AVM GmbH", sizeof(ctrl->manu));
|
|
|
|
dversion = cinfo->version[VER_DRIVER];
|
|
|
|
ctrl->version.majorversion = 2;
|
|
|
|
ctrl->version.minorversion = 0;
|
|
|
|
ctrl->version.majormanuversion = (((dversion[0] - '0') & 0xf) << 4);
|
|
|
|
ctrl->version.majormanuversion |= ((dversion[2] - '0') & 0xf);
|
|
|
|
ctrl->version.minormanuversion = (dversion[3] - '0') << 4;
|
|
|
|
ctrl->version.minormanuversion |=
|
2012-02-19 20:52:38 -07:00
|
|
|
(dversion[5] - '0') * 10 + ((dversion[6] - '0') & 0xf);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
profp = &ctrl->profile;
|
|
|
|
|
|
|
|
flag = ((u8 *)(profp->manu))[1];
|
|
|
|
switch (flag) {
|
|
|
|
case 0: if (cinfo->version[VER_CARDTYPE])
|
2012-02-19 20:52:38 -07:00
|
|
|
strcpy(cinfo->cardname, cinfo->version[VER_CARDTYPE]);
|
|
|
|
else strcpy(cinfo->cardname, "B1");
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
2012-02-19 20:52:38 -07:00
|
|
|
case 3: strcpy(cinfo->cardname, "PCMCIA B"); break;
|
|
|
|
case 4: strcpy(cinfo->cardname, "PCMCIA M1"); break;
|
|
|
|
case 5: strcpy(cinfo->cardname, "PCMCIA M2"); break;
|
|
|
|
case 6: strcpy(cinfo->cardname, "B1 V3.0"); break;
|
|
|
|
case 7: strcpy(cinfo->cardname, "B1 PCI"); break;
|
2005-04-16 16:20:36 -06:00
|
|
|
default: sprintf(cinfo->cardname, "AVM?%u", (unsigned int)flag); break;
|
2012-02-19 20:52:38 -07:00
|
|
|
}
|
|
|
|
printk(KERN_NOTICE "%s: card %d \"%s\" ready.\n",
|
|
|
|
card->name, ctrl->cnr, cinfo->cardname);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
flag = ((u8 *)(profp->manu))[3];
|
|
|
|
if (flag)
|
2005-04-16 16:20:36 -06:00
|
|
|
printk(KERN_NOTICE "%s: card %d Protocol:%s%s%s%s%s%s%s\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
card->name,
|
|
|
|
ctrl->cnr,
|
|
|
|
(flag & 0x01) ? " DSS1" : "",
|
|
|
|
(flag & 0x02) ? " CT1" : "",
|
|
|
|
(flag & 0x04) ? " VN3" : "",
|
|
|
|
(flag & 0x08) ? " NI1" : "",
|
|
|
|
(flag & 0x10) ? " AUSTEL" : "",
|
|
|
|
(flag & 0x20) ? " ESS" : "",
|
|
|
|
(flag & 0x40) ? " 1TR6" : ""
|
2005-04-16 16:20:36 -06:00
|
|
|
);
|
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
flag = ((u8 *)(profp->manu))[5];
|
2005-04-16 16:20:36 -06:00
|
|
|
if (flag)
|
|
|
|
printk(KERN_NOTICE "%s: card %d Linetype:%s%s%s%s\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
card->name,
|
|
|
|
ctrl->cnr,
|
|
|
|
(flag & 0x01) ? " point to point" : "",
|
|
|
|
(flag & 0x02) ? " point to multipoint" : "",
|
|
|
|
(flag & 0x08) ? " leased line without D-channel" : "",
|
|
|
|
(flag & 0x04) ? " leased line with D-channel" : ""
|
2005-04-16 16:20:36 -06:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 07:55:46 -06:00
|
|
|
irqreturn_t b1_interrupt(int interrupt, void *devptr)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
avmcard *card = devptr;
|
|
|
|
avmctrl_info *cinfo = &card->ctrlinfo[0];
|
|
|
|
struct capi_ctr *ctrl = &cinfo->capi_ctrl;
|
|
|
|
unsigned char b1cmd;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
unsigned ApplId;
|
|
|
|
unsigned MsgLen;
|
|
|
|
unsigned DataB3Len;
|
|
|
|
unsigned NCCI;
|
|
|
|
unsigned WindowSize;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&card->lock, flags);
|
|
|
|
|
|
|
|
if (!b1_rx_full(card->port)) {
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
b1cmd = b1_get_byte(card->port);
|
|
|
|
|
|
|
|
switch (b1cmd) {
|
|
|
|
|
|
|
|
case RECEIVE_DATA_B3_IND:
|
|
|
|
|
|
|
|
ApplId = (unsigned) b1_get_word(card->port);
|
|
|
|
MsgLen = b1_get_slice(card->port, card->msgbuf);
|
|
|
|
DataB3Len = b1_get_slice(card->port, card->databuf);
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
|
|
|
|
if (MsgLen < 30) { /* not CAPI 64Bit */
|
2012-02-19 20:52:38 -07:00
|
|
|
memset(card->msgbuf + MsgLen, 0, 30-MsgLen);
|
2005-04-16 16:20:36 -06:00
|
|
|
MsgLen = 30;
|
|
|
|
CAPIMSG_SETLEN(card->msgbuf, 30);
|
|
|
|
}
|
|
|
|
if (!(skb = alloc_skb(DataB3Len + MsgLen, GFP_ATOMIC))) {
|
|
|
|
printk(KERN_ERR "%s: incoming packet dropped\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
card->name);
|
2005-04-16 16:20:36 -06:00
|
|
|
} else {
|
|
|
|
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
|
|
|
|
memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len);
|
|
|
|
capi_ctr_handle_message(ctrl, ApplId, skb);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RECEIVE_MESSAGE:
|
|
|
|
|
|
|
|
ApplId = (unsigned) b1_get_word(card->port);
|
|
|
|
MsgLen = b1_get_slice(card->port, card->msgbuf);
|
|
|
|
if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) {
|
|
|
|
printk(KERN_ERR "%s: incoming packet dropped\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
card->name);
|
2007-10-18 04:04:31 -06:00
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
} else {
|
|
|
|
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
|
|
|
|
if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF)
|
|
|
|
capilib_data_b3_conf(&cinfo->ncci_head, ApplId,
|
|
|
|
CAPIMSG_NCCI(skb->data),
|
|
|
|
CAPIMSG_MSGID(skb->data));
|
2007-10-18 04:04:31 -06:00
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
capi_ctr_handle_message(ctrl, ApplId, skb);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RECEIVE_NEW_NCCI:
|
|
|
|
|
|
|
|
ApplId = b1_get_word(card->port);
|
|
|
|
NCCI = b1_get_word(card->port);
|
|
|
|
WindowSize = b1_get_word(card->port);
|
|
|
|
capilib_new_ncci(&cinfo->ncci_head, ApplId, NCCI, WindowSize);
|
2007-10-18 04:04:31 -06:00
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RECEIVE_FREE_NCCI:
|
|
|
|
|
|
|
|
ApplId = b1_get_word(card->port);
|
|
|
|
NCCI = b1_get_word(card->port);
|
|
|
|
if (NCCI != 0xffffffff)
|
|
|
|
capilib_free_ncci(&cinfo->ncci_head, ApplId, NCCI);
|
2007-10-18 04:04:31 -06:00
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RECEIVE_START:
|
2012-02-19 20:52:38 -07:00
|
|
|
/* b1_put_byte(card->port, SEND_POLLACK); */
|
2005-04-16 16:20:36 -06:00
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
capi_ctr_resume_output(ctrl);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RECEIVE_STOP:
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
capi_ctr_suspend_output(ctrl);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RECEIVE_INIT:
|
|
|
|
|
|
|
|
cinfo->versionlen = b1_get_slice(card->port, cinfo->versionbuf);
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
b1_parse_version(cinfo);
|
|
|
|
printk(KERN_INFO "%s: %s-card (%s) now active\n",
|
|
|
|
card->name,
|
|
|
|
cinfo->version[VER_CARDTYPE],
|
|
|
|
cinfo->version[VER_DRIVER]);
|
|
|
|
capi_ctr_ready(ctrl);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RECEIVE_TASK_READY:
|
|
|
|
ApplId = (unsigned) b1_get_word(card->port);
|
|
|
|
MsgLen = b1_get_slice(card->port, card->msgbuf);
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
card->msgbuf[MsgLen] = 0;
|
2012-02-19 20:52:38 -07:00
|
|
|
while (MsgLen > 0
|
|
|
|
&& (card->msgbuf[MsgLen - 1] == '\n'
|
|
|
|
|| card->msgbuf[MsgLen - 1] == '\r')) {
|
|
|
|
card->msgbuf[MsgLen - 1] = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
MsgLen--;
|
|
|
|
}
|
|
|
|
printk(KERN_INFO "%s: task %d \"%s\" ready.\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
card->name, ApplId, card->msgbuf);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RECEIVE_DEBUGMSG:
|
|
|
|
MsgLen = b1_get_slice(card->port, card->msgbuf);
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
card->msgbuf[MsgLen] = 0;
|
2012-02-19 20:52:38 -07:00
|
|
|
while (MsgLen > 0
|
|
|
|
&& (card->msgbuf[MsgLen - 1] == '\n'
|
|
|
|
|| card->msgbuf[MsgLen - 1] == '\r')) {
|
|
|
|
card->msgbuf[MsgLen - 1] = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
MsgLen--;
|
|
|
|
}
|
|
|
|
printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xff:
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
printk(KERN_ERR "%s: card removed ?\n", card->name);
|
|
|
|
return IRQ_NONE;
|
|
|
|
default:
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
printk(KERN_ERR "%s: b1_interrupt: 0x%x ???\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
card->name, b1cmd);
|
2005-04-16 16:20:36 -06:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
2010-01-14 04:10:54 -07:00
|
|
|
static int b1ctl_proc_show(struct seq_file *m, void *v)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2010-01-14 04:10:54 -07:00
|
|
|
struct capi_ctr *ctrl = m->private;
|
2005-04-16 16:20:36 -06:00
|
|
|
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
|
|
|
|
avmcard *card = cinfo->card;
|
|
|
|
u8 flag;
|
|
|
|
char *s;
|
|
|
|
|
2010-01-14 04:10:54 -07:00
|
|
|
seq_printf(m, "%-16s %s\n", "name", card->name);
|
|
|
|
seq_printf(m, "%-16s 0x%x\n", "io", card->port);
|
|
|
|
seq_printf(m, "%-16s %d\n", "irq", card->irq);
|
2005-04-16 16:20:36 -06:00
|
|
|
switch (card->cardtype) {
|
|
|
|
case avm_b1isa: s = "B1 ISA"; break;
|
|
|
|
case avm_b1pci: s = "B1 PCI"; break;
|
|
|
|
case avm_b1pcmcia: s = "B1 PCMCIA"; break;
|
|
|
|
case avm_m1: s = "M1"; break;
|
|
|
|
case avm_m2: s = "M2"; break;
|
|
|
|
case avm_t1isa: s = "T1 ISA (HEMA)"; break;
|
|
|
|
case avm_t1pci: s = "T1 PCI"; break;
|
|
|
|
case avm_c4: s = "C4"; break;
|
|
|
|
case avm_c2: s = "C2"; break;
|
|
|
|
default: s = "???"; break;
|
|
|
|
}
|
2010-01-14 04:10:54 -07:00
|
|
|
seq_printf(m, "%-16s %s\n", "type", s);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (card->cardtype == avm_t1isa)
|
2010-01-14 04:10:54 -07:00
|
|
|
seq_printf(m, "%-16s %d\n", "cardnr", card->cardnr);
|
2008-04-28 03:14:38 -06:00
|
|
|
if ((s = cinfo->version[VER_DRIVER]) != NULL)
|
2010-01-14 04:10:54 -07:00
|
|
|
seq_printf(m, "%-16s %s\n", "ver_driver", s);
|
2008-04-28 03:14:38 -06:00
|
|
|
if ((s = cinfo->version[VER_CARDTYPE]) != NULL)
|
2010-01-14 04:10:54 -07:00
|
|
|
seq_printf(m, "%-16s %s\n", "ver_cardtype", s);
|
2008-04-28 03:14:38 -06:00
|
|
|
if ((s = cinfo->version[VER_SERIAL]) != NULL)
|
2010-01-14 04:10:54 -07:00
|
|
|
seq_printf(m, "%-16s %s\n", "ver_serial", s);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (card->cardtype != avm_m1) {
|
2012-02-19 20:52:38 -07:00
|
|
|
flag = ((u8 *)(ctrl->profile.manu))[3];
|
|
|
|
if (flag)
|
2010-01-14 04:10:54 -07:00
|
|
|
seq_printf(m, "%-16s%s%s%s%s%s%s%s\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
"protocol",
|
|
|
|
(flag & 0x01) ? " DSS1" : "",
|
|
|
|
(flag & 0x02) ? " CT1" : "",
|
|
|
|
(flag & 0x04) ? " VN3" : "",
|
|
|
|
(flag & 0x08) ? " NI1" : "",
|
|
|
|
(flag & 0x10) ? " AUSTEL" : "",
|
|
|
|
(flag & 0x20) ? " ESS" : "",
|
|
|
|
(flag & 0x40) ? " 1TR6" : ""
|
|
|
|
);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
if (card->cardtype != avm_m1) {
|
2012-02-19 20:52:38 -07:00
|
|
|
flag = ((u8 *)(ctrl->profile.manu))[5];
|
2005-04-16 16:20:36 -06:00
|
|
|
if (flag)
|
2010-01-14 04:10:54 -07:00
|
|
|
seq_printf(m, "%-16s%s%s%s%s\n",
|
2012-02-19 20:52:38 -07:00
|
|
|
"linetype",
|
|
|
|
(flag & 0x01) ? " point to point" : "",
|
|
|
|
(flag & 0x02) ? " point to multipoint" : "",
|
|
|
|
(flag & 0x08) ? " leased line without D-channel" : "",
|
|
|
|
(flag & 0x04) ? " leased line with D-channel" : ""
|
|
|
|
);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2010-01-14 04:10:54 -07:00
|
|
|
seq_printf(m, "%-16s %s\n", "cardname", cinfo->cardname);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int b1ctl_proc_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2013-03-31 16:16:14 -06:00
|
|
|
return single_open(file, b1ctl_proc_show, PDE_DATA(inode));
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2010-01-14 04:10:54 -07:00
|
|
|
const struct file_operations b1ctl_proc_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = b1ctl_proc_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = single_release,
|
|
|
|
};
|
|
|
|
EXPORT_SYMBOL(b1ctl_proc_fops);
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
|
|
|
|
avmcard_dmainfo *
|
|
|
|
avmcard_dma_alloc(char *name, struct pci_dev *pdev, long rsize, long ssize)
|
|
|
|
{
|
|
|
|
avmcard_dmainfo *p;
|
|
|
|
void *buf;
|
|
|
|
|
2006-12-08 03:39:35 -07:00
|
|
|
p = kzalloc(sizeof(avmcard_dmainfo), GFP_KERNEL);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!p) {
|
|
|
|
printk(KERN_WARNING "%s: no memory.\n", name);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
p->recvbuf.size = rsize;
|
|
|
|
buf = pci_alloc_consistent(pdev, rsize, &p->recvbuf.dmaaddr);
|
|
|
|
if (!buf) {
|
|
|
|
printk(KERN_WARNING "%s: allocation of receive dma buffer failed.\n", name);
|
|
|
|
goto err_kfree;
|
|
|
|
}
|
|
|
|
p->recvbuf.dmabuf = buf;
|
|
|
|
|
|
|
|
p->sendbuf.size = ssize;
|
|
|
|
buf = pci_alloc_consistent(pdev, ssize, &p->sendbuf.dmaaddr);
|
|
|
|
if (!buf) {
|
|
|
|
printk(KERN_WARNING "%s: allocation of send dma buffer failed.\n", name);
|
|
|
|
goto err_free_consistent;
|
|
|
|
}
|
|
|
|
|
|
|
|
p->sendbuf.dmabuf = buf;
|
|
|
|
skb_queue_head_init(&p->send_queue);
|
|
|
|
|
|
|
|
return p;
|
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
err_free_consistent:
|
2005-04-16 16:20:36 -06:00
|
|
|
pci_free_consistent(p->pcidev, p->recvbuf.size,
|
|
|
|
p->recvbuf.dmabuf, p->recvbuf.dmaaddr);
|
2012-02-19 20:52:38 -07:00
|
|
|
err_kfree:
|
2005-04-16 16:20:36 -06:00
|
|
|
kfree(p);
|
2012-02-19 20:52:38 -07:00
|
|
|
err:
|
2005-04-16 16:20:36 -06:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void avmcard_dma_free(avmcard_dmainfo *p)
|
|
|
|
{
|
|
|
|
pci_free_consistent(p->pcidev, p->recvbuf.size,
|
|
|
|
p->recvbuf.dmabuf, p->recvbuf.dmaaddr);
|
|
|
|
pci_free_consistent(p->pcidev, p->sendbuf.size,
|
|
|
|
p->sendbuf.dmabuf, p->sendbuf.dmaaddr);
|
|
|
|
skb_queue_purge(&p->send_queue);
|
|
|
|
kfree(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(avmcard_dma_alloc);
|
|
|
|
EXPORT_SYMBOL(avmcard_dma_free);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(b1_irq_table);
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(b1_alloc_card);
|
|
|
|
EXPORT_SYMBOL(b1_free_card);
|
|
|
|
EXPORT_SYMBOL(b1_detect);
|
|
|
|
EXPORT_SYMBOL(b1_getrevision);
|
|
|
|
EXPORT_SYMBOL(b1_load_t4file);
|
|
|
|
EXPORT_SYMBOL(b1_load_config);
|
|
|
|
EXPORT_SYMBOL(b1_loaded);
|
|
|
|
EXPORT_SYMBOL(b1_load_firmware);
|
|
|
|
EXPORT_SYMBOL(b1_reset_ctr);
|
|
|
|
EXPORT_SYMBOL(b1_register_appl);
|
|
|
|
EXPORT_SYMBOL(b1_release_appl);
|
|
|
|
EXPORT_SYMBOL(b1_send_message);
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(b1_parse_version);
|
|
|
|
EXPORT_SYMBOL(b1_interrupt);
|
|
|
|
|
|
|
|
static int __init b1_init(void)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
char rev[32];
|
|
|
|
|
2008-04-28 03:14:38 -06:00
|
|
|
if ((p = strchr(revision, ':')) != NULL && p[1]) {
|
2005-04-16 16:20:36 -06:00
|
|
|
strlcpy(rev, p + 2, 32);
|
2008-04-28 03:14:38 -06:00
|
|
|
if ((p = strchr(rev, '$')) != NULL && p > rev)
|
2012-02-19 20:52:38 -07:00
|
|
|
*(p - 1) = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
} else
|
|
|
|
strcpy(rev, "1.0");
|
|
|
|
|
|
|
|
printk(KERN_INFO "b1: revision %s\n", rev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit b1_exit(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(b1_init);
|
|
|
|
module_exit(b1_exit);
|