import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / drivers / isdn / hisax / gazel.c
1 /* $Id: gazel.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $
2  *
3  * low level stuff for Gazel isdn cards
4  *
5  * Author       BeWan Systems
6  *              based on source code from Karsten Keil
7  * Copyright    by BeWan Systems
8  * 
9  * This software may be used and distributed according to the terms
10  * of the GNU General Public License, incorporated herein by reference.
11  *
12  */
13
14 #include <linux/config.h>
15 #include <linux/init.h>
16 #define __NO_VERSION__
17 #include "hisax.h"
18 #include "isac.h"
19 #include "hscx.h"
20 #include "isdnl1.h"
21 #include "ipac.h"
22 #include <linux/pci.h>
23
24 extern const char *CardType[];
25 const char *gazel_revision = "$Revision: 1.1.4.1 $";
26
27 #define R647      1
28 #define R685      2
29 #define R753      3
30 #define R742      4
31
32 #define PLX_CNTRL    0x50       /* registre de controle PLX */
33 #define RESET_GAZEL  0x4
34 #define RESET_9050   0x40000000
35 #define PLX_INCSR    0x4C       /* registre d'IT du 9050 */
36 #define INT_ISAC_EN  0x8        /* 1 = enable IT isac */
37 #define INT_ISAC     0x20       /* 1 = IT isac en cours */
38 #define INT_HSCX_EN  0x1        /* 1 = enable IT hscx */
39 #define INT_HSCX     0x4        /* 1 = IT hscx en cours */
40 #define INT_PCI_EN   0x40       /* 1 = enable IT PCI */
41 #define INT_IPAC_EN  0x3        /* enable IT ipac */
42
43
44 #define byteout(addr,val) outb(val,addr)
45 #define bytein(addr) inb(addr)
46
47 static inline u_char
48 readreg(unsigned int adr, u_short off)
49 {
50         return bytein(adr + off);
51 }
52
53 static inline void
54 writereg(unsigned int adr, u_short off, u_char data)
55 {
56         byteout(adr + off, data);
57 }
58
59
60 static inline void
61 read_fifo(unsigned int adr, u_char * data, int size)
62 {
63         insb(adr, data, size);
64 }
65
66 static void
67 write_fifo(unsigned int adr, u_char * data, int size)
68 {
69         outsb(adr, data, size);
70 }
71
72 static inline u_char
73 readreg_ipac(unsigned int adr, u_short off)
74 {
75         register u_char ret;
76         long flags;
77
78         save_flags(flags);
79         cli();
80         byteout(adr, off);
81         ret = bytein(adr + 4);
82         restore_flags(flags);
83         return ret;
84 }
85
86 static inline void
87 writereg_ipac(unsigned int adr, u_short off, u_char data)
88 {
89         long flags;
90
91         save_flags(flags);
92         cli();
93         byteout(adr, off);
94         byteout(adr + 4, data);
95         restore_flags(flags);
96 }
97
98
99 static inline void
100 read_fifo_ipac(unsigned int adr, u_short off, u_char * data, int size)
101 {
102         byteout(adr, off);
103         insb(adr + 4, data, size);
104 }
105
106 static void
107 write_fifo_ipac(unsigned int adr, u_short off, u_char * data, int size)
108 {
109         byteout(adr, off);
110         outsb(adr + 4, data, size);
111 }
112
113 /* Interface functions */
114
115 static u_char
116 ReadISAC(struct IsdnCardState *cs, u_char offset)
117 {
118         u_short off2 = offset;
119
120         switch (cs->subtyp) {
121                 case R647:
122                         off2 = ((off2 << 8 & 0xf000) | (off2 & 0xf));
123                 case R685:
124                         return (readreg(cs->hw.gazel.isac, off2));
125                 case R753:
126                 case R742:
127                         return (readreg_ipac(cs->hw.gazel.ipac, 0x80 + off2));
128         }
129         return 0;
130 }
131
132 static void
133 WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
134 {
135         u_short off2 = offset;
136
137         switch (cs->subtyp) {
138                 case R647:
139                         off2 = ((off2 << 8 & 0xf000) | (off2 & 0xf));
140                 case R685:
141                         writereg(cs->hw.gazel.isac, off2, value);
142                         break;
143                 case R753:
144                 case R742:
145                         writereg_ipac(cs->hw.gazel.ipac, 0x80 + off2, value);
146                         break;
147         }
148 }
149
150 static void
151 ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
152 {
153         switch (cs->subtyp) {
154                 case R647:
155                 case R685:
156                         read_fifo(cs->hw.gazel.isacfifo, data, size);
157                         break;
158                 case R753:
159                 case R742:
160                         read_fifo_ipac(cs->hw.gazel.ipac, 0x80, data, size);
161                         break;
162         }
163 }
164
165 static void
166 WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
167 {
168         switch (cs->subtyp) {
169                 case R647:
170                 case R685:
171                         write_fifo(cs->hw.gazel.isacfifo, data, size);
172                         break;
173                 case R753:
174                 case R742:
175                         write_fifo_ipac(cs->hw.gazel.ipac, 0x80, data, size);
176                         break;
177         }
178 }
179
180 static void
181 ReadHSCXfifo(struct IsdnCardState *cs, int hscx, u_char * data, int size)
182 {
183         switch (cs->subtyp) {
184                 case R647:
185                 case R685:
186                         read_fifo(cs->hw.gazel.hscxfifo[hscx], data, size);
187                         break;
188                 case R753:
189                 case R742:
190                         read_fifo_ipac(cs->hw.gazel.ipac, hscx * 0x40, data, size);
191                         break;
192         }
193 }
194
195 static void
196 WriteHSCXfifo(struct IsdnCardState *cs, int hscx, u_char * data, int size)
197 {
198         switch (cs->subtyp) {
199                 case R647:
200                 case R685:
201                         write_fifo(cs->hw.gazel.hscxfifo[hscx], data, size);
202                         break;
203                 case R753:
204                 case R742:
205                         write_fifo_ipac(cs->hw.gazel.ipac, hscx * 0x40, data, size);
206                         break;
207         }
208 }
209
210 static u_char
211 ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
212 {
213         u_short off2 = offset;
214
215         switch (cs->subtyp) {
216                 case R647:
217                         off2 = ((off2 << 8 & 0xf000) | (off2 & 0xf));
218                 case R685:
219                         return (readreg(cs->hw.gazel.hscx[hscx], off2));
220                 case R753:
221                 case R742:
222                         return (readreg_ipac(cs->hw.gazel.ipac, hscx * 0x40 + off2));
223         }
224         return 0;
225 }
226
227 static void
228 WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
229 {
230         u_short off2 = offset;
231
232         switch (cs->subtyp) {
233                 case R647:
234                         off2 = ((off2 << 8 & 0xf000) | (off2 & 0xf));
235                 case R685:
236                         writereg(cs->hw.gazel.hscx[hscx], off2, value);
237                         break;
238                 case R753:
239                 case R742:
240                         writereg_ipac(cs->hw.gazel.ipac, hscx * 0x40 + off2, value);
241                         break;
242         }
243 }
244
245 /*
246  * fast interrupt HSCX stuff goes here
247  */
248
249 #define READHSCX(cs, nr, reg) ReadHSCX(cs, nr, reg)
250 #define WRITEHSCX(cs, nr, reg, data) WriteHSCX(cs, nr, reg, data)
251 #define READHSCXFIFO(cs, nr, ptr, cnt) ReadHSCXfifo(cs, nr, ptr, cnt)
252 #define WRITEHSCXFIFO(cs, nr, ptr, cnt) WriteHSCXfifo(cs, nr, ptr, cnt)
253
254 #include "hscx_irq.c"
255
256 static void
257 gazel_interrupt(int intno, void *dev_id, struct pt_regs *regs)
258 {
259 #define MAXCOUNT 5
260         struct IsdnCardState *cs = dev_id;
261         u_char valisac, valhscx;
262         int count = 0;
263
264         if (!cs) {
265                 printk(KERN_WARNING "Gazel: Spurious interrupt!\n");
266                 return;
267         }
268         do {
269                 valhscx = ReadHSCX(cs, 1, HSCX_ISTA);
270                 if (valhscx)
271                         hscx_int_main(cs, valhscx);
272                 valisac = ReadISAC(cs, ISAC_ISTA);
273                 if (valisac)
274                         isac_interrupt(cs, valisac);
275                 count++;
276         } while ((valhscx || valisac) && (count < MAXCOUNT));
277
278         WriteHSCX(cs, 0, HSCX_MASK, 0xFF);
279         WriteHSCX(cs, 1, HSCX_MASK, 0xFF);
280         WriteISAC(cs, ISAC_MASK, 0xFF);
281         WriteISAC(cs, ISAC_MASK, 0x0);
282         WriteHSCX(cs, 0, HSCX_MASK, 0x0);
283         WriteHSCX(cs, 1, HSCX_MASK, 0x0);
284 }
285
286
287 static void
288 gazel_interrupt_ipac(int intno, void *dev_id, struct pt_regs *regs)
289 {
290         struct IsdnCardState *cs = dev_id;
291         u_char ista, val;
292         int count = 0;
293
294         if (!cs) {
295                 printk(KERN_WARNING "Gazel: Spurious interrupt!\n");
296                 return;
297         }
298         ista = ReadISAC(cs, IPAC_ISTA - 0x80);
299         do {
300                 if (ista & 0x0f) {
301                         val = ReadHSCX(cs, 1, HSCX_ISTA);
302                         if (ista & 0x01)
303                                 val |= 0x01;
304                         if (ista & 0x04)
305                                 val |= 0x02;
306                         if (ista & 0x08)
307                                 val |= 0x04;
308                         if (val) {
309                                 hscx_int_main(cs, val);
310                         }
311                 }
312                 if (ista & 0x20) {
313                         val = 0xfe & ReadISAC(cs, ISAC_ISTA);
314                         if (val) {
315                                 isac_interrupt(cs, val);
316                         }
317                 }
318                 if (ista & 0x10) {
319                         val = 0x01;
320                         isac_interrupt(cs, val);
321                 }
322                 ista = ReadISAC(cs, IPAC_ISTA - 0x80);
323                 count++;
324         }
325         while ((ista & 0x3f) && (count < MAXCOUNT));
326
327         WriteISAC(cs, IPAC_MASK - 0x80, 0xFF);
328         WriteISAC(cs, IPAC_MASK - 0x80, 0xC0);
329 }
330 void
331 release_io_gazel(struct IsdnCardState *cs)
332 {
333         unsigned int i;
334
335         switch (cs->subtyp) {
336                 case R647:
337                         for (i = 0x0000; i < 0xC000; i += 0x1000)
338                                 release_region(i + cs->hw.gazel.hscx[0], 16);
339                         release_region(0xC000 + cs->hw.gazel.hscx[0], 1);
340                         break;
341
342                 case R685:
343                         release_region(cs->hw.gazel.hscx[0], 0x100);
344                         release_region(cs->hw.gazel.cfg_reg, 0x80);
345                         break;
346
347                 case R753:
348                         release_region(cs->hw.gazel.ipac, 0x8);
349                         release_region(cs->hw.gazel.cfg_reg, 0x80);
350                         break;
351
352                 case R742:
353                         release_region(cs->hw.gazel.ipac, 8);
354                         break;
355         }
356 }
357
358 static int
359 reset_gazel(struct IsdnCardState *cs)
360 {
361         long flags;
362         unsigned long plxcntrl, addr = cs->hw.gazel.cfg_reg;
363
364         switch (cs->subtyp) {
365                 case R647:
366                         save_flags(flags);
367                         cli();
368                         writereg(addr, 0, 0);
369                         HZDELAY(10);
370                         writereg(addr, 0, 1);
371                         HZDELAY(2);
372                         restore_flags(flags);
373                         break;
374                 case R685:
375                         plxcntrl = inl(addr + PLX_CNTRL);
376                         plxcntrl |= (RESET_9050 + RESET_GAZEL);
377                         outl(plxcntrl, addr + PLX_CNTRL);
378                         plxcntrl &= ~(RESET_9050 + RESET_GAZEL);
379                         HZDELAY(4);
380                         outl(plxcntrl, addr + PLX_CNTRL);
381                         HZDELAY(10);
382                         outb(INT_ISAC_EN + INT_HSCX_EN + INT_PCI_EN, addr + PLX_INCSR);
383                         break;
384                 case R753:
385                         plxcntrl = inl(addr + PLX_CNTRL);
386                         plxcntrl |= (RESET_9050 + RESET_GAZEL);
387                         outl(plxcntrl, addr + PLX_CNTRL);
388                         plxcntrl &= ~(RESET_9050 + RESET_GAZEL);
389                         WriteISAC(cs, IPAC_POTA2 - 0x80, 0x20);
390                         HZDELAY(4);
391                         outl(plxcntrl, addr + PLX_CNTRL);
392                         HZDELAY(10);
393                         WriteISAC(cs, IPAC_POTA2 - 0x80, 0x00);
394                         WriteISAC(cs, IPAC_ACFG - 0x80, 0xff);
395                         WriteISAC(cs, IPAC_AOE - 0x80, 0x0);
396                         WriteISAC(cs, IPAC_MASK - 0x80, 0xff);
397                         WriteISAC(cs, IPAC_CONF - 0x80, 0x1);
398                         outb(INT_IPAC_EN + INT_PCI_EN, addr + PLX_INCSR);
399                         WriteISAC(cs, IPAC_MASK - 0x80, 0xc0);
400                         break;
401                 case R742:
402                         WriteISAC(cs, IPAC_POTA2 - 0x80, 0x20);
403                         HZDELAY(4);
404                         WriteISAC(cs, IPAC_POTA2 - 0x80, 0x00);
405                         WriteISAC(cs, IPAC_ACFG - 0x80, 0xff);
406                         WriteISAC(cs, IPAC_AOE - 0x80, 0x0);
407                         WriteISAC(cs, IPAC_MASK - 0x80, 0xff);
408                         WriteISAC(cs, IPAC_CONF - 0x80, 0x1);
409                         WriteISAC(cs, IPAC_MASK - 0x80, 0xc0);
410                         break;
411         }
412         return (0);
413 }
414
415 static int
416 Gazel_card_msg(struct IsdnCardState *cs, int mt, void *arg)
417 {
418         switch (mt) {
419                 case CARD_RESET:
420                         reset_gazel(cs);
421                         return (0);
422                 case CARD_RELEASE:
423                         release_io_gazel(cs);
424                         return (0);
425                 case CARD_INIT:
426                         inithscxisac(cs, 1);
427                         if ((cs->subtyp==R647)||(cs->subtyp==R685)) {
428                                 int i;
429                                 for (i=0;i<(2+MAX_WAITING_CALLS);i++) {
430                                         cs->bcs[i].hw.hscx.tsaxr0 = 0x1f;
431                                         cs->bcs[i].hw.hscx.tsaxr1 = 0x23;
432                                 }
433                         }
434                         return (0);
435                 case CARD_TEST:
436                         return (0);
437         }
438         return (0);
439 }
440
441 static int
442 reserve_regions(struct IsdnCard *card, struct IsdnCardState *cs)
443 {
444         unsigned int i, base = 0, adr = 0, len = 0;
445
446         switch (cs->subtyp) {
447                 case R647:
448                         base = cs->hw.gazel.hscx[0];
449                         for (i = 0x0000; i < 0xC000; i += 0x1000) {
450                                 if (check_region(adr = (i + base), len = 16))
451                                         goto error;
452                         }
453                         if (check_region(adr = (0xC000 + base), len = 1))
454                                 goto error;
455
456                         for (i = 0x0000; i < 0xC000; i += 0x1000)
457                                 request_region(i + base, 16, "gazel");
458                         request_region(0xC000 + base, 1, "gazel");
459
460                         break;
461
462                 case R685:
463                         if (check_region(adr = cs->hw.gazel.hscx[0], len = 0x100))
464                                 goto error;
465                         if (check_region(adr = cs->hw.gazel.cfg_reg, len = 0x80))
466                                 goto error;
467
468                         request_region(cs->hw.gazel.hscx[0], 0x100, "gazel");
469                         request_region(cs->hw.gazel.cfg_reg, 0x80, "gazel");
470                         break;
471
472                 case R753:
473                         if (check_region(adr = cs->hw.gazel.ipac, len = 0x8))
474                                 goto error;
475                         if (check_region(adr = cs->hw.gazel.cfg_reg, len = 0x80))
476                                 goto error;
477
478                         request_region(cs->hw.gazel.ipac, 0x8, "gazel");
479                         request_region(cs->hw.gazel.cfg_reg, 0x80, "gazel");
480                         break;
481
482                 case R742:
483                         if (check_region(adr = cs->hw.gazel.ipac, len = 0x8))
484                                 goto error;
485                         request_region(cs->hw.gazel.ipac, 0x8, "gazel");
486                         break;
487         }
488
489         return 0;
490
491       error:
492         printk(KERN_WARNING "Gazel: %s io ports 0x%x-0x%x already in use\n",
493                CardType[cs->typ], adr, adr + len);
494         return 1;
495 }
496
497 static int __init
498 setup_gazelisa(struct IsdnCard *card, struct IsdnCardState *cs)
499 {
500         printk(KERN_INFO "Gazel: ISA PnP card automatic recognition\n");
501         // we got an irq parameter, assume it is an ISA card
502         // R742 decodes address even in not started...
503         // R647 returns FF if not present or not started
504         // eventually needs improvment
505         if (readreg_ipac(card->para[1], IPAC_ID) == 1)
506                 cs->subtyp = R742;
507         else
508                 cs->subtyp = R647;
509
510         cs->hw.gazel.cfg_reg = card->para[1] + 0xC000;
511         cs->hw.gazel.ipac = card->para[1];
512         cs->hw.gazel.isac = card->para[1] + 0x8000;
513         cs->hw.gazel.hscx[0] = card->para[1];
514         cs->hw.gazel.hscx[1] = card->para[1] + 0x4000;
515         cs->irq = card->para[0];
516         cs->hw.gazel.isacfifo = cs->hw.gazel.isac;
517         cs->hw.gazel.hscxfifo[0] = cs->hw.gazel.hscx[0];
518         cs->hw.gazel.hscxfifo[1] = cs->hw.gazel.hscx[1];
519
520         switch (cs->subtyp) {
521                 case R647:
522                         printk(KERN_INFO "Gazel: Card ISA R647/R648 found\n");
523                         cs->dc.isac.adf2 = 0x87;
524                         printk(KERN_INFO
525                                 "Gazel: config irq:%d isac:0x%X  cfg:0x%X\n",
526                                 cs->irq, cs->hw.gazel.isac, cs->hw.gazel.cfg_reg);
527                         printk(KERN_INFO
528                                 "Gazel: hscx A:0x%X  hscx B:0x%X\n",
529                                 cs->hw.gazel.hscx[0], cs->hw.gazel.hscx[1]);
530
531                         break;
532                 case R742:
533                         printk(KERN_INFO "Gazel: Card ISA R742 found\n");
534                         test_and_set_bit(HW_IPAC, &cs->HW_Flags);
535                         printk(KERN_INFO
536                                "Gazel: config irq:%d ipac:0x%X\n",
537                                cs->irq, cs->hw.gazel.ipac);
538                         break;
539         }
540
541         return (0);
542 }
543
544 static struct pci_dev *dev_tel __initdata = NULL;
545
546 static int __init
547 setup_gazelpci(struct IsdnCardState *cs)
548 {
549         u_int pci_ioaddr0 = 0, pci_ioaddr1 = 0;
550         u_char pci_irq = 0, found;
551         u_int nbseek, seekcard;
552
553         printk(KERN_WARNING "Gazel: PCI card automatic recognition\n");
554
555         found = 0;
556         if (!pci_present()) {
557                 printk(KERN_WARNING "Gazel: No PCI bus present\n");
558                 return 1;
559         }
560         seekcard = PCI_DEVICE_ID_PLX_R685;
561         for (nbseek = 0; nbseek < 3; nbseek++) {
562                 if ((dev_tel = pci_find_device(PCI_VENDOR_ID_PLX, seekcard, dev_tel))) {
563                         if (pci_enable_device(dev_tel))
564                                 return 1;
565                         pci_irq = dev_tel->irq;
566                         pci_ioaddr0 = pci_resource_start(dev_tel, 1);
567                         pci_ioaddr1 = pci_resource_start(dev_tel, 2);
568                         found = 1;
569                 }
570                 if (found)
571                         break;
572                 else {
573                         switch (seekcard) {
574                                 case PCI_DEVICE_ID_PLX_R685:
575                                         seekcard = PCI_DEVICE_ID_PLX_R753;
576                                         break;
577                                 case PCI_DEVICE_ID_PLX_R753:
578                                         seekcard = PCI_DEVICE_ID_PLX_DJINN_ITOO;
579                                         break;
580                         }
581                 }
582         }
583         if (!found) {
584                 printk(KERN_WARNING "Gazel: No PCI card found\n");
585                 return (1);
586         }
587         if (!pci_irq) {
588                 printk(KERN_WARNING "Gazel: No IRQ for PCI card found\n");
589                 return 1;
590         }
591         cs->hw.gazel.pciaddr[0] = pci_ioaddr0;
592         cs->hw.gazel.pciaddr[1] = pci_ioaddr1;
593
594         pci_ioaddr1 &= 0xfffe;
595         cs->hw.gazel.cfg_reg = pci_ioaddr0 & 0xfffe;
596         cs->hw.gazel.ipac = pci_ioaddr1;
597         cs->hw.gazel.isac = pci_ioaddr1 + 0x80;
598         cs->hw.gazel.hscx[0] = pci_ioaddr1;
599         cs->hw.gazel.hscx[1] = pci_ioaddr1 + 0x40;
600         cs->hw.gazel.isacfifo = cs->hw.gazel.isac;
601         cs->hw.gazel.hscxfifo[0] = cs->hw.gazel.hscx[0];
602         cs->hw.gazel.hscxfifo[1] = cs->hw.gazel.hscx[1];
603         cs->irq = pci_irq;
604         cs->irq_flags |= SA_SHIRQ;
605
606         switch (seekcard) {
607                 case PCI_DEVICE_ID_PLX_R685:
608                         printk(KERN_INFO "Gazel: Card PCI R685 found\n");
609                         cs->subtyp = R685;
610                         cs->dc.isac.adf2 = 0x87;
611                         printk(KERN_INFO
612                             "Gazel: config irq:%d isac:0x%X  cfg:0x%X\n",
613                         cs->irq, cs->hw.gazel.isac, cs->hw.gazel.cfg_reg);
614                         printk(KERN_INFO
615                                "Gazel: hscx A:0x%X  hscx B:0x%X\n",
616                              cs->hw.gazel.hscx[0], cs->hw.gazel.hscx[1]);
617                         break;
618                 case PCI_DEVICE_ID_PLX_R753:
619                 case PCI_DEVICE_ID_PLX_DJINN_ITOO:
620                         printk(KERN_INFO "Gazel: Card PCI R753 found\n");
621                         cs->subtyp = R753;
622                         test_and_set_bit(HW_IPAC, &cs->HW_Flags);
623                         printk(KERN_INFO
624                             "Gazel: config irq:%d ipac:0x%X  cfg:0x%X\n",
625                         cs->irq, cs->hw.gazel.ipac, cs->hw.gazel.cfg_reg);
626                         break;
627         }
628
629         return (0);
630 }
631
632 int __init
633 setup_gazel(struct IsdnCard *card)
634 {
635         struct IsdnCardState *cs = card->cs;
636         char tmp[64];
637         u_char val;
638
639         strcpy(tmp, gazel_revision);
640         printk(KERN_INFO "Gazel: Driver Revision %s\n", HiSax_getrev(tmp));
641
642         if (cs->typ != ISDN_CTYPE_GAZEL)
643                 return (0);
644
645         if (card->para[0]) {
646                 if (setup_gazelisa(card, cs))
647                         return (0);
648         } else {
649
650 #if CONFIG_PCI
651                 if (setup_gazelpci(cs))
652                         return (0);
653 #else
654                 printk(KERN_WARNING "Gazel: Card PCI requested and NO_PCI_BIOS, unable to config\n");
655                 return (0);
656 #endif                          /* CONFIG_PCI */
657         }
658
659         if (reserve_regions(card, cs)) {
660                 return (0);
661         }
662         if (reset_gazel(cs)) {
663                 printk(KERN_WARNING "Gazel: wrong IRQ\n");
664                 release_io_gazel(cs);
665                 return (0);
666         }
667         cs->readisac = &ReadISAC;
668         cs->writeisac = &WriteISAC;
669         cs->readisacfifo = &ReadISACfifo;
670         cs->writeisacfifo = &WriteISACfifo;
671         cs->BC_Read_Reg = &ReadHSCX;
672         cs->BC_Write_Reg = &WriteHSCX;
673         cs->BC_Send_Data = &hscx_fill_fifo;
674         cs->cardmsg = &Gazel_card_msg;
675
676         switch (cs->subtyp) {
677                 case R647:
678                 case R685:
679                         cs->irq_func = &gazel_interrupt;
680                         ISACVersion(cs, "Gazel:");
681                         if (HscxVersion(cs, "Gazel:")) {
682                                 printk(KERN_WARNING
683                                        "Gazel: wrong HSCX versions check IO address\n");
684                                 release_io_gazel(cs);
685                                 return (0);
686                         }
687                         break;
688                 case R742:
689                 case R753:
690                         cs->irq_func = &gazel_interrupt_ipac;
691                         val = ReadISAC(cs, IPAC_ID - 0x80);
692                         printk(KERN_INFO "Gazel: IPAC version %x\n", val);
693                         break;
694         }
695
696         return (1);
697 }