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/] [sportster.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/* $Id: sportster.c,v 1.1.1.1 2001-09-10 07:44:19 simons Exp $
2
 
3
 * sportster.c     low level stuff for USR Sportster internal TA
4
 *
5
 * Author       Karsten Keil (keil@temic-ech.spacenet.de)
6
 *
7
 * Thanks to Christian "naddy" Weisgerber (3Com, US Robotics) for documentation
8
 *
9
 * $Log: not supported by cvs2svn $
10
 * Revision 1.1.1.1  2001/07/02 17:58:32  simons
11
 * Initial revision
12
 *
13
 * Revision 1.1.2.4  1998/04/08 21:58:46  keil
14
 * New init code
15
 *
16
 * Revision 1.1.2.3  1998/01/27 22:37:31  keil
17
 * fast io
18
 *
19
 * Revision 1.1.2.2  1997/11/15 18:50:57  keil
20
 * new common init function
21
 *
22
 * Revision 1.1.2.1  1997/10/17 22:10:58  keil
23
 * new files on 2.0
24
 *
25
 */
26
#define __NO_VERSION__
27
#include "hisax.h"
28
#include "isac.h"
29
#include "hscx.h"
30
#include "isdnl1.h"
31
 
32
extern const char *CardType[];
33
const char *sportster_revision = "$Revision: 1.1.1.1 $";
34
 
35
#define byteout(addr,val) outb(val,addr)
36
#define bytein(addr) inb(addr)
37
 
38
#define  SPORTSTER_ISAC         0xC000
39
#define  SPORTSTER_HSCXA        0x0000
40
#define  SPORTSTER_HSCXB        0x4000
41
#define  SPORTSTER_RES_IRQ      0x8000
42
#define  SPORTSTER_RESET        0x80
43
#define  SPORTSTER_INTE         0x40
44
 
45
static inline int
46
calc_off(unsigned int base, unsigned int off)
47
{
48
        return(base + ((off & 0xfc)<<8) + ((off & 3)<<1));
49
}
50
 
51
static inline void
52
read_fifo(unsigned int adr, u_char * data, int size)
53
{
54
        insb(adr, data, size);
55
}
56
 
57
static void
58
write_fifo(unsigned int adr, u_char * data, int size)
59
{
60
        outsb(adr, data, size);
61
}
62
 
63
/* Interface functions */
64
 
65
static u_char
66
ReadISAC(struct IsdnCardState *cs, u_char offset)
67
{
68
        return (bytein(calc_off(cs->hw.spt.isac, offset)));
69
}
70
 
71
static void
72
WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
73
{
74
        byteout(calc_off(cs->hw.spt.isac, offset), value);
75
}
76
 
77
static void
78
ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
79
{
80
        read_fifo(cs->hw.spt.isac, data, size);
81
}
82
 
83
static void
84
WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
85
{
86
        write_fifo(cs->hw.spt.isac, data, size);
87
}
88
 
89
static u_char
90
ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
91
{
92
        return (bytein(calc_off(cs->hw.spt.hscx[hscx], offset)));
93
}
94
 
95
static void
96
WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
97
{
98
        byteout(calc_off(cs->hw.spt.hscx[hscx], offset), value);
99
}
100
 
101
/*
102
 * fast interrupt HSCX stuff goes here
103
 */
104
 
105
#define READHSCX(cs, nr, reg) bytein(calc_off(cs->hw.spt.hscx[nr], reg))
106
#define WRITEHSCX(cs, nr, reg, data) byteout(calc_off(cs->hw.spt.hscx[nr], reg), data)
107
#define READHSCXFIFO(cs, nr, ptr, cnt) read_fifo(cs->hw.spt.hscx[nr], ptr, cnt)
108
#define WRITEHSCXFIFO(cs, nr, ptr, cnt) write_fifo(cs->hw.spt.hscx[nr], ptr, cnt)
109
 
110
#include "hscx_irq.c"
111
 
112
static void
113
sportster_interrupt(int intno, void *dev_id, struct pt_regs *regs)
114
{
115
        struct IsdnCardState *cs = dev_id;
116
        u_char val;
117
 
118
        if (!cs) {
119
                printk(KERN_WARNING "Sportster: Spurious interrupt!\n");
120
                return;
121
        }
122
        val = READHSCX(cs, 1, HSCX_ISTA);
123
      Start_HSCX:
124
        if (val)
125
                hscx_int_main(cs, val);
126
        val = ReadISAC(cs, ISAC_ISTA);
127
      Start_ISAC:
128
        if (val)
129
                isac_interrupt(cs, val);
130
        val = READHSCX(cs, 1, HSCX_ISTA);
131
        if (val) {
132
                if (cs->debug & L1_DEB_HSCX)
133
                        debugl1(cs, "HSCX IntStat after IntRoutine");
134
                goto Start_HSCX;
135
        }
136
        val = ReadISAC(cs, ISAC_ISTA);
137
        if (val) {
138
                if (cs->debug & L1_DEB_ISAC)
139
                        debugl1(cs, "ISAC IntStat after IntRoutine");
140
                goto Start_ISAC;
141
        }
142
        /* get a new irq impulse if there any pending */
143
        bytein(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ +1);
144
}
145
 
146
void
147
release_io_sportster(struct IsdnCardState *cs)
148
{
149
        int i, adr;
150
 
151
        byteout(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ, 0);
152
        for (i=0; i<64; i++) {
153
                adr = cs->hw.spt.cfg_reg + i *1024;
154
                release_region(adr, 8);
155
        }
156
}
157
 
158
void
159
reset_sportster(struct IsdnCardState *cs)
160
{
161
        long flags;
162
 
163
        cs->hw.spt.res_irq |= SPORTSTER_RESET; /* Reset On */
164
        byteout(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ, cs->hw.spt.res_irq);
165
        save_flags(flags);
166
        sti();
167
        current->state = TASK_INTERRUPTIBLE;
168
        current->timeout = jiffies + 1;
169
        schedule();
170
        cs->hw.spt.res_irq &= ~SPORTSTER_RESET; /* Reset Off */
171
        byteout(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ, cs->hw.spt.res_irq);
172
        current->state = TASK_INTERRUPTIBLE;
173
        current->timeout = jiffies + 1;
174
        schedule();
175
        restore_flags(flags);
176
}
177
 
178
static int
179
Sportster_card_msg(struct IsdnCardState *cs, int mt, void *arg)
180
{
181
        switch (mt) {
182
                case CARD_RESET:
183
                        reset_sportster(cs);
184
                        return(0);
185
                case CARD_RELEASE:
186
                        release_io_sportster(cs);
187
                        return(0);
188
                case CARD_SETIRQ:
189
                        return(request_irq(cs->irq, &sportster_interrupt,
190
                                        I4L_IRQ_FLAG, "HiSax", cs));
191
                case CARD_INIT:
192
                        inithscxisac(cs, 1);
193
                        cs->hw.spt.res_irq |= SPORTSTER_INTE; /* IRQ On */
194
                        byteout(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ, cs->hw.spt.res_irq);
195
                        inithscxisac(cs, 2);
196
                        return(0);
197
                case CARD_TEST:
198
                        return(0);
199
        }
200
        return(0);
201
}
202
 
203
__initfunc(int
204
get_io_range(struct IsdnCardState *cs))
205
{
206
        int i, j, adr;
207
 
208
        for (i=0;i<64;i++) {
209
                adr = cs->hw.spt.cfg_reg + i *1024;
210
                if (check_region(adr, 8)) {
211
                        printk(KERN_WARNING
212
                                "HiSax: %s config port %x-%x already in use\n",
213
                                CardType[cs->typ], adr, adr + 8);
214
                        break;
215
                } else
216
                        request_region(adr, 8, "sportster");
217
        }
218
        if (i==64)
219
                return(1);
220
        else {
221
                for (j=0; j<i; j++) {
222
                        adr = cs->hw.spt.cfg_reg + j *1024;
223
                        release_region(adr, 8);
224
                }
225
                return(0);
226
        }
227
}
228
 
229
__initfunc(int
230
setup_sportster(struct IsdnCard *card))
231
{
232
        struct IsdnCardState *cs = card->cs;
233
        char tmp[64];
234
 
235
        strcpy(tmp, sportster_revision);
236
        printk(KERN_INFO "HiSax: USR Sportster driver Rev. %s\n", HiSax_getrev(tmp));
237
        if (cs->typ != ISDN_CTYPE_SPORTSTER)
238
                return (0);
239
 
240
        cs->hw.spt.cfg_reg = card->para[1];
241
        cs->irq = card->para[0];
242
        if (!get_io_range(cs))
243
                return (0);
244
        cs->hw.spt.isac = cs->hw.spt.cfg_reg + SPORTSTER_ISAC;
245
        cs->hw.spt.hscx[0] = cs->hw.spt.cfg_reg + SPORTSTER_HSCXA;
246
        cs->hw.spt.hscx[1] = cs->hw.spt.cfg_reg + SPORTSTER_HSCXB;
247
 
248
        switch(cs->irq) {
249
                case 5: cs->hw.spt.res_irq = 1;
250
                        break;
251
                case 7: cs->hw.spt.res_irq = 2;
252
                        break;
253
                case 10:cs->hw.spt.res_irq = 3;
254
                        break;
255
                case 11:cs->hw.spt.res_irq = 4;
256
                        break;
257
                case 12:cs->hw.spt.res_irq = 5;
258
                        break;
259
                case 14:cs->hw.spt.res_irq = 6;
260
                        break;
261
                case 15:cs->hw.spt.res_irq = 7;
262
                        break;
263
                default:release_io_sportster(cs);
264
                        printk(KERN_WARNING "Sportster: wrong IRQ\n");
265
                        return(0);
266
        }
267
        reset_sportster(cs);
268
        printk(KERN_INFO
269
               "HiSax: %s config irq:%d cfg:0x%X\n",
270
               CardType[cs->typ], cs->irq,
271
               cs->hw.spt.cfg_reg);
272
 
273
        cs->readisac = &ReadISAC;
274
        cs->writeisac = &WriteISAC;
275
        cs->readisacfifo = &ReadISACfifo;
276
        cs->writeisacfifo = &WriteISACfifo;
277
        cs->BC_Read_Reg = &ReadHSCX;
278
        cs->BC_Write_Reg = &WriteHSCX;
279
        cs->BC_Send_Data = &hscx_fill_fifo;
280
        cs->cardmsg = &Sportster_card_msg;
281
        ISACVersion(cs, "Sportster:");
282
        if (HscxVersion(cs, "Sportster:")) {
283
                printk(KERN_WARNING
284
                       "Sportster: wrong HSCX versions check IO address\n");
285
                release_io_sportster(cs);
286
                return (0);
287
        }
288
        return (1);
289
}

powered by: WebSVN 2.1.0

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