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

Subversion Repositories or1k

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

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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