48 #include <linux/pci.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
133 insb(adr, data, size);
148 outsb(adr, data, size);
156 return (
readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset));
162 writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset, value);
168 readfifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0, data, 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));
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);
204 return (
readreg(cs->hw.sedl.adr,
205 cs->hw.sedl.hscx, offset + (hscx ? 0x40 : 0)));
212 cs->hw.sedl.hscx, offset + (hscx ? 0x40 : 0), value);
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));
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);
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)
261 sedlbauer_interrupt(
int intno,
void *
dev_id)
263 struct IsdnCardState *cs =
dev_id;
271 spin_unlock_irqrestore(&cs->lock, flags);
279 hscx_int_main(cs, val);
286 if (cs->debug & L1_DEB_HSCX)
287 debugl1(cs,
"HSCX IntStat after IntRoutine");
292 if (cs->debug & L1_DEB_ISAC)
293 debugl1(cs,
"ISAC IntStat after IntRoutine");
302 spin_unlock_irqrestore(&cs->lock, flags);
307 sedlbauer_interrupt_ipac(
int intno,
void *
dev_id)
309 struct IsdnCardState *cs =
dev_id;
316 if (cs->debug & L1_DEB_IPAC)
317 debugl1(cs,
"IPAC ISTA %02X", ista);
327 hscx_int_main(cs, val);
340 if ((ista & 0x3f) && icnt) {
345 if (cs->debug & L1_DEB_ISAC)
346 debugl1(cs,
"Sedlbauer IRQ LOOP");
349 spin_unlock_irqrestore(&cs->lock, flags);
354 sedlbauer_interrupt_isar(
int intno,
void *dev_id)
356 struct IsdnCardState *cs =
dev_id;
371 if ((val & ISAR_IRQSTA) && --cnt) {
372 if (cs->debug & L1_DEB_HSCX)
373 debugl1(cs,
"ISAR IntStat after IntRoutine");
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");
390 spin_unlock_irqrestore(&cs->lock, flags);
395 release_io_sedlbauer(
struct IsdnCardState *cs)
404 if (cs->hw.sedl.cfg_reg)
409 reset_sedlbauer(
struct IsdnCardState *cs)
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);
434 byteout(cs->hw.sedl.reset_off, 0);
441 Sedl_card_msg(
struct IsdnCardState *cs,
int mt,
void *
arg)
449 spin_unlock_irqrestore(&cs->lock, flags);
454 byteout(cs->hw.sedl.cfg_reg + 5, 0);
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);
474 byteout(cs->hw.sedl.cfg_reg + 5, 0x02);
478 writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx,
489 spin_unlock_irqrestore(&cs->lock, flags);
501 byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off);
502 spin_unlock_irqrestore(&cs->lock, flags);
512 byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off);
513 spin_unlock_irqrestore(&cs->lock, flags);
523 (
unsigned long)
"Speed win" },
526 (
unsigned long)
"Speed Fax+" },
534 setup_sedlbauer_isapnp(
struct IsdnCard *
card,
int *bytecnt)
536 struct IsdnCardState *cs = card->
cs;
542 while (ipid->card_vendor) {
544 ipid->card_device, pnp_c))) {
547 ipid->vendor, ipid->function, pnp_d))) {
551 (
char *)ipid->driver_data);
559 card->
para[1] = pnp_port_start(pnp_d, 0);
562 if (!card->
para[0] || !card->
para[1]) {
563 printk(
KERN_ERR "Sedlbauer PnP:some resources are missing %ld/%lx\n",
568 cs->hw.sedl.cfg_reg = card->
para[1];
569 cs->irq = card->
para[0];
581 printk(
KERN_ERR "Sedlbauer PnP: PnP error card found, no device\n");
595 setup_sedlbauer_isapnp(
struct IsdnCard *card,
int *bytecnt)
602 static struct pci_dev *dev_sedl __devinitdata =
NULL;
605 setup_sedlbauer_pci(
struct IsdnCard *card)
607 struct IsdnCardState *cs = card->
cs;
614 cs->irq = dev_sedl->irq;
626 sub_vendor_id = dev_sedl->subsystem_vendor;
627 sub_id = dev_sedl->subsystem_device;
629 sub_vendor_id, sub_id);
631 cs->hw.sedl.cfg_reg);
656 byteout(cs->hw.sedl.cfg_reg, 0xff);
657 byteout(cs->hw.sedl.cfg_reg, 0x00);
658 byteout(cs->hw.sedl.cfg_reg + 2, 0xdd);
659 byteout(cs->hw.sedl.cfg_reg + 5, 0);
660 byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_on);
662 byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off);
671 setup_sedlbauer_pci(
struct IsdnCard *card)
682 struct IsdnCardState *cs = card->
cs;
685 strcpy(tmp, Sedlbauer_revision);
705 cs->hw.sedl.cfg_reg = card->
para[1];
706 cs->irq = card->
para[0];
711 rc = setup_sedlbauer_isapnp(card, &bytecnt);
718 rc = setup_sedlbauer_pci(card);
732 !
request_region(cs->hw.sedl.cfg_reg, bytecnt,
"sedlbauer isdn")) {
734 "HiSax: %s config port %x-%x already in use\n",
737 cs->hw.sedl.cfg_reg + bytecnt);
742 "Sedlbauer: defined at 0x%x-0x%x IRQ %d\n",
744 cs->hw.sedl.cfg_reg + bytecnt,
749 cs->BC_Send_Data = &hscx_fill_fifo;
750 cs->cardmsg = &Sedl_card_msg;
761 if ((val == 1) || (val == 2)) {
780 Sedlbauer_Types[cs->subtyp]);
794 cs->readisac = &ReadISAC_IPAC;
795 cs->writeisac = &WriteISAC_IPAC;
796 cs->readisacfifo = &ReadISACfifo_IPAC;
797 cs->writeisacfifo = &WriteISACfifo_IPAC;
798 cs->irq_func = &sedlbauer_interrupt_ipac;
805 cs->readisacfifo = &ReadISACfifo;
806 cs->writeisacfifo = &WriteISACfifo;
809 cs->hw.sedl.adr = cs->hw.sedl.cfg_reg +
811 cs->hw.sedl.isac = cs->hw.sedl.cfg_reg +
813 cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg +
816 cs->hw.sedl.adr = cs->hw.sedl.cfg_reg +
818 cs->hw.sedl.isac = cs->hw.sedl.cfg_reg +
820 cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg +
822 cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg +
824 cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg +
827 cs->bcs[0].hw.isar.reg = &cs->hw.sedl.isar;
828 cs->bcs[1].hw.isar.reg = &cs->hw.sedl.isar;
830 cs->irq_func = &sedlbauer_interrupt_isar;
833 cs->BC_Read_Reg = &ReadISAR;
834 cs->BC_Write_Reg = &WriteISAR;
841 "Sedlbauer: wrong ISAR version (ret = %d)\n",
ver);
848 release_io_sedlbauer(cs);
866 cs->irq_func = &sedlbauer_interrupt;
871 "Sedlbauer: wrong HSCX versions check IO address\n");
872 release_io_sedlbauer(cs);