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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [uclinux/] [uClinux-2.0.x/] [drivers/] [isdn/] [hisax/] [mic.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/* $Id: mic.c,v 1.1.1.1 2001-09-10 07:44:18 simons Exp $
2
 
3
 * mic.c  low level stuff for mic cards
4
 *
5
 * Copyright (C) 1997
6
 *
7
 * Author  Stephan von Krawczynski <skraw@ithnet.com>
8
 *
9
 *
10
 * $Log: not supported by cvs2svn $
11
 * Revision 1.1.1.1  2001/07/02 17:58:32  simons
12
 * Initial revision
13
 *
14
 * Revision 1.1.2.5  1998/04/08 21:58:43  keil
15
 * New init code
16
 *
17
 * Revision 1.1.2.4  1998/02/17 15:39:20  keil
18
 * fix reset problem
19
 *
20
 * Revision 1.1.2.3  1998/01/27 22:37:25  keil
21
 * fast io
22
 *
23
 * Revision 1.1.2.2  1997/11/15 18:50:54  keil
24
 * new common init function
25
 *
26
 * Revision 1.1.2.1  1997/10/17 22:10:54  keil
27
 * new files on 2.0
28
 *
29
 *
30
 */
31
 
32
#define __NO_VERSION__
33
#include "hisax.h"
34
#include "isac.h"
35
#include "hscx.h"
36
#include "isdnl1.h"
37
 
38
extern const char *CardType[];
39
 
40
const char *mic_revision = "$Revision: 1.1.1.1 $";
41
 
42
#define byteout(addr,val) outb(val,addr)
43
#define bytein(addr) inb(addr)
44
 
45
#define MIC_ISAC        2
46
#define MIC_HSCX        1
47
#define MIC_ADR         7
48
 
49
/* CARD_ADR (Write) */
50
#define MIC_RESET      0x3      /* same as DOS driver */
51
 
52
static inline u_char
53
readreg(unsigned int ale, unsigned int adr, u_char off)
54
{
55
        register u_char ret;
56
        long flags;
57
 
58
        save_flags(flags);
59
        cli();
60
        byteout(ale, off);
61
        ret = bytein(adr);
62
        restore_flags(flags);
63
 
64
        return (ret);
65
}
66
 
67
static inline void
68
readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
69
{
70
        /* fifo read without cli because it's allready done  */
71
 
72
        byteout(ale, off);
73
        insb(adr, data, size);
74
}
75
 
76
 
77
static inline void
78
writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
79
{
80
        long flags;
81
 
82
        save_flags(flags);
83
        cli();
84
        byteout(ale, off);
85
        byteout(adr, data);
86
        restore_flags(flags);
87
}
88
 
89
static inline void
90
writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
91
{
92
        /* fifo write without cli because it's allready done  */
93
        byteout(ale, off);
94
        outsb(adr, data, size);
95
}
96
 
97
/* Interface functions */
98
 
99
static u_char
100
ReadISAC(struct IsdnCardState *cs, u_char offset)
101
{
102
        return (readreg(cs->hw.mic.adr, cs->hw.mic.isac, offset));
103
}
104
 
105
static void
106
WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
107
{
108
        writereg(cs->hw.mic.adr, cs->hw.mic.isac, offset, value);
109
}
110
 
111
static void
112
ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
113
{
114
        readfifo(cs->hw.mic.adr, cs->hw.mic.isac, 0, data, size);
115
}
116
 
117
static void
118
WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
119
{
120
        writefifo(cs->hw.mic.adr, cs->hw.mic.isac, 0, data, size);
121
}
122
 
123
static u_char
124
ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
125
{
126
        return (readreg(cs->hw.mic.adr,
127
                        cs->hw.mic.hscx, offset + (hscx ? 0x40 : 0)));
128
}
129
 
130
static void
131
WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
132
{
133
        writereg(cs->hw.mic.adr,
134
                 cs->hw.mic.hscx, offset + (hscx ? 0x40 : 0), value);
135
}
136
 
137
/*
138
 * fast interrupt HSCX stuff goes here
139
 */
140
 
141
#define READHSCX(cs, nr, reg) readreg(cs->hw.mic.adr, \
142
                cs->hw.mic.hscx, reg + (nr ? 0x40 : 0))
143
#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.mic.adr, \
144
                cs->hw.mic.hscx, reg + (nr ? 0x40 : 0), data)
145
 
146
#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.mic.adr, \
147
                cs->hw.mic.hscx, (nr ? 0x40 : 0), ptr, cnt)
148
 
149
#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.mic.adr, \
150
                cs->hw.mic.hscx, (nr ? 0x40 : 0), ptr, cnt)
151
 
152
#include "hscx_irq.c"
153
 
154
static void
155
mic_interrupt(int intno, void *dev_id, struct pt_regs *regs)
156
{
157
        struct IsdnCardState *cs = dev_id;
158
        u_char val, stat = 0;
159
 
160
        if (!cs) {
161
                printk(KERN_WARNING "mic: Spurious interrupt!\n");
162
                return;
163
        }
164
        val = readreg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_ISTA + 0x40);
