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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
/* $Id: teles0.c,v 1.1 2005-12-20 10:17:01 jcastillo Exp $
2
 
3
 * teles0.c     low level stuff for Teles Memory IO isdn cards
4
 *              based on the teles driver from Jan den Ouden
5
 *
6
 * Author       Karsten Keil (keil@temic-ech.spacenet.de)
7
 *
8
 * Thanks to    Jan den Ouden
9
 *              Fritz Elfert
10
 *              Beat Doebeli
11
 *
12
 * $Log: not supported by cvs2svn $
13
 * Revision 1.1.1.1  2001/09/10 07:44:19  simons
14
 * Initial import
15
 *
16
 * Revision 1.1.1.1  2001/07/02 17:58:32  simons
17
 * Initial revision
18
 *
19
 * Revision 1.8.2.9  1998/04/08 21:58:49  keil
20
 * New init code
21
 *
22
 * Revision 1.8.2.8  1998/03/07 23:15:40  tsbogend
23
 * made HiSax working on Linux/Alpha
24
 *
25
 * Revision 1.8.2.7  1998/02/03 23:17:16  keil
26
 * IRQ 9
27
 *
28
 * Revision 1.8.2.6  1998/01/27 22:37:43  keil
29
 * fast io
30
 *
31
 * Revision 1.8.2.5  1997/11/15 18:51:00  keil
32
 * new common init function
33
 *
34
 * Revision 1.8.2.4  1997/10/17 22:14:26  keil
35
 * update to last hisax version
36
 *
37
 * Revision 2.1  1997/07/27 21:47:10  keil
38
 * new interface structures
39
 *
40
 * Revision 2.0  1997/06/26 11:02:43  keil
41
 * New Layer and card interface
42
 *
43
 * Revision 1.8  1997/04/13 19:54:04  keil
44
 * Change in IRQ check delay for SMP
45
 *
46
 * Revision 1.7  1997/04/06 22:54:04  keil
47
 * Using SKB's
48
 *
49
 * removed old log info /KKe
50
 *
51
 */
52
#define __NO_VERSION__
53
#include "hisax.h"
54
#include "isdnl1.h"
55
#include "isac.h"
56
#include "hscx.h"
57
 
58
extern const char *CardType[];
59
 
60
const char *teles0_revision = "$Revision: 1.1 $";
61
 
62
#define byteout(addr,val) outb(val,addr)
63
#define bytein(addr) inb(addr)
64
 
65
static inline u_char
66
readisac(unsigned int adr, u_char off)
67
{
68
        return readb(adr + ((off & 1) ? 0x2ff : 0x100) + off);
69
}
70
 
71
static inline void
72
writeisac(unsigned int adr, u_char off, u_char data)
73
{
74
        writeb(data, adr + ((off & 1) ? 0x2ff : 0x100) + off); mb();
75
}
76
 
77
 
78
static inline u_char
79
readhscx(unsigned int adr, int hscx, u_char off)
80
{
81
        return readb(adr + (hscx ? 0x1c0 : 0x180) +
82
                     ((off & 1) ? 0x1ff : 0) + off);
83
}
84
 
85
static inline void
86
writehscx(unsigned int adr, int hscx, u_char off, u_char data)
87
{
88
        writeb(data, adr + (hscx ? 0x1c0 : 0x180) +
89
               ((off & 1) ? 0x1ff : 0) + off); mb();
90
}
91
 
92
static inline void
93
read_fifo_isac(unsigned int adr, u_char * data, int size)
94
{
95
        register int i;
96
        register u_char *ad = (u_char *) ((long)adr + 0x100);
97
        for (i = 0; i < size; i++)
98
                data[i] = readb(ad);
99
}
100
 
101
static inline void
102
write_fifo_isac(unsigned int adr, u_char * data, int size)
103
{
104
        register int i;
105
        register u_char *ad = (u_char *) ((long)adr + 0x100);
106
        for (i = 0; i < size; i++) {
107
                writeb(data[i], ad); mb();
108
        }
109
}
110
 
111
static inline void
112
read_fifo_hscx(unsigned int adr, int hscx, u_char * data, int size)
113
{
114
        register int i;
115
        register u_char *ad = (u_char *) ((long)adr + (hscx ? 0x1c0 : 0x180));
116
        for (i = 0; i < size; i++)
117
                data[i] = readb(ad);
118
}
119
 
120
static inline void
121
write_fifo_hscx(unsigned int adr, int hscx, u_char * data, int size)
122
{
123
        int i;
124
        register u_char *ad = (u_char *) ((long)adr + (hscx ? 0x1c0 : 0x180));
125
        for (i = 0; i < size; i++) {
126
                writeb(data[i], ad); mb();
127
        }
128
}
129
 
130
/* Interface functions */
131
 
132
static u_char
133
ReadISAC(struct IsdnCardState *cs, u_char offset)
134
{
135
        return (readisac(cs->hw.teles0.membase, offset));
136
}
137
 
138
static void
139
WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
140
{
141
        writeisac(cs->hw.teles0.membase, offset, value);
142
}
143
 
144
static void
145
ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
146
{
147
        read_fifo_isac(cs->hw.teles0.membase, data, size);
148
}
149
 
150
static void
151
WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
152
{
153
        write_fifo_isac(cs->hw.teles0.membase, data, size);
154
}
155
 
156
static u_char
157
ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
158
{
159
        return (readhscx(cs->hw.teles0.membase, hscx, offset));
160
}
161
 
162
static void
163
WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
164
{
165
        writehscx(cs->hw.teles0.membase, hscx, offset, value);
166
}
167
 
168
/*
169
 * fast interrupt HSCX stuff goes here
170
 */
171
 
172
#define READHSCX(cs, nr, reg) readhscx(cs->hw.teles0.membase, nr, reg)
173
#define WRITEHSCX(cs, nr, reg, data) writehscx(cs->hw.teles0.membase, nr, reg, data)
174
#define READHSCXFIFO(cs, nr, ptr, cnt) read_fifo_hscx(cs->hw.teles0.membase, nr, ptr, cnt)
175
#define WRITEHSCXFIFO(cs, nr, ptr, cnt) write_fifo_hscx(cs->hw.teles0.membase, nr, ptr, cnt)
176
 
177
#include "hscx_irq.c"
178
 
179
static void
180
teles0_interrupt(int intno, void *dev_id, struct pt_regs *regs)
181
{
182
        struct IsdnCardState *cs = dev_id;
183
        u_char val, stat = 0;
184
        int count = 0;
185
 
186
        if (!cs) {
187
                printk(KERN_WARNING "Teles0: Spurious interrupt!\n");
188
                return;
189
        }
190
        val = readhscx(cs->hw.teles0.membase, 1, HSCX_ISTA);
191
      Start_HSCX:
192
        if (val) {
193
                hscx_int_main(cs, val);
194
                stat |= 1;
195
        }
196
        val = readisac(cs->hw.teles0.membase, ISAC_ISTA);
197
      Start_ISAC:
198
        if (val) {
199
                isac_interrupt(cs, val);
200
                stat |= 2;
201
        }
202
        count++;
203
        val = readhscx(cs->hw.teles0.membase, 1, HSCX_ISTA);
204
        if (val && count < 20) {
205
                if (cs->debug & L1_DEB_HSCX)
206
                        debugl1(cs, "HSCX IntStat after IntRoutine");
207
                goto Start_HSCX;
208
        }
209
        val = readisac(cs->hw.teles0.membase, ISAC_ISTA);
210
        if (val && count < 20) {
211
                if (cs->debug & L1_DEB_ISAC)
212
                        debugl1(cs, "ISAC IntStat after IntRoutine");
213
                goto Start_ISAC;
214
        }
215
        if (stat & 1) {
216
                writehscx(cs->hw.teles0.membase, 0, HSCX_MASK, 0xFF);
217
                writehscx(cs->hw.teles0.membase, 1, HSCX_MASK, 0xFF);
218
                writehscx(cs->hw.teles0.membase, 0, HSCX_MASK, 0x0);
219
                writehscx(cs->hw.teles0.membase, 1, HSCX_MASK, 0x0);
220
        }
221
        if (stat & 2) {
222
                writeisac(cs->hw.teles0.membase, ISAC_MASK, 0xFF);
223
                writeisac(cs->hw.teles0.membase, ISAC_MASK, 0x0);
224
        }
225
}
226
 
227
void
228
release_io_teles0(struct IsdnCardState *cs)
229
{
230
        if (cs->hw.teles0.cfg_reg)
231
                release_region(cs->hw.teles0.cfg_reg, 8);
232
}
233
 
234
static int
235
reset_teles0(struct IsdnCardState *cs)
236
{
237
        u_char cfval;
238
        long flags;
239
 
240
        save_flags(flags);
241
        sti();
242
        if (cs->hw.teles0.cfg_reg) {
243
                switch (cs->irq) {
244
                        case 2:
245
                        case 9:
246
                                cfval = 0x00;
247
                                break;
248
                        case 3:
249
                                cfval = 0x02;
250
                                break;
251
                        case 4:
252
                                cfval = 0x04;
253
                                break;
254
                        case 5:
255
                                cfval = 0x06;
256
                                break;
257
                        case 10:
258
                                cfval = 0x08;
259
                                break;
260
                        case 11:
261
                                cfval = 0x0A;
262
                                break;
263
                        case 12:
264
                                cfval = 0x0C;
265
                                break;
266
                        case 15:
267
                                cfval = 0x0E;
268
                                break;
269
                        default:
270
                                return(1);
271
                }
272
                cfval |= ((cs->hw.teles0.membase >> 9) & 0xF0);
273
                byteout(cs->hw.teles0.cfg_reg + 4, cfval);
274
                HZDELAY(HZ / 10 + 1);
275
                byteout(cs->hw.teles0.cfg_reg + 4, cfval | 1);
276
                HZDELAY(HZ / 10 + 1);
277
        }
278
        writeb(0, cs->hw.teles0.membase + 0x80); mb();
279
        HZDELAY(HZ / 5 + 1);
280
        writeb(1, cs->hw.teles0.membase + 0x80); mb();
281
        HZDELAY(HZ / 5 + 1);
282
        restore_flags(flags);
283
        return(0);
284
}
285
 
286
static int
287
Teles_card_msg(struct IsdnCardState *cs, int mt, void *arg)
288
{
289
        switch (mt) {
290
                case CARD_RESET:
291
                        reset_teles0(cs);
292
                        return(0);
293
                case CARD_RELEASE:
294
                        release_io_teles0(cs);
295
                        return(0);
296
                case CARD_SETIRQ:
297
                        return(request_irq(cs->irq, &teles0_interrupt,
298
                                        I4L_IRQ_FLAG, "HiSax", cs));
299
                case CARD_INIT:
300
                        inithscxisac(cs, 3);
301
                        return(0);
302
                case CARD_TEST:
303
                        return(0);
304
        }
305
        return(0);
306
}
307
 
308
__initfunc(int
309
setup_teles0(struct IsdnCard *card))
310
{
311
        u_char val;
312
        struct IsdnCardState *cs = card->cs;
313
        char tmp[64];
314
 
315
        strcpy(tmp, teles0_revision);
316
        printk(KERN_INFO "HiSax: Teles 8.0/16.0 driver Rev. %s\n", HiSax_getrev(tmp));
317
        if ((cs->typ != ISDN_CTYPE_16_0) && (cs->typ != ISDN_CTYPE_8_0))
318
                return (0);
319
 
320
        if (cs->typ == ISDN_CTYPE_16_0)
321
                cs->hw.teles0.cfg_reg = card->para[2];
322
        else                    /* 8.0 */
323
                cs->hw.teles0.cfg_reg = 0;
324
 
325
        if (card->para[1] < 0x10000) {
326
                card->para[1] <<= 4;
327
                printk(KERN_INFO
328
                   "Teles0: membase configured DOSish, assuming 0x%lx\n",
329
                       (unsigned long) card->para[1]);
330
        }
331
        cs->hw.teles0.membase = card->para[1];
332
        cs->irq = card->para[0];
333
        if (cs->hw.teles0.cfg_reg) {
334
                if (check_region((cs->hw.teles0.cfg_reg), 8)) {
335
                        printk(KERN_WARNING
336
                          "HiSax: %s config port %x-%x already in use\n",
337
                               CardType[card->typ],
338
                               cs->hw.teles0.cfg_reg,
339
                               cs->hw.teles0.cfg_reg + 8);
340
                        return (0);
341
                } else {
342
                        request_region(cs->hw.teles0.cfg_reg, 8, "teles cfg");
343
                }
344
        }
345
        if (cs->hw.teles0.cfg_reg) {
346
                if ((val = bytein(cs->hw.teles0.cfg_reg + 0)) != 0x51) {
347
                        printk(KERN_WARNING "Teles0: 16.0 Byte at %x is %x\n",
348
                               cs->hw.teles0.cfg_reg + 0, val);
349
                        release_region(cs->hw.teles0.cfg_reg, 8);
350
                        return (0);
351
                }
352
                if ((val = bytein(cs->hw.teles0.cfg_reg + 1)) != 0x93) {
353
                        printk(KERN_WARNING "Teles0: 16.0 Byte at %x is %x\n",
354
                               cs->hw.teles0.cfg_reg + 1, val);
355
                        release_region(cs->hw.teles0.cfg_reg, 8);
356
                        return (0);
357
                }
358
                val = bytein(cs->hw.teles0.cfg_reg + 2);        /* 0x1e=without AB
359
                                                                   * 0x1f=with AB
360
                                                                   * 0x1c 16.3 ???
361
                                                                 */
362
                if (val != 0x1e && val != 0x1f) {
363
                        printk(KERN_WARNING "Teles0: 16.0 Byte at %x is %x\n",
364
                               cs->hw.teles0.cfg_reg + 2, val);
365
                        release_region(cs->hw.teles0.cfg_reg, 8);
366
                        return (0);
367
                }
368
        }
369
        /* 16.0 and 8.0 designed for IOM1 */
370
        test_and_set_bit(HW_IOM1, &cs->HW_Flags);
371
        printk(KERN_INFO
372
               "HiSax: %s config irq:%d mem:0x%X cfg:0x%X\n",
373
               CardType[cs->typ], cs->irq,
374
               cs->hw.teles0.membase, cs->hw.teles0.cfg_reg);
375
        if (reset_teles0(cs)) {
376
                printk(KERN_WARNING "Teles0: wrong IRQ\n");
377
                release_io_teles0(cs);
378
                return (0);
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 = &Teles_card_msg;
388
        ISACVersion(cs, "Teles0:");
389
        if (HscxVersion(cs, "Teles0:")) {
390
                printk(KERN_WARNING
391
                 "Teles0: wrong HSCX versions check IO/MEM addresses\n");
392
                release_io_teles0(cs);
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.