/*
* Driver for AVM Fritz!PCI, Fritz!PCI v2, Fritz!PnP ISDN cards
*
* Author Kai Germaschewski
* Copyright 2001 by Kai Germaschewski <kai.germaschewski@gmx.de>
* 2001 by Karsten Keil <keil@isdn4linux.de>
*
* based upon Karsten Keil's original avm_pci.c driver
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
* Thanks to Wizard Computersysteme GmbH, Bremervoerde and
* SoHaNet Technology GmbH, Berlin
* for supporting the development of this driver
*/
/* TODO:
*
* o POWER PC
* o clean up debugging
* o tx_skb at PH_DEACTIVATE time
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/isapnp.h>
#include <linux/kmod.h>
#include <linux/slab.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/delay.h>
#include <asm/io.h>
#include "hisax_fcpcipnp.h"
// debugging cruft
#define __debug_variable debug
#include "hisax_debug.h"
#ifdef CONFIG_HISAX_DEBUG
static int debug = 0;
/* static int hdlcfifosize = 32; */
module_param(debug, int, 0);
/* module_param(hdlcfifosize, int, 0); */
#endif
MODULE_AUTHOR("Kai Germaschewski <kai.germaschewski@gmx.de>/Karsten Keil <kkeil@suse.de>");
MODULE_DESCRIPTION("AVM Fritz!PCI/PnP ISDN driver");
static struct pci_device_id fcpci_ids[] = {
{ .vendor = PCI_VENDOR_ID_AVM,
.device = PCI_DEVICE_ID_AVM_A1,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
.driver_data = (unsigned long) "Fritz!Card PCI",
},
{ .vendor = PCI_VENDOR_ID_AVM,
.device = PCI_DEVICE_ID_AVM_A1_V2,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
.driver_data = (unsigned long) "Fritz!Card PCI v2" },
{}
};
MODULE_DEVICE_TABLE(pci, fcpci_ids);
#ifdef __ISAPNP__
static struct pnp_device_id fcpnp_ids[] __devinitdata = {
{
.id = "AVM0900",
.driver_data = (unsigned long) "Fritz!Card PnP",
},
};
MODULE_DEVICE_TABLE(isapnp, fcpnp_ids);
#endif
static int protocol = 2; /* EURO-ISDN Default */
module_param(protocol, int, 0);
MODULE_LICENSE("GPL");
// ----------------------------------------------------------------------
#define AVM_INDEX 0x04
#define AVM_DATA 0x10
#define AVM_IDX_HDLC_1 0x00
#define AVM_IDX_HDLC_2 0x01
#define AVM_IDX_ISAC_FIFO 0x02
#define AVM_IDX_ISAC_REG_LOW 0x04
#define AVM_IDX_ISAC_REG_HIGH 0x06
#define AVM_STATUS0 0x02
#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 0x03
#define AVM_STATUS1_ENA_IOM 0x80
#define HDLC_FIFO 0x0
#define HDLC_STATUS 0x4
#define HDLC_CTRL 0x4
#define HDLC_MODE_ITF_FLG 0x01
#define HDLC_MODE_TRANS 0x02
#define HDLC_MODE_CCR_7 0x04
#define HDLC_MODE_CCR_16 0x08
#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
#define HDLC_STAT_RML_MASK 0xff00
#define HDLC_CMD_XRS 0x80
#define HDLC_CMD_XME 0x01
#define HDLC_CMD_RRS 0x20
#define HDLC_CMD_XML_MASK 0xff00
#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_ISACSX_INDEX 0x04
#define AVM_ISACSX_DATA 0x08
// ----------------------------------------------------------------------
// Fritz!PCI
static unsigned char fcpci_read_isac(struct isac *isac, unsigned char offset)
{
struct fritz_adapter *adapter = isac->priv;
unsigned char idx = (offset > 0x2f) ?
AVM_IDX_ISAC_REG_HIGH : AVM_IDX_ISAC_REG_LOW;
unsigned char val;
unsigned long flags;
spin_lock_irqsave(&adapter->hw_lock, flags);
outb(idx, adapter->io + AVM_INDEX);
val = inb(adapter->io + AVM_DATA + (offset & 0xf));
spin_unlock_irqrestore(&adapter->hw_lock, flags);
DBG(0x1000, " port %#x, value %#x",
offset, val);
return val;
}
static void fcpci_write_isac(struct isac *isac, unsigned char offset,
unsigned char value)
{
struct fritz_adapter *adapter = isac->priv;
unsigned char idx = (offset > 0x2f) ?
AVM_IDX_ISAC_REG_HIGH : AVM_IDX_ISAC_REG_LOW;
unsigned long flags;
DBG(0x1000, " port %#x, value %#x",
offset, value);
spin_lock_irqsave(&adapter->hw_lock, flags);
outb(idx, adapter->io + AVM_INDEX);
outb(value, adapter->io + AVM_DATA + (offset & 0xf));
spin_unlock_irqrestore(&adapter->hw_lock, flags);
}
static void fcpci_read_isac_fifo(struct isac *isac, unsigned char * data,
int size)
{
struct fritz_adapter *adapter = isac->priv;
unsigned long flags;
spin_lock_irqsave(&adapter->hw_lock, flags);
outb(AVM_IDX_ISAC_FIFO, adapter->io + AVM_INDEX);