2005-04-16 16:20:36 -06:00
|
|
|
/* $Id: bkm_a4t.c,v 1.22.2.4 2004/01/14 16:04:48 keil Exp $
|
|
|
|
*
|
|
|
|
* low level stuff for T-Berkom A4T
|
|
|
|
*
|
|
|
|
* Author Roland Klabunde
|
|
|
|
* Copyright by Roland Klabunde <R.Klabunde@Berkom.de>
|
|
|
|
*
|
|
|
|
* This software may be used and distributed according to the terms
|
|
|
|
* of the GNU General Public License, incorporated herein by reference.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include "hisax.h"
|
|
|
|
#include "isac.h"
|
|
|
|
#include "hscx.h"
|
|
|
|
#include "jade.h"
|
|
|
|
#include "isdnl1.h"
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include "bkm_ax.h"
|
|
|
|
|
2005-06-25 15:59:18 -06:00
|
|
|
static const char *bkm_a4t_revision = "$Revision: 1.22.2.4 $";
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
static inline u_char
|
|
|
|
readreg(unsigned int ale, unsigned long adr, u_char off)
|
|
|
|
{
|
|
|
|
register u_int ret;
|
|
|
|
unsigned int *po = (unsigned int *) adr; /* Postoffice */
|
|
|
|
|
|
|
|
*po = (GCS_2 | PO_WRITE | off);
|
|
|
|
__WAITI20__(po);
|
|
|
|
*po = (ale | PO_READ);
|
|
|
|
__WAITI20__(po);
|
|
|
|
ret = *po;
|
|
|
|
return ((unsigned char) ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
readfifo(unsigned int ale, unsigned long adr, u_char off, u_char * data, int size)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
*data++ = readreg(ale, adr, off);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
writereg(unsigned int ale, unsigned long adr, u_char off, u_char data)
|
|
|
|
{
|
|
|
|
unsigned int *po = (unsigned int *) adr; /* Postoffice */
|
|
|
|
*po = (GCS_2 | PO_WRITE | off);
|
|
|
|
__WAITI20__(po);
|
|
|
|
*po = (ale | PO_WRITE | data);
|
|
|
|
__WAITI20__(po);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
writefifo(unsigned int ale, unsigned long adr, u_char off, u_char * data, int size)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
writereg(ale, adr, off, *data++);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Interface functions */
|
|
|
|
|
|
|
|
static u_char
|
|
|
|
ReadISAC(struct IsdnCardState *cs, u_char offset)
|
|
|
|
{
|
|
|
|
return (readreg(cs->hw.ax.isac_ale, cs->hw.ax.isac_adr, offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
|
|
|
|
{
|
|
|
|
writereg(cs->hw.ax.isac_ale, cs->hw.ax.isac_adr, offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
|
|
|
|
{
|
|
|
|
readfifo(cs->hw.ax.isac_ale, cs->hw.ax.isac_adr, 0, data, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
|
|
|
|
{
|
|
|
|
writefifo(cs->hw.ax.isac_ale, cs->hw.ax.isac_adr, 0, data, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u_char
|
|
|
|
ReadJADE(struct IsdnCardState *cs, int jade, u_char offset)
|
|
|
|
{
|
|
|
|
return (readreg(cs->hw.ax.jade_ale, cs->hw.ax.jade_adr, offset + (jade == -1 ? 0 : (jade ? 0xC0 : 0x80))));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
WriteJADE(struct IsdnCardState *cs, int jade, u_char offset, u_char value)
|
|
|
|
{
|
|
|
|
writereg(cs->hw.ax.jade_ale, cs->hw.ax.jade_adr, offset + (jade == -1 ? 0 : (jade ? 0xC0 : 0x80)), value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* fast interrupt JADE stuff goes here
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define READJADE(cs, nr, reg) readreg(cs->hw.ax.jade_ale,\
|
|
|
|
cs->hw.ax.jade_adr, reg + (nr == -1 ? 0 : (nr ? 0xC0 : 0x80)))
|
|
|
|
#define WRITEJADE(cs, nr, reg, data) writereg(cs->hw.ax.jade_ale,\
|
|
|
|
cs->hw.ax.jade_adr, reg + (nr == -1 ? 0 : (nr ? 0xC0 : 0x80)), data)
|
|
|
|
|
|
|
|
#define READJADEFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.ax.jade_ale,\
|
|
|
|
cs->hw.ax.jade_adr, (nr == -1 ? 0 : (nr ? 0xC0 : 0x80)), ptr, cnt)
|
|
|
|
#define WRITEJADEFIFO(cs, nr, ptr, cnt) writefifo( cs->hw.ax.jade_ale,\
|
|
|
|
cs->hw.ax.jade_adr, (nr == -1 ? 0 : (nr ? 0xC0 : 0x80)), ptr, cnt)
|
|
|
|
|
|
|
|
#include "jade_irq.c"
|
|
|
|
|
|
|
|
static irqreturn_t
|
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
|
|
|
bkm_interrupt(int intno, void *dev_id)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
struct IsdnCardState *cs = dev_id;
|
|
|
|
u_char val = 0;
|
|
|
|
u_long flags;
|
|
|
|
I20_REGISTER_FILE *pI20_Regs;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&cs->lock, flags);
|
|
|
|
pI20_Regs = (I20_REGISTER_FILE *) (cs->hw.ax.base);
|
|
|
|
|
|
|
|
/* ISDN interrupt pending? */
|
|
|
|
if (pI20_Regs->i20IntStatus & intISDN) {
|
|
|
|
/* Reset the ISDN interrupt */
|
|
|
|
pI20_Regs->i20IntStatus = intISDN;
|
|
|
|
/* Disable ISDN interrupt */
|
|
|
|
pI20_Regs->i20IntCtrl &= ~intISDN;
|
|
|
|
/* Channel A first */
|
|
|
|
val = readreg(cs->hw.ax.jade_ale, cs->hw.ax.jade_adr, jade_HDLC_ISR + 0x80);
|
|
|
|
if (val) {
|
|
|
|
jade_int_main(cs, val, 0);
|
|
|
|
}
|
|
|
|
/* Channel B */
|
|
|
|
val = readreg(cs->hw.ax.jade_ale, cs->hw.ax.jade_adr, jade_HDLC_ISR + 0xC0);
|
|
|
|
if (val) {
|
|
|
|
jade_int_main(cs, val, 1);
|
|
|
|
}
|
|
|
|
/* D-Channel */
|
|
|
|
val = readreg(cs->hw.ax.isac_ale, cs->hw.ax.isac_adr, ISAC_ISTA);
|
|
|
|
if (val) {
|
|
|
|
isac_interrupt(cs, val);
|
|
|
|
}
|
|
|
|
/* Reenable ISDN interrupt */
|
|
|
|
pI20_Regs->i20IntCtrl |= intISDN;
|
|
|
|
spin_unlock_irqrestore(&cs->lock, flags);
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
} else {
|
|
|
|
spin_unlock_irqrestore(&cs->lock, flags);
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-25 15:59:18 -06:00
|
|
|
static void
|
2005-04-16 16:20:36 -06:00
|
|
|
release_io_bkm(struct IsdnCardState *cs)
|
|
|
|
{
|
|
|
|
if (cs->hw.ax.base) {
|
|
|
|
iounmap((void *) cs->hw.ax.base);
|
|
|
|
cs->hw.ax.base = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
enable_bkm_int(struct IsdnCardState *cs, unsigned bEnable)
|
|
|
|
{
|
|
|
|
if (cs->typ == ISDN_CTYPE_BKM_A4T) {
|
|
|
|
I20_REGISTER_FILE *pI20_Regs = (I20_REGISTER_FILE *) (cs->hw.ax.base);
|
|
|
|
if (bEnable)
|
|
|
|
pI20_Regs->i20IntCtrl |= (intISDN | intPCI);
|
|
|
|
else
|
|
|
|
/* CAUTION: This disables the video capture driver too */
|
|
|
|
pI20_Regs->i20IntCtrl &= ~(intISDN | intPCI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
reset_bkm(struct IsdnCardState *cs)
|
|
|
|
{
|
|
|
|
if (cs->typ == ISDN_CTYPE_BKM_A4T) {
|
|
|
|
I20_REGISTER_FILE *pI20_Regs = (I20_REGISTER_FILE *) (cs->hw.ax.base);
|
|
|
|
/* Issue the I20 soft reset */
|
|
|
|
pI20_Regs->i20SysControl = 0xFF; /* all in */
|
|
|
|
mdelay(10);
|
|
|
|
/* Remove the soft reset */
|
|
|
|
pI20_Regs->i20SysControl = sysRESET | 0xFF;
|
|
|
|
mdelay(10);
|
|
|
|
/* Set our configuration */
|
|
|
|
pI20_Regs->i20SysControl = sysRESET | sysCFG;
|
|
|
|
/* Issue ISDN reset */
|
|
|
|
pI20_Regs->i20GuestControl = guestWAIT_CFG |
|
|
|
|
g_A4T_JADE_RES |
|
|
|
|
g_A4T_ISAR_RES |
|
|
|
|
g_A4T_ISAC_RES |
|
|
|
|
g_A4T_JADE_BOOTR |
|
|
|
|
g_A4T_ISAR_BOOTR;
|
|
|
|
mdelay(10);
|
|
|
|
|
|
|
|
/* Remove RESET state from ISDN */
|
|
|
|
pI20_Regs->i20GuestControl &= ~(g_A4T_ISAC_RES |
|
|
|
|
g_A4T_JADE_RES |
|
|
|
|
g_A4T_ISAR_RES);
|
|
|
|
mdelay(10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
BKM_card_msg(struct IsdnCardState *cs, int mt, void *arg)
|
|
|
|
{
|
|
|
|
u_long flags;
|
|
|
|
|
|
|
|
switch (mt) {
|
|
|
|
case CARD_RESET:
|
|
|
|
/* Disable ints */
|
|
|
|
spin_lock_irqsave(&cs->lock, flags);
|
|
|
|
enable_bkm_int(cs, 0);
|
|
|
|
reset_bkm(cs);
|
|
|
|
spin_unlock_irqrestore(&cs->lock, flags);
|
|
|
|
return (0);
|
|
|
|
case CARD_RELEASE:
|
|
|
|
/* Sanity */
|
|
|
|
spin_lock_irqsave(&cs->lock, flags);
|
|
|
|
enable_bkm_int(cs, 0);
|
|
|
|
reset_bkm(cs);
|
|
|
|
spin_unlock_irqrestore(&cs->lock, flags);
|
|
|
|
release_io_bkm(cs);
|
|
|
|
return (0);
|
|
|
|
case CARD_INIT:
|
|
|
|
spin_lock_irqsave(&cs->lock, flags);
|
|
|
|
clear_pending_isac_ints(cs);
|
|
|
|
clear_pending_jade_ints(cs);
|
|
|
|
initisac(cs);
|
|
|
|
initjade(cs);
|
|
|
|
/* Enable ints */
|
|
|
|
enable_bkm_int(cs, 1);
|
|
|
|
spin_unlock_irqrestore(&cs->lock, flags);
|
|
|
|
return (0);
|
|
|
|
case CARD_TEST:
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2007-07-15 17:58:24 -06:00
|
|
|
static int __devinit a4t_pci_probe(struct pci_dev *dev_a4t,
|
|
|
|
struct IsdnCardState *cs,
|
|
|
|
u_int *found,
|
|
|
|
u_int *pci_memaddr)
|
|
|
|
{
|
|
|
|
u16 sub_sys;
|
|
|
|
u16 sub_vendor;
|
|
|
|
|
|
|
|
sub_vendor = dev_a4t->subsystem_vendor;
|
|
|
|
sub_sys = dev_a4t->subsystem_device;
|
|
|
|
if ((sub_sys == PCI_DEVICE_ID_BERKOM_A4T) && (sub_vendor == PCI_VENDOR_ID_BERKOM)) {
|
|
|
|
if (pci_enable_device(dev_a4t))
|
|
|
|
return (0); /* end loop & function */
|
|
|
|
*found = 1;
|
|
|
|
*pci_memaddr = pci_resource_start(dev_a4t, 0);
|
|
|
|
cs->irq = dev_a4t->irq;
|
|
|
|
return (1); /* end loop */
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-07-15 17:58:24 -06:00
|
|
|
return (-1); /* continue looping */
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __devinit a4t_cs_init(struct IsdnCard *card,
|
|
|
|
struct IsdnCardState *cs,
|
|
|
|
u_int pci_memaddr)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
I20_REGISTER_FILE *pI20_Regs;
|
|
|
|
|
|
|
|
if (!cs->irq) { /* IRQ range check ?? */
|
2007-10-31 01:42:07 -06:00
|
|
|
printk(KERN_WARNING "HiSax: Telekom A4T: No IRQ\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
cs->hw.ax.base = (long) ioremap(pci_memaddr, 4096);
|
|
|
|
/* Check suspecious address */
|
|
|
|
pI20_Regs = (I20_REGISTER_FILE *) (cs->hw.ax.base);
|
|
|
|
if ((pI20_Regs->i20IntStatus & 0x8EFFFFFF) != 0) {
|
2007-10-31 01:42:07 -06:00
|
|
|
printk(KERN_WARNING "HiSax: Telekom A4T address "
|
|
|
|
"%lx-%lx suspicious\n",
|
|
|
|
cs->hw.ax.base, cs->hw.ax.base + 4096);
|
2005-04-16 16:20:36 -06:00
|
|
|
iounmap((void *) cs->hw.ax.base);
|
|
|
|
cs->hw.ax.base = 0;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
cs->hw.ax.isac_adr = cs->hw.ax.base + PO_OFFSET;
|
|
|
|
cs->hw.ax.jade_adr = cs->hw.ax.base + PO_OFFSET;
|
|
|
|
cs->hw.ax.isac_ale = GCS_1;
|
|
|
|
cs->hw.ax.jade_ale = GCS_3;
|
2007-07-15 17:58:24 -06:00
|
|
|
|
2007-10-31 01:42:07 -06:00
|
|
|
printk(KERN_INFO "HiSax: Telekom A4T: Card configured at "
|
|
|
|
"0x%lX IRQ %d\n",
|
|
|
|
cs->hw.ax.base, cs->irq);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
setup_isac(cs);
|
|
|
|
cs->readisac = &ReadISAC;
|
|
|
|
cs->writeisac = &WriteISAC;
|
|
|
|
cs->readisacfifo = &ReadISACfifo;
|
|
|
|
cs->writeisacfifo = &WriteISACfifo;
|
|
|
|
cs->BC_Read_Reg = &ReadJADE;
|
|
|
|
cs->BC_Write_Reg = &WriteJADE;
|
|
|
|
cs->BC_Send_Data = &jade_fill_fifo;
|
|
|
|
cs->cardmsg = &BKM_card_msg;
|
|
|
|
cs->irq_func = &bkm_interrupt;
|
2006-07-01 20:29:36 -06:00
|
|
|
cs->irq_flags |= IRQF_SHARED;
|
2005-04-16 16:20:36 -06:00
|
|
|
ISACVersion(cs, "Telekom A4T:");
|
|
|
|
/* Jade version */
|
|
|
|
JadeVersion(cs, "Telekom A4T:");
|
2007-07-15 17:58:24 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
return (1);
|
|
|
|
}
|
2007-07-15 17:58:24 -06:00
|
|
|
|
|
|
|
static struct pci_dev *dev_a4t __devinitdata = NULL;
|
|
|
|
|
|
|
|
int __devinit
|
|
|
|
setup_bkm_a4t(struct IsdnCard *card)
|
|
|
|
{
|
|
|
|
struct IsdnCardState *cs = card->cs;
|
|
|
|
char tmp[64];
|
|
|
|
u_int pci_memaddr = 0, found = 0;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
strcpy(tmp, bkm_a4t_revision);
|
|
|
|
printk(KERN_INFO "HiSax: T-Berkom driver Rev. %s\n", HiSax_getrev(tmp));
|
|
|
|
if (cs->typ == ISDN_CTYPE_BKM_A4T) {
|
|
|
|
cs->subtyp = BKM_A4T;
|
|
|
|
} else
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
while ((dev_a4t = pci_find_device(PCI_VENDOR_ID_ZORAN,
|
|
|
|
PCI_DEVICE_ID_ZORAN_36120, dev_a4t))) {
|
|
|
|
ret = a4t_pci_probe(dev_a4t, cs, &found, &pci_memaddr);
|
|
|
|
if (!ret)
|
|
|
|
return (0);
|
|
|
|
if (ret > 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!found) {
|
2007-10-31 01:42:07 -06:00
|
|
|
printk(KERN_WARNING "HiSax: Telekom A4T: Card not found\n");
|
2007-07-15 17:58:24 -06:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (!pci_memaddr) {
|
2007-10-31 01:42:07 -06:00
|
|
|
printk(KERN_WARNING "HiSax: Telekom A4T: "
|
|
|
|
"No Memory base address\n");
|
2007-07-15 17:58:24 -06:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return a4t_cs_init(card, cs, pci_memaddr);
|
|
|
|
}
|