20 #include <linux/pci.h>
23 #define ATTEMPT_PCI_REMAPPING
25 static const char sct_quadro_revision[] =
"$Revision: 1.22.2.4 $";
27 static const char *sct_quadro_subtypes[] =
37 #define wordout(addr, val) outw(val, addr)
38 #define wordin(addr) inw(addr)
54 for (i = 0; i <
size; i++)
55 data[i] =
wordin(adr) & 0xFF;
67 writefifo(
unsigned int ale,
unsigned int adr,
u_char off,
u_char *data,
int size)
71 for (i = 0; i <
size; i++)
80 return (
readreg(cs->hw.ax.base, cs->hw.ax.data_adr, offset | 0x80));
86 writereg(cs->hw.ax.base, cs->hw.ax.data_adr, offset | 0x80, value);
90 ReadISACfifo(
struct IsdnCardState *cs,
u_char *data,
int size)
92 readfifo(cs->hw.ax.base, cs->hw.ax.data_adr, 0x80, data, size);
96 WriteISACfifo(
struct IsdnCardState *cs,
u_char *data,
int size)
98 writefifo(cs->hw.ax.base, cs->hw.ax.data_adr, 0x80, data, size);
105 return (
readreg(cs->hw.ax.base, cs->hw.ax.data_adr, offset + (hscx ? 0x40 : 0)));
111 writereg(cs->hw.ax.base, cs->hw.ax.data_adr, offset + (hscx ? 0x40 : 0), value);
116 set_ipac_active(
struct IsdnCardState *cs,
u_int active)
120 active ? 0xc0 : 0xff);
127 #define READHSCX(cs, nr, reg) readreg(cs->hw.ax.base, \
128 cs->hw.ax.data_adr, reg + (nr ? 0x40 : 0))
129 #define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.ax.base, \
130 cs->hw.ax.data_adr, reg + (nr ? 0x40 : 0), data)
131 #define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.ax.base, \
132 cs->hw.ax.data_adr, (nr ? 0x40 : 0), ptr, cnt)
133 #define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.ax.base, \
134 cs->hw.ax.data_adr, (nr ? 0x40 : 0), ptr, cnt)
139 bkm_interrupt_ipac(
int intno,
void *
dev_id)
141 struct IsdnCardState *cs =
dev_id;
147 if (!(ista & 0x3f)) {
148 spin_unlock_irqrestore(&cs->lock, flags);
152 if (cs->debug & L1_DEB_IPAC)
153 debugl1(cs,
"IPAC ISTA %02X", ista);
163 hscx_int_main(cs, val);
177 if ((ista & 0x3f) && icnt) {
183 sct_quadro_subtypes[cs->subtyp]);
186 spin_unlock_irqrestore(&cs->lock, flags);
191 release_io_sct_quadro(
struct IsdnCardState *cs)
194 if (cs->subtyp ==
SCT_1)
199 enable_bkm_int(
struct IsdnCardState *cs,
unsigned bEnable)
203 wordout(cs->hw.ax.plx_adr + 0x4C, (
wordin(cs->hw.ax.plx_adr + 0x4C) | 0x41));
205 wordout(cs->hw.ax.plx_adr + 0x4C, (
wordin(cs->hw.ax.plx_adr + 0x4C) & ~0x41));
210 reset_bkm(
struct IsdnCardState *cs)
212 if (cs->subtyp ==
SCT_1) {
213 wordout(cs->hw.ax.plx_adr + 0x50, (
wordin(cs->hw.ax.plx_adr + 0x50) & ~4));
216 wordout(cs->hw.ax.plx_adr + 0x50, (
wordin(cs->hw.ax.plx_adr + 0x50) | 4));
222 BKM_card_msg(
struct IsdnCardState *cs,
int mt,
void *
arg)
230 set_ipac_active(cs, 0);
231 enable_bkm_int(cs, 0);
233 spin_unlock_irqrestore(&cs->lock, flags);
238 set_ipac_active(cs, 0);
239 enable_bkm_int(cs, 0);
240 spin_unlock_irqrestore(&cs->lock, flags);
241 release_io_sct_quadro(cs);
245 cs->debug |= L1_DEB_IPAC;
246 set_ipac_active(cs, 1);
249 enable_bkm_int(cs, 1);
250 spin_unlock_irqrestore(&cs->lock, flags);
263 "HiSax: Scitel port %#x-%#x already in use\n",
272 static u16 sub_sys_id __devinitdata = 0;
274 static u_char pci_device_fn __devinitdata = 0;
275 static u_char pci_irq __devinitdata = 0;
280 struct IsdnCardState *cs = card->
cs;
283 u_int pci_ioaddr1, pci_ioaddr2, pci_ioaddr3, pci_ioaddr4, pci_ioaddr5;
285 strcpy(tmp, sct_quadro_revision);
294 cs->subtyp = card->
para[0];
297 "subcontroller in configuration, default to 1\n");
303 if (cs->subtyp ==
SCT_1) {
308 sub_sys_id = dev_a8->subsystem_device;
314 pci_irq = dev_a8->irq;
316 pci_device_fn = dev_a8->devfn;
324 sct_quadro_subtypes[cs->subtyp]);
327 #ifdef ATTEMPT_PCI_REMAPPING
329 if ((pci_ioaddr1 & 0x80) && (dev_a8->revision == 1)) {
331 "PLX rev 1, remapping required!\n",
332 sct_quadro_subtypes[cs->subtyp]);
339 dev_a8->resource[1].start = pci_ioaddr1;
345 sct_quadro_subtypes[cs->subtyp]);
353 if (!pci_ioaddr1 || !pci_ioaddr2 || !pci_ioaddr3 || !pci_ioaddr4 || !pci_ioaddr5) {
355 "No IO base address(es)\n",
356 sct_quadro_subtypes[cs->subtyp]);
372 cs->hw.ax.plx_adr = pci_ioaddr1;
374 switch (cs->subtyp) {
376 cs->hw.ax.base = pci_ioaddr5 + 0x00;
377 if (sct_alloc_io(pci_ioaddr1, 128))
379 if (sct_alloc_io(pci_ioaddr5, 64))
382 writereg(pci_ioaddr5, pci_ioaddr5 + 4,
384 writereg(pci_ioaddr4 + 0x08, pci_ioaddr4 + 0x0c,
386 writereg(pci_ioaddr3 + 0x10, pci_ioaddr3 + 0x14,
388 writereg(pci_ioaddr2 + 0x20, pci_ioaddr2 + 0x24,
392 cs->hw.ax.base = pci_ioaddr4 + 0x08;
393 if (sct_alloc_io(pci_ioaddr4, 64))
397 cs->hw.ax.base = pci_ioaddr3 + 0x10;
398 if (sct_alloc_io(pci_ioaddr3, 64))
402 cs->hw.ax.base = pci_ioaddr2 + 0x20;
403 if (sct_alloc_io(pci_ioaddr2, 64))
408 cs->hw.ax.data_adr = cs->hw.ax.base + 4;
411 "0x%.4lX, 0x%.4lX, 0x%.4lX and IRQ %d\n",
412 sct_quadro_subtypes[cs->subtyp],
422 cs->readisacfifo = &ReadISACfifo;
423 cs->writeisacfifo = &WriteISACfifo;
427 cs->BC_Send_Data = &hscx_fill_fifo;
428 cs->cardmsg = &BKM_card_msg;
429 cs->irq_func = &bkm_interrupt_ipac;
432 sct_quadro_subtypes[cs->subtyp],