1 /* $Id: nj_u.c,v 2.8.6.1 2000/11/29 16:00:14 kai Exp $
3 * This file is (c) under GNU PUBLIC LICENSE
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 const char *NETjet_U_revision
= "$Revision: 2.8.6.1 $";
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
;
37 printk(KERN_WARNING
"NETspider-U: Spurious interrupt!\n");
40 if (!((sval
= bytein(cs
->hw
.njet
.base
+ NETJET_IRQSTAT1
)) &
42 val
= NETjet_ReadIC(cs
, ICC_ISTA
);
43 if (cs
->debug
& L1_DEB_ISAC
)
44 debugl1(cs
, "tiger: i1 %x %x", sval
, val
);
46 icc_interrupt(cs
, val
);
47 NETjet_WriteIC(cs
, ICC_MASK
, 0xFF);
48 NETjet_WriteIC(cs
, ICC_MASK
, 0x0);
53 /* start new code 13/07/00 GE */
54 /* set bits in sval to indicate which page is free */
55 if (inl(cs
->hw
.njet
.base
+ NETJET_DMA_WRITE_ADR
) <
56 inl(cs
->hw
.njet
.base
+ NETJET_DMA_WRITE_IRQ
))
57 /* the 2nd write page is free */
59 else /* the 1st write page is free */
61 if (inl(cs
->hw
.njet
.base
+ NETJET_DMA_READ_ADR
) <
62 inl(cs
->hw
.njet
.base
+ NETJET_DMA_READ_IRQ
))
63 /* the 2nd read page is free */
65 else /* the 1st read page is free */
67 if (sval
!= cs
->hw
.njet
.last_is0
) /* we have a DMA interrupt */
69 if (test_and_set_bit(FLG_LOCK_ATOMIC
, &cs
->HW_Flags
)) {
73 cs
->hw
.njet
.irqstat0
= sval
;
75 if ((cs
->hw
.njet
.irqstat0
& NETJET_IRQM0_READ
) !=
76 (cs
->hw
.njet
.last_is0
& NETJET_IRQM0_READ
))
77 /* we have a read dma int */
79 if ((cs
->hw
.njet
.irqstat0
& NETJET_IRQM0_WRITE
) !=
80 (cs
->hw
.njet
.last_is0
& NETJET_IRQM0_WRITE
))
81 /* we have a write dma int */
83 /* end new code 13/07/00 GE */
84 test_and_clear_bit(FLG_LOCK_ATOMIC
, &cs
->HW_Flags
);
89 cs->hw.njet.dmactrl = 0;
90 byteout(cs->hw.njet.base + NETJET_DMACTRL,
92 byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0);
98 reset_netjet_u(struct IsdnCardState
*cs
)
104 cs
->hw
.njet
.ctrl_reg
= 0xff; /* Reset On */
105 byteout(cs
->hw
.njet
.base
+ NETJET_CTRL
, cs
->hw
.njet
.ctrl_reg
);
106 set_current_state(TASK_UNINTERRUPTIBLE
);
107 schedule_timeout((10*HZ
)/1000); /* Timeout 10ms */
108 cs
->hw
.njet
.ctrl_reg
= 0x40; /* Reset Off and status read clear */
109 /* now edge triggered for TJ320 GE 13/07/00 */
110 byteout(cs
->hw
.njet
.base
+ NETJET_CTRL
, cs
->hw
.njet
.ctrl_reg
);
111 set_current_state(TASK_UNINTERRUPTIBLE
);
112 schedule_timeout((10*HZ
)/1000); /* Timeout 10ms */
113 restore_flags(flags
);
114 cs
->hw
.njet
.auxd
= 0xC0;
115 cs
->hw
.njet
.dmactrl
= 0;
116 byteout(cs
->hw
.njet
.auxa
, 0);
117 byteout(cs
->hw
.njet
.base
+ NETJET_AUXCTRL
, ~NETJET_ISACIRQ
);
118 byteout(cs
->hw
.njet
.base
+ NETJET_IRQMASK1
, NETJET_ISACIRQ
);
119 byteout(cs
->hw
.njet
.auxa
, cs
->hw
.njet
.auxd
);
123 NETjet_U_card_msg(struct IsdnCardState
*cs
, int mt
, void *arg
)
130 release_io_netjet(cs
);
134 clear_pending_icc_ints(cs
);
136 /* Reenable all IRQ */
137 cs
->writeisac(cs
, ICC_MASK
, 0);
145 static struct pci_dev
*dev_netjet __initdata
= NULL
;
148 setup_netjet_u(struct IsdnCard
*card
)
151 struct IsdnCardState
*cs
= card
->cs
;
157 #error "not running on big endian machines now"
159 strcpy(tmp
, NETjet_U_revision
);
160 printk(KERN_INFO
"HiSax: Traverse Tech. NETspider-U driver Rev. %s\n", HiSax_getrev(tmp
));
161 if (cs
->typ
!= ISDN_CTYPE_NETJET_U
)
163 test_and_clear_bit(FLG_LOCK_ATOMIC
, &cs
->HW_Flags
);
169 if (!pci_present()) {
170 printk(KERN_ERR
"Netjet: no PCI bus present\n");
173 if ((dev_netjet
= pci_find_device(PCI_VENDOR_ID_TIGERJET
,
174 PCI_DEVICE_ID_TIGERJET_300
, dev_netjet
))) {
175 if (pci_enable_device(dev_netjet
))
177 cs
->irq
= dev_netjet
->irq
;
179 printk(KERN_WARNING
"NETspider-U: No IRQ for PCI card found\n");
182 cs
->hw
.njet
.base
= pci_resource_start(dev_netjet
, 0);
183 if (!cs
->hw
.njet
.base
) {
184 printk(KERN_WARNING
"NETspider-U: No IO-Adr for PCI card found\n");
188 printk(KERN_WARNING
"NETspider-U: No PCI card found\n");
192 cs
->hw
.njet
.auxa
= cs
->hw
.njet
.base
+ NETJET_AUXDATA
;
193 cs
->hw
.njet
.isac
= cs
->hw
.njet
.base
| NETJET_ISAC_OFF
;
198 cs
->hw
.njet
.ctrl_reg
= 0xff; /* Reset On */
199 byteout(cs
->hw
.njet
.base
+ NETJET_CTRL
, cs
->hw
.njet
.ctrl_reg
);
201 set_current_state(TASK_UNINTERRUPTIBLE
);
202 schedule_timeout((10*HZ
)/1000); /* Timeout 10ms */
204 cs
->hw
.njet
.ctrl_reg
= 0x00; /* Reset Off and status read clear */
205 byteout(cs
->hw
.njet
.base
+ NETJET_CTRL
, cs
->hw
.njet
.ctrl_reg
);
207 set_current_state(TASK_UNINTERRUPTIBLE
);
208 schedule_timeout((10*HZ
)/1000); /* Timeout 10ms */
210 restore_flags(flags
);
212 cs
->hw
.njet
.auxd
= 0xC0;
213 cs
->hw
.njet
.dmactrl
= 0;
215 byteout(cs
->hw
.njet
.auxa
, 0);
216 byteout(cs
->hw
.njet
.base
+ NETJET_AUXCTRL
, ~NETJET_ISACIRQ
);
217 byteout(cs
->hw
.njet
.base
+ NETJET_IRQMASK1
, NETJET_ISACIRQ
);
218 byteout(cs
->hw
.njet
.auxa
, cs
->hw
.njet
.auxd
);
220 switch ( ( ( NETjet_ReadIC( cs
, ICC_RBCH
) >> 5 ) & 3 ) )
226 printk( KERN_WARNING
"NETspider-U: NETjet-S PCI card found\n" );
230 printk( KERN_WARNING
"NETspider-U: No PCI card found\n" );
237 printk(KERN_WARNING
"NETspider-U: NO_PCI_BIOS\n");
238 printk(KERN_WARNING
"NETspider-U: unable to config NETspider-U PCI\n");
241 #endif /* CONFIG_PCI */
246 "NETspider-U: PCI card configured at 0x%x IRQ %d\n",
247 cs
->hw
.njet
.base
, cs
->irq
);
248 if (check_region(cs
->hw
.njet
.base
, bytecnt
)) {
250 "HiSax: %s config port %x-%x already in use\n",
253 cs
->hw
.njet
.base
+ bytecnt
);
256 request_region(cs
->hw
.njet
.base
, bytecnt
, "netspider-u isdn");
259 cs
->readisac
= &NETjet_ReadIC
;
260 cs
->writeisac
= &NETjet_WriteIC
;
261 cs
->readisacfifo
= &NETjet_ReadICfifo
;
262 cs
->writeisacfifo
= &NETjet_WriteICfifo
;
263 cs
->BC_Read_Reg
= &dummyrr
;
264 cs
->BC_Write_Reg
= &dummywr
;
265 cs
->BC_Send_Data
= &netjet_fill_dma
;
266 cs
->cardmsg
= &NETjet_U_card_msg
;
267 cs
->irq_func
= &netjet_u_interrupt
;
268 cs
->irq_flags
|= SA_SHIRQ
;
269 ICCVersion(cs
, "NETspider-U:");