1 // $Id: nj_s.c,v 2.3 2000/06/26 08:59:14 keil Exp $
3 // This file is (c) under GNU PUBLIC LICENSE
6 #include <linux/config.h>
10 #include <linux/pci.h>
11 #include <linux/interrupt.h>
12 #include <linux/ppp_defs.h>
15 const char *NETjet_S_revision
= "$Revision: 2.3 $";
17 static u_char
dummyrr(struct IsdnCardState
*cs
, int chan
, u_char off
)
22 static void dummywr(struct IsdnCardState
*cs
, int chan
, u_char off
, u_char value
)
27 netjet_s_interrupt(int intno
, void *dev_id
, struct pt_regs
*regs
)
29 struct IsdnCardState
*cs
= dev_id
;
34 printk(KERN_WARNING
"NETjet-S: Spurious interrupt!\n");
37 if (!((sval
= bytein(cs
->hw
.njet
.base
+ NETJET_IRQSTAT1
)) &
39 val
= NETjet_ReadIC(cs
, ISAC_ISTA
);
40 if (cs
->debug
& L1_DEB_ISAC
)
41 debugl1(cs
, "tiger: i1 %x %x", sval
, val
);
43 isac_interrupt(cs
, val
);
44 NETjet_WriteIC(cs
, ISAC_MASK
, 0xFF);
45 NETjet_WriteIC(cs
, ISAC_MASK
, 0x0);
50 if ((sval
= bytein(cs
->hw
.njet
.base
+ NETJET_IRQSTAT0
))) {
51 if (test_and_set_bit(FLG_LOCK_ATOMIC
, &cs
->HW_Flags
)) {
55 cs
->hw
.njet
.irqstat0
= sval
;
57 /* debugl1(cs, "tiger: ist0 %x %x %x %x/%x pulse=%d",
59 bytein(cs->hw.njet.base + NETJET_DMACTRL),
60 bytein(cs->hw.njet.base + NETJET_IRQMASK0),
61 inl(cs->hw.njet.base + NETJET_DMA_READ_ADR),
62 inl(cs->hw.njet.base + NETJET_DMA_WRITE_ADR),
63 bytein(cs->hw.njet.base + NETJET_PULSE_CNT));
65 /* cs->hw.njet.irqmask0 = ((0x0f & cs->hw.njet.irqstat0) ^ 0x0f) | 0x30;
66 */ byteout(cs
->hw
.njet
.base
+ NETJET_IRQSTAT0
, cs
->hw
.njet
.irqstat0
);
67 /* byteout(cs->hw.njet.base + NETJET_IRQMASK0, cs->hw.njet.irqmask0);
68 */ if (cs
->hw
.njet
.irqstat0
& NETJET_IRQM0_READ
)
70 if (cs
->hw
.njet
.irqstat0
& NETJET_IRQM0_WRITE
)
72 test_and_clear_bit(FLG_LOCK_ATOMIC
, &cs
->HW_Flags
);
77 cs->hw.njet.dmactrl = 0;
78 byteout(cs->hw.njet.base + NETJET_DMACTRL,
80 byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0);
86 reset_netjet_s(struct IsdnCardState
*cs
)
92 cs
->hw
.njet
.ctrl_reg
= 0xff; /* Reset On */
93 byteout(cs
->hw
.njet
.base
+ NETJET_CTRL
, cs
->hw
.njet
.ctrl_reg
);
94 set_current_state(TASK_UNINTERRUPTIBLE
);
95 schedule_timeout((10*HZ
)/1000); /* Timeout 10ms */
96 cs
->hw
.njet
.ctrl_reg
= 0x00; /* Reset Off and status read clear */
97 byteout(cs
->hw
.njet
.base
+ NETJET_CTRL
, cs
->hw
.njet
.ctrl_reg
);
98 set_current_state(TASK_UNINTERRUPTIBLE
);
99 schedule_timeout((10*HZ
)/1000); /* Timeout 10ms */
100 restore_flags(flags
);
101 cs
->hw
.njet
.auxd
= 0;
102 cs
->hw
.njet
.dmactrl
= 0;
103 byteout(cs
->hw
.njet
.base
+ NETJET_AUXCTRL
, ~NETJET_ISACIRQ
);
104 byteout(cs
->hw
.njet
.base
+ NETJET_IRQMASK1
, NETJET_ISACIRQ
);
105 byteout(cs
->hw
.njet
.auxa
, cs
->hw
.njet
.auxd
);
109 NETjet_S_card_msg(struct IsdnCardState
*cs
, int mt
, void *arg
)
116 release_io_netjet(cs
);
120 clear_pending_isac_ints(cs
);
122 /* Reenable all IRQ */
123 cs
->writeisac(cs
, ISAC_MASK
, 0);
131 static struct pci_dev
*dev_netjet __initdata
= NULL
;
134 setup_netjet_s(struct IsdnCard
*card
))
137 struct IsdnCardState
*cs
= card
->cs
;
143 #error "not running on big endian machines now"
145 strcpy(tmp
, NETjet_S_revision
);
146 printk(KERN_INFO
"HiSax: Traverse Tech. NETjet-S driver Rev. %s\n", HiSax_getrev(tmp
));
147 if (cs
->typ
!= ISDN_CTYPE_NETJET_S
)
149 test_and_clear_bit(FLG_LOCK_ATOMIC
, &cs
->HW_Flags
);
156 if (!pci_present()) {
157 printk(KERN_ERR
"Netjet: no PCI bus present\n");
160 if ((dev_netjet
= pci_find_device(PCI_VENDOR_ID_TIGERJET
,
161 PCI_DEVICE_ID_TIGERJET_300
, dev_netjet
))) {
162 if (pci_enable_device(dev_netjet
))
164 cs
->irq
= dev_netjet
->irq
;
166 printk(KERN_WARNING
"NETjet-S: No IRQ for PCI card found\n");
169 cs
->hw
.njet
.base
= pci_resource_start(dev_netjet
, 0);
170 if (!cs
->hw
.njet
.base
) {
171 printk(KERN_WARNING
"NETjet-S: No IO-Adr for PCI card found\n");
175 printk(KERN_WARNING
"NETjet-S: No PCI card found\n");
179 cs
->hw
.njet
.auxa
= cs
->hw
.njet
.base
+ NETJET_AUXDATA
;
180 cs
->hw
.njet
.isac
= cs
->hw
.njet
.base
| NETJET_ISAC_OFF
;
185 cs
->hw
.njet
.ctrl_reg
= 0xff; /* Reset On */
186 byteout(cs
->hw
.njet
.base
+ NETJET_CTRL
, cs
->hw
.njet
.ctrl_reg
);
188 set_current_state(TASK_UNINTERRUPTIBLE
);
189 schedule_timeout((10*HZ
)/1000); /* Timeout 10ms */
191 cs
->hw
.njet
.ctrl_reg
= 0x00; /* Reset Off and status read clear */
192 byteout(cs
->hw
.njet
.base
+ NETJET_CTRL
, cs
->hw
.njet
.ctrl_reg
);
194 set_current_state(TASK_UNINTERRUPTIBLE
);
195 schedule_timeout((10*HZ
)/1000); /* Timeout 10ms */
197 restore_flags(flags
);
199 cs
->hw
.njet
.auxd
= 0xC0;
200 cs
->hw
.njet
.dmactrl
= 0;
202 byteout(cs
->hw
.njet
.base
+ NETJET_AUXCTRL
, ~NETJET_ISACIRQ
);
203 byteout(cs
->hw
.njet
.base
+ NETJET_IRQMASK1
, NETJET_ISACIRQ
);
204 byteout(cs
->hw
.njet
.auxa
, cs
->hw
.njet
.auxd
);
206 switch ( ( ( NETjet_ReadIC( cs
, ISAC_RBCH
) >> 5 ) & 3 ) )
212 printk( KERN_WARNING
"NETjet-S: NETspider-U PCI card found\n" );
216 printk( KERN_WARNING
"NETjet-S: No PCI card found\n" );
223 printk(KERN_WARNING
"NETjet-S: NO_PCI_BIOS\n");
224 printk(KERN_WARNING
"NETjet-S: unable to config NETJET-S PCI\n");
227 #endif /* CONFIG_PCI */
232 "NETjet-S: PCI card configured at 0x%x IRQ %d\n",
233 cs
->hw
.njet
.base
, cs
->irq
);
234 if (check_region(cs
->hw
.njet
.base
, bytecnt
)) {
236 "HiSax: %s config port %x-%x already in use\n",
239 cs
->hw
.njet
.base
+ bytecnt
);
242 request_region(cs
->hw
.njet
.base
, bytecnt
, "netjet-s isdn");
245 cs
->readisac
= &NETjet_ReadIC
;
246 cs
->writeisac
= &NETjet_WriteIC
;
247 cs
->readisacfifo
= &NETjet_ReadICfifo
;
248 cs
->writeisacfifo
= &NETjet_WriteICfifo
;
249 cs
->BC_Read_Reg
= &dummyrr
;
250 cs
->BC_Write_Reg
= &dummywr
;
251 cs
->BC_Send_Data
= &netjet_fill_dma
;
252 cs
->cardmsg
= &NETjet_S_card_msg
;
253 cs
->irq_func
= &netjet_s_interrupt
;
254 cs
->irq_flags
|= SA_SHIRQ
;
255 ISACVersion(cs
, "NETjet-S:");