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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
/* $Id: avm_a1p.c,v 1.1 2005-12-20 10:17:01 jcastillo Exp $
2
 *
3
 * avm_a1p.c    low level stuff for the following AVM cards:
4
 *              A1 PCMCIA
5
 *              FRITZ!Card PCMCIA
6
 *              FRITZ!Card PCMCIA 2.0
7
 *
8
 * Author       Carsten Paeth (calle@calle.in-berlin.de)
9
 *
10
 * $Log: not supported by cvs2svn $
11
 * Revision 1.1.1.1  2001/09/10 07:44:18  simons
12
 * Initial import
13
 *
14
 * Revision 1.1.1.1  2001/07/02 17:58:32  simons
15
 * Initial revision
16
 *
17
 * Revision 1.1.2.3  1998/11/03 00:05:47  keil
18
 * certification related changes
19
 * fixed logging for smaller stack use
20
 *
21
 * Revision 1.1.2.2  1998/09/27 13:05:33  keil
22
 * Apply most changes from 2.1.X (HiSax 3.1)
23
 *
24
 * Revision 1.1.2.1  1998/07/15 14:43:26  calle
25
 * Support for AVM passive PCMCIA cards:
26
 *    A1 PCMCIA, FRITZ!Card PCMCIA and FRITZ!Card PCMCIA 2.0
27
 *
28
 *
29
 */
30
#define __NO_VERSION__
31
#include "hisax.h"
32
#include "isac.h"
33
#include "hscx.h"
34
#include "isdnl1.h"
35
 
36
/* register offsets */
37
#define ADDRREG_OFFSET          0x02
38
#define DATAREG_OFFSET          0x03
39
#define ASL0_OFFSET             0x04
40
#define ASL1_OFFSET             0x05
41
#define MODREG_OFFSET           0x06
42
#define VERREG_OFFSET           0x07
43
 
44
/* address offsets */
45
#define ISAC_FIFO_OFFSET        0x00
46
#define ISAC_REG_OFFSET         0x20
47
#define HSCX_CH_DIFF            0x40
48
#define HSCX_FIFO_OFFSET        0x80
49
#define HSCX_REG_OFFSET         0xa0
50
 
51
/* read bits ASL0 */
52
#define  ASL0_R_TIMER           0x10 /* active low */
53
#define  ASL0_R_ISAC            0x20 /* active low */
54
#define  ASL0_R_HSCX            0x40 /* active low */
55
#define  ASL0_R_TESTBIT         0x80
56
#define  ASL0_R_IRQPENDING      (ASL0_R_ISAC|ASL0_R_HSCX|ASL0_R_TIMER)
57
 
58
/* write bits ASL0 */
59
#define  ASL0_W_RESET           0x01
60
#define  ASL0_W_TDISABLE        0x02
61
#define  ASL0_W_TRESET          0x04
62
#define  ASL0_W_IRQENABLE       0x08
63
#define  ASL0_W_TESTBIT         0x80
64
 
65
/* write bits ASL1 */
66
#define  ASL1_W_LED0            0x10
67
#define  ASL1_W_LED1            0x20
68
#define  ASL1_W_ENABLE_S0       0xC0
69
 
70
#define byteout(addr,val) outb(val,addr)
71
#define bytein(addr) inb(addr)
72
 
73
static const char *avm_revision = "$Revision: 1.1 $";
74
 
75
static inline u_char
76
ReadISAC(struct IsdnCardState *cs, u_char offset)
77
{
78
        long flags;
79
        u_char ret;
80
 
81
        offset -= 0x20;
82
        save_flags(flags);
83
        cli();
84
        byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET,ISAC_REG_OFFSET+offset);
85
        ret = bytein(cs->hw.avm.cfg_reg+DATAREG_OFFSET);
86
        restore_flags(flags);
87
        return ret;
88
}
89
 
90
static inline void
91
WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
92
{
93
        long flags;
94
 
95
        offset -= 0x20;
96
 
97
        save_flags(flags);
98
        cli();
99
        byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET,ISAC_REG_OFFSET+offset);
100
        byteout(cs->hw.avm.cfg_reg+DATAREG_OFFSET, value);
101
        restore_flags(flags);
102
}
103
 
104
static inline void
105
ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
106
{
107
        long flags;
108
 
109
        save_flags(flags);
110
        cli();
111
        byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET,ISAC_FIFO_OFFSET);
112
        insb(cs->hw.avm.cfg_reg+DATAREG_OFFSET, data, size);
113
        restore_flags(flags);
114
}
115
 
116
static inline void
117
WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
118
{
119
        long flags;
120
 
121
        save_flags(flags);
122
        cli();
123
        byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET,ISAC_FIFO_OFFSET);
124
        outsb(cs->hw.avm.cfg_reg+DATAREG_OFFSET, data, size);
125
        restore_flags(flags);
126
}
127
 
128
static inline u_char
129
ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
130
{
131
        u_char ret;
132
        long flags;
133
 
134
        offset -= 0x20;
135
 
136
        save_flags(flags);
137
        cli();
138
        byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET,
139
                        HSCX_REG_OFFSET+hscx*HSCX_CH_DIFF+offset);
140
        ret = bytein(cs->hw.avm.cfg_reg+DATAREG_OFFSET);
141
        restore_flags(flags);
142
        return ret;
143
}
144
 
145
static inline void
146
WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
147
{
148
        long flags;
149
 
150
        offset -= 0x20;
151
 
152
        save_flags(flags);
153
        cli();
154
        byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET,
155
                        HSCX_REG_OFFSET+hscx*HSCX_CH_DIFF+offset);
156
        byteout(cs->hw.avm.cfg_reg+DATAREG_OFFSET, value);
157
        restore_flags(flags);
158
}
159
 
160
static inline void
161
ReadHSCXfifo(struct IsdnCardState *cs, int hscx, u_char * data, int size)
162
{
163
        long flags;
164
 
165
        save_flags(flags);
166
        cli();
167
        byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET,
168
                        HSCX_FIFO_OFFSET+hscx*HSCX_CH_DIFF);
169
        insb(cs->hw.avm.cfg_reg+DATAREG_OFFSET, data, size);
170
        restore_flags(flags);
171
}
172
 
173
static inline void
174
WriteHSCXfifo(struct IsdnCardState *cs, int hscx, u_char * data, int size)
175
{
176
        long flags;
177
 
178
        save_flags(flags);
179
        cli();
180
        byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET,
181
                        HSCX_FIFO_OFFSET+hscx*HSCX_CH_DIFF);
182
        outsb(cs->hw.avm.cfg_reg+DATAREG_OFFSET, data, size);
183
        restore_flags(flags);
184
}
185
 
186
/*
187
 * fast interrupt HSCX stuff goes here
188
 */
189
 
190
#define READHSCX(cs, nr, reg) ReadHSCX(cs, nr, reg)
191
#define WRITEHSCX(cs, nr, reg, data) WriteHSCX(cs, nr, reg, data)
192
#define READHSCXFIFO(cs, nr, ptr, cnt) ReadHSCXfifo(cs, nr, ptr, cnt) 
193
#define WRITEHSCXFIFO(cs, nr, ptr, cnt) WriteHSCXfifo(cs, nr, ptr, cnt)
194
 
195
#include "hscx_irq.c"
196
 
197
static void
198
avm_a1p_interrupt(int intno, void *dev_id, struct pt_regs *regs)
199
{
200
        struct IsdnCardState *cs = dev_id;
201
        u_char val, sval, stat = 0;
202
 
203
        if (!cs) {
204
                printk(KERN_WARNING "AVM A1 PCMCIA: Spurious interrupt!\n");
205
                return;
206
        }
207
        while ((sval = (~bytein(cs->hw.avm.cfg_reg+ASL0_OFFSET) & ASL0_R_IRQPENDING))) {
208
                if (cs->debug & L1_DEB_INTSTAT)
209
                        debugl1(cs, "avm IntStatus %x", sval);
210
                if (sval & ASL0_R_HSCX) {
211
                        val = ReadHSCX(cs, 1, HSCX_ISTA);
212
                        if (val) {
213
                                hscx_int_main(cs, val);
214
                                stat |= 1;
215
                        }
216
                }
217
                if (sval & ASL0_R_ISAC) {
218
                        val = ReadISAC(cs, ISAC_ISTA);
219
                        if (val) {
220
                                isac_interrupt(cs, val);
221
                                stat |= 2;
222
                        }
223
                }
224
        }
225
        if (stat & 1) {
226
                WriteHSCX(cs, 0, HSCX_MASK, 0xff);
227
                WriteHSCX(cs, 1, HSCX_MASK, 0xff);
228
                WriteHSCX(cs, 0, HSCX_MASK, 0x00);
229
                WriteHSCX(cs, 1, HSCX_MASK, 0x00);
230
        }
231
        if (stat & 2) {
232
                WriteISAC(cs, ISAC_MASK, 0xff);
233
                WriteISAC(cs, ISAC_MASK, 0x00);
234
        }
235
}
236
 
237
static int
238
AVM_card_msg(struct IsdnCardState *cs, int mt, void *arg)
239
{
240
        int ret;
241
        switch (mt) {
242
                case CARD_RESET:
243
                        byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,0x00);
244
                        HZDELAY(HZ / 5 + 1);
245
                        byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,ASL0_W_RESET);
246
                        HZDELAY(HZ / 5 + 1);
247
                        byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,0x00);
248
                        return 0;
249
 
250
                case CARD_RELEASE:
251
                        /* free_irq is done in HiSax_closecard(). */
252
                        /* free_irq(cs->irq, cs); */
253
                        return 0;
254
 
255
                case CARD_SETIRQ:
256
                        ret = request_irq(cs->irq, &avm_a1p_interrupt,
257
                                        I4L_IRQ_FLAG, "HiSax", cs);
258
                        if (ret)
259
                                return ret;
260
                        byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,
261
                                ASL0_W_TDISABLE|ASL0_W_TRESET|ASL0_W_IRQENABLE);
262
                        return 0;
263
 
264
                case CARD_INIT:
265
                        clear_pending_isac_ints(cs);
266
                        clear_pending_hscx_ints(cs);
267
                        inithscxisac(cs, 1);
268
                        inithscxisac(cs, 2);
269
                        return 0;
270
 
271
                case CARD_TEST:
272
                        /* we really don't need it for the PCMCIA Version */
273
                        return 0;
274
 
275
                default:
276
                        /* all card drivers ignore others, so we do the same */
277
                        return 0;
278
        }
279
        return 0;
280
}
281
 
282
__initfunc(int
283
setup_avm_a1_pcmcia(struct IsdnCard *card))
284
{
285
        u_char model, vers;
286
        struct IsdnCardState *cs = card->cs;
287
        long flags;
288
        char tmp[64];
289
 
290
 
291
        strcpy(tmp, avm_revision);
292
        printk(KERN_INFO "HiSax: AVM A1 PCMCIA driver Rev. %s\n",
293
                                                 HiSax_getrev(tmp));
294
        if (cs->typ != ISDN_CTYPE_A1_PCMCIA)
295
                return (0);
296
 
297
        cs->hw.avm.cfg_reg = card->para[1];
298
        cs->irq = card->para[0];
299
 
300
 
301
        save_flags(flags);
302
        outb(cs->hw.avm.cfg_reg+ASL1_OFFSET, ASL1_W_ENABLE_S0);
303
        sti();
304
 
305
        byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,0x00);
306
        HZDELAY(HZ / 5 + 1);
307
        byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,ASL0_W_RESET);
308
        HZDELAY(HZ / 5 + 1);
309
        byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,0x00);
310
 
311
        byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET, ASL0_W_TDISABLE|ASL0_W_TRESET);
312
 
313
        restore_flags(flags);
314
 
315
        model = bytein(cs->hw.avm.cfg_reg+MODREG_OFFSET);
316
        vers = bytein(cs->hw.avm.cfg_reg+VERREG_OFFSET);
317
 
318
        printk(KERN_INFO "AVM A1 PCMCIA: io 0x%x irq %d model %d version %d\n",
319
                                cs->hw.avm.cfg_reg, cs->irq, model, vers);
320
 
321
        cs->readisac = &ReadISAC;
322
        cs->writeisac = &WriteISAC;
323
        cs->readisacfifo = &ReadISACfifo;
324
        cs->writeisacfifo = &WriteISACfifo;
325
        cs->BC_Read_Reg = &ReadHSCX;
326
        cs->BC_Write_Reg = &WriteHSCX;
327
        cs->BC_Send_Data = &hscx_fill_fifo;
328
        cs->cardmsg = &AVM_card_msg;
329
 
330
        ISACVersion(cs, "AVM A1 PCMCIA:");
331
        if (HscxVersion(cs, "AVM A1 PCMCIA:")) {
332
                printk(KERN_WARNING
333
                       "AVM A1 PCMCIA: wrong HSCX versions check IO address\n");
334
                return (0);
335
        }
336
        return (1);
337
}

powered by: WebSVN 2.1.0

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