1 /* $Id: mic.c,v 1.7 1998/04/15 16:44:32 keil Exp $
3 * mic.c low level stuff for mic cards
7 * Author Stephan von Krawczynski <skraw@ithnet.com>
11 * Revision 1.7 1998/04/15 16:44:32 keil
14 * Revision 1.6 1998/02/17 15:39:57 keil
17 * Revision 1.5 1998/02/02 13:29:43 keil
20 * Revision 1.4 1997/11/08 21:35:51 keil
23 * Revision 1.3 1997/11/06 17:09:11 keil
26 * Revision 1.2 1997/10/29 18:51:17 keil
29 * Revision 1.1.2.1 1997/10/17 22:10:54 keil
35 #define __NO_VERSION__
41 extern const char *CardType
[];
43 const char *mic_revision
= "$Revision: 1.7 $";
45 #define byteout(addr,val) outb(val,addr)
46 #define bytein(addr) inb(addr)
52 /* CARD_ADR (Write) */
53 #define MIC_RESET 0x3 /* same as DOS driver */
56 readreg(unsigned int ale
, unsigned int adr
, u_char off
)
71 readfifo(unsigned int ale
, unsigned int adr
, u_char off
, u_char
* data
, int size
)
73 /* fifo read without cli because it's allready done */
76 insb(adr
, data
, size
);
81 writereg(unsigned int ale
, unsigned int adr
, u_char off
, u_char data
)
93 writefifo(unsigned int ale
, unsigned int adr
, u_char off
, u_char
* data
, int size
)
95 /* fifo write without cli because it's allready done */
97 outsb(adr
, data
, size
);
100 /* Interface functions */
103 ReadISAC(struct IsdnCardState
*cs
, u_char offset
)
105 return (readreg(cs
->hw
.mic
.adr
, cs
->hw
.mic
.isac
, offset
));
109 WriteISAC(struct IsdnCardState
*cs
, u_char offset
, u_char value
)
111 writereg(cs
->hw
.mic
.adr
, cs
->hw
.mic
.isac
, offset
, value
);
115 ReadISACfifo(struct IsdnCardState
*cs
, u_char
* data
, int size
)
117 readfifo(cs
->hw
.mic
.adr
, cs
->hw
.mic
.isac
, 0, data
, size
);
121 WriteISACfifo(struct IsdnCardState
*cs
, u_char
* data
, int size
)
123 writefifo(cs
->hw
.mic
.adr
, cs
->hw
.mic
.isac
, 0, data
, size
);
127 ReadHSCX(struct IsdnCardState
*cs
, int hscx
, u_char offset
)
129 return (readreg(cs
->hw
.mic
.adr
,
130 cs
->hw
.mic
.hscx
, offset
+ (hscx
? 0x40 : 0)));
134 WriteHSCX(struct IsdnCardState
*cs
, int hscx
, u_char offset
, u_char value
)
136 writereg(cs
->hw
.mic
.adr
,
137 cs
->hw
.mic
.hscx
, offset
+ (hscx
? 0x40 : 0), value
);
141 * fast interrupt HSCX stuff goes here
144 #define READHSCX(cs, nr, reg) readreg(cs->hw.mic.adr, \
145 cs->hw.mic.hscx, reg + (nr ? 0x40 : 0))
146 #define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.mic.adr, \
147 cs->hw.mic.hscx, reg + (nr ? 0x40 : 0), data)
149 #define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.mic.adr, \
150 cs->hw.mic.hscx, (nr ? 0x40 : 0), ptr, cnt)
152 #define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.mic.adr, \
153 cs->hw.mic.hscx, (nr ? 0x40 : 0), ptr, cnt)
155 #include "hscx_irq.c"
158 mic_interrupt(int intno
, void *dev_id
, struct pt_regs
*regs
)
160 struct IsdnCardState
*cs
= dev_id
;
161 u_char val
, stat
= 0;
164 printk(KERN_WARNING
"mic: Spurious interrupt!\n");
167 val
= readreg(cs
->hw
.mic
.adr
, cs
->hw
.mic
.hscx
, HSCX_ISTA
+ 0x40);
170 hscx_int_main(cs
, val
);
173 val
= readreg(cs
->hw
.mic
.adr
, cs
->hw
.mic
.isac
, ISAC_ISTA
);
176 isac_interrupt(cs
, val
);
179 val
= readreg(cs
->hw
.mic
.adr
, cs
->hw
.mic
.hscx
, HSCX_ISTA
+ 0x40);
181 if (cs
->debug
& L1_DEB_HSCX
)
182 debugl1(cs
, "HSCX IntStat after IntRoutine");
185 val
= readreg(cs
->hw
.mic
.adr
, cs
->hw
.mic
.isac
, ISAC_ISTA
);
187 if (cs
->debug
& L1_DEB_ISAC
)
188 debugl1(cs
, "ISAC IntStat after IntRoutine");
192 writereg(cs
->hw
.mic
.adr
, cs
->hw
.mic
.hscx
, HSCX_MASK
, 0xFF);
193 writereg(cs
->hw
.mic
.adr
, cs
->hw
.mic
.hscx
, HSCX_MASK
+ 0x40, 0xFF);
194 writereg(cs
->hw
.mic
.adr
, cs
->hw
.mic
.hscx
, HSCX_MASK
, 0x0);
195 writereg(cs
->hw
.mic
.adr
, cs
->hw
.mic
.hscx
, HSCX_MASK
+ 0x40, 0x0);
198 writereg(cs
->hw
.mic
.adr
, cs
->hw
.mic
.isac
, ISAC_MASK
, 0xFF);
199 writereg(cs
->hw
.mic
.adr
, cs
->hw
.mic
.isac
, ISAC_MASK
, 0x0);
204 release_io_mic(struct IsdnCardState
*cs
)
208 if (cs
->hw
.mic
.cfg_reg
)
209 release_region(cs
->hw
.mic
.cfg_reg
, bytecnt
);
213 mic_card_msg(struct IsdnCardState
*cs
, int mt
, void *arg
)
222 return(request_irq(cs
->irq
, &mic_interrupt
,
223 I4L_IRQ_FLAG
, "HiSax", cs
));
225 inithscx(cs
); /* /RTSA := ISAC RST */
235 setup_mic(struct IsdnCard
*card
))
238 struct IsdnCardState
*cs
= card
->cs
;
241 strcpy(tmp
, mic_revision
);
242 printk(KERN_INFO
"HiSax: mic driver Rev. %s\n", HiSax_getrev(tmp
));
243 if (cs
->typ
!= ISDN_CTYPE_MIC
)
247 cs
->hw
.mic
.cfg_reg
= card
->para
[1];
248 cs
->irq
= card
->para
[0];
249 cs
->hw
.mic
.adr
= cs
->hw
.mic
.cfg_reg
+ MIC_ADR
;
250 cs
->hw
.mic
.isac
= cs
->hw
.mic
.cfg_reg
+ MIC_ISAC
;
251 cs
->hw
.mic
.hscx
= cs
->hw
.mic
.cfg_reg
+ MIC_HSCX
;
253 if (check_region((cs
->hw
.mic
.cfg_reg
), bytecnt
)) {
255 "HiSax: %s config port %x-%x already in use\n",
258 cs
->hw
.mic
.cfg_reg
+ bytecnt
);
261 request_region(cs
->hw
.mic
.cfg_reg
, bytecnt
, "mic isdn");
265 "mic: defined at 0x%x IRQ %d\n",
268 cs
->readisac
= &ReadISAC
;
269 cs
->writeisac
= &WriteISAC
;
270 cs
->readisacfifo
= &ReadISACfifo
;
271 cs
->writeisacfifo
= &WriteISACfifo
;
272 cs
->BC_Read_Reg
= &ReadHSCX
;
273 cs
->BC_Write_Reg
= &WriteHSCX
;
274 cs
->BC_Send_Data
= &hscx_fill_fifo
;
275 cs
->cardmsg
= &mic_card_msg
;
276 ISACVersion(cs
, "mic:");
277 if (HscxVersion(cs
, "mic:")) {
279 "mic: wrong HSCX versions check IO address\n");