OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [isdn/] [hisax/] [avm_a1.c] - Blame information for rev 1772

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
/* $Id: avm_a1.c,v 1.1 2005-12-20 10:17:01 jcastillo Exp $
2
 
3
 * avm_a1.c     low level stuff for AVM A1 (Fritz) isdn cards
4
 *
5
 * Author       Karsten Keil (keil@isdn4linux.de)
6
 *
7
 *
8
 * $Log: not supported by cvs2svn $
9
 * Revision 1.1.1.1  2001/09/10 07:44:18  simons
10
 * Initial import
11
 *
12
 * Revision 1.1.1.1  2001/07/02 17:58:32  simons
13
 * Initial revision
14
 *
15
 * Revision 1.6.2.12  1998/11/03 00:05:44  keil
16
 * certification related changes
17
 * fixed logging for smaller stack use
18
 *
19
 * Revision 1.6.2.11  1998/09/27 13:05:30  keil
20
 * Apply most changes from 2.1.X (HiSax 3.1)
21
 *
22
 * Revision 1.6.2.10  1998/05/27 18:04:50  keil
23
 * HiSax 3.0
24
 *
25
 * Revision 1.6.2.9  1998/04/08 21:58:39  keil
26
 * New init code
27
 *
28
 * Revision 1.6.2.8  1998/01/27 22:37:49  keil
29
 * fast io
30
 *
31
 * Revision 1.6.2.7  1998/01/13 23:06:11  keil
32
 * really disable internal timer
33
 *
34
 * Revision 1.6.2.6  1998/01/02 06:49:01  calle
35
 * Perodic timer of A1 now disabled, no need for linux driver.
36
 *
37
 * Revision 1.6.2.5  1997/11/15 18:50:41  keil
38
 * new common init function
39
 *
40
 * Revision 1.6.2.4  1997/10/17 22:13:29  keil
41
 * update to last hisax version
42
 *
43
 * Revision 2.1  1997/07/27 21:47:13  keil
44
 * new interface structures
45
 *
46
 * Revision 2.0  1997/06/26 11:02:48  keil
47
 * New Layer and card interface
48
 *
49
 * Revision 1.6  1997/04/13 19:54:07  keil
50
 * Change in IRQ check delay for SMP
51
 *
52
 * Revision 1.5  1997/04/06 22:54:10  keil
53
 * Using SKB's
54
 *
55
 * Revision 1.4  1997/01/27 15:50:21  keil
56
 * SMP proof,cosmetics
57
 *
58
 * Revision 1.3  1997/01/21 22:14:20  keil
59
 * cleanups
60
 *
61
 * Revision 1.2  1996/10/27 22:07:31  keil
62
 * cosmetic changes
63
 *
64
 * Revision 1.1  1996/10/13 20:04:49  keil
65
 * Initial revision
66
 *
67
 *
68
 */
69
#define __NO_VERSION__
70
#include "hisax.h"
71
#include "isac.h"
72
#include "hscx.h"
73
#include "isdnl1.h"
74
 
75
extern const char *CardType[];
76
static const char *avm_revision = "$Revision: 1.1 $";
77
 
78
#define  AVM_A1_STAT_ISAC       0x01
79
#define  AVM_A1_STAT_HSCX       0x02
80
#define  AVM_A1_STAT_TIMER      0x04
81
 
82
#define byteout(addr,val) outb(val,addr)
83
#define bytein(addr) inb(addr)
84
 
85
static inline u_char
86
readreg(unsigned int adr, u_char off)
87
{
88
        return (bytein(adr + off));
89
}
90
 
91
static inline void
92
writereg(unsigned int adr, u_char off, u_char data)
93
{
94
        byteout(adr + off, data);
95
}
96
 
97
 
98
static inline void
99
read_fifo(unsigned int adr, u_char * data, int size)
100
{
101
        insb(adr, data, size);
102
}
103
 
104
static void
105
write_fifo(unsigned int adr, u_char * data, int size)
106
{
107
        outsb(adr, data, size);
108
}
109
 
110
/* Interface functions */
111
 
112
static u_char
113
ReadISAC(struct IsdnCardState *cs, u_char offset)
114
{
115
        return (readreg(cs->hw.avm.isac, offset));
116
}
117
 
