]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/isdn/hisax/avm_a1.c
1 /* $Id: avm_a1.c,v 2.15.2.4 2004/01/13 21:46:03 keil Exp $
3 * low level stuff for AVM A1 (Fritz) isdn cards
6 * Copyright by Karsten Keil <keil@isdn4linux.de>
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
13 #include <linux/init.h>
19 static const char *avm_revision
= "$Revision: 2.15.2.4 $";
21 #define AVM_A1_STAT_ISAC 0x01
22 #define AVM_A1_STAT_HSCX 0x02
23 #define AVM_A1_STAT_TIMER 0x04
25 #define byteout(addr, val) outb(val, addr)
26 #define bytein(addr) inb(addr)
29 readreg(unsigned int adr
, u_char off
)
31 return (bytein(adr
+ off
));
35 writereg(unsigned int adr
, u_char off
, u_char data
)
37 byteout(adr
+ off
, data
);
42 read_fifo(unsigned int adr
, u_char
*data
, int size
)
44 insb(adr
, data
, size
);
48 write_fifo(unsigned int adr
, u_char
*data
, int size
)
50 outsb(adr
, data
, size
);
53 /* Interface functions */
56 ReadISAC(struct IsdnCardState
*cs
, u_char offset
)
58 return (readreg(cs
->hw
.avm
.isac
, offset
));
62 WriteISAC(struct IsdnCardState
*cs
, u_char offset
, u_char value
)
64 writereg(cs
->hw
.avm
.isac
, offset
, value
);
68 ReadISACfifo(struct IsdnCardState
*cs
, u_char
*data
, int size
)
70 read_fifo(cs
->hw
.avm
.isacfifo
, data
, size
);
74 WriteISACfifo(struct IsdnCardState
*cs
, u_char
*data
, int size
)
76 write_fifo(cs
->hw
.avm
.isacfifo
, data
, size
);
80 ReadHSCX(struct IsdnCardState
*cs
, int hscx
, u_char offset
)
82 return (readreg(cs
->hw
.avm
.hscx
[hscx
], offset
));
86 WriteHSCX(struct IsdnCardState
*cs
, int hscx
, u_char offset
, u_char value
)
88 writereg(cs
->hw
.avm
.hscx
[hscx
], offset
, value
);
92 * fast interrupt HSCX stuff goes here
95 #define READHSCX(cs, nr, reg) readreg(cs->hw.avm.hscx[nr], reg)
96 #define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.avm.hscx[nr], reg, data)
97 #define READHSCXFIFO(cs, nr, ptr, cnt) read_fifo(cs->hw.avm.hscxfifo[nr], ptr, cnt)
98 #define WRITEHSCXFIFO(cs, nr, ptr, cnt) write_fifo(cs->hw.avm.hscxfifo[nr], ptr, cnt)
100 #include "hscx_irq.c"
103 avm_a1_interrupt(int intno
, void *dev_id
)
105 struct IsdnCardState
*cs
= dev_id
;
109 spin_lock_irqsave(&cs
->lock
, flags
);
110 while (((sval
= bytein(cs
->hw
.avm
.cfg_reg
)) & 0xf) != 0x7) {
111 if (!(sval
& AVM_A1_STAT_TIMER
)) {
112 byteout(cs
->hw
.avm
.cfg_reg
, 0x1E);
113 sval
= bytein(cs
->hw
.avm
.cfg_reg
);
114 } else if (cs
->debug
& L1_DEB_INTSTAT
)
115 debugl1(cs
, "avm IntStatus %x", sval
);
116 if (!(sval
& AVM_A1_STAT_HSCX
)) {
117 val
= readreg(cs
->hw
.avm
.hscx
[1], HSCX_ISTA
);
119 hscx_int_main(cs
, val
);
121 if (!(sval
& AVM_A1_STAT_ISAC
)) {
122 val
= readreg(cs
->hw
.avm
.isac
, ISAC_ISTA
);
124 isac_interrupt(cs
, val
);
127 writereg(cs
->hw
.avm
.hscx
[0], HSCX_MASK
, 0xFF);
128 writereg(cs
->hw
.avm
.hscx
[1], HSCX_MASK
, 0xFF);
129 writereg(cs
->hw
.avm
.isac
, ISAC_MASK
, 0xFF);
130 writereg(cs
->hw
.avm
.isac
, ISAC_MASK
, 0x0);
131 writereg(cs
->hw
.avm
.hscx
[0], HSCX_MASK
, 0x0);
132 writereg(cs
->hw
.avm
.hscx
[1], HSCX_MASK
, 0x0);
133 spin_unlock_irqrestore(&cs
->lock
, flags
);
138 release_ioregs(struct IsdnCardState
*cs
, int mask
)
140 release_region(cs
->hw
.avm
.cfg_reg
, 8);
142 release_region(cs
->hw
.avm
.isac
+ 32, 32);
144 release_region(cs
->hw
.avm
.isacfifo
, 1);
146 release_region(cs
->hw
.avm
.hscx
[0] + 32, 32);
148 release_region(cs
->hw
.avm
.hscxfifo
[0], 1);
150 release_region(cs
->hw
.avm
.hscx
[1] + 32, 32);
152 release_region(cs
->hw
.avm
.hscxfifo
[1], 1);
156 AVM_card_msg(struct IsdnCardState
*cs
, int mt
, void *arg
)
164 release_ioregs(cs
, 0x3f);
167 spin_lock_irqsave(&cs
->lock
, flags
);
169 byteout(cs
->hw
.avm
.cfg_reg
, 0x16);
170 byteout(cs
->hw
.avm
.cfg_reg
, 0x1E);
172 spin_unlock_irqrestore(&cs
->lock
, flags
);
180 int setup_avm_a1(struct IsdnCard
*card
)
183 struct IsdnCardState
*cs
= card
->cs
;
186 strcpy(tmp
, avm_revision
);
187 printk(KERN_INFO
"HiSax: AVM driver Rev. %s\n", HiSax_getrev(tmp
));
188 if (cs
->typ
!= ISDN_CTYPE_A1
)
191 cs
->hw
.avm
.cfg_reg
= card
->para
[1] + 0x1800;
192 cs
->hw
.avm
.isac
= card
->para
[1] + 0x1400 - 0x20;
193 cs
->hw
.avm
.hscx
[0] = card
->para
[1] + 0x400 - 0x20;
194 cs
->hw
.avm
.hscx
[1] = card
->para
[1] + 0xc00 - 0x20;
195 cs
->hw
.avm
.isacfifo
= card
->para
[1] + 0x1000;
196 cs
->hw
.avm
.hscxfifo
[0] = card
->para
[1];
197 cs
->hw
.avm
.hscxfifo
[1] = card
->para
[1] + 0x800;
198 cs
->irq
= card
->para
[0];
199 if (!request_region(cs
->hw
.avm
.cfg_reg
, 8, "avm cfg")) {
201 "HiSax: AVM A1 config port %x-%x already in use\n",
203 cs
->hw
.avm
.cfg_reg
+ 8);
206 if (!request_region(cs
->hw
.avm
.isac
+ 32, 32, "HiSax isac")) {
208 "HiSax: AVM A1 isac ports %x-%x already in use\n",
209 cs
->hw
.avm
.isac
+ 32,
210 cs
->hw
.avm
.isac
+ 64);
211 release_ioregs(cs
, 0);
214 if (!request_region(cs
->hw
.avm
.isacfifo
, 1, "HiSax isac fifo")) {
216 "HiSax: AVM A1 isac fifo port %x already in use\n",
217 cs
->hw
.avm
.isacfifo
);
218 release_ioregs(cs
, 1);
221 if (!request_region(cs
->hw
.avm
.hscx
[0] + 32, 32, "HiSax hscx A")) {
223 "HiSax: AVM A1 hscx A ports %x-%x already in use\n",
224 cs
->hw
.avm
.hscx
[0] + 32,
225 cs
->hw
.avm
.hscx
[0] + 64);
226 release_ioregs(cs
, 3);
229 if (!request_region(cs
->hw
.avm
.hscxfifo
[0], 1, "HiSax hscx A fifo")) {
231 "HiSax: AVM A1 hscx A fifo port %x already in use\n",
232 cs
->hw
.avm
.hscxfifo
[0]);
233 release_ioregs(cs
, 7);
236 if (!request_region(cs
->hw
.avm
.hscx
[1] + 32, 32, "HiSax hscx B")) {
238 "HiSax: AVM A1 hscx B ports %x-%x already in use\n",
239 cs
->hw
.avm
.hscx
[1] + 32,
240 cs
->hw
.avm
.hscx
[1] + 64);
241 release_ioregs(cs
, 0xf);
244 if (!request_region(cs
->hw
.avm
.hscxfifo
[1], 1, "HiSax hscx B fifo")) {
246 "HiSax: AVM A1 hscx B fifo port %x already in use\n",
247 cs
->hw
.avm
.hscxfifo
[1]);
248 release_ioregs(cs
, 0x1f);
251 byteout(cs
->hw
.avm
.cfg_reg
, 0x0);
253 byteout(cs
->hw
.avm
.cfg_reg
, 0x1);
255 byteout(cs
->hw
.avm
.cfg_reg
, 0x0);
260 byteout(cs
->hw
.avm
.cfg_reg
+ 1, val
);
262 byteout(cs
->hw
.avm
.cfg_reg
, 0x0);
265 val
= bytein(cs
->hw
.avm
.cfg_reg
);
266 printk(KERN_INFO
"AVM A1: Byte at %x is %x\n",
267 cs
->hw
.avm
.cfg_reg
, val
);
268 val
= bytein(cs
->hw
.avm
.cfg_reg
+ 3);
269 printk(KERN_INFO
"AVM A1: Byte at %x is %x\n",
270 cs
->hw
.avm
.cfg_reg
+ 3, val
);
271 val
= bytein(cs
->hw
.avm
.cfg_reg
+ 2);
272 printk(KERN_INFO
"AVM A1: Byte at %x is %x\n",
273 cs
->hw
.avm
.cfg_reg
+ 2, val
);
274 val
= bytein(cs
->hw
.avm
.cfg_reg
);
275 printk(KERN_INFO
"AVM A1: Byte at %x is %x\n",
276 cs
->hw
.avm
.cfg_reg
, val
);
278 printk(KERN_INFO
"HiSax: AVM A1 config irq:%d cfg:0x%X\n",
282 "HiSax: isac:0x%X/0x%X\n",
283 cs
->hw
.avm
.isac
+ 32, cs
->hw
.avm
.isacfifo
);
285 "HiSax: hscx A:0x%X/0x%X hscx B:0x%X/0x%X\n",
286 cs
->hw
.avm
.hscx
[0] + 32, cs
->hw
.avm
.hscxfifo
[0],
287 cs
->hw
.avm
.hscx
[1] + 32, cs
->hw
.avm
.hscxfifo
[1]);
289 cs
->readisac
= &ReadISAC
;
290 cs
->writeisac
= &WriteISAC
;
291 cs
->readisacfifo
= &ReadISACfifo
;
292 cs
->writeisacfifo
= &WriteISACfifo
;
293 cs
->BC_Read_Reg
= &ReadHSCX
;
294 cs
->BC_Write_Reg
= &WriteHSCX
;
295 cs
->BC_Send_Data
= &hscx_fill_fifo
;
297 cs
->cardmsg
= &AVM_card_msg
;
298 cs
->irq_func
= &avm_a1_interrupt
;
299 ISACVersion(cs
, "AVM A1:");
300 if (HscxVersion(cs
, "AVM A1:")) {
302 "AVM A1: wrong HSCX versions check IO address\n");
303 release_ioregs(cs
, 0x3f);