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

Subversion Repositories or1k

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

powered by: WebSVN 2.1.0

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