1998-02-02 13:32:06 +00:00
|
|
|
/* $Id$
|
|
|
|
|
1999-07-01 08:16:04 +00:00
|
|
|
* hfcscard.c low level stuff for hfcs based cards (Teles3c, ACER P10)
|
1998-02-02 13:32:06 +00:00
|
|
|
*
|
1998-11-15 23:55:28 +00:00
|
|
|
* Author Karsten Keil (keil@isdn4linux.de)
|
1998-02-02 13:32:06 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* $Log$
|
1999-09-04 06:20:07 +00:00
|
|
|
* Revision 1.4 1999/08/09 18:59:59 keil
|
|
|
|
* Fix S0 init - Thanks to Stefan Gybas
|
|
|
|
*
|
1999-08-09 18:59:59 +00:00
|
|
|
* Revision 1.3 1999/07/12 21:05:12 keil
|
|
|
|
* fix race in IRQ handling
|
|
|
|
* added watchdog for lost IRQs
|
|
|
|
*
|
1999-07-12 21:05:34 +00:00
|
|
|
* Revision 1.2 1999/07/01 08:16:03 keil
|
|
|
|
* teles3c ---> hfcscard
|
|
|
|
*
|
1998-02-02 13:32:06 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define __NO_VERSION__
|
|
|
|
#include "hisax.h"
|
|
|
|
#include "hfc_2bds0.h"
|
|
|
|
#include "isdnl1.h"
|
|
|
|
|
|
|
|
extern const char *CardType[];
|
|
|
|
|
1999-07-01 08:16:04 +00:00
|
|
|
static const char *hfcs_revision = "$Revision$";
|
1998-02-02 13:32:06 +00:00
|
|
|
|
|
|
|
static void
|
1999-07-01 08:16:04 +00:00
|
|
|
hfcs_interrupt(int intno, void *dev_id, struct pt_regs *regs)
|
1998-02-02 13:32:06 +00:00
|
|
|
{
|
|
|
|
struct IsdnCardState *cs = dev_id;
|
|
|
|
u_char val, stat;
|
|
|
|
|
|
|
|
if (!cs) {
|
1999-07-01 08:16:04 +00:00
|
|
|
printk(KERN_WARNING "HFCS: Spurious interrupt!\n");
|
1998-02-02 13:32:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((HFCD_ANYINT | HFCD_BUSY_NBUSY) &
|
|
|
|
(stat = cs->BC_Read_Reg(cs, HFCD_DATA, HFCD_STAT))) {
|
|
|
|
val = cs->BC_Read_Reg(cs, HFCD_DATA, HFCD_INT_S1);
|
1998-11-15 23:55:28 +00:00
|
|
|
if (cs->debug & L1_DEB_ISAC)
|
1999-07-01 08:16:04 +00:00
|
|
|
debugl1(cs, "HFCS: stat(%02x) s1(%02x)", stat, val);
|
1998-02-02 13:32:06 +00:00
|
|
|
hfc2bds0_interrupt(cs, val);
|
|
|
|
} else {
|
1998-11-15 23:55:28 +00:00
|
|
|
if (cs->debug & L1_DEB_ISAC)
|
1999-07-01 08:16:04 +00:00
|
|
|
debugl1(cs, "HFCS: irq_no_irq stat(%02x)", stat);
|
1998-02-02 13:32:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:16:04 +00:00
|
|
|
hfcs_Timer(struct IsdnCardState *cs)
|
1998-02-02 13:32:06 +00:00
|
|
|
{
|
|
|
|
cs->hw.hfcD.timer.expires = jiffies + 75;
|
|
|
|
/* WD RESET */
|
|
|
|
/* WriteReg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt | 0x80);
|
|
|
|
add_timer(&cs->hw.hfcD.timer);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-07-01 08:16:04 +00:00
|
|
|
release_io_hfcs(struct IsdnCardState *cs)
|
1998-02-02 13:32:06 +00:00
|
|
|
{
|
|
|
|
release2bds0(cs);
|
|
|
|
del_timer(&cs->hw.hfcD.timer);
|
|
|
|
if (cs->hw.hfcD.addr)
|
|
|
|
release_region(cs->hw.hfcD.addr, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:16:04 +00:00
|
|
|
reset_hfcs(struct IsdnCardState *cs)
|
1998-02-02 13:32:06 +00:00
|
|
|
{
|
|
|
|
long flags;
|
|
|
|
|
1999-07-01 08:16:04 +00:00
|
|
|
printk(KERN_INFO "HFCS: resetting card\n");
|
|
|
|
cs->hw.hfcD.cirm = HFCD_RESET;
|
|
|
|
if (cs->typ == ISDN_CTYPE_TELES3C)
|
|
|
|
cs->hw.hfcD.cirm |= HFCD_MEM8K;
|
1998-02-02 13:32:06 +00:00
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm); /* Reset On */
|
|
|
|
save_flags(flags);
|
|
|
|
sti();
|
1999-09-04 06:20:07 +00:00
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
1999-07-01 08:16:04 +00:00
|
|
|
schedule_timeout((30*HZ)/1000);
|
|
|
|
cs->hw.hfcD.cirm = 0;
|
|
|
|
if (cs->typ == ISDN_CTYPE_TELES3C)
|
|
|
|
cs->hw.hfcD.cirm |= HFCD_MEM8K;
|
1998-02-02 13:32:06 +00:00
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm); /* Reset Off */
|
1999-09-04 06:20:07 +00:00
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
1999-07-01 08:16:04 +00:00
|
|
|
schedule_timeout((10*HZ)/1000);
|
|
|
|
if (cs->typ == ISDN_CTYPE_TELES3C)
|
|
|
|
cs->hw.hfcD.cirm |= HFCD_INTB;
|
|
|
|
else if (cs->typ == ISDN_CTYPE_ACERP10)
|
|
|
|
cs->hw.hfcD.cirm |= HFCD_INTA;
|
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm);
|
1998-02-02 13:32:06 +00:00
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CLKDEL, 0x0e);
|
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_TEST, HFCD_AUTO_AWAKE); /* S/T Auto awake */
|
|
|
|
cs->hw.hfcD.ctmt = HFCD_TIM25 | HFCD_AUTO_TIMER;
|
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt);
|
|
|
|
cs->hw.hfcD.int_m2 = HFCD_IRQ_ENABLE;
|
|
|
|
cs->hw.hfcD.int_m1 = HFCD_INTS_B1TRANS | HFCD_INTS_B2TRANS |
|
|
|
|
HFCD_INTS_DTRANS | HFCD_INTS_B1REC | HFCD_INTS_B2REC |
|
|
|
|
HFCD_INTS_DREC | HFCD_INTS_L1STATE;
|
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_INT_M1, cs->hw.hfcD.int_m1);
|
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_INT_M2, cs->hw.hfcD.int_m2);
|
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_STATES, HFCD_LOAD_STATE | 2); /* HFC ST 2 */
|
|
|
|
udelay(10);
|
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_STATES, 2); /* HFC ST 2 */
|
1999-08-09 18:59:59 +00:00
|
|
|
cs->hw.hfcD.mst_m = HFCD_MASTER;
|
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_MST_MODE, cs->hw.hfcD.mst_m); /* HFC Master */
|
1998-02-02 13:32:06 +00:00
|
|
|
cs->hw.hfcD.sctrl = 0;
|
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_SCTRL, cs->hw.hfcD.sctrl);
|
|
|
|
restore_flags(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-07-01 08:16:04 +00:00
|
|
|
hfcs_card_msg(struct IsdnCardState *cs, int mt, void *arg)
|
1998-02-02 13:32:06 +00:00
|
|
|
{
|
|
|
|
long flags;
|
|
|
|
|
1998-11-15 23:55:28 +00:00
|
|
|
if (cs->debug & L1_DEB_ISAC)
|
1999-07-01 08:16:04 +00:00
|
|
|
debugl1(cs, "HFCS: card_msg %x", mt);
|
1998-02-02 13:32:06 +00:00
|
|
|
switch (mt) {
|
|
|
|
case CARD_RESET:
|
1999-07-01 08:16:04 +00:00
|
|
|
reset_hfcs(cs);
|
1998-02-02 13:32:06 +00:00
|
|
|
return(0);
|
|
|
|
case CARD_RELEASE:
|
1999-07-01 08:16:04 +00:00
|
|
|
release_io_hfcs(cs);
|
1998-02-02 13:32:06 +00:00
|
|
|
return(0);
|
1999-07-12 21:05:34 +00:00
|
|
|
case CARD_INIT:
|
1998-02-02 13:32:06 +00:00
|
|
|
cs->hw.hfcD.timer.expires = jiffies + 75;
|
|
|
|
add_timer(&cs->hw.hfcD.timer);
|
|
|
|
init2bds0(cs);
|
|
|
|
save_flags(flags);
|
|
|
|
sti();
|
1999-09-04 06:20:07 +00:00
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
1998-11-15 23:55:28 +00:00
|
|
|
schedule_timeout((80*HZ)/1000);
|
1998-02-02 13:32:06 +00:00
|
|
|
cs->hw.hfcD.ctmt |= HFCD_TIM800;
|
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt);
|
|
|
|
cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_MST_MODE, cs->hw.hfcD.mst_m);
|
|
|
|
restore_flags(flags);
|
|
|
|
return(0);
|
|
|
|
case CARD_TEST:
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
__initfunc(int
|
1999-07-01 08:16:04 +00:00
|
|
|
setup_hfcs(struct IsdnCard *card))
|
1998-02-02 13:32:06 +00:00
|
|
|
{
|
|
|
|
struct IsdnCardState *cs = card->cs;
|
|
|
|
char tmp[64];
|
|
|
|
|
1999-07-01 08:16:04 +00:00
|
|
|
strcpy(tmp, hfcs_revision);
|
|
|
|
printk(KERN_INFO "HiSax: HFC-S driver Rev. %s\n", HiSax_getrev(tmp));
|
1998-02-02 13:32:06 +00:00
|
|
|
cs->hw.hfcD.addr = card->para[1] & 0xfffe;
|
|
|
|
cs->irq = card->para[0];
|
|
|
|
cs->hw.hfcD.cip = 0;
|
|
|
|
cs->hw.hfcD.int_s1 = 0;
|
|
|
|
cs->hw.hfcD.send = NULL;
|
|
|
|
cs->bcs[0].hw.hfc.send = NULL;
|
|
|
|
cs->bcs[1].hw.hfc.send = NULL;
|
|
|
|
cs->hw.hfcD.dfifosize = 512;
|
1999-07-01 08:16:04 +00:00
|
|
|
cs->dc.hfcd.ph_state = 0;
|
1998-02-02 13:32:06 +00:00
|
|
|
cs->hw.hfcD.fifo = 255;
|
1999-07-01 08:16:04 +00:00
|
|
|
if (cs->typ == ISDN_CTYPE_TELES3C) {
|
|
|
|
cs->hw.hfcD.bfifosize = 1024 + 512;
|
|
|
|
} else if (cs->typ == ISDN_CTYPE_ACERP10) {
|
|
|
|
cs->hw.hfcD.bfifosize = 7*1024 + 512;
|
|
|
|
} else
|
|
|
|
return (0);
|
1998-02-02 13:32:06 +00:00
|
|
|
if (check_region((cs->hw.hfcD.addr), 2)) {
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"HiSax: %s config port %x-%x already in use\n",
|
|
|
|
CardType[card->typ],
|
|
|
|
cs->hw.hfcD.addr,
|
|
|
|
cs->hw.hfcD.addr + 2);
|
|
|
|
return (0);
|
|
|
|
} else {
|
1999-07-01 08:16:04 +00:00
|
|
|
request_region(cs->hw.hfcD.addr, 2, "HFCS isdn");
|
1998-02-02 13:32:06 +00:00
|
|
|
}
|
|
|
|
printk(KERN_INFO
|
1999-07-01 08:16:04 +00:00
|
|
|
"HFCS: defined at 0x%x IRQ %d HZ %d\n",
|
1998-02-02 13:32:06 +00:00
|
|
|
cs->hw.hfcD.addr,
|
|
|
|
cs->irq, HZ);
|
1999-07-01 08:16:04 +00:00
|
|
|
if (cs->typ == ISDN_CTYPE_TELES3C) {
|
|
|
|
/* Teles 16.3c IO ADR is 0x200 | YY0U (YY Bit 15/14 address) */
|
|
|
|
outb(0x00, cs->hw.hfcD.addr);
|
|
|
|
outb(0x56, cs->hw.hfcD.addr | 1);
|
|
|
|
} else if (cs->typ == ISDN_CTYPE_ACERP10) {
|
|
|
|
/* Acer P10 IO ADR is 0x300 */
|
|
|
|
outb(0x00, cs->hw.hfcD.addr);
|
|
|
|
outb(0x57, cs->hw.hfcD.addr | 1);
|
|
|
|
}
|
1998-02-02 13:32:06 +00:00
|
|
|
set_cs_func(cs);
|
1999-07-01 08:16:04 +00:00
|
|
|
cs->hw.hfcD.timer.function = (void *) hfcs_Timer;
|
1998-02-02 13:32:06 +00:00
|
|
|
cs->hw.hfcD.timer.data = (long) cs;
|
|
|
|
init_timer(&cs->hw.hfcD.timer);
|
1999-07-01 08:16:04 +00:00
|
|
|
reset_hfcs(cs);
|
|
|
|
cs->cardmsg = &hfcs_card_msg;
|
1999-07-12 21:05:34 +00:00
|
|
|
cs->irq_func = &hfcs_interrupt;
|
1998-02-02 13:32:06 +00:00
|
|
|
return (1);
|
|
|
|
}
|