diff options
Diffstat (limited to 'drivers/isdn/hisax/nj_u.c')
-rw-r--r-- | drivers/isdn/hisax/nj_u.c | 244 |
1 files changed, 244 insertions, 0 deletions
diff --git a/drivers/isdn/hisax/nj_u.c b/drivers/isdn/hisax/nj_u.c new file mode 100644 index 000000000000..3d6441e9633c --- /dev/null +++ b/drivers/isdn/hisax/nj_u.c | |||
@@ -0,0 +1,244 @@ | |||
1 | /* $Id: nj_u.c,v 2.14.2.3 2004/01/13 14:31:26 keil Exp $ | ||
2 | * | ||
3 | * This software may be used and distributed according to the terms | ||
4 | * of the GNU General Public License, incorporated herein by reference. | ||
5 | * | ||
6 | */ | ||
7 | |||
8 | #include <linux/config.h> | ||
9 | #include <linux/init.h> | ||
10 | #include "hisax.h" | ||
11 | #include "icc.h" | ||
12 | #include "isdnl1.h" | ||
13 | #include <linux/pci.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/ppp_defs.h> | ||
16 | #include "netjet.h" | ||
17 | |||
18 | const char *NETjet_U_revision = "$Revision: 2.14.2.3 $"; | ||
19 | |||
20 | static u_char dummyrr(struct IsdnCardState *cs, int chan, u_char off) | ||
21 | { | ||
22 | return(5); | ||
23 | } | ||
24 | |||
25 | static void dummywr(struct IsdnCardState *cs, int chan, u_char off, u_char value) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | static irqreturn_t | ||
30 | netjet_u_interrupt(int intno, void *dev_id, struct pt_regs *regs) | ||
31 | { | ||
32 | struct IsdnCardState *cs = dev_id; | ||
33 | u_char val, sval; | ||
34 | u_long flags; | ||
35 | |||
36 | spin_lock_irqsave(&cs->lock, flags); | ||
37 | if (!((sval = bytein(cs->hw.njet.base + NETJET_IRQSTAT1)) & | ||
38 | NETJET_ISACIRQ)) { | ||
39 | val = NETjet_ReadIC(cs, ICC_ISTA); | ||
40 | if (cs->debug & L1_DEB_ISAC) | ||
41 | debugl1(cs, "tiger: i1 %x %x", sval, val); | ||
42 | if (val) { | ||
43 | icc_interrupt(cs, val); | ||
44 | NETjet_WriteIC(cs, ICC_MASK, 0xFF); | ||
45 | NETjet_WriteIC(cs, ICC_MASK, 0x0); | ||
46 | } | ||
47 | } | ||
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 */ | ||
53 | sval = 0x08; | ||
54 | else /* the 1st write page is free */ | ||
55 | sval = 0x04; | ||
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 */ | ||
59 | sval = sval | 0x02; | ||
60 | else /* the 1st read page is free */ | ||
61 | sval = sval | 0x01; | ||
62 | if (sval != cs->hw.njet.last_is0) /* we have a DMA interrupt */ | ||
63 | { | ||
64 | if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { | ||
65 | spin_unlock_irqrestore(&cs->lock, flags); | ||
66 | return IRQ_HANDLED; | ||
67 | } | ||
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 */ | ||
72 | read_tiger(cs); | ||
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 */ | ||
76 | write_tiger(cs); | ||
77 | /* end new code 13/07/00 GE */ | ||
78 | test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); | ||
79 | } | ||
80 | spin_unlock_irqrestore(&cs->lock, flags); | ||
81 | return IRQ_HANDLED; | ||
82 | } | ||
83 | |||
84 | static void | ||
85 | reset_netjet_u(struct IsdnCardState *cs) | ||
86 | { | ||
87 | cs->hw.njet.ctrl_reg = 0xff; /* Reset On */ | ||
88 | byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg); | ||
89 | mdelay(10); | ||
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); | ||
93 | mdelay(10); | ||
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); | ||
100 | } | ||
101 | |||
102 | static int | ||
103 | NETjet_U_card_msg(struct IsdnCardState *cs, int mt, void *arg) | ||
104 | { | ||
105 | u_long flags; | ||
106 | |||
107 | switch (mt) { | ||
108 | case CARD_RESET: | ||
109 | spin_lock_irqsave(&cs->lock, flags); | ||
110 | reset_netjet_u(cs); | ||
111 | spin_unlock_irqrestore(&cs->lock, flags); | ||
112 | return(0); | ||
113 | case CARD_RELEASE: | ||
114 | release_io_netjet(cs); | ||
115 | return(0); | ||
116 | case CARD_INIT: | ||
117 | spin_lock_irqsave(&cs->lock, flags); | ||
118 | inittiger(cs); | ||
119 | reset_netjet_u(cs); | ||
120 | clear_pending_icc_ints(cs); | ||
121 | initicc(cs); | ||
122 | /* Reenable all IRQ */ | ||
123 | cs->writeisac(cs, ICC_MASK, 0); | ||
124 | spin_unlock_irqrestore(&cs->lock, flags); | ||
125 | return(0); | ||
126 | case CARD_TEST: | ||
127 | return(0); | ||
128 | } | ||
129 | return(0); | ||
130 | } | ||
131 | |||
132 | static struct pci_dev *dev_netjet __initdata = NULL; | ||
133 | |||
134 | int __init | ||
135 | setup_netjet_u(struct IsdnCard *card) | ||
136 | { | ||
137 | int bytecnt; | ||
138 | struct IsdnCardState *cs = card->cs; | ||
139 | char tmp[64]; | ||
140 | #ifdef CONFIG_PCI | ||
141 | #endif | ||
142 | #ifdef __BIG_ENDIAN | ||
143 | #error "not running on big endian machines now" | ||
144 | #endif | ||
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) | ||
148 | return(0); | ||
149 | test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); | ||
150 | |||
151 | #ifdef CONFIG_PCI | ||
152 | |||
153 | for ( ;; ) | ||
154 | { | ||
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)) | ||
158 | return(0); | ||
159 | pci_set_master(dev_netjet); | ||
160 | cs->irq = dev_netjet->irq; | ||
161 | if (!cs->irq) { | ||
162 | printk(KERN_WARNING "NETspider-U: No IRQ for PCI card found\n"); | ||
163 | return(0); | ||
164 | } | ||
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"); | ||
168 | return(0); | ||
169 | } | ||
170 | } else { | ||
171 | printk(KERN_WARNING "NETspider-U: No PCI card found\n"); | ||
172 | return(0); | ||
173 | } | ||
174 | |||
175 | cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA; | ||
176 | cs->hw.njet.isac = cs->hw.njet.base | NETJET_ISAC_OFF; | ||
177 | mdelay(10); | ||
178 | |||
179 | cs->hw.njet.ctrl_reg = 0xff; /* Reset On */ | ||
180 | byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg); | ||
181 | mdelay(10); | ||
182 | |||
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); | ||
185 | mdelay(10); | ||
186 | |||
187 | cs->hw.njet.auxd = 0xC0; | ||
188 | cs->hw.njet.dmactrl = 0; | ||
189 | |||
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); | ||
194 | |||
195 | switch ( ( ( NETjet_ReadIC( cs, ICC_RBCH ) >> 5 ) & 3 ) ) | ||
196 | { | ||
197 | case 3 : | ||
198 | break; | ||
199 | |||
200 | case 0 : | ||
201 | printk( KERN_WARNING "NETspider-U: NETjet-S PCI card found\n" ); | ||
202 | continue; | ||
203 | |||
204 | default : | ||
205 | printk( KERN_WARNING "NETspider-U: No PCI card found\n" ); | ||
206 | return 0; | ||
207 | } | ||
208 | break; | ||
209 | } | ||
210 | #else | ||
211 | |||
212 | printk(KERN_WARNING "NETspider-U: NO_PCI_BIOS\n"); | ||
213 | printk(KERN_WARNING "NETspider-U: unable to config NETspider-U PCI\n"); | ||
214 | return (0); | ||
215 | |||
216 | #endif /* CONFIG_PCI */ | ||
217 | |||
218 | bytecnt = 256; | ||
219 | |||
220 | printk(KERN_INFO | ||
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")) { | ||
224 | printk(KERN_WARNING | ||
225 | "HiSax: %s config port %#lx-%#lx already in use\n", | ||
226 | CardType[card->typ], | ||
227 | cs->hw.njet.base, | ||
228 | cs->hw.njet.base + bytecnt); | ||
229 | return (0); | ||
230 | } | ||
231 | setup_icc(cs); | ||
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:"); | ||
243 | return (1); | ||
244 | } | ||