1 /* $Id: sedlbauer.c,v 1.34.2.6 2004/01/24 20:47:24 keil Exp $
3 * low level stuff for Sedlbauer cards
4 * includes support for the Sedlbauer speed star (speed star II),
5 * support for the Sedlbauer speed fax+,
6 * support for the Sedlbauer ISDN-Controller PC/104 and
7 * support for the Sedlbauer speed pci
8 * derived from the original file asuscom.c from Karsten Keil
10 * Author Marcus Niemann
11 * Copyright by Marcus Niemann <niemann@www-bib.fh-bielefeld.de>
13 * This software may be used and distributed according to the terms
14 * of the GNU General Public License, incorporated herein by reference.
16 * Thanks to Karsten Keil
17 * Sedlbauer AG for informations
23 * Card: Chip: Configuration: Comment:
24 * ---------------------------------------------------------------------
25 * Speed Card ISAC_HSCX DIP-SWITCH
26 * Speed Win ISAC_HSCX ISAPNP
27 * Speed Fax+ ISAC_ISAR ISAPNP Full analog support
28 * Speed Star ISAC_HSCX CARDMGR
29 * Speed Win2 IPAC ISAPNP
30 * ISDN PC/104 IPAC DIP-SWITCH
31 * Speed Star2 IPAC CARDMGR
32 * Speed PCI IPAC PCI PNP
33 * Speed Fax+ ISAC_ISAR PCI PNP Full analog support
36 * For the sedlbauer speed fax+ to work properly you have to download
37 * the firmware onto the card.
38 * For example: hisaxctrl <DriverID> 9 ISAR.BIN
41 #include <linux/init.h>
48 #include <linux/pci.h>
49 #include <linux/isapnp.h>
51 static const char *Sedlbauer_revision = "$Revision: 1.34.2.6 $";
53 static const char *Sedlbauer_Types[] =
54 {"None", "speed card/win", "speed star", "speed fax+",
55 "speed win II / ISDN PC/104", "speed star II", "speed pci",
56 "speed fax+ pyramid", "speed fax+ pci", "HST Saphir III"};
58 #define PCI_SUBVENDOR_SPEEDFAX_PYRAMID 0x51
59 #define PCI_SUBVENDOR_HST_SAPHIR3 0x52
60 #define PCI_SUBVENDOR_SEDLBAUER_PCI 0x53
61 #define PCI_SUBVENDOR_SPEEDFAX_PCI 0x54
62 #define PCI_SUB_ID_SEDLBAUER 0x01
64 #define SEDL_SPEED_CARD_WIN 1
65 #define SEDL_SPEED_STAR 2
66 #define SEDL_SPEED_FAX 3
67 #define SEDL_SPEED_WIN2_PC104 4
68 #define SEDL_SPEED_STAR2 5
69 #define SEDL_SPEED_PCI 6
70 #define SEDL_SPEEDFAX_PYRAMID 7
71 #define SEDL_SPEEDFAX_PCI 8
74 #define SEDL_CHIP_TEST 0
75 #define SEDL_CHIP_ISAC_HSCX 1
76 #define SEDL_CHIP_ISAC_ISAR 2
77 #define SEDL_CHIP_IPAC 3
79 #define SEDL_BUS_ISA 1
80 #define SEDL_BUS_PCI 2
81 #define SEDL_BUS_PCMCIA 3
83 #define byteout(addr, val) outb(val, addr)
84 #define bytein(addr) inb(addr)
86 #define SEDL_HSCX_ISA_RESET_ON 0
87 #define SEDL_HSCX_ISA_RESET_OFF 1
88 #define SEDL_HSCX_ISA_ISAC 2
89 #define SEDL_HSCX_ISA_HSCX 3
90 #define SEDL_HSCX_ISA_ADR 4
92 #define SEDL_HSCX_PCMCIA_RESET 0
93 #define SEDL_HSCX_PCMCIA_ISAC 1
94 #define SEDL_HSCX_PCMCIA_HSCX 2
95 #define SEDL_HSCX_PCMCIA_ADR 4
97 #define SEDL_ISAR_ISA_ISAC 4
98 #define SEDL_ISAR_ISA_ISAR 6
99 #define SEDL_ISAR_ISA_ADR 8
100 #define SEDL_ISAR_ISA_ISAR_RESET_ON 10
101 #define SEDL_ISAR_ISA_ISAR_RESET_OFF 12
103 #define SEDL_IPAC_ANY_ADR 0
104 #define SEDL_IPAC_ANY_IPAC 2
106 #define SEDL_IPAC_PCI_BASE 0
107 #define SEDL_IPAC_PCI_ADR 0xc0
108 #define SEDL_IPAC_PCI_IPAC 0xc8
109 #define SEDL_ISAR_PCI_ADR 0xc8
110 #define SEDL_ISAR_PCI_ISAC 0xd0
111 #define SEDL_ISAR_PCI_ISAR 0xe0
112 #define SEDL_ISAR_PCI_ISAR_RESET_ON 0x01
113 #define SEDL_ISAR_PCI_ISAR_RESET_OFF 0x18
114 #define SEDL_ISAR_PCI_LED1 0x08
115 #define SEDL_ISAR_PCI_LED2 0x10
117 #define SEDL_RESET 0x3 /* same as DOS driver */
120 readreg(unsigned int ale, unsigned int adr, u_char off)
130 readfifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size)
133 insb(adr, data, size);
138 writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
145 writefifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size)
148 outsb(adr, data, size);
151 /* Interface functions */
154 ReadISAC(struct IsdnCardState *cs, u_char offset)
156 return (readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset));
160 WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
162 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset, value);
166 ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size)
168 readfifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0, data, size);
172 WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size)
174 writefifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0, data, size);
178 ReadISAC_IPAC(struct IsdnCardState *cs, u_char offset)
180 return (readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset | 0x80));
184 WriteISAC_IPAC(struct IsdnCardState *cs, u_char offset, u_char value)
186 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset | 0x80, value);
190 ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size)
192 readfifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0x80, data, size);
196 WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size)
198 writefifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0x80, data, size);
202 ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
204 return (readreg(cs->hw.sedl.adr,
205 cs->hw.sedl.hscx, offset + (hscx ? 0x40 : 0)));
209 WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
211 writereg(cs->hw.sedl.adr,
212 cs->hw.sedl.hscx, offset + (hscx ? 0x40 : 0), value);
215 /* ISAR access routines
216 * mode = 0 access with IRQ on
217 * mode = 1 access with IRQ off
218 * mode = 2 access with IRQ off and using last offset
222 ReadISAR(struct IsdnCardState *cs, int mode, u_char offset)
225 return (readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, offset));
227 byteout(cs->hw.sedl.adr, offset);
228 return (bytein(cs->hw.sedl.hscx));
232 WriteISAR(struct IsdnCardState *cs, int mode, u_char offset, u_char value)
235 writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, offset, value);
238 byteout(cs->hw.sedl.adr, offset);
239 byteout(cs->hw.sedl.hscx, value);
244 * fast interrupt HSCX stuff goes here
247 #define READHSCX(cs, nr, reg) readreg(cs->hw.sedl.adr, \
248 cs->hw.sedl.hscx, reg + (nr ? 0x40 : 0))
249 #define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.sedl.adr, \
250 cs->hw.sedl.hscx, reg + (nr ? 0x40 : 0), data)
252 #define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.sedl.adr, \
253 cs->hw.sedl.hscx, (nr ? 0x40 : 0), ptr, cnt)
255 #define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.sedl.adr, \
256 cs->hw.sedl.hscx, (nr ? 0x40 : 0), ptr, cnt)
258 #include "hscx_irq.c"
261 sedlbauer_interrupt(int intno, void *dev_id)
263 struct IsdnCardState *cs = dev_id;
267 spin_lock_irqsave(&cs->lock, flags);
268 if ((cs->hw.sedl.bus == SEDL_BUS_PCMCIA) && (*cs->busy_flag == 1)) {
269 /* The card tends to generate interrupts while being removed
270 causing us to just crash the kernel. bad. */
271 spin_unlock_irqrestore(&cs->lock, flags);
272 printk(KERN_WARNING "Sedlbauer: card not available!\n");
276 val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40);
279 hscx_int_main(cs, val);
280 val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA);
283 isac_interrupt(cs, val);
284 val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40);
286 if (cs->debug & L1_DEB_HSCX)
287 debugl1(cs, "HSCX IntStat after IntRoutine");
290 val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA);
292 if (cs->debug & L1_DEB_ISAC)
293 debugl1(cs, "ISAC IntStat after IntRoutine");
296 writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK, 0xFF);
297 writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK + 0x40, 0xFF);
298 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0xFF);
299 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0x0);
300 writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK, 0x0);
301 writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK + 0x40, 0x0);
302 spin_unlock_irqrestore(&cs->lock, flags);
307 sedlbauer_interrupt_ipac(int intno, void *dev_id)
309 struct IsdnCardState *cs = dev_id;
310 u_char ista, val, icnt = 5;
313 spin_lock_irqsave(&cs->lock, flags);
314 ista = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ISTA);
316 if (cs->debug & L1_DEB_IPAC)
317 debugl1(cs, "IPAC ISTA %02X", ista);
319 val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40);
327 hscx_int_main(cs, val);
330 val = 0xfe & readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA | 0x80);
332 isac_interrupt(cs, val);
337 isac_interrupt(cs, val);
339 ista = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ISTA);
340 if ((ista & 0x3f) && icnt) {
345 if (cs->debug & L1_DEB_ISAC)
346 debugl1(cs, "Sedlbauer IRQ LOOP");
347 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_MASK, 0xFF);
348 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_MASK, 0xC0);
349 spin_unlock_irqrestore(&cs->lock, flags);
354 sedlbauer_interrupt_isar(int intno, void *dev_id)
356 struct IsdnCardState *cs = dev_id;
361 spin_lock_irqsave(&cs->lock, flags);
362 val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT);
364 if (val & ISAR_IRQSTA)
366 val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA);
369 isac_interrupt(cs, val);
370 val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT);
371 if ((val & ISAR_IRQSTA) && --cnt) {
372 if (cs->debug & L1_DEB_HSCX)
373 debugl1(cs, "ISAR IntStat after IntRoutine");
376 val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA);
378 if (cs->debug & L1_DEB_ISAC)
379 debugl1(cs, "ISAC IntStat after IntRoutine");
383 if (cs->debug & L1_DEB_ISAC)
384 debugl1(cs, "Sedlbauer IRQ LOOP");
386 writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT, 0);
387 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0xFF);
388 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0x0);
389 writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT, ISAR_IRQMSK);
390 spin_unlock_irqrestore(&cs->lock, flags);
395 release_io_sedlbauer(struct IsdnCardState *cs)
399 if (cs->subtyp == SEDL_SPEED_FAX) {
401 } else if (cs->hw.sedl.bus == SEDL_BUS_PCI) {
404 if (cs->hw.sedl.cfg_reg)
405 release_region(cs->hw.sedl.cfg_reg, bytecnt);
409 reset_sedlbauer(struct IsdnCardState *cs)
411 printk(KERN_INFO "Sedlbauer: resetting card\n");
413 if (!((cs->hw.sedl.bus == SEDL_BUS_PCMCIA) &&
414 (cs->hw.sedl.chip == SEDL_CHIP_ISAC_HSCX))) {
415 if (cs->hw.sedl.chip == SEDL_CHIP_IPAC) {
416 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_POTA2, 0x20);
418 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_POTA2, 0x0);
420 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_CONF, 0x0);
421 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ACFG, 0xff);
422 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_AOE, 0x0);
423 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_MASK, 0xc0);
424 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_PCFG, 0x12);
425 } else if ((cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) &&
426 (cs->hw.sedl.bus == SEDL_BUS_PCI)) {
427 byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_on);
429 byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off);
432 byteout(cs->hw.sedl.reset_on, SEDL_RESET); /* Reset On */
434 byteout(cs->hw.sedl.reset_off, 0); /* Reset Off */
441 Sedl_card_msg(struct IsdnCardState *cs, int mt, void *arg)
447 spin_lock_irqsave(&cs->lock, flags);
449 spin_unlock_irqrestore(&cs->lock, flags);
452 if (cs->hw.sedl.bus == SEDL_BUS_PCI)
453 /* disable all IRQ */
454 byteout(cs->hw.sedl.cfg_reg + 5, 0);
455 if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) {
456 spin_lock_irqsave(&cs->lock, flags);
457 writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx,
459 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac,
462 writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx,
464 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac,
466 spin_unlock_irqrestore(&cs->lock, flags);
468 release_io_sedlbauer(cs);
471 spin_lock_irqsave(&cs->lock, flags);
472 if (cs->hw.sedl.bus == SEDL_BUS_PCI)
474 byteout(cs->hw.sedl.cfg_reg + 5, 0x02);
476 if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) {
477 clear_pending_isac_ints(cs);
478 writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx,
482 /* Reenable all IRQ */
483 cs->writeisac(cs, ISAC_MASK, 0);
484 /* RESET Receiver and Transmitter */
485 cs->writeisac(cs, ISAC_CMDR, 0x41);
489 spin_unlock_irqrestore(&cs->lock, flags);
494 if (cs->subtyp != SEDL_SPEEDFAX_PYRAMID)
496 spin_lock_irqsave(&cs->lock, flags);
498 cs->hw.sedl.reset_off &= ~SEDL_ISAR_PCI_LED2;
500 cs->hw.sedl.reset_off &= ~SEDL_ISAR_PCI_LED1;
501 byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off);
502 spin_unlock_irqrestore(&cs->lock, flags);
505 if (cs->subtyp != SEDL_SPEEDFAX_PYRAMID)
507 spin_lock_irqsave(&cs->lock, flags);
509 cs->hw.sedl.reset_off |= SEDL_ISAR_PCI_LED2;
511 cs->hw.sedl.reset_off |= SEDL_ISAR_PCI_LED1;
512 byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off);
513 spin_unlock_irqrestore(&cs->lock, flags);
520 static struct isapnp_device_id sedl_ids[] = {
521 { ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01),
522 ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01),
523 (unsigned long) "Speed win" },
524 { ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x02),
525 ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x02),
526 (unsigned long) "Speed Fax+" },
530 static struct isapnp_device_id *ipid = &sedl_ids[0];
531 static struct pnp_card *pnp_c = NULL;
533 static int setup_sedlbauer_isapnp(struct IsdnCard *card, int *bytecnt)
535 struct IsdnCardState *cs = card->cs;
536 struct pnp_dev *pnp_d;
538 if (!isapnp_present())
541 while (ipid->card_vendor) {
542 if ((pnp_c = pnp_find_card(ipid->card_vendor,
543 ipid->card_device, pnp_c))) {
545 if ((pnp_d = pnp_find_dev(pnp_c,
546 ipid->vendor, ipid->function, pnp_d))) {
549 printk(KERN_INFO "HiSax: %s detected\n",
550 (char *)ipid->driver_data);
551 pnp_disable_dev(pnp_d);
552 err = pnp_activate_dev(pnp_d);
554 printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n",
558 card->para[1] = pnp_port_start(pnp_d, 0);
559 card->para[0] = pnp_irq(pnp_d, 0);
561 if (!card->para[0] || !card->para[1]) {
562 printk(KERN_ERR "Sedlbauer PnP:some resources are missing %ld/%lx\n",
563 card->para[0], card->para[1]);
564 pnp_disable_dev(pnp_d);
567 cs->hw.sedl.cfg_reg = card->para[1];
568 cs->irq = card->para[0];
569 if (ipid->function == ISAPNP_FUNCTION(0x2)) {
570 cs->subtyp = SEDL_SPEED_FAX;
571 cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
574 cs->subtyp = SEDL_SPEED_CARD_WIN;
575 cs->hw.sedl.chip = SEDL_CHIP_TEST;
580 printk(KERN_ERR "Sedlbauer PnP: PnP error card found, no device\n");
588 printk(KERN_INFO "Sedlbauer PnP: no ISAPnP card found\n");
593 static int setup_sedlbauer_isapnp(struct IsdnCard *card, int *bytecnt)
597 #endif /* __ISAPNP__ */
600 static struct pci_dev *dev_sedl = NULL;
602 static int setup_sedlbauer_pci(struct IsdnCard *card)
604 struct IsdnCardState *cs = card->cs;
605 u16 sub_vendor_id, sub_id;
607 if ((dev_sedl = hisax_find_pci_device(PCI_VENDOR_ID_TIGERJET,
608 PCI_DEVICE_ID_TIGERJET_100, dev_sedl))) {
609 if (pci_enable_device(dev_sedl))
611 cs->irq = dev_sedl->irq;
613 printk(KERN_WARNING "Sedlbauer: No IRQ for PCI card found\n");
616 cs->hw.sedl.cfg_reg = pci_resource_start(dev_sedl, 0);
618 printk(KERN_WARNING "Sedlbauer: No PCI card found\n");
621 cs->irq_flags |= IRQF_SHARED;
622 cs->hw.sedl.bus = SEDL_BUS_PCI;
623 sub_vendor_id = dev_sedl->subsystem_vendor;
624 sub_id = dev_sedl->subsystem_device;
625 printk(KERN_INFO "Sedlbauer: PCI subvendor:%x subid %x\n",
626 sub_vendor_id, sub_id);
627 printk(KERN_INFO "Sedlbauer: PCI base adr %#x\n",
628 cs->hw.sedl.cfg_reg);
629 if (sub_id != PCI_SUB_ID_SEDLBAUER) {
630 printk(KERN_ERR "Sedlbauer: unknown sub id %#x\n", sub_id);
633 if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PYRAMID) {
634 cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
635 cs->subtyp = SEDL_SPEEDFAX_PYRAMID;
636 } else if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PCI) {
637 cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
638 cs->subtyp = SEDL_SPEEDFAX_PCI;
639 } else if (sub_vendor_id == PCI_SUBVENDOR_HST_SAPHIR3) {
640 cs->hw.sedl.chip = SEDL_CHIP_IPAC;
641 cs->subtyp = HST_SAPHIR3;
642 } else if (sub_vendor_id == PCI_SUBVENDOR_SEDLBAUER_PCI) {
643 cs->hw.sedl.chip = SEDL_CHIP_IPAC;
644 cs->subtyp = SEDL_SPEED_PCI;
646 printk(KERN_ERR "Sedlbauer: unknown sub vendor id %#x\n",
651 cs->hw.sedl.reset_on = SEDL_ISAR_PCI_ISAR_RESET_ON;
652 cs->hw.sedl.reset_off = SEDL_ISAR_PCI_ISAR_RESET_OFF;
653 byteout(cs->hw.sedl.cfg_reg, 0xff);
654 byteout(cs->hw.sedl.cfg_reg, 0x00);
655 byteout(cs->hw.sedl.cfg_reg + 2, 0xdd);
656 byteout(cs->hw.sedl.cfg_reg + 5, 0); /* disable all IRQ */
657 byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_on);
659 byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off);
667 static int setup_sedlbauer_pci(struct IsdnCard *card)
672 #endif /* CONFIG_PCI */
674 int setup_sedlbauer(struct IsdnCard *card)
676 int bytecnt = 8, ver, val, rc;
677 struct IsdnCardState *cs = card->cs;
680 strcpy(tmp, Sedlbauer_revision);
681 printk(KERN_INFO "HiSax: Sedlbauer driver Rev. %s\n", HiSax_getrev(tmp));
683 if (cs->typ == ISDN_CTYPE_SEDLBAUER) {
684 cs->subtyp = SEDL_SPEED_CARD_WIN;
685 cs->hw.sedl.bus = SEDL_BUS_ISA;
686 cs->hw.sedl.chip = SEDL_CHIP_TEST;
687 } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_PCMCIA) {
688 cs->subtyp = SEDL_SPEED_STAR;
689 cs->hw.sedl.bus = SEDL_BUS_PCMCIA;
690 cs->hw.sedl.chip = SEDL_CHIP_TEST;
691 } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_FAX) {
692 cs->subtyp = SEDL_SPEED_FAX;
693 cs->hw.sedl.bus = SEDL_BUS_ISA;
694 cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
700 cs->hw.sedl.cfg_reg = card->para[1];
701 cs->irq = card->para[0];
702 if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) {
706 rc = setup_sedlbauer_isapnp(card, &bytecnt);
712 /* Probe for Sedlbauer speed pci */
713 rc = setup_sedlbauer_pci(card);
722 /* In case of the sedlbauer pcmcia card, this region is in use,
723 * reserved for us by the card manager. So we do not check it
724 * here, it would fail.
726 if (cs->hw.sedl.bus != SEDL_BUS_PCMCIA &&
727 !request_region(cs->hw.sedl.cfg_reg, bytecnt, "sedlbauer isdn")) {
729 "HiSax: %s config port %x-%x already in use\n",
732 cs->hw.sedl.cfg_reg + bytecnt);
737 "Sedlbauer: defined at 0x%x-0x%x IRQ %d\n",
739 cs->hw.sedl.cfg_reg + bytecnt,
742 cs->BC_Read_Reg = &ReadHSCX;
743 cs->BC_Write_Reg = &WriteHSCX;
744 cs->BC_Send_Data = &hscx_fill_fifo;
745 cs->cardmsg = &Sedl_card_msg;
748 * testing ISA and PCMCIA Cards for IPAC, default is ISAC
749 * do not test for PCI card, because ports are different
750 * and PCI card uses only IPAC (for the moment)
752 if (cs->hw.sedl.bus != SEDL_BUS_PCI) {
753 val = readreg(cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_ADR,
754 cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC, IPAC_ID);
755 printk(KERN_DEBUG "Sedlbauer: testing IPAC version %x\n", val);
756 if ((val == 1) || (val == 2)) {
758 cs->subtyp = SEDL_SPEED_WIN2_PC104;
759 if (cs->hw.sedl.bus == SEDL_BUS_PCMCIA) {
760 cs->subtyp = SEDL_SPEED_STAR2;
762 cs->hw.sedl.chip = SEDL_CHIP_IPAC;
764 /* ISAC_HSCX oder ISAC_ISAR */
765 if (cs->hw.sedl.chip == SEDL_CHIP_TEST) {
766 cs->hw.sedl.chip = SEDL_CHIP_ISAC_HSCX;
772 * hw.sedl.chip is now properly set
774 printk(KERN_INFO "Sedlbauer: %s detected\n",
775 Sedlbauer_Types[cs->subtyp]);
778 if (cs->hw.sedl.chip == SEDL_CHIP_IPAC) {
779 if (cs->hw.sedl.bus == SEDL_BUS_PCI) {
780 cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_ADR;
781 cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_IPAC;
782 cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_IPAC;
784 cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_ADR;
785 cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC;
786 cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC;
788 test_and_set_bit(HW_IPAC, &cs->HW_Flags);
789 cs->readisac = &ReadISAC_IPAC;
790 cs->writeisac = &WriteISAC_IPAC;
791 cs->readisacfifo = &ReadISACfifo_IPAC;
792 cs->writeisacfifo = &WriteISACfifo_IPAC;
793 cs->irq_func = &sedlbauer_interrupt_ipac;
794 val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ID);
795 printk(KERN_INFO "Sedlbauer: IPAC version %x\n", val);
797 /* ISAC_HSCX oder ISAC_ISAR */
798 cs->readisac = &ReadISAC;
799 cs->writeisac = &WriteISAC;
800 cs->readisacfifo = &ReadISACfifo;
801 cs->writeisacfifo = &WriteISACfifo;
802 if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) {
803 if (cs->hw.sedl.bus == SEDL_BUS_PCI) {
804 cs->hw.sedl.adr = cs->hw.sedl.cfg_reg +
806 cs->hw.sedl.isac = cs->hw.sedl.cfg_reg +
808 cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg +
811 cs->hw.sedl.adr = cs->hw.sedl.cfg_reg +
813 cs->hw.sedl.isac = cs->hw.sedl.cfg_reg +
815 cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg +
817 cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg +
818 SEDL_ISAR_ISA_ISAR_RESET_ON;
819 cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg +
820 SEDL_ISAR_ISA_ISAR_RESET_OFF;
822 cs->bcs[0].hw.isar.reg = &cs->hw.sedl.isar;
823 cs->bcs[1].hw.isar.reg = &cs->hw.sedl.isar;
824 test_and_set_bit(HW_ISAR, &cs->HW_Flags);
825 cs->irq_func = &sedlbauer_interrupt_isar;
826 cs->auxcmd = &isar_auxcmd;
827 ISACVersion(cs, "Sedlbauer:");
828 cs->BC_Read_Reg = &ReadISAR;
829 cs->BC_Write_Reg = &WriteISAR;
830 cs->BC_Send_Data = &isar_fill_fifo;
833 ver = ISARVersion(cs, "Sedlbauer:");
836 "Sedlbauer: wrong ISAR version (ret = %d)\n", ver);
843 release_io_sedlbauer(cs);
847 if (cs->hw.sedl.bus == SEDL_BUS_PCMCIA) {
848 cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_ADR;
849 cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_ISAC;
850 cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_HSCX;
851 cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_RESET;
852 cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_RESET;
853 cs->irq_flags |= IRQF_SHARED;
855 cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_ADR;
856 cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_ISAC;
857 cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_HSCX;
858 cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_RESET_ON;
859 cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_RESET_OFF;
861 cs->irq_func = &sedlbauer_interrupt;
862 ISACVersion(cs, "Sedlbauer:");
864 if (HscxVersion(cs, "Sedlbauer:")) {
866 "Sedlbauer: wrong HSCX versions check IO address\n");
867 release_io_sedlbauer(cs);