21 #include <linux/pci.h>
24 static const char *niccy_revision =
"$Revision: 1.21.2.4 $";
26 #define byteout(addr, val) outb(val, addr)
27 #define bytein(addr) inb(addr)
29 #define ISAC_PCI_DATA 0
30 #define HSCX_PCI_DATA 1
31 #define ISAC_PCI_ADDR 2
32 #define HSCX_PCI_ADDR 3
41 #define PCI_IRQ_CTRL_REG 0x38
42 #define PCI_IRQ_ENABLE 0x1f00
43 #define PCI_IRQ_DISABLE 0xff0000
44 #define PCI_IRQ_ASSERT 0x800000
55 static inline void readfifo(
unsigned int ale,
unsigned int adr,
u_char off,
59 insb(adr, data, size);
62 static inline void writereg(
unsigned int ale,
unsigned int adr,
u_char off,
69 static inline void writefifo(
unsigned int ale,
unsigned int adr,
u_char off,
73 outsb(adr, data, size);
80 return readreg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, offset);
85 writereg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, offset, value);
90 readfifo(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, 0, data, size);
95 writefifo(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, 0, data, size);
100 return readreg(cs->hw.niccy.hscx_ale,
101 cs->hw.niccy.hscx, offset + (hscx ? 0x40 : 0));
108 cs->hw.niccy.hscx, offset + (hscx ? 0x40 : 0), value);
111 #define READHSCX(cs, nr, reg) readreg(cs->hw.niccy.hscx_ale, \
112 cs->hw.niccy.hscx, reg + (nr ? 0x40 : 0))
113 #define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.niccy.hscx_ale, \
114 cs->hw.niccy.hscx, reg + (nr ? 0x40 : 0), data)
116 #define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.niccy.hscx_ale, \
117 cs->hw.niccy.hscx, (nr ? 0x40 : 0), ptr, cnt)
119 #define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.niccy.hscx_ale, \
120 cs->hw.niccy.hscx, (nr ? 0x40 : 0), ptr, cnt)
135 spin_unlock_irqrestore(&cs->lock, flags);
140 val =
readreg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx,
144 hscx_int_main(cs, val);
149 val =
readreg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx,
152 if (cs->debug & L1_DEB_HSCX)
153 debugl1(cs,
"HSCX IntStat after IntRoutine");
158 if (cs->debug & L1_DEB_ISAC)
159 debugl1(cs,
"ISAC IntStat after IntRoutine");
169 spin_unlock_irqrestore(&cs->lock, flags);
173 static void release_io_niccy(
struct IsdnCardState *
cs)
189 static void niccy_reset(
struct IsdnCardState *cs)
201 static int niccy_card_msg(
struct IsdnCardState *cs,
int mt,
void *
arg)
209 spin_unlock_irqrestore(&cs->lock, flags);
212 release_io_niccy(cs);
217 spin_unlock_irqrestore(&cs->lock, flags);
231 struct IsdnCardState *cs = card->
cs;
234 strcpy(tmp, niccy_revision);
251 "found, no device\n");
258 "ret(%d)\n", __func__, err);
261 card->
para[1] = pnp_port_start(pnp_d, 0);
262 card->
para[2] = pnp_port_start(pnp_d, 1);
264 if (!card->
para[0] || !card->
para[1] ||
267 "missing %ld/%lx/%lx\n",
282 cs->hw.niccy.cfg_reg = 0;
284 cs->irq = card->
para[0];
288 cs->hw.niccy.isac, cs->hw.niccy.isac + 1);
294 cs->hw.niccy.isac_ale,
295 cs->hw.niccy.isac_ale + 1);
311 if (!niccy_dev->irq) {
313 "Niccy: No IRQ for PCI card found\n");
316 cs->irq = niccy_dev->irq;
318 if (!cs->hw.niccy.cfg_reg) {
320 "Niccy: No IO-Adr for PCI cfg found\n");
326 "Niccy: No IO-Adr for PCI card found\n");
341 "HiSax: NICCY data port %x-%x already in use\n",
342 cs->hw.niccy.isac, cs->hw.niccy.isac + 4);
347 "HiSax: NICCY pci port %x-%x already in use\n",
348 cs->hw.niccy.cfg_reg,
349 cs->hw.niccy.cfg_reg + 0x40);
360 (cs->subtyp == 1) ?
"PnP" :
"PCI",
361 cs->irq, cs->hw.niccy.isac, cs->hw.niccy.isac_ale);
365 cs->readisacfifo = &ReadISACfifo;
366 cs->writeisacfifo = &WriteISACfifo;
369 cs->BC_Send_Data = &hscx_fill_fifo;
370 cs->cardmsg = &niccy_card_msg;
371 cs->irq_func = &niccy_interrupt;
376 release_io_niccy(cs);