118
static void
119
WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
120
{
121
        writereg(cs->hw.avm.isac, offset, value);
122
}
123
 
124
static void
125
ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
126
{
127
        read_fifo(cs->hw.avm.isacfifo, data, size);
128
}
129
 
130
static void
131
WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
132
{
133
        write_fifo(cs->hw.avm.isacfifo, data, size);
134
}
135
 
136
static u_char
137
ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
138
{
139
        return (readreg(cs->hw.avm.hscx[hscx], offset));
140
}
141
 
142
static void
143
WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
144
{
145
        writereg(cs->hw.avm.hscx[hscx], offset, value);
146
}
147
 
148
/*
149
 * fast interrupt HSCX stuff goes here
150
 */
151
 
152
#define READHSCX(cs, nr, reg) readreg(cs->hw.avm.hscx[nr], reg)
153
#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.avm.hscx[nr], reg, data)
154
#define READHSCXFIFO(cs, nr, ptr, cnt) read_fifo(cs->hw.avm.hscxfifo[nr], ptr, cnt)
155
#define WRITEHSCXFIFO(cs, nr, ptr, cnt) write_fifo(cs->hw.avm.hscxfifo[nr], ptr, cnt)
156
 
157
#include "hscx_irq.c"
158
 
159
static void
160
avm_a1_interrupt(int intno, void *dev_id, struct pt_regs *regs)
161
{
162
        struct IsdnCardState *cs = dev_id;
163
        u_char val, sval, stat = 0;
164
 
165
        if (!cs) {
166
                printk(KERN_WARNING "AVM A1: Spurious interrupt!\n");
167
                return;
168
        }
169
        while (((sval = bytein(cs->hw.avm.cfg_reg)) & 0xf) != 0x7) {
170
                if (!(sval & AVM_A1_STAT_TIMER)) {
171
                        byteout(cs->hw.avm.cfg_reg, 0x1E);
172
                        sval = bytein(cs->hw.avm.cfg_reg);
173
                } else if (cs->debug & L1_DEB_INTSTAT)
174
                        debugl1(cs, "avm IntStatus %x", sval);
175
                if (!(sval & AVM_A1_STAT_HSCX)) {
176
                        val = readreg(cs->hw.avm.hscx[1], HSCX_ISTA);
177
                        if (val) {
178
                                hscx_int_main(cs, val);
179
                                stat |= 1;
180
                        }
181
                }
182
                if (!(sval & AVM_A1_STAT_ISAC)) {
183
                        val = readreg(cs->hw.avm.isac, ISAC_ISTA);
184
                        if (val) {
185
                                isac_interrupt(cs, val);
186
                                stat |= 2;
187
                        }
188
                }
189
        }
190
        if (stat & 1) {
191
                writereg(cs->hw.avm.hscx[0], HSCX_MASK, 0xFF);
192
                writereg(cs->hw.avm.hscx[1], HSCX_MASK, 0xFF);
193
                writereg(cs->hw.avm.hscx[0], HSCX_MASK, 0x0);
194
                writereg(cs->hw.avm.hscx[1], HSCX_MASK, 0x0);
195
        }
196
        if (stat & 2) {
197
                writereg(cs->hw.avm.isac, ISAC_MASK, 0xFF);
198
                writereg(cs->hw.avm.isac, ISAC_MASK, 0x0);
199
        }
200
}
201
 
202
inline static void
203
release_ioregs(struct IsdnCardState *cs, int mask)
204
{
205
        release_region(cs->hw.avm.cfg_reg, 8);
206
        if (mask & 1)
207
                release_region(cs->hw.avm.isac + 32, 32);
208
        if (mask & 2)
209
                release_region(cs->hw.avm.isacfifo, 1);
210
        if (mask & 4)
211
                release_region(cs->hw.avm.hscx[0] + 32, 32);
212
        if (mask & 8)
213
                release_region(cs->hw.avm.hscxfifo[0], 1);
214
        if (mask & 0x10)
215
                release_region(cs->hw.avm.hscx[1] + 32, 32);
216
        if (mask & 0x20)
217
                release_region(cs->hw.avm.hscxfifo[1], 1);
218
}
219
 
220
static int
221
AVM_card_msg(struct IsdnCardState *cs, int mt, void *arg)
222
{
223
        switch (mt) {
224
                case CARD_RESET:
225
                        return(0);
226
                case CARD_RELEASE:
227
                        release_ioregs(cs, 0x3f);
228
                        return(0);
229
                case CARD_SETIRQ:
230
                        return(request_irq(cs->irq, &avm_a1_interrupt,
231
                                        I4L_IRQ_FLAG, "HiSax", cs));
232
                case CARD_INIT:
233
                        inithscxisac(cs, 1);
234
                        byteout(cs->hw.avm.cfg_reg, 0x16);
235
                        byteout(cs->hw.avm.cfg_reg, 0x1E);
236
                        inithscxisac(cs, 2);
237
                        return(0);
238
                case CARD_TEST:
239
                        return(0);
240
        }
241
        return(0);
242
}
243
 
244
__initfunc(int
245
setup_avm_a1(struct IsdnCard *card))
246
{
247
        u_char val;
248
        struct IsdnCardState *cs = card->cs;
249
        long flags;
250
        char tmp[64];
251
 
252
        strcpy(tmp, avm_revision);
253
        printk(KERN_INFO "HiSax: AVM driver Rev. %s\n", HiSax_getrev(tmp));
254
        if (cs->typ != ISDN_CTYPE_A1)
255
                return (0);
256
 
257
        cs->hw.avm.cfg_reg = card->para[1] + 0x1800;
258
        cs->hw.avm.isac = card->para[1] + 0x1400 - 0x20;
259
        cs->hw.avm.hscx[0] = card->para[1] + 0x400 - 0x20;
260
        cs->hw.avm.hscx[1] = card->para[1] + 0xc00 - 0x20;
261
        cs->hw.avm.isacfifo = card->para[1] + 0x1000;
262
        cs->hw.avm.hscxfifo[0] = card->para[1];
263
        cs->hw.avm.hscxfifo[1] = card->para[1] + 0x800;
264
        cs->irq = card->para[0];
265
        if (check_region((cs->hw.avm.cfg_reg), 8)) {
266
                printk(KERN_WARNING
267
                       "HiSax: %s config port %x-%x already in use\n",
268
                       CardType[card->typ],
269
                       cs->hw.avm.cfg_reg,
270
                       cs->hw.avm.cfg_reg + 8);
271
                return (0);
272
        } else {
273
                request_region(cs->hw.avm.cfg_reg, 8, "avm cfg");
274
        }
275
        if (check_region((cs->hw.avm.isac + 32), 32)) {
276
                printk(KERN_WARNING
277
                       "HiSax: %s isac ports %x-%x already in use\n",
278
                       CardType[cs->typ],
279
                       cs->hw.avm.isac + 32,
280
                       cs->hw.avm.isac + 64);
281
                release_ioregs(cs, 0);
282
                return (0);
283
        } else {
284
                request_region(cs->hw.avm.isac + 32, 32, "HiSax isac");
285
        }
286
        if (check_region((cs->hw.avm.isacfifo), 1)) {
287
                printk(KERN_WARNING
288
                       "HiSax: %s isac fifo port %x already in use\n",
289
                       CardType[cs->typ],
290
                       cs->hw.avm.isacfifo);
291
                release_ioregs(cs, 1);
292
                return (0);
293
        } else {
294
                request_region(cs->hw.avm.isacfifo, 1, "HiSax isac fifo");
295
        }
296
        if (check_region((cs->hw.avm.hscx[0]) + 32, 32)) {
297
                printk(KERN_WARNING
298
                       "HiSax: %s hscx A ports %x-%x already in use\n",
299
                       CardType[cs->typ],
300
                       cs->hw.avm.hscx[0] + 32,
301
                       cs->hw.avm.hscx[0] + 64);
302
                release_ioregs(cs, 3);
303
                return (0);
304
        } else {
305
                request_region(cs->hw.avm.hscx[0] + 32, 32, "HiSax hscx A");
306
        }
307
        if (check_region(cs->hw.avm.hscxfifo[0], 1)) {
308
                printk(KERN_WARNING
309
                       "HiSax: %s hscx A fifo port %x already in use\n",
310
                       CardType[cs->typ],
311
                       cs->hw.avm.hscxfifo[0]);
312
                release_ioregs(cs, 7);
313
                return (0);
314
        } else {
315
                request_region(cs->hw.avm.hscxfifo[0], 1, "HiSax hscx A fifo");
316
        }
317
        if (check_region(cs->hw.avm.hscx[1] + 32, 32)) {
318
                printk(KERN_WARNING
319
                       "HiSax: %s hscx B ports %x-%x already in use\n",
320
                       CardType[cs->typ],
321
                       cs->hw.avm.hscx[1] + 32,
322
                       cs->hw.avm.hscx[1] + 64);
323
                release_ioregs(cs, 0xf);
324
                return (0);
325
        } else {
326
                request_region(cs->hw.avm.hscx[1] + 32, 32, "HiSax hscx B");
327
        }
328
        if (check_region(cs->hw.avm.hscxfifo[1], 1)) {
329
                printk(KERN_WARNING
330
                       "HiSax: %s hscx B fifo port %x already in use\n",
331
                       CardType[cs->typ],
332
                       cs->hw.avm.hscxfifo[1]);
333
                release_ioregs(cs, 0x1f);
334
                return (0);
335
        } else {
336
                request_region(cs->hw.avm.hscxfifo[1], 1, "HiSax hscx B fifo");
337
        }
338
        save_flags(flags);
339
        byteout(cs->hw.avm.cfg_reg, 0x0);
340
        sti();
341
        HZDELAY(HZ / 5 + 1);
342
        byteout(cs->hw.avm.cfg_reg, 0x1);
343
        HZDELAY(HZ / 5 + 1);
344
        byteout(cs->hw.avm.cfg_reg, 0x0);
345
        HZDELAY(HZ / 5 + 1);
346
        val = cs->irq;
347
        if (val == 9)
348
                val = 2;
349
        byteout(cs->hw.avm.cfg_reg + 1, val);
350
        HZDELAY(HZ / 5 + 1);
351
        byteout(cs->hw.avm.cfg_reg, 0x0);
352
        HZDELAY(HZ / 5 + 1);
353
        restore_flags(flags);
354
 
355
        val = bytein(cs->hw.avm.cfg_reg);
356
        printk(KERN_INFO "AVM A1: Byte at %x is %x\n",
357
               cs->hw.avm.cfg_reg, val);
358
        val = bytein(cs->hw.avm.cfg_reg + 3);
359
        printk(KERN_INFO "AVM A1: Byte at %x is %x\n",
360
               cs->hw.avm.cfg_reg + 3, val);
361
        val = bytein(cs->hw.avm.cfg_reg + 2);
362
        printk(KERN_INFO "AVM A1: Byte at %x is %x\n",
363
               cs->hw.avm.cfg_reg + 2, val);
364
        val = bytein(cs->hw.avm.cfg_reg);
365
        printk(KERN_INFO "AVM A1: Byte at %x is %x\n",
366
               cs->hw.avm.cfg_reg, val);
367
 
368
        printk(KERN_INFO
369
               "HiSax: %s config irq:%d cfg:0x%X\n",
370
               CardType[cs->typ], cs->irq,
371
               cs->hw.avm.cfg_reg);
372
        printk(KERN_INFO
373
               "HiSax: isac:0x%X/0x%X\n",
374
               cs->hw.avm.isac + 32, cs->hw.avm.isacfifo);
375
        printk(KERN_INFO
376
               "HiSax: hscx A:0x%X/0x%X  hscx B:0x%X/0x%X\n",
377
               cs->hw.avm.hscx[0] + 32, cs->hw.avm.hscxfifo[0],
378
               cs->hw.avm.hscx[1] + 32, cs->hw.avm.hscxfifo[1]);
379
 
380
        cs->readisac = &ReadISAC;
381
        cs->writeisac = &WriteISAC;
382
        cs->readisacfifo = &ReadISACfifo;
383
        cs->writeisacfifo = &WriteISACfifo;
384
        cs->BC_Read_Reg = &ReadHSCX;
385
        cs->BC_Write_Reg = &WriteHSCX;
386
        cs->BC_Send_Data = &hscx_fill_fifo;
387
        cs->cardmsg = &AVM_card_msg;
388
        ISACVersion(cs, "AVM A1:");
389
        if (HscxVersion(cs, "AVM A1:")) {
390
                printk(KERN_WARNING
391
                       "AVM A1: wrong HSCX versions check IO address\n");
392
                release_ioregs(cs, 0x3f);
393
                return (0);
394
        }
395
        return (1);
396
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.