165
      Start_HSCX:
166
        if (val) {
167
                hscx_int_main(cs, val);
168
                stat |= 1;
169
        }
170
        val = readreg(cs->hw.mic.adr, cs->hw.mic.isac, ISAC_ISTA);
171
      Start_ISAC:
172
        if (val) {
173
                isac_interrupt(cs, val);
174
                stat |= 2;
175
        }
176
        val = readreg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_ISTA + 0x40);
177
        if (val) {
178
                if (cs->debug & L1_DEB_HSCX)
179
                        debugl1(cs, "HSCX IntStat after IntRoutine");
180
                goto Start_HSCX;
181
        }
182
        val = readreg(cs->hw.mic.adr, cs->hw.mic.isac, ISAC_ISTA);
183
        if (val) {
184
                if (cs->debug & L1_DEB_ISAC)
185
                        debugl1(cs, "ISAC IntStat after IntRoutine");
186
                goto Start_ISAC;
187
        }
188
        if (stat & 1) {
189
                writereg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_MASK, 0xFF);
190
                writereg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_MASK + 0x40, 0xFF);
191
                writereg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_MASK, 0x0);
192
                writereg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_MASK + 0x40, 0x0);
193
        }
194
        if (stat & 2) {
195
                writereg(cs->hw.mic.adr, cs->hw.mic.isac, ISAC_MASK, 0xFF);
196
                writereg(cs->hw.mic.adr, cs->hw.mic.isac, ISAC_MASK, 0x0);
197
        }
198
}
199
 
200
void
201
release_io_mic(struct IsdnCardState *cs)
202
{
203
        int bytecnt = 8;
204
 
205
        if (cs->hw.mic.cfg_reg)
206
                release_region(cs->hw.mic.cfg_reg, bytecnt);
207
}
208
 
209
static int
210
mic_card_msg(struct IsdnCardState *cs, int mt, void *arg)
211
{
212
        switch (mt) {
213
                case CARD_RESET:
214
                        return(0);
215
                case CARD_RELEASE:
216
                        release_io_mic(cs);
217
                        return(0);
218
                case CARD_SETIRQ:
219
                        return(request_irq(cs->irq, &mic_interrupt,
220
                                        I4L_IRQ_FLAG, "HiSax", cs));
221
                case CARD_INIT:
222
                        inithscx(cs); /* /RTSA := ISAC RST */
223
                        inithscxisac(cs, 3);
224
                        return(0);
225
                case CARD_TEST:
226
                        return(0);
227
        }
228
        return(0);
229
}
230
 
231
__initfunc(int
232
setup_mic(struct IsdnCard *card))
233
{
234
        int bytecnt;
235
        struct IsdnCardState *cs = card->cs;
236
        char tmp[64];
237
 
238
        strcpy(tmp, mic_revision);
239
        printk(KERN_INFO "HiSax: mic driver Rev. %s\n", HiSax_getrev(tmp));
240
        if (cs->typ != ISDN_CTYPE_MIC)
241
                return (0);
242
 
243
        bytecnt = 8;
244
        cs->hw.mic.cfg_reg = card->para[1];
245
        cs->irq = card->para[0];
246
        cs->hw.mic.adr = cs->hw.mic.cfg_reg + MIC_ADR;
247
        cs->hw.mic.isac = cs->hw.mic.cfg_reg + MIC_ISAC;
248
        cs->hw.mic.hscx = cs->hw.mic.cfg_reg + MIC_HSCX;
249
 
250
        if (check_region((cs->hw.mic.cfg_reg), bytecnt)) {
251
                printk(KERN_WARNING
252
                       "HiSax: %s config port %x-%x already in use\n",
253
                       CardType[card->typ],
254
                       cs->hw.mic.cfg_reg,
255
                       cs->hw.mic.cfg_reg + bytecnt);
256
                return (0);
257
        } else {
258
                request_region(cs->hw.mic.cfg_reg, bytecnt, "mic isdn");
259
        }
260
 
261
        printk(KERN_INFO
262
               "mic: defined at 0x%x IRQ %d\n",
263
               cs->hw.mic.cfg_reg,
264
               cs->irq);
265
        cs->readisac = &ReadISAC;
266
        cs->writeisac = &WriteISAC;
267
        cs->readisacfifo = &ReadISACfifo;
268
        cs->writeisacfifo = &WriteISACfifo;
269
        cs->BC_Read_Reg = &ReadHSCX;
270
        cs->BC_Write_Reg = &WriteHSCX;
271
        cs->BC_Send_Data = &hscx_fill_fifo;
272
        cs->cardmsg = &mic_card_msg;
273
        ISACVersion(cs, "mic:");
274
        if (HscxVersion(cs, "mic:")) {
275
                printk(KERN_WARNING
276
                    "mic: wrong HSCX versions check IO address\n");
277
                release_io_mic(cs);
278
                return (0);
279
        }
280
        return (1);
281
}

powered by: WebSVN 2.1.0

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