📄 elsa.c
字号:
/* $Id: elsa.c,v 2.26.6.1 2000/11/28 12:02:46 kai Exp $ * * elsa.c low level stuff for Elsa isdn cards * * Author Karsten Keil (keil@isdn4linux.de) * * This file is (c) under GNU PUBLIC LICENSE * For changes and modifications please read * ../../../Documentation/isdn/HiSax.cert * * Thanks to Elsa GmbH for documents and informations * * Klaus Lichtenwalder (Klaus.Lichtenwalder@WebForum.DE) * for ELSA PCMCIA support * */#define __NO_VERSION__#include <linux/init.h>#include <linux/config.h>#include "hisax.h"#include "arcofi.h"#include "isac.h"#include "ipac.h"#include "hscx.h"#include "isdnl1.h"#include <linux/pci.h>#include <linux/serial.h>#include <linux/serial_reg.h>extern const char *CardType[];const char *Elsa_revision = "$Revision: 2.26.6.1 $";const char *Elsa_Types[] ={"None", "PC", "PCC-8", "PCC-16", "PCF", "PCF-Pro", "PCMCIA", "QS 1000", "QS 3000", "Microlink PCI", "QS 3000 PCI", "PCMCIA-IPAC" };const char *ITACVer[] ={"?0?", "?1?", "?2?", "?3?", "?4?", "V2.2", "B1", "A1"};#define byteout(addr,val) outb(val,addr)#define bytein(addr) inb(addr)#define ELSA_ISAC 0#define ELSA_ISAC_PCM 1#define ELSA_ITAC 1#define ELSA_HSCX 2#define ELSA_ALE 3#define ELSA_ALE_PCM 4#define ELSA_CONTROL 4#define ELSA_CONFIG 5#define ELSA_START_TIMER 6#define ELSA_TRIG_IRQ 7#define ELSA_PC 1#define ELSA_PCC8 2#define ELSA_PCC16 3#define ELSA_PCF 4#define ELSA_PCFPRO 5#define ELSA_PCMCIA 6#define ELSA_QS1000 7#define ELSA_QS3000 8#define ELSA_QS1000PCI 9#define ELSA_QS3000PCI 10#define ELSA_PCMCIA_IPAC 11/* PCI stuff */#define ELSA_PCI_IRQ_MASK 0x04/* ITAC Registeradressen (only Microlink PC) */#define ITAC_SYS 0x34#define ITAC_ISEN 0x48#define ITAC_RFIE 0x4A#define ITAC_XFIE 0x4C#define ITAC_SCIE 0x4E#define ITAC_STIE 0x46/*** *** *** Makros als Befehle fuer die Kartenregister *** *** (mehrere Befehle werden durch Bit-Oderung kombiniert) *** *** ***//* Config-Register (Read) */#define ELSA_TIMER_RUN 0x02 /* Bit 1 des Config-Reg */#define ELSA_TIMER_RUN_PCC8 0x01 /* Bit 0 des Config-Reg bei PCC */#define ELSA_IRQ_IDX 0x38 /* Bit 3,4,5 des Config-Reg */#define ELSA_IRQ_IDX_PCC8 0x30 /* Bit 4,5 des Config-Reg */#define ELSA_IRQ_IDX_PC 0x0c /* Bit 2,3 des Config-Reg *//* Control-Register (Write) */#define ELSA_LINE_LED 0x02 /* Bit 1 Gelbe LED */#define ELSA_STAT_LED 0x08 /* Bit 3 Gruene LED */#define ELSA_ISDN_RESET 0x20 /* Bit 5 Reset-Leitung */#define ELSA_ENA_TIMER_INT 0x80 /* Bit 7 Freigabe Timer Interrupt *//* ALE-Register (Read) */#define ELSA_HW_RELEASE 0x07 /* Bit 0-2 Hardwarerkennung */#define ELSA_S0_POWER_BAD 0x08 /* Bit 3 S0-Bus Spannung fehlt *//* Status Flags */#define ELSA_TIMER_AKTIV 1#define ELSA_BAD_PWR 2#define ELSA_ASSIGN 4#define RS_ISR_PASS_LIMIT 256#define _INLINE_ inline#define FLG_MODEM_ACTIVE 1/* IPAC AUX */#define ELSA_IPAC_LINE_LED 0x40 /* Bit 6 Gelbe LED */#define ELSA_IPAC_STAT_LED 0x80 /* Bit 7 Gruene LED */#if ARCOFI_USEstatic struct arcofi_msg ARCOFI_XOP_F = {NULL,0,2,{0xa1,0x3f,0,0,0,0,0,0,0,0}}; /* Normal OP */static struct arcofi_msg ARCOFI_XOP_1 = {&ARCOFI_XOP_F,0,2,{0xa1,0x31,0,0,0,0,0,0,0,0}}; /* PWR UP */static struct arcofi_msg ARCOFI_SOP_F = {&ARCOFI_XOP_1,0,10,{0xa1,0x1f,0x00,0x50,0x10,0x00,0x00,0x80,0x02,0x12}};static struct arcofi_msg ARCOFI_COP_9 = {&ARCOFI_SOP_F,0,10,{0xa1,0x29,0x80,0xcb,0xe9,0x88,0x00,0xc8,0xd8,0x80}}; /* RX */static struct arcofi_msg ARCOFI_COP_8 = {&ARCOFI_COP_9,0,10,{0xa1,0x28,0x49,0x31,0x8,0x13,0x6e,0x88,0x2a,0x61}}; /* TX */static struct arcofi_msg ARCOFI_COP_7 = {&ARCOFI_COP_8,0,4,{0xa1,0x27,0x80,0x80,0,0,0,0,0,0}}; /* GZ */static struct arcofi_msg ARCOFI_COP_6 = {&ARCOFI_COP_7,0,6,{0xa1,0x26,0,0,0x82,0x7c,0,0,0,0}}; /* GRL GRH */static struct arcofi_msg ARCOFI_COP_5 = {&ARCOFI_COP_6,0,4,{0xa1,0x25,0xbb,0x4a,0,0,0,0,0,0}}; /* GTX */static struct arcofi_msg ARCOFI_VERSION = {NULL,1,2,{0xa0,0,0,0,0,0,0,0,0,0}};static struct arcofi_msg ARCOFI_XOP_0 = {NULL,0,2,{0xa1,0x30,0,0,0,0,0,0,0,0}}; /* PWR Down */static void set_arcofi(struct IsdnCardState *cs, int bc);#include "elsa_ser.c"#endif /* ARCOFI_USE */static inline u_charreadreg(unsigned int ale, unsigned int adr, u_char off){ register u_char ret; long flags; save_flags(flags); cli(); byteout(ale, off); ret = bytein(adr); restore_flags(flags); return (ret);}static inline voidreadfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size){ /* fifo read without cli because it's allready done */ byteout(ale, off); insb(adr, data, size);}static inline voidwritereg(unsigned int ale, unsigned int adr, u_char off, u_char data){ long flags; save_flags(flags); cli(); byteout(ale, off); byteout(adr, data); restore_flags(flags);}static inline voidwritefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size){ /* fifo write without cli because it's allready done */ byteout(ale, off); outsb(adr, data, size);}/* Interface functions */static u_charReadISAC(struct IsdnCardState *cs, u_char offset){ return (readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset));}static voidWriteISAC(struct IsdnCardState *cs, u_char offset, u_char value){ writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset, value);}static voidReadISACfifo(struct IsdnCardState *cs, u_char * data, int size){ readfifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0, data, size);}static voidWriteISACfifo(struct IsdnCardState *cs, u_char * data, int size){ writefifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0, data, size);}static u_charReadISAC_IPAC(struct IsdnCardState *cs, u_char offset){ return (readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset+0x80));}static voidWriteISAC_IPAC(struct IsdnCardState *cs, u_char offset, u_char value){ writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset|0x80, value);}static voidReadISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size){ readfifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0x80, data, size);}static voidWriteISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size){ writefifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0x80, data, size);}static u_charReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset){ return (readreg(cs->hw.elsa.ale, cs->hw.elsa.hscx, offset + (hscx ? 0x40 : 0)));}static voidWriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value){ writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, offset + (hscx ? 0x40 : 0), value);}static inline u_charreaditac(struct IsdnCardState *cs, u_char off){ register u_char ret; long flags; save_flags(flags); cli(); byteout(cs->hw.elsa.ale, off); ret = bytein(cs->hw.elsa.itac); restore_flags(flags); return (ret);}static inline voidwriteitac(struct IsdnCardState *cs, u_char off, u_char data){ long flags; save_flags(flags); cli(); byteout(cs->hw.elsa.ale, off); byteout(cs->hw.elsa.itac, data); restore_flags(flags);}static inline intTimerRun(struct IsdnCardState *cs){ register u_char v; v = bytein(cs->hw.elsa.cfg); if ((cs->subtyp == ELSA_QS1000) || (cs->subtyp == ELSA_QS3000)) return (0 == (v & ELSA_TIMER_RUN)); else if (cs->subtyp == ELSA_PCC8) return (v & ELSA_TIMER_RUN_PCC8); return (v & ELSA_TIMER_RUN);}/* * fast interrupt HSCX stuff goes here */#define READHSCX(cs, nr, reg) readreg(cs->hw.elsa.ale, \ cs->hw.elsa.hscx, reg + (nr ? 0x40 : 0))#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.elsa.ale, \ cs->hw.elsa.hscx, reg + (nr ? 0x40 : 0), data)#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.elsa.ale, \ cs->hw.elsa.hscx, (nr ? 0x40 : 0), ptr, cnt)#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.elsa.ale, \ cs->hw.elsa.hscx, (nr ? 0x40 : 0), ptr, cnt)#include "hscx_irq.c"static voidelsa_interrupt(int intno, void *dev_id, struct pt_regs *regs){ struct IsdnCardState *cs = dev_id; u_char val; int icnt=5; if (!cs) { printk(KERN_WARNING "Elsa: Spurious interrupt!\n"); return; } if ((cs->typ == ISDN_CTYPE_ELSA_PCMCIA) && (*cs->busy_flag == 1)) { /* The card tends to generate interrupts while being removed causing us to just crash the kernel. bad. */ printk(KERN_WARNING "Elsa: card not available!\n"); return; }#if ARCOFI_USE if (cs->hw.elsa.MFlag) { val = serial_inp(cs, UART_IIR); if (!(val & UART_IIR_NO_INT)) { debugl1(cs,"IIR %02x", val); rs_interrupt_elsa(intno, cs); } }#endif val = readreg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_ISTA + 0x40); Start_HSCX: if (val) { hscx_int_main(cs, val); } val = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_ISTA); Start_ISAC: if (val) { isac_interrupt(cs, val); } val = readreg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_ISTA + 0x40); if (val && icnt) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "HSCX IntStat after IntRoutine"); icnt--; goto Start_HSCX; } val = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_ISTA); if (val && icnt) { if (cs->debug & L1_DEB_ISAC) debugl1(cs, "ISAC IntStat after IntRoutine"); icnt--; goto Start_ISAC; } if (!icnt) printk(KERN_WARNING"ELSA IRQ LOOP\n"); writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK, 0xFF); writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK + 0x40, 0xFF); writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_MASK, 0xFF); if (cs->hw.elsa.status & ELSA_TIMER_AKTIV) { if (!TimerRun(cs)) { /* Timer Restart */ byteout(cs->hw.elsa.timer, 0); cs->hw.elsa.counter++; } }#if ARCOFI_USE if (cs->hw.elsa.MFlag) { val = serial_inp(cs, UART_MCR); val ^= 0x8; serial_outp(cs, UART_MCR, val); val = serial_inp(cs, UART_MCR); val ^= 0x8; serial_outp(cs, UART_MCR, val); }#endif if (cs->hw.elsa.trig) byteout(cs->hw.elsa.trig, 0x00); writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK, 0x0); writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK + 0x40, 0x0); writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_MASK, 0x0);}static voidelsa_interrupt_ipac(int intno, void *dev_id, struct pt_regs *regs){ struct IsdnCardState *cs = dev_id; u_char ista,val;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -