2009-07-23 01:52:24 +08:00
|
|
|
/*
|
|
|
|
* avm_fritz.c low level stuff for AVM FRITZ!CARD PCI ISDN cards
|
|
|
|
* Thanks to AVM, Berlin for informations
|
|
|
|
*
|
|
|
|
* Author Karsten Keil <keil@isdn4linux.de>
|
|
|
|
*
|
|
|
|
* Copyright 2009 by Karsten Keil <keil@isdn4linux.de>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
*/
|
2011-06-06 18:43:46 +08:00
|
|
|
#include <linux/interrupt.h>
|
2009-07-23 01:52:24 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/mISDNhw.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 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2009-07-23 01:52:24 +08:00
|
|
|
#include <asm/unaligned.h>
|
|
|
|
#include "ipac.h"
|
|
|
|
|
|
|
|
|
2012-05-16 07:51:07 +08:00
|
|
|
#define AVMFRITZ_REV "2.3"
|
2009-07-23 01:52:24 +08:00
|
|
|
|
|
|
|
static int AVM_cnt;
|
|
|
|
static int debug;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
AVM_FRITZ_PCI,
|
|
|
|
AVM_FRITZ_PCIV2,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define HDLC_FIFO 0x0
|
|
|
|
#define HDLC_STATUS 0x4
|
|
|
|
#define CHIP_WINDOW 0x10
|
|
|
|
|
|
|
|
#define CHIP_INDEX 0x4
|
|
|
|
#define AVM_HDLC_1 0x00
|
|
|
|
#define AVM_HDLC_2 0x01
|
|
|
|
#define AVM_ISAC_FIFO 0x02
|
|
|
|
#define AVM_ISAC_REG_LOW 0x04
|
|
|
|
#define AVM_ISAC_REG_HIGH 0x06
|
|
|
|
|
|
|
|
#define AVM_STATUS0_IRQ_ISAC 0x01
|
|
|
|
#define AVM_STATUS0_IRQ_HDLC 0x02
|
|
|
|
#define AVM_STATUS0_IRQ_TIMER 0x04
|
|
|
|
#define AVM_STATUS0_IRQ_MASK 0x07
|
|
|
|
|
|
|
|
#define AVM_STATUS0_RESET 0x01
|
|
|
|
#define AVM_STATUS0_DIS_TIMER 0x02
|
|
|
|
#define AVM_STATUS0_RES_TIMER 0x04
|
|
|
|
#define AVM_STATUS0_ENA_IRQ 0x08
|
|
|
|
#define AVM_STATUS0_TESTBIT 0x10
|
|
|
|
|
|
|
|
#define AVM_STATUS1_INT_SEL 0x0f
|
|
|
|
#define AVM_STATUS1_ENA_IOM 0x80
|
|
|
|
|
|
|
|
#define HDLC_MODE_ITF_FLG 0x01
|
|
|
|
#define HDLC_MODE_TRANS 0x02
|
|
|
|
#define HDLC_MODE_CCR_7 0x04
|
|
|
|
#define HDLC_MODE_CCR_16 0x08
|
2012-05-16 07:51:03 +08:00
|
|
|
#define HDLC_FIFO_SIZE_128 0x20
|
2009-07-23 01:52:24 +08:00
|
|
|
#define HDLC_MODE_TESTLOOP 0x80
|
|
|
|
|
|
|
|
#define HDLC_INT_XPR 0x80
|
|
|
|
#define HDLC_INT_XDU 0x40
|
|
|
|
#define HDLC_INT_RPR 0x20
|
|
|
|
#define HDLC_INT_MASK 0xE0
|
|
|
|
|
|
|
|
#define HDLC_STAT_RME 0x01
|
|
|
|
#define HDLC_STAT_RDO 0x10
|
|
|
|
#define HDLC_STAT_CRCVFRRAB 0x0E
|
|
|
|
#define HDLC_STAT_CRCVFR 0x06
|
2012-05-16 07:51:03 +08:00
|
|
|
#define HDLC_STAT_RML_MASK_V1 0x3f00
|
|
|
|
#define HDLC_STAT_RML_MASK_V2 0x7f00
|
2009-07-23 01:52:24 +08:00
|
|
|
|
|
|
|
#define HDLC_CMD_XRS 0x80
|
|
|
|
#define HDLC_CMD_XME 0x01
|
|
|
|
#define HDLC_CMD_RRS 0x20
|
|
|
|
#define HDLC_CMD_XML_MASK 0x3f00
|
2012-05-16 07:51:03 +08:00
|
|
|
|
|
|
|
#define HDLC_FIFO_SIZE_V1 32
|
|
|
|
#define HDLC_FIFO_SIZE_V2 128
|
2009-07-23 01:52:24 +08:00
|
|
|
|
|
|
|
/* Fritz PCI v2.0 */
|
|
|
|
|
|
|
|
#define AVM_HDLC_FIFO_1 0x10
|
|
|
|
#define AVM_HDLC_FIFO_2 0x18
|
|
|
|
|
|
|
|
#define AVM_HDLC_STATUS_1 0x14
|
|
|
|
#define AVM_HDLC_STATUS_2 0x1c
|
|
|
|
|
|
|
|
#define AVM_ISACX_INDEX 0x04
|
|
|
|
#define AVM_ISACX_DATA 0x08
|
|
|
|
|
|
|
|
/* data struct */
|
|
|
|
#define LOG_SIZE 63
|
|
|
|
|
|
|
|
struct hdlc_stat_reg {
|
|
|
|
#ifdef __BIG_ENDIAN
|
|
|
|
u8 fill;
|
|
|
|
u8 mode;
|
|
|
|
u8 xml;
|
|
|
|
u8 cmd;
|
|
|
|
#else
|
|
|
|
u8 cmd;
|
|
|
|
u8 xml;
|
|
|
|
u8 mode;
|
|
|
|
u8 fill;
|
|
|
|
#endif
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct hdlc_hw {
|
|
|
|
union {
|
|
|
|
u32 ctrl;
|
|
|
|
struct hdlc_stat_reg sr;
|
|
|
|
} ctrl;
|
|
|
|
u32 stat;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fritzcard {
|
|
|
|
struct list_head list;
|
|
|
|
struct pci_dev *pdev;
|
|
|
|
char name[MISDN_MAX_IDLEN];
|
|
|
|
u8 type;
|
|
|
|
u8 ctrlreg;
|
|
|
|
u16 irq;
|
|
|
|
u32 irqcnt;
|
|
|
|
u32 addr;
|
|
|
|
spinlock_t lock; /* hw lock */
|
|
|
|
struct isac_hw isac;
|
|
|
|
struct hdlc_hw hdlc[2];
|
|
|
|
struct bchannel bch[2];
|
|
|
|
char log[LOG_SIZE + 1];
|
|
|
|
};
|
|
|
|
|
|
|
|
static LIST_HEAD(Cards);
|
|
|
|
static DEFINE_RWLOCK(card_lock); /* protect Cards */
|
|
|
|
|
|
|
|
static void
|
|
|
|
_set_debug(struct fritzcard *card)
|
|
|
|
{
|
|
|
|
card->isac.dch.debug = debug;
|
|
|
|
card->bch[0].debug = debug;
|
|
|
|
card->bch[1].debug = debug;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
treewide: Fix function prototypes for module_param_call()
Several function prototypes for the set/get functions defined by
module_param_call() have a slightly wrong argument types. This fixes
those in an effort to clean up the calls when running under type-enforced
compiler instrumentation for CFI. This is the result of running the
following semantic patch:
@match_module_param_call_function@
declarer name module_param_call;
identifier _name, _set_func, _get_func;
expression _arg, _mode;
@@
module_param_call(_name, _set_func, _get_func, _arg, _mode);
@fix_set_prototype
depends on match_module_param_call_function@
identifier match_module_param_call_function._set_func;
identifier _val, _param;
type _val_type, _param_type;
@@
int _set_func(
-_val_type _val
+const char * _val
,
-_param_type _param
+const struct kernel_param * _param
) { ... }
@fix_get_prototype
depends on match_module_param_call_function@
identifier match_module_param_call_function._get_func;
identifier _val, _param;
type _val_type, _param_type;
@@
int _get_func(
-_val_type _val
+char * _val
,
-_param_type _param
+const struct kernel_param * _param
) { ... }
Two additional by-hand changes are included for places where the above
Coccinelle script didn't notice them:
drivers/platform/x86/thinkpad_acpi.c
fs/lockd/svc.c
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
2017-10-18 10:04:42 +08:00
|
|
|
set_debug(const char *val, const struct kernel_param *kp)
|
2009-07-23 01:52:24 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct fritzcard *card;
|
|
|
|
|
|
|
|
ret = param_set_uint(val, kp);
|
|
|
|
if (!ret) {
|
|
|
|
read_lock(&card_lock);
|
|
|
|
list_for_each_entry(card, &Cards, list)
|
|
|
|
_set_debug(card);
|
|
|
|
read_unlock(&card_lock);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Karsten Keil");
|
|
|
|
MODULE_LICENSE("GPL v2");
|
|
|
|
MODULE_VERSION(AVMFRITZ_REV);
|
|
|
|
module_param_call(debug, set_debug, param_get_uint, &debug, S_IRUGO | S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(debug, "avmfritz debug mask");
|
|
|
|
|
|
|
|
/* Interface functions */
|
|
|
|
|
|
|
|
static u8
|
|
|
|
ReadISAC_V1(void *p, u8 offset)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = p;
|
|
|
|
u8 idx = (offset > 0x2f) ? AVM_ISAC_REG_HIGH : AVM_ISAC_REG_LOW;
|
|
|
|
|
|
|
|
outb(idx, fc->addr + CHIP_INDEX);
|
|
|
|
return inb(fc->addr + CHIP_WINDOW + (offset & 0xf));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
WriteISAC_V1(void *p, u8 offset, u8 value)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = p;
|
|
|
|
u8 idx = (offset > 0x2f) ? AVM_ISAC_REG_HIGH : AVM_ISAC_REG_LOW;
|
|
|
|
|
|
|
|
outb(idx, fc->addr + CHIP_INDEX);
|
|
|
|
outb(value, fc->addr + CHIP_WINDOW + (offset & 0xf));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ReadFiFoISAC_V1(void *p, u8 off, u8 *data, int size)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = p;
|
|
|
|
|
|
|
|
outb(AVM_ISAC_FIFO, fc->addr + CHIP_INDEX);
|
|
|
|
insb(fc->addr + CHIP_WINDOW, data, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
WriteFiFoISAC_V1(void *p, u8 off, u8 *data, int size)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = p;
|
|
|
|
|
|
|
|
outb(AVM_ISAC_FIFO, fc->addr + CHIP_INDEX);
|
|
|
|
outsb(fc->addr + CHIP_WINDOW, data, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8
|
|
|
|
ReadISAC_V2(void *p, u8 offset)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = p;
|
|
|
|
|
|
|
|
outl(offset, fc->addr + AVM_ISACX_INDEX);
|
|
|
|
return 0xff & inl(fc->addr + AVM_ISACX_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
WriteISAC_V2(void *p, u8 offset, u8 value)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = p;
|
|
|
|
|
|
|
|
outl(offset, fc->addr + AVM_ISACX_INDEX);
|
|
|
|
outl(value, fc->addr + AVM_ISACX_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ReadFiFoISAC_V2(void *p, u8 off, u8 *data, int size)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = p;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
outl(off, fc->addr + AVM_ISACX_INDEX);
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
data[i] = 0xff & inl(fc->addr + AVM_ISACX_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
WriteFiFoISAC_V2(void *p, u8 off, u8 *data, int size)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = p;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
outl(off, fc->addr + AVM_ISACX_INDEX);
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
outl(data[i], fc->addr + AVM_ISACX_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct bchannel *
|
|
|
|
Sel_BCS(struct fritzcard *fc, u32 channel)
|
|
|
|
{
|
|
|
|
if (test_bit(FLG_ACTIVE, &fc->bch[0].Flags) &&
|
2012-02-20 11:52:38 +08:00
|
|
|
(fc->bch[0].nr & channel))
|
2009-07-23 01:52:24 +08:00
|
|
|
return &fc->bch[0];
|
|
|
|
else if (test_bit(FLG_ACTIVE, &fc->bch[1].Flags) &&
|
2012-02-20 11:52:38 +08:00
|
|
|
(fc->bch[1].nr & channel))
|
2009-07-23 01:52:24 +08:00
|
|
|
return &fc->bch[1];
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
__write_ctrl_pci(struct fritzcard *fc, struct hdlc_hw *hdlc, u32 channel) {
|
|
|
|
u32 idx = channel == 2 ? AVM_HDLC_2 : AVM_HDLC_1;
|
|
|
|
|
|
|
|
outl(idx, fc->addr + CHIP_INDEX);
|
|
|
|
outl(hdlc->ctrl.ctrl, fc->addr + CHIP_WINDOW + HDLC_STATUS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
__write_ctrl_pciv2(struct fritzcard *fc, struct hdlc_hw *hdlc, u32 channel) {
|
|
|
|
outl(hdlc->ctrl.ctrl, fc->addr + (channel == 2 ? AVM_HDLC_STATUS_2 :
|
2012-02-20 11:52:38 +08:00
|
|
|
AVM_HDLC_STATUS_1));
|
2009-07-23 01:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-01 14:16:24 +08:00
|
|
|
static void
|
2009-07-23 01:52:24 +08:00
|
|
|
write_ctrl(struct bchannel *bch, int which) {
|
|
|
|
struct fritzcard *fc = bch->hw;
|
|
|
|
struct hdlc_hw *hdlc;
|
|
|
|
|
|
|
|
hdlc = &fc->hdlc[(bch->nr - 1) & 1];
|
|
|
|
pr_debug("%s: hdlc %c wr%x ctrl %x\n", fc->name, '@' + bch->nr,
|
2012-02-20 11:52:38 +08:00
|
|
|
which, hdlc->ctrl.ctrl);
|
2009-07-23 01:52:24 +08:00
|
|
|
switch (fc->type) {
|
|
|
|
case AVM_FRITZ_PCIV2:
|
|
|
|
__write_ctrl_pciv2(fc, hdlc, bch->nr);
|
|
|
|
break;
|
|
|
|
case AVM_FRITZ_PCI:
|
|
|
|
__write_ctrl_pci(fc, hdlc, bch->nr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline u32
|
|
|
|
__read_status_pci(u_long addr, u32 channel)
|
|
|
|
{
|
|
|
|
outl(channel == 2 ? AVM_HDLC_2 : AVM_HDLC_1, addr + CHIP_INDEX);
|
|
|
|
return inl(addr + CHIP_WINDOW + HDLC_STATUS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u32
|
|
|
|
__read_status_pciv2(u_long addr, u32 channel)
|
|
|
|
{
|
|
|
|
return inl(addr + (channel == 2 ? AVM_HDLC_STATUS_2 :
|
2012-02-20 11:52:38 +08:00
|
|
|
AVM_HDLC_STATUS_1));
|
2009-07-23 01:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static u32
|
|
|
|
read_status(struct fritzcard *fc, u32 channel)
|
|
|
|
{
|
|
|
|
switch (fc->type) {
|
|
|
|
case AVM_FRITZ_PCIV2:
|
|
|
|
return __read_status_pciv2(fc->addr, channel);
|
|
|
|
case AVM_FRITZ_PCI:
|
|
|
|
return __read_status_pci(fc->addr, channel);
|
|
|
|
}
|
|
|
|
/* dummy */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
enable_hwirq(struct fritzcard *fc)
|
|
|
|
{
|
|
|
|
fc->ctrlreg |= AVM_STATUS0_ENA_IRQ;
|
|
|
|
outb(fc->ctrlreg, fc->addr + 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
disable_hwirq(struct fritzcard *fc)
|
|
|
|
{
|
|
|
|
fc->ctrlreg &= ~AVM_STATUS0_ENA_IRQ;
|
|
|
|
outb(fc->ctrlreg, fc->addr + 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
modehdlc(struct bchannel *bch, int protocol)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = bch->hw;
|
|
|
|
struct hdlc_hw *hdlc;
|
2012-05-16 07:51:03 +08:00
|
|
|
u8 mode;
|
2009-07-23 01:52:24 +08:00
|
|
|
|
|
|
|
hdlc = &fc->hdlc[(bch->nr - 1) & 1];
|
|
|
|
pr_debug("%s: hdlc %c protocol %x-->%x ch %d\n", fc->name,
|
2012-02-20 11:52:38 +08:00
|
|
|
'@' + bch->nr, bch->state, protocol, bch->nr);
|
2009-07-23 01:52:24 +08:00
|
|
|
hdlc->ctrl.ctrl = 0;
|
2012-05-16 07:51:03 +08:00
|
|
|
mode = (fc->type == AVM_FRITZ_PCIV2) ? HDLC_FIFO_SIZE_128 : 0;
|
|
|
|
|
2009-07-23 01:52:24 +08:00
|
|
|
switch (protocol) {
|
|
|
|
case -1: /* used for init */
|
|
|
|
bch->state = -1;
|
|
|
|
case ISDN_P_NONE:
|
|
|
|
if (bch->state == ISDN_P_NONE)
|
|
|
|
break;
|
|
|
|
hdlc->ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS;
|
2012-05-16 07:51:03 +08:00
|
|
|
hdlc->ctrl.sr.mode = mode | HDLC_MODE_TRANS;
|
2009-07-23 01:52:24 +08:00
|
|
|
write_ctrl(bch, 5);
|
|
|
|
bch->state = ISDN_P_NONE;
|
|
|
|
test_and_clear_bit(FLG_HDLC, &bch->Flags);
|
|
|
|
test_and_clear_bit(FLG_TRANSPARENT, &bch->Flags);
|
|
|
|
break;
|
|
|
|
case ISDN_P_B_RAW:
|
|
|
|
bch->state = protocol;
|
|
|
|
hdlc->ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS;
|
2012-05-16 07:51:03 +08:00
|
|
|
hdlc->ctrl.sr.mode = mode | HDLC_MODE_TRANS;
|
2009-07-23 01:52:24 +08:00
|
|
|
write_ctrl(bch, 5);
|
|
|
|
hdlc->ctrl.sr.cmd = HDLC_CMD_XRS;
|
|
|
|
write_ctrl(bch, 1);
|
|
|
|
hdlc->ctrl.sr.cmd = 0;
|
|
|
|
test_and_set_bit(FLG_TRANSPARENT, &bch->Flags);
|
|
|
|
break;
|
|
|
|
case ISDN_P_B_HDLC:
|
|
|
|
bch->state = protocol;
|
|
|
|
hdlc->ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS;
|
2012-05-16 07:51:03 +08:00
|
|
|
hdlc->ctrl.sr.mode = mode | HDLC_MODE_ITF_FLG;
|
2009-07-23 01:52:24 +08:00
|
|
|
write_ctrl(bch, 5);
|
|
|
|
hdlc->ctrl.sr.cmd = HDLC_CMD_XRS;
|
|
|
|
write_ctrl(bch, 1);
|
|
|
|
hdlc->ctrl.sr.cmd = 0;
|
|
|
|
test_and_set_bit(FLG_HDLC, &bch->Flags);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pr_info("%s: protocol not known %x\n", fc->name, protocol);
|
|
|
|
return -ENOPROTOOPT;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
hdlc_empty_fifo(struct bchannel *bch, int count)
|
|
|
|
{
|
|
|
|
u32 *ptr;
|
|
|
|
u8 *p;
|
|
|
|
u32 val, addr;
|
2012-05-16 07:51:05 +08:00
|
|
|
int cnt;
|
2009-07-23 01:52:24 +08:00
|
|
|
struct fritzcard *fc = bch->hw;
|
|
|
|
|
|
|
|
pr_debug("%s: %s %d\n", fc->name, __func__, count);
|
2012-05-16 07:51:08 +08:00
|
|
|
if (test_bit(FLG_RX_OFF, &bch->Flags)) {
|
|
|
|
p = NULL;
|
|
|
|
bch->dropcnt += count;
|
|
|
|
} else {
|
|
|
|
cnt = bchannel_get_rxbuf(bch, count);
|
|
|
|
if (cnt < 0) {
|
|
|
|
pr_warning("%s.B%d: No bufferspace for %d bytes\n",
|
|
|
|
fc->name, bch->nr, count);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
p = skb_put(bch->rx_skb, count);
|
2009-07-23 01:52:24 +08:00
|
|
|
}
|
|
|
|
ptr = (u32 *)p;
|
2012-05-16 07:51:03 +08:00
|
|
|
if (fc->type == AVM_FRITZ_PCIV2)
|
2009-07-23 01:52:24 +08:00
|
|
|
addr = fc->addr + (bch->nr == 2 ?
|
2012-02-20 11:52:38 +08:00
|
|
|
AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1);
|
2009-07-23 01:52:24 +08:00
|
|
|
else {
|
|
|
|
addr = fc->addr + CHIP_WINDOW;
|
|
|
|
outl(bch->nr == 2 ? AVM_HDLC_2 : AVM_HDLC_1, fc->addr);
|
|
|
|
}
|
2012-05-16 07:51:05 +08:00
|
|
|
cnt = 0;
|
2009-07-23 01:52:24 +08:00
|
|
|
while (cnt < count) {
|
|
|
|
val = le32_to_cpu(inl(addr));
|
2012-05-16 07:51:08 +08:00
|
|
|
if (p) {
|
|
|
|
put_unaligned(val, ptr);
|
|
|
|
ptr++;
|
|
|
|
}
|
2009-07-23 01:52:24 +08:00
|
|
|
cnt += 4;
|
|
|
|
}
|
2012-05-16 07:51:08 +08:00
|
|
|
if (p && (debug & DEBUG_HW_BFIFO)) {
|
2009-07-23 01:52:24 +08:00
|
|
|
snprintf(fc->log, LOG_SIZE, "B%1d-recv %s %d ",
|
2012-02-20 11:52:38 +08:00
|
|
|
bch->nr, fc->name, count);
|
2009-07-23 01:52:24 +08:00
|
|
|
print_hex_dump_bytes(fc->log, DUMP_PREFIX_OFFSET, p, count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
hdlc_fill_fifo(struct bchannel *bch)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = bch->hw;
|
|
|
|
struct hdlc_hw *hdlc;
|
2012-07-29 15:15:13 +08:00
|
|
|
int count, fs, cnt = 0, idx;
|
|
|
|
bool fillempty = false;
|
2009-07-23 01:52:24 +08:00
|
|
|
u8 *p;
|
|
|
|
u32 *ptr, val, addr;
|
|
|
|
|
2012-05-16 07:51:07 +08:00
|
|
|
idx = (bch->nr - 1) & 1;
|
|
|
|
hdlc = &fc->hdlc[idx];
|
2012-05-16 07:51:03 +08:00
|
|
|
fs = (fc->type == AVM_FRITZ_PCIV2) ?
|
|
|
|
HDLC_FIFO_SIZE_V2 : HDLC_FIFO_SIZE_V1;
|
2012-05-16 07:51:07 +08:00
|
|
|
if (!bch->tx_skb) {
|
|
|
|
if (!test_bit(FLG_TX_EMPTY, &bch->Flags))
|
|
|
|
return;
|
|
|
|
count = fs;
|
|
|
|
p = bch->fill;
|
2012-07-29 15:15:13 +08:00
|
|
|
fillempty = true;
|
2012-05-16 07:51:07 +08:00
|
|
|
} else {
|
|
|
|
count = bch->tx_skb->len - bch->tx_idx;
|
|
|
|
if (count <= 0)
|
|
|
|
return;
|
|
|
|
p = bch->tx_skb->data + bch->tx_idx;
|
|
|
|
}
|
2009-07-23 01:52:24 +08:00
|
|
|
hdlc->ctrl.sr.cmd &= ~HDLC_CMD_XME;
|
2012-05-16 07:51:03 +08:00
|
|
|
if (count > fs) {
|
|
|
|
count = fs;
|
2009-07-23 01:52:24 +08:00
|
|
|
} else {
|
|
|
|
if (test_bit(FLG_HDLC, &bch->Flags))
|
|
|
|
hdlc->ctrl.sr.cmd |= HDLC_CMD_XME;
|
|
|
|
}
|
|
|
|
ptr = (u32 *)p;
|
2012-07-29 15:15:13 +08:00
|
|
|
if (!fillempty) {
|
2012-05-16 07:51:07 +08:00
|
|
|
pr_debug("%s.B%d: %d/%d/%d", fc->name, bch->nr, count,
|
|
|
|
bch->tx_idx, bch->tx_skb->len);
|
|
|
|
bch->tx_idx += count;
|
|
|
|
} else {
|
|
|
|
pr_debug("%s.B%d: fillempty %d\n", fc->name, bch->nr, count);
|
|
|
|
}
|
2012-05-16 07:51:03 +08:00
|
|
|
hdlc->ctrl.sr.xml = ((count == fs) ? 0 : count);
|
|
|
|
if (fc->type == AVM_FRITZ_PCIV2) {
|
2009-07-23 01:52:24 +08:00
|
|
|
__write_ctrl_pciv2(fc, hdlc, bch->nr);
|
|
|
|
addr = fc->addr + (bch->nr == 2 ?
|
2012-02-20 11:52:38 +08:00
|
|
|
AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1);
|
2009-07-23 01:52:24 +08:00
|
|
|
} else {
|
|
|
|
__write_ctrl_pci(fc, hdlc, bch->nr);
|
|
|
|
addr = fc->addr + CHIP_WINDOW;
|
|
|
|
}
|
2012-05-16 07:51:07 +08:00
|
|
|
if (fillempty) {
|
|
|
|
while (cnt < count) {
|
|
|
|
/* all bytes the same - no worry about endian */
|
|
|
|
outl(*ptr, addr);
|
|
|
|
cnt += 4;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
while (cnt < count) {
|
|
|
|
val = get_unaligned(ptr);
|
|
|
|
outl(cpu_to_le32(val), addr);
|
|
|
|
ptr++;
|
|
|
|
cnt += 4;
|
|
|
|
}
|
2009-07-23 01:52:24 +08:00
|
|
|
}
|
2012-05-16 07:51:07 +08:00
|
|
|
if ((debug & DEBUG_HW_BFIFO) && !fillempty) {
|
2009-07-23 01:52:24 +08:00
|
|
|
snprintf(fc->log, LOG_SIZE, "B%1d-send %s %d ",
|
2012-02-20 11:52:38 +08:00
|
|
|
bch->nr, fc->name, count);
|
2009-07-23 01:52:24 +08:00
|
|
|
print_hex_dump_bytes(fc->log, DUMP_PREFIX_OFFSET, p, count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
HDLC_irq_xpr(struct bchannel *bch)
|
|
|
|
{
|
2012-05-16 07:51:02 +08:00
|
|
|
if (bch->tx_skb && bch->tx_idx < bch->tx_skb->len) {
|
2009-07-23 01:52:24 +08:00
|
|
|
hdlc_fill_fifo(bch);
|
2012-05-16 07:51:02 +08:00
|
|
|
} else {
|
|
|
|
if (bch->tx_skb)
|
2009-07-23 01:52:24 +08:00
|
|
|
dev_kfree_skb(bch->tx_skb);
|
2012-05-16 07:51:07 +08:00
|
|
|
if (get_next_bframe(bch)) {
|
2009-07-23 01:52:24 +08:00
|
|
|
hdlc_fill_fifo(bch);
|
2012-05-16 07:51:07 +08:00
|
|
|
test_and_clear_bit(FLG_TX_EMPTY, &bch->Flags);
|
|
|
|
} else if (test_bit(FLG_TX_EMPTY, &bch->Flags)) {
|
|
|
|
hdlc_fill_fifo(bch);
|
|
|
|
}
|
2009-07-23 01:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
HDLC_irq(struct bchannel *bch, u32 stat)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = bch->hw;
|
2012-05-16 07:51:03 +08:00
|
|
|
int len, fs;
|
|
|
|
u32 rmlMask;
|
2009-07-23 01:52:24 +08:00
|
|
|
struct hdlc_hw *hdlc;
|
|
|
|
|
|
|
|
hdlc = &fc->hdlc[(bch->nr - 1) & 1];
|
|
|
|
pr_debug("%s: ch%d stat %#x\n", fc->name, bch->nr, stat);
|
2012-05-16 07:51:03 +08:00
|
|
|
if (fc->type == AVM_FRITZ_PCIV2) {
|
|
|
|
rmlMask = HDLC_STAT_RML_MASK_V2;
|
|
|
|
fs = HDLC_FIFO_SIZE_V2;
|
|
|
|
} else {
|
|
|
|
rmlMask = HDLC_STAT_RML_MASK_V1;
|
|
|
|
fs = HDLC_FIFO_SIZE_V1;
|
|
|
|
}
|
2009-07-23 01:52:24 +08:00
|
|
|
if (stat & HDLC_INT_RPR) {
|
|
|
|
if (stat & HDLC_STAT_RDO) {
|
2012-05-16 07:51:03 +08:00
|
|
|
pr_warning("%s: ch%d stat %x RDO\n",
|
|
|
|
fc->name, bch->nr, stat);
|
2009-07-23 01:52:24 +08:00
|
|
|
hdlc->ctrl.sr.xml = 0;
|
|
|
|
hdlc->ctrl.sr.cmd |= HDLC_CMD_RRS;
|
|
|
|
write_ctrl(bch, 1);
|
|
|
|
hdlc->ctrl.sr.cmd &= ~HDLC_CMD_RRS;
|
|
|
|
write_ctrl(bch, 1);
|
|
|
|
if (bch->rx_skb)
|
|
|
|
skb_trim(bch->rx_skb, 0);
|
|
|
|
} else {
|
2012-05-16 07:51:03 +08:00
|
|
|
len = (stat & rmlMask) >> 8;
|
2009-07-23 01:52:24 +08:00
|
|
|
if (!len)
|
2012-05-16 07:51:03 +08:00
|
|
|
len = fs;
|
2009-07-23 01:52:24 +08:00
|
|
|
hdlc_empty_fifo(bch, len);
|
|
|
|
if (!bch->rx_skb)
|
|
|
|
goto handle_tx;
|
2012-05-16 07:51:06 +08:00
|
|
|
if (test_bit(FLG_TRANSPARENT, &bch->Flags)) {
|
|
|
|
recv_Bchannel(bch, 0, false);
|
|
|
|
} else if (stat & HDLC_STAT_RME) {
|
|
|
|
if ((stat & HDLC_STAT_CRCVFRRAB) ==
|
|
|
|
HDLC_STAT_CRCVFR) {
|
|
|
|
recv_Bchannel(bch, 0, false);
|
2009-07-23 01:52:24 +08:00
|
|
|
} else {
|
2012-05-16 07:51:03 +08:00
|
|
|
pr_warning("%s: got invalid frame\n",
|
|
|
|
fc->name);
|
2009-07-23 01:52:24 +08:00
|
|
|
skb_trim(bch->rx_skb, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handle_tx:
|
|
|
|
if (stat & HDLC_INT_XDU) {
|
|
|
|
/* Here we lost an TX interrupt, so
|
|
|
|
* restart transmitting the whole frame on HDLC
|
|
|
|
* in transparent mode we send the next data
|
|
|
|
*/
|
2012-05-16 07:51:03 +08:00
|
|
|
pr_warning("%s: ch%d stat %x XDU %s\n", fc->name, bch->nr,
|
|
|
|
stat, bch->tx_skb ? "tx_skb" : "no tx_skb");
|
2009-07-23 01:52:24 +08:00
|
|
|
if (bch->tx_skb && bch->tx_skb->len) {
|
|
|
|
if (!test_bit(FLG_TRANSPARENT, &bch->Flags))
|
|
|
|
bch->tx_idx = 0;
|
2012-05-16 07:51:07 +08:00
|
|
|
} else if (test_bit(FLG_FILLEMPTY, &bch->Flags)) {
|
|
|
|
test_and_set_bit(FLG_TX_EMPTY, &bch->Flags);
|
2009-07-23 01:52:24 +08:00
|
|
|
}
|
|
|
|
hdlc->ctrl.sr.xml = 0;
|
|
|
|
hdlc->ctrl.sr.cmd |= HDLC_CMD_XRS;
|
|
|
|
write_ctrl(bch, 1);
|
|
|
|
hdlc->ctrl.sr.cmd &= ~HDLC_CMD_XRS;
|
|
|
|
HDLC_irq_xpr(bch);
|
|
|
|
return;
|
|
|
|
} else if (stat & HDLC_INT_XPR)
|
|
|
|
HDLC_irq_xpr(bch);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
HDLC_irq_main(struct fritzcard *fc)
|
|
|
|
{
|
|
|
|
u32 stat;
|
|
|
|
struct bchannel *bch;
|
|
|
|
|
|
|
|
stat = read_status(fc, 1);
|
|
|
|
if (stat & HDLC_INT_MASK) {
|
|
|
|
bch = Sel_BCS(fc, 1);
|
|
|
|
if (bch)
|
|
|
|
HDLC_irq(bch, stat);
|
|
|
|
else
|
|
|
|
pr_debug("%s: spurious ch1 IRQ\n", fc->name);
|
|
|
|
}
|
|
|
|
stat = read_status(fc, 2);
|
|
|
|
if (stat & HDLC_INT_MASK) {
|
|
|
|
bch = Sel_BCS(fc, 2);
|
|
|
|
if (bch)
|
|
|
|
HDLC_irq(bch, stat);
|
|
|
|
else
|
|
|
|
pr_debug("%s: spurious ch2 IRQ\n", fc->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t
|
|
|
|
avm_fritz_interrupt(int intno, void *dev_id)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = dev_id;
|
|
|
|
u8 val;
|
|
|
|
u8 sval;
|
|
|
|
|
|
|
|
spin_lock(&fc->lock);
|
|
|
|
sval = inb(fc->addr + 2);
|
|
|
|
pr_debug("%s: irq stat0 %x\n", fc->name, sval);
|
|
|
|
if ((sval & AVM_STATUS0_IRQ_MASK) == AVM_STATUS0_IRQ_MASK) {
|
|
|
|
/* shared IRQ from other HW */
|
|
|
|
spin_unlock(&fc->lock);
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
fc->irqcnt++;
|
|
|
|
|
|
|
|
if (!(sval & AVM_STATUS0_IRQ_ISAC)) {
|
|
|
|
val = ReadISAC_V1(fc, ISAC_ISTA);
|
|
|
|
mISDNisac_irq(&fc->isac, val);
|
|
|
|
}
|
|
|
|
if (!(sval & AVM_STATUS0_IRQ_HDLC))
|
|
|
|
HDLC_irq_main(fc);
|
|
|
|
spin_unlock(&fc->lock);
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t
|
|
|
|
avm_fritzv2_interrupt(int intno, void *dev_id)
|
|
|
|
{
|
|
|
|
struct fritzcard *fc = dev_id;
|
|
|
|
u8 val;
|
|
|
|
u8 sval;
|
|
|
|
|
|
|
|
spin_lock(&fc->lock);
|
|
|
|
sval = inb(fc->addr + 2);
|
|
|
|
pr_debug("%s: irq stat0 %x\n", fc->name, sval);
|
|
|
|
if (!(sval & AVM_STATUS0_IRQ_MASK)) {
|
|
|
|
/* shared IRQ from other HW */
|
|
|
|
spin_unlock(&fc->lock);
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
fc->irqcnt++;
|
|
|
|
|
|
|
|
if (sval & AVM_STATUS0_IRQ_HDLC)
|
|
|
|
HDLC_irq_main(fc);
|
|
|
|
if (sval & AVM_STATUS0_IRQ_ISAC) {
|
|
|
|
val = ReadISAC_V2(fc, ISACX_ISTA);
|
|
|
|
mISDNisac_irq(&fc->isac, val);
|
|
|
|
}
|
|
|
|
if (sval & AVM_STATUS0_IRQ_TIMER) {
|
|
|
|
pr_debug("%s: timer irq\n", fc->name);
|
|
|
|
outb(fc->ctrlreg | AVM_STATUS0_RES_TIMER, fc->addr + 2);
|
|
|
|
udelay(1);
|
|
|
|
outb(fc->ctrlreg, fc->addr + 2);
|
|
|
|
}
|
|
|
|
spin_unlock(&fc->lock);
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
avm_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct bchannel *bch = container_of(ch, struct bchannel, ch);
|
|
|
|
struct fritzcard *fc = bch->hw;
|
|
|
|
int ret = -EINVAL;
|
|
|
|
struct mISDNhead *hh = mISDN_HEAD_P(skb);
|
2012-05-16 07:51:02 +08:00
|
|
|
unsigned long flags;
|
2009-07-23 01:52:24 +08:00
|
|
|
|
|
|
|
switch (hh->prim) {
|
|
|
|
case PH_DATA_REQ:
|
|
|
|
spin_lock_irqsave(&fc->lock, flags);
|
|
|
|
ret = bchannel_senddata(bch, skb);
|
|
|
|
if (ret > 0) { /* direct TX */
|
|
|
|
hdlc_fill_fifo(bch);
|
|
|
|
ret = 0;
|
2012-05-16 07:51:02 +08:00
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&fc->lock, flags);
|
2009-07-23 01:52:24 +08:00
|
|
|
return ret;
|
|
|
|
case PH_ACTIVATE_REQ:
|
|
|
|
spin_lock_irqsave(&fc->lock, flags);
|
|
|
|
if (!test_and_set_bit(FLG_ACTIVE, &bch->Flags))
|
|
|
|
ret = modehdlc(bch, ch->protocol);
|
|
|
|
else
|
|
|
|
ret = 0;
|
|
|
|
spin_unlock_irqrestore(&fc->lock, flags);
|
|
|
|
if (!ret)
|
|
|
|
_queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, 0,
|
2012-02-20 11:52:38 +08:00
|
|
|
NULL, GFP_KERNEL);
|
2009-07-23 01:52:24 +08:00
|
|
|
break;
|
|
|
|
case PH_DEACTIVATE_REQ:
|
|
|
|
spin_lock_irqsave(&fc->lock, flags);
|
|
|
|
mISDN_clear_bchannel(bch);
|
|
|
|
modehdlc(bch, ISDN_P_NONE);
|
|
|
|
spin_unlock_irqrestore(&fc->lock, flags);
|
|
|
|
_queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0,
|
2012-02-20 11:52:38 +08:00
|
|
|
NULL, GFP_KERNEL);
|
2009-07-23 01:52:24 +08:00
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!ret)
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
inithdlc(struct fritzcard *fc)
|
|
|
|
{
|
|
|
|
modehdlc(&fc->bch[0], -1);
|
|
|
|
modehdlc(&fc->bch[1], -1);
|
|
|
|
}
|
|
|
|
|
2016-09-01 14:16:24 +08:00
|
|
|
static void
|
2009-07-23 01:52:24 +08:00
|
|
|
clear_pending_hdlc_ints(struct fritzcard *fc)
|
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
val = read_status(fc, 1);
|
|
|
|
pr_debug("%s: HDLC 1 STA %x\n", fc->name, val);
|
|
|
|
val = read_status(fc, 2);
|
|
|
|
pr_debug("%s: HDLC 2 STA %x\n", fc->name, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
reset_avm(struct fritzcard *fc)
|
|
|
|
{
|
|
|
|
switch (fc->type) {
|
|
|
|
case AVM_FRITZ_PCI:
|
|
|
|
fc->ctrlreg = AVM_STATUS0_RESET | AVM_STATUS0_DIS_TIMER;
|
|
|
|
break;
|
|
|
|
case AVM_FRITZ_PCIV2:
|
|
|
|
fc->ctrlreg = AVM_STATUS0_RESET;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (debug & DEBUG_HW)
|
|
|
|
pr_notice("%s: reset\n", fc->name);
|
|
|
|
disable_hwirq(fc);
|
|
|
|
mdelay(5);
|
|
|
|
switch (fc->type) {
|
|
|
|
case AVM_FRITZ_PCI:
|
|
|
|
fc->ctrlreg = AVM_STATUS0_DIS_TIMER | AVM_STATUS0_RES_TIMER;
|
|
|
|
disable_hwirq(fc);
|
|
|
|
outb(AVM_STATUS1_ENA_IOM, fc->addr + 3);
|
|
|
|
break;
|
|
|
|
case AVM_FRITZ_PCIV2:
|
|
|
|
fc->ctrlreg = 0;
|
|
|
|
disable_hwirq(fc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mdelay(1);
|
|
|
|
if (debug & DEBUG_HW)
|
|
|
|
pr_notice("%s: S0/S1 %x/%x\n", fc->name,
|
2012-02-20 11:52:38 +08:00
|
|
|
inb(fc->addr + 2), inb(fc->addr + 3));
|
2009-07-23 01:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
init_card(struct fritzcard *fc)
|
|
|
|
{
|
|
|
|
int ret, cnt = 3;
|
|
|
|
u_long flags;
|
|
|
|
|
|
|
|
reset_avm(fc); /* disable IRQ */
|
|
|
|
if (fc->type == AVM_FRITZ_PCIV2)
|
|
|
|
ret = request_irq(fc->irq, avm_fritzv2_interrupt,
|
2012-02-20 11:52:38 +08:00
|
|
|
IRQF_SHARED, fc->name, fc);
|
2009-07-23 01:52:24 +08:00
|
|
|
else
|
|
|
|
ret = request_irq(fc->irq, avm_fritz_interrupt,
|
2012-02-20 11:52:38 +08:00
|
|
|
IRQF_SHARED, fc->name, fc);
|
2009-07-23 01:52:24 +08:00
|
|
|
if (ret) {
|
|
|
|
pr_info("%s: couldn't get interrupt %d\n",
|
|
|
|
fc->name, fc->irq);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
while (cnt--) {
|
|
|
|
spin_lock_irqsave(&fc->lock, flags);
|
|
|
|
ret = fc->isac.init(&fc->isac);
|
|
|
|
if (ret) {
|
|
|
|
spin_unlock_irqrestore(&fc->lock, flags);
|
|
|
|
pr_info("%s: ISAC init failed with %d\n",
|
|
|
|
fc->name, ret);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
clear_pending_hdlc_ints(fc);
|
|
|
|
inithdlc(fc);
|
|
|
|
enable_hwirq(fc);
|
|
|
|
/* RESET Receiver and Transmitter */
|
2012-05-16 07:51:03 +08:00
|
|
|
if (fc->type == AVM_FRITZ_PCIV2) {
|
2009-07-23 01:52:24 +08:00
|
|
|
WriteISAC_V2(fc, ISACX_MASK, 0);
|
|
|
|
WriteISAC_V2(fc, ISACX_CMDRD, 0x41);
|
|
|
|
} else {
|
|
|
|
WriteISAC_V1(fc, ISAC_MASK, 0);
|
|
|
|
WriteISAC_V1(fc, ISAC_CMDR, 0x41);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&fc->lock, flags);
|
|
|
|
/* Timeout 10ms */
|
|
|
|
msleep_interruptible(10);
|
|
|
|
if (debug & DEBUG_HW)
|
|
|
|
pr_notice("%s: IRQ %d count %d\n", fc->name,
|
2012-02-20 11:52:38 +08:00
|
|
|
fc->irq, fc->irqcnt);
|
2009-07-23 01:52:24 +08:00
|
|
|
if (!fc->irqcnt) {
|
|
|
|
pr_info("%s: IRQ(%d) getting no IRQs during init %d\n",
|
|
|
|
fc->name, fc->irq, 3 - cnt);
|
|
|
|
reset_avm(fc);
|
|
|
|
} else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
free_irq(fc->irq, fc);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
|
|
|
|
{
|
2012-05-16 07:51:06 +08:00
|
|
|
return mISDN_ctrl_bchannel(bch, cq);
|
2009-07-23 01:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
avm_bctrl(struct mISDNchannel *ch, u32 cmd, void *arg)
|
|
|
|
{
|
|
|
|
struct bchannel *bch = container_of(ch, struct bchannel, ch);
|
|
|
|
struct fritzcard *fc = bch->hw;
|
|
|
|
int ret = -EINVAL;
|
|
|
|
u_long flags;
|
|
|
|
|
|
|
|
pr_debug("%s: %s cmd:%x %p\n", fc->name, __func__, cmd, arg);
|
|
|
|
switch (cmd) {
|
|
|
|
case CLOSE_CHANNEL:
|
|
|
|
test_and_clear_bit(FLG_OPEN, &bch->Flags);
|
2012-09-13 12:36:20 +08:00
|
|
|
cancel_work_sync(&bch->workq);
|
2012-05-16 07:51:01 +08:00
|
|
|
spin_lock_irqsave(&fc->lock, flags);
|
2012-09-13 12:36:20 +08:00
|
|
|
mISDN_clear_bchannel(bch);
|
2012-05-16 07:51:01 +08:00
|
|
|
modehdlc(bch, ISDN_P_NONE);
|
|
|
|
spin_unlock_irqrestore(&fc->lock, flags);
|
2009-07-23 01:52:24 +08:00
|
|
|
ch->protocol = ISDN_P_NONE;
|
|
|
|
ch->peer = NULL;
|
|
|
|
module_put(THIS_MODULE);
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
case CONTROL_CHANNEL:
|
|
|
|
ret = channel_bctrl(bch, arg);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pr_info("%s: %s unknown prim(%x)\n", fc->name, __func__, cmd);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
channel_ctrl(struct fritzcard *fc, struct mISDN_ctrl_req *cq)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
switch (cq->op) {
|
|
|
|
case MISDN_CTRL_GETOP:
|
2012-05-04 12:15:33 +08:00
|
|
|
cq->op = MISDN_CTRL_LOOP | MISDN_CTRL_L1_TIMER3;
|
2009-07-23 01:52:24 +08:00
|
|
|
break;
|
|
|
|
case MISDN_CTRL_LOOP:
|
|
|
|
/* cq->channel: 0 disable, 1 B1 loop 2 B2 loop, 3 both */
|
|
|
|
if (cq->channel < 0 || cq->channel > 3) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ret = fc->isac.ctrl(&fc->isac, HW_TESTLOOP, cq->channel);
|
|
|
|
break;
|
2012-05-04 12:15:33 +08:00
|
|
|
case MISDN_CTRL_L1_TIMER3:
|
|
|
|
ret = fc->isac.ctrl(&fc->isac, HW_TIMER3_VALUE, cq->p1);
|
|
|
|
break;
|
2009-07-23 01:52:24 +08:00
|
|
|
default:
|
|
|
|
pr_info("%s: %s unknown Op %x\n", fc->name, __func__, cq->op);
|
|
|
|
ret = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
open_bchannel(struct fritzcard *fc, struct channel_req *rq)
|
|
|
|
{
|
|
|
|
struct bchannel *bch;
|
|
|
|
|
2012-03-27 05:20:48 +08:00
|
|
|
if (rq->adr.channel == 0 || rq->adr.channel > 2)
|
2009-07-23 01:52:24 +08:00
|
|
|
return -EINVAL;
|
|
|
|
if (rq->protocol == ISDN_P_NONE)
|
|
|
|
return -EINVAL;
|
|
|
|
bch = &fc->bch[rq->adr.channel - 1];
|
|
|
|
if (test_and_set_bit(FLG_OPEN, &bch->Flags))
|
|
|
|
return -EBUSY; /* b-channel can be only open once */
|
|
|
|
bch->ch.protocol = rq->protocol;
|
|
|
|
rq->ch = &bch->ch;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* device control function
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
avm_dctrl(struct mISDNchannel *ch, u32 cmd, void *arg)
|
|
|
|
{
|
|
|
|
struct mISDNdevice *dev = container_of(ch, struct mISDNdevice, D);
|
|
|
|
struct dchannel *dch = container_of(dev, struct dchannel, dev);
|
|
|
|
struct fritzcard *fc = dch->hw;
|
|
|
|
struct channel_req *rq;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
pr_debug("%s: %s cmd:%x %p\n", fc->name, __func__, cmd, arg);
|
|
|
|
switch (cmd) {
|
|
|
|
case OPEN_CHANNEL:
|
|
|
|
rq = arg;
|
|
|
|
if (rq->protocol == ISDN_P_TE_S0)
|
|
|
|
err = fc->isac.open(&fc->isac, rq);
|
|
|
|
else
|
|
|
|
err = open_bchannel(fc, rq);
|
|
|
|
if (err)
|
|
|
|
break;
|
|
|
|
if (!try_module_get(THIS_MODULE))
|
|
|
|
pr_info("%s: cannot get module\n", fc->name);
|
|
|
|
break;
|
|
|
|
case CLOSE_CHANNEL:
|
|
|
|
pr_debug("%s: dev(%d) close from %p\n", fc->name, dch->dev.id,
|
2012-02-20 11:52:38 +08:00
|
|
|
__builtin_return_address(0));
|
2009-07-23 01:52:24 +08:00
|
|
|
module_put(THIS_MODULE);
|
|
|
|
break;
|
|
|
|
case CONTROL_CHANNEL:
|
|
|
|
err = channel_ctrl(fc, arg);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pr_debug("%s: %s unknown command %x\n",
|
2012-02-20 11:52:38 +08:00
|
|
|
fc->name, __func__, cmd);
|
2009-07-23 01:52:24 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2016-09-01 14:16:24 +08:00
|
|
|
static int
|
2009-07-23 01:52:24 +08:00
|
|
|
setup_fritz(struct fritzcard *fc)
|
|
|
|
{
|
|
|
|
u32 val, ver;
|
|
|
|
|
|
|
|
if (!request_region(fc->addr, 32, fc->name)) {
|
|
|
|
pr_info("%s: AVM config port %x-%x already in use\n",
|
|
|
|
fc->name, fc->addr, fc->addr + 31);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
switch (fc->type) {
|
|
|
|
case AVM_FRITZ_PCI:
|
|
|
|
val = inl(fc->addr);
|
|
|
|
outl(AVM_HDLC_1, fc->addr + CHIP_INDEX);
|
|
|
|
ver = inl(fc->addr + CHIP_WINDOW + HDLC_STATUS) >> 24;
|
|
|
|
if (debug & DEBUG_HW) {
|
|
|
|
pr_notice("%s: PCI stat %#x\n", fc->name, val);
|
|
|
|
pr_notice("%s: PCI Class %X Rev %d\n", fc->name,
|
2012-02-20 11:52:38 +08:00
|
|
|
val & 0xff, (val >> 8) & 0xff);
|
2009-07-23 01:52:24 +08:00
|
|
|
pr_notice("%s: HDLC version %x\n", fc->name, ver & 0xf);
|
|
|
|
}
|
|
|
|
ASSIGN_FUNC(V1, ISAC, fc->isac);
|
|
|
|
fc->isac.type = IPAC_TYPE_ISAC;
|
|
|
|
break;
|
|
|
|
case AVM_FRITZ_PCIV2:
|
|
|
|
val = inl(fc->addr);
|
|
|
|
ver = inl(fc->addr + AVM_HDLC_STATUS_1) >> 24;
|
|
|
|
if (debug & DEBUG_HW) {
|
|
|
|
pr_notice("%s: PCI V2 stat %#x\n", fc->name, val);
|
|
|
|
pr_notice("%s: PCI V2 Class %X Rev %d\n", fc->name,
|
2012-02-20 11:52:38 +08:00
|
|
|
val & 0xff, (val >> 8) & 0xff);
|
2009-07-23 01:52:24 +08:00
|
|
|
pr_notice("%s: HDLC version %x\n", fc->name, ver & 0xf);
|
|
|
|
}
|
|
|
|
ASSIGN_FUNC(V2, ISAC, fc->isac);
|
|
|
|
fc->isac.type = IPAC_TYPE_ISACX;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
release_region(fc->addr, 32);
|
|
|
|
pr_info("%s: AVM unknown type %d\n", fc->name, fc->type);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
pr_notice("%s: %s config irq:%d base:0x%X\n", fc->name,
|
2012-02-20 11:52:38 +08:00
|
|
|
(fc->type == AVM_FRITZ_PCI) ? "AVM Fritz!CARD PCI" :
|
|
|
|
"AVM Fritz!CARD PCIv2", fc->irq, fc->addr);
|
2009-07-23 01:52:24 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
release_card(struct fritzcard *card)
|
|
|
|
{
|
|
|
|
u_long flags;
|
|
|
|
|
|
|
|
disable_hwirq(card);
|
|
|
|
spin_lock_irqsave(&card->lock, flags);
|
|
|
|
modehdlc(&card->bch[0], ISDN_P_NONE);
|
|
|
|
modehdlc(&card->bch[1], ISDN_P_NONE);
|
|
|
|
spin_unlock_irqrestore(&card->lock, flags);
|
|
|
|
card->isac.release(&card->isac);
|
|
|
|
free_irq(card->irq, card);
|
|
|
|
mISDN_freebchannel(&card->bch[1]);
|
|
|
|
mISDN_freebchannel(&card->bch[0]);
|
|
|
|
mISDN_unregister_device(&card->isac.dch.dev);
|
|
|
|
release_region(card->addr, 32);
|
|
|
|
pci_disable_device(card->pdev);
|
|
|
|
pci_set_drvdata(card->pdev, NULL);
|
|
|
|
write_lock_irqsave(&card_lock, flags);
|
|
|
|
list_del(&card->list);
|
|
|
|
write_unlock_irqrestore(&card_lock, flags);
|
|
|
|
kfree(card);
|
|
|
|
AVM_cnt--;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:13:05 +08:00
|
|
|
static int
|
2009-07-23 01:52:24 +08:00
|
|
|
setup_instance(struct fritzcard *card)
|
|
|
|
{
|
|
|
|
int i, err;
|
2012-05-16 07:51:06 +08:00
|
|
|
unsigned short minsize;
|
2009-07-23 01:52:24 +08:00
|
|
|
u_long flags;
|
|
|
|
|
|
|
|
snprintf(card->name, MISDN_MAX_IDLEN - 1, "AVM.%d", AVM_cnt + 1);
|
|
|
|
write_lock_irqsave(&card_lock, flags);
|
|
|
|
list_add_tail(&card->list, &Cards);
|
|
|
|
write_unlock_irqrestore(&card_lock, flags);
|
|
|
|
|
|
|
|
_set_debug(card);
|
|
|
|
card->isac.name = card->name;
|
|
|
|
spin_lock_init(&card->lock);
|
|
|
|
card->isac.hwlock = &card->lock;
|
|
|
|
mISDNisac_init(&card->isac, card);
|
|
|
|
|
|
|
|
card->isac.dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
|
2012-02-20 11:52:38 +08:00
|
|
|
(1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
|
2009-07-23 01:52:24 +08:00
|
|
|
card->isac.dch.dev.D.ctrl = avm_dctrl;
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
card->bch[i].nr = i + 1;
|
|
|
|
set_channelmap(i + 1, card->isac.dch.dev.channelmap);
|
2012-05-16 07:51:06 +08:00
|
|
|
if (AVM_FRITZ_PCIV2 == card->type)
|
|
|
|
minsize = HDLC_FIFO_SIZE_V2;
|
|
|
|
else
|
|
|
|
minsize = HDLC_FIFO_SIZE_V1;
|
|
|
|
mISDN_initbchannel(&card->bch[i], MAX_DATA_MEM, minsize);
|
2009-07-23 01:52:24 +08:00
|
|
|
card->bch[i].hw = card;
|
|
|
|
card->bch[i].ch.send = avm_l2l1B;
|
|
|
|
card->bch[i].ch.ctrl = avm_bctrl;
|
|
|
|
card->bch[i].ch.nr = i + 1;
|
|
|
|
list_add(&card->bch[i].ch.list, &card->isac.dch.dev.bchannels);
|
|
|
|
}
|
|
|
|
err = setup_fritz(card);
|
|
|
|
if (err)
|
|
|
|
goto error;
|
|
|
|
err = mISDN_register_device(&card->isac.dch.dev, &card->pdev->dev,
|
2012-02-20 11:52:38 +08:00
|
|
|
card->name);
|
2009-07-23 01:52:24 +08:00
|
|
|
if (err)
|
|
|
|
goto error_reg;
|
|
|
|
err = init_card(card);
|
|
|
|
if (!err) {
|
|
|
|
AVM_cnt++;
|
|
|
|
pr_notice("AVM %d cards installed DEBUG\n", AVM_cnt);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
mISDN_unregister_device(&card->isac.dch.dev);
|
|
|
|
error_reg:
|
|
|
|
release_region(card->addr, 32);
|
|
|
|
error:
|
|
|
|
card->isac.release(&card->isac);
|
|
|
|
mISDN_freebchannel(&card->bch[1]);
|
|
|
|
mISDN_freebchannel(&card->bch[0]);
|
|
|
|
write_lock_irqsave(&card_lock, flags);
|
|
|
|
list_del(&card->list);
|
|
|
|
write_unlock_irqrestore(&card_lock, flags);
|
|
|
|
kfree(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:13:05 +08:00
|
|
|
static int
|
2009-07-23 01:52:24 +08:00
|
|
|
fritzpci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|
|
|
{
|
|
|
|
int err = -ENOMEM;
|
|
|
|
struct fritzcard *card;
|
|
|
|
|
|
|
|
card = kzalloc(sizeof(struct fritzcard), GFP_KERNEL);
|
|
|
|
if (!card) {
|
|
|
|
pr_info("No kmem for fritzcard\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
if (pdev->device == PCI_DEVICE_ID_AVM_A1_V2)
|
|
|
|
card->type = AVM_FRITZ_PCIV2;
|
|
|
|
else
|
|
|
|
card->type = AVM_FRITZ_PCI;
|
|
|
|
card->pdev = pdev;
|
|
|
|
err = pci_enable_device(pdev);
|
|
|
|
if (err) {
|
|
|
|
kfree(card);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
pr_notice("mISDN: found adapter %s at %s\n",
|
2012-02-20 11:52:38 +08:00
|
|
|
(char *) ent->driver_data, pci_name(pdev));
|
2009-07-23 01:52:24 +08:00
|
|
|
|
|
|
|
card->addr = pci_resource_start(pdev, 1);
|
|
|
|
card->irq = pdev->irq;
|
|
|
|
pci_set_drvdata(pdev, card);
|
|
|
|
err = setup_instance(card);
|
|
|
|
if (err)
|
|
|
|
pci_set_drvdata(pdev, NULL);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:13:05 +08:00
|
|
|
static void
|
2009-07-23 01:52:24 +08:00
|
|
|
fritz_remove_pci(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
struct fritzcard *card = pci_get_drvdata(pdev);
|
|
|
|
|
|
|
|
if (card)
|
|
|
|
release_card(card);
|
|
|
|
else
|
|
|
|
if (debug)
|
2010-07-03 02:41:51 +08:00
|
|
|
pr_info("%s: drvdata already removed\n", __func__);
|
2009-07-23 01:52:24 +08:00
|
|
|
}
|
|
|
|
|
2017-07-15 12:25:49 +08:00
|
|
|
static const struct pci_device_id fcpci_ids[] = {
|
2009-07-23 01:52:24 +08:00
|
|
|
{ PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1, PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0, (unsigned long) "Fritz!Card PCI"},
|
|
|
|
{ PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1_V2, PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0, (unsigned long) "Fritz!Card PCI v2" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, fcpci_ids);
|
|
|
|
|
|
|
|
static struct pci_driver fcpci_driver = {
|
|
|
|
.name = "fcpci",
|
|
|
|
.probe = fritzpci_probe,
|
2012-12-22 05:13:05 +08:00
|
|
|
.remove = fritz_remove_pci,
|
2009-07-23 01:52:24 +08:00
|
|
|
.id_table = fcpci_ids,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init AVM_init(void)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
pr_notice("AVM Fritz PCI driver Rev. %s\n", AVMFRITZ_REV);
|
|
|
|
err = pci_register_driver(&fcpci_driver);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit AVM_cleanup(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&fcpci_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(AVM_init);
|
|
|
|
module_exit(AVM_cleanup);
|