1 /* $Id: nj_u.c,v 2.14.2.3 2004/01/13 14:31:26 keil Exp $
3 * This software may be used and distributed according to the terms
4 * of the GNU General Public License, incorporated herein by reference.
8 #include <linux/config.h>
9 #include <linux/init.h>
13 #include <linux/pci.h>
14 #include <linux/interrupt.h>
15 #include <linux/ppp_defs.h>
18 static const char *NETjet_U_revision = "$Revision: 2.14.2.3 $";
20 static u_char dummyrr(struct IsdnCardState *cs, int chan, u_char off)
25 static void dummywr(struct IsdnCardState *cs, int chan, u_char off, u_char value)
30 netjet_u_interrupt(int intno, void *dev_id, struct pt_regs *regs)
32 struct IsdnCardState *cs = dev_id;
36 spin_lock_irqsave(&cs->lock, flags);
37 if (!((sval = bytein(cs->hw.njet.base + NETJET_IRQSTAT1)) &
39 val = NETjet_ReadIC(cs, ICC_ISTA);
40 if (cs->debug & L1_DEB_ISAC)
41 debugl1(cs, "tiger: i1 %x %x", sval, val);
43 icc_interrupt(cs, val);
44 NETjet_WriteIC(cs, ICC_MASK, 0xFF);
45 NETjet_WriteIC(cs, ICC_MASK, 0x0);
48 /* start new code 13/07/00 GE */
49 /* set bits in sval to indicate which page is free */
50 if (inl(cs->hw.njet.base + NETJET_DMA_WRITE_ADR) <
51 inl(cs->hw.njet.base + NETJET_DMA_WRITE_IRQ))
52 /* the 2nd write page is free */
54 else /* the 1st write page is free */
56 if (inl(cs->hw.njet.base + NETJET_DMA_READ_ADR) <
57 inl(cs->hw.njet.base + NETJET_DMA_READ_IRQ))
58 /* the 2nd read page is free */
60 else /* the 1st read page is free */
62 if (sval != cs->hw.njet.last_is0) /* we have a DMA interrupt */
64 if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
65 spin_unlock_irqrestore(&cs->lock, flags);
68 cs->hw.njet.irqstat0 = sval;
69 if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_READ) !=
70 (cs->hw.njet.last_is0 & NETJET_IRQM0_READ))
71 /* we have a read dma int */
73 if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_WRITE) !=
74 (cs->hw.njet.last_is0 & NETJET_IRQM0_WRITE))
75 /* we have a write dma int */
77 /* end new code 13/07/00 GE */
78 test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
80 spin_unlock_irqrestore(&cs->lock, flags);
85 reset_netjet_u(struct IsdnCardState *cs)
87 cs->hw.njet.ctrl_reg = 0xff; /* Reset On */
88 byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
90 cs->hw.njet.ctrl_reg = 0x40; /* Reset Off and status read clear */
91 /* now edge triggered for TJ320 GE 13/07/00 */
92 byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
94 cs->hw.njet.auxd = 0xC0;
95 cs->hw.njet.dmactrl = 0;
96 byteout(cs->hw.njet.auxa, 0);
97 byteout(cs->hw.njet.base + NETJET_AUXCTRL, ~NETJET_ISACIRQ);
98 byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ);
99 byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
103 NETjet_U_card_msg(struct IsdnCardState *cs, int mt, void *arg)
109 spin_lock_irqsave(&cs->lock, flags);
111 spin_unlock_irqrestore(&cs->lock, flags);
114 release_io_netjet(cs);
117 spin_lock_irqsave(&cs->lock, flags);
120 clear_pending_icc_ints(cs);
122 /* Reenable all IRQ */
123 cs->writeisac(cs, ICC_MASK, 0);
124 spin_unlock_irqrestore(&cs->lock, flags);
132 static struct pci_dev *dev_netjet __initdata = NULL;
135 setup_netjet_u(struct IsdnCard *card)
138 struct IsdnCardState *cs = card->cs;
143 #error "not running on big endian machines now"
145 strcpy(tmp, NETjet_U_revision);
146 printk(KERN_INFO "HiSax: Traverse Tech. NETspider-U driver Rev. %s\n", HiSax_getrev(tmp));
147 if (cs->typ != ISDN_CTYPE_NETJET_U)
149 test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
155 if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
156 PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) {
157 if (pci_enable_device(dev_netjet))
159 pci_set_master(dev_netjet);
160 cs->irq = dev_netjet->irq;
162 printk(KERN_WARNING "NETspider-U: No IRQ for PCI card found\n");
165 cs->hw.njet.base = pci_resource_start(dev_netjet, 0);
166 if (!cs->hw.njet.base) {
167 printk(KERN_WARNING "NETspider-U: No IO-Adr for PCI card found\n");
171 printk(KERN_WARNING "NETspider-U: No PCI card found\n");
175 cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA;
176 cs->hw.njet.isac = cs->hw.njet.base | NETJET_ISAC_OFF;
179 cs->hw.njet.ctrl_reg = 0xff; /* Reset On */
180 byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
183 cs->hw.njet.ctrl_reg = 0x00; /* Reset Off and status read clear */
184 byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
187 cs->hw.njet.auxd = 0xC0;
188 cs->hw.njet.dmactrl = 0;
190 byteout(cs->hw.njet.auxa, 0);
191 byteout(cs->hw.njet.base + NETJET_AUXCTRL, ~NETJET_ISACIRQ);
192 byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ);
193 byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
195 switch ( ( ( NETjet_ReadIC( cs, ICC_RBCH ) >> 5 ) & 3 ) )
201 printk( KERN_WARNING "NETspider-U: NETjet-S PCI card found\n" );
205 printk( KERN_WARNING "NETspider-U: No PCI card found\n" );
212 printk(KERN_WARNING "NETspider-U: NO_PCI_BIOS\n");
213 printk(KERN_WARNING "NETspider-U: unable to config NETspider-U PCI\n");
216 #endif /* CONFIG_PCI */
221 "NETspider-U: PCI card configured at %#lx IRQ %d\n",
222 cs->hw.njet.base, cs->irq);
223 if (!request_region(cs->hw.njet.base, bytecnt, "netspider-u isdn")) {
225 "HiSax: %s config port %#lx-%#lx already in use\n",
228 cs->hw.njet.base + bytecnt);
232 cs->readisac = &NETjet_ReadIC;
233 cs->writeisac = &NETjet_WriteIC;
234 cs->readisacfifo = &NETjet_ReadICfifo;
235 cs->writeisacfifo = &NETjet_WriteICfifo;
236 cs->BC_Read_Reg = &dummyrr;
237 cs->BC_Write_Reg = &dummywr;
238 cs->BC_Send_Data = &netjet_fill_dma;
239 cs->cardmsg = &NETjet_U_card_msg;
240 cs->irq_func = &netjet_u_interrupt;
241 cs->irq_flags |= SA_SHIRQ;
242 ICCVersion(cs, "NETspider-U:");