diff options
Diffstat (limited to 'drivers/isdn/hisax/hisax_fcpcipnp.c')
-rw-r--r-- | drivers/isdn/hisax/hisax_fcpcipnp.c | 1028 |
1 files changed, 1028 insertions, 0 deletions
diff --git a/drivers/isdn/hisax/hisax_fcpcipnp.c b/drivers/isdn/hisax/hisax_fcpcipnp.c new file mode 100644 index 000000000000..b4d795d40154 --- /dev/null +++ b/drivers/isdn/hisax/hisax_fcpcipnp.c | |||
@@ -0,0 +1,1028 @@ | |||
1 | /* | ||
2 | * Driver for AVM Fritz!PCI, Fritz!PCI v2, Fritz!PnP ISDN cards | ||
3 | * | ||
4 | * Author Kai Germaschewski | ||
5 | * Copyright 2001 by Kai Germaschewski <kai.germaschewski@gmx.de> | ||
6 | * 2001 by Karsten Keil <keil@isdn4linux.de> | ||
7 | * | ||
8 | * based upon Karsten Keil's original avm_pci.c driver | ||
9 | * | ||
10 | * This software may be used and distributed according to the terms | ||
11 | * of the GNU General Public License, incorporated herein by reference. | ||
12 | * | ||
13 | * Thanks to Wizard Computersysteme GmbH, Bremervoerde and | ||
14 | * SoHaNet Technology GmbH, Berlin | ||
15 | * for supporting the development of this driver | ||
16 | */ | ||
17 | |||
18 | |||
19 | /* TODO: | ||
20 | * | ||
21 | * o POWER PC | ||
22 | * o clean up debugging | ||
23 | * o tx_skb at PH_DEACTIVATE time | ||
24 | */ | ||
25 | |||
26 | #include <linux/version.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/init.h> | ||
29 | #include <linux/pci.h> | ||
30 | #include <linux/isapnp.h> | ||
31 | #include <linux/kmod.h> | ||
32 | #include <linux/slab.h> | ||
33 | #include <linux/skbuff.h> | ||
34 | #include <linux/netdevice.h> | ||
35 | #include <linux/delay.h> | ||
36 | |||
37 | #include <asm/io.h> | ||
38 | |||
39 | #include "hisax_fcpcipnp.h" | ||
40 | |||
41 | // debugging cruft | ||
42 | #define __debug_variable debug | ||
43 | #include "hisax_debug.h" | ||
44 | |||
45 | #ifdef CONFIG_HISAX_DEBUG | ||
46 | static int debug = 0; | ||
47 | /* static int hdlcfifosize = 32; */ | ||
48 | module_param(debug, int, 0); | ||
49 | /* module_param(hdlcfifosize, int, 0); */ | ||
50 | #endif | ||
51 | |||
52 | MODULE_AUTHOR("Kai Germaschewski <kai.germaschewski@gmx.de>/Karsten Keil <kkeil@suse.de>"); | ||
53 | MODULE_DESCRIPTION("AVM Fritz!PCI/PnP ISDN driver"); | ||
54 | |||
55 | static struct pci_device_id fcpci_ids[] = { | ||
56 | { .vendor = PCI_VENDOR_ID_AVM, | ||
57 | .device = PCI_DEVICE_ID_AVM_A1, | ||
58 | .subvendor = PCI_ANY_ID, | ||
59 | .subdevice = PCI_ANY_ID, | ||
60 | .driver_data = (unsigned long) "Fritz!Card PCI", | ||
61 | }, | ||
62 | { .vendor = PCI_VENDOR_ID_AVM, | ||
63 | .device = PCI_DEVICE_ID_AVM_A1_V2, | ||
64 | .subvendor = PCI_ANY_ID, | ||
65 | .subdevice = PCI_ANY_ID, | ||
66 | .driver_data = (unsigned long) "Fritz!Card PCI v2" }, | ||
67 | {} | ||
68 | }; | ||
69 | |||
70 | MODULE_DEVICE_TABLE(pci, fcpci_ids); | ||
71 | |||
72 | #ifdef __ISAPNP__ | ||
73 | static struct pnp_device_id fcpnp_ids[] __devinitdata = { | ||
74 | { | ||
75 | .id = "AVM0900", | ||
76 | .driver_data = (unsigned long) "Fritz!Card PnP", | ||
77 | }, | ||
78 | }; | ||
79 | |||
80 | MODULE_DEVICE_TABLE(isapnp, fcpnp_ids); | ||
81 | #endif | ||
82 | |||
83 | static int protocol = 2; /* EURO-ISDN Default */ | ||
84 | module_param(protocol, int, 0); | ||
85 | MODULE_LICENSE("GPL"); | ||
86 | |||
87 | // ---------------------------------------------------------------------- | ||
88 | |||
89 | #define AVM_INDEX 0x04 | ||
90 | #define AVM_DATA 0x10 | ||
91 | |||
92 | #define AVM_IDX_HDLC_1 0x00 | ||
93 | #define AVM_IDX_HDLC_2 0x01 | ||
94 | #define AVM_IDX_ISAC_FIFO 0x02 | ||
95 | #define AVM_IDX_ISAC_REG_LOW 0x04 | ||
96 | #define AVM_IDX_ISAC_REG_HIGH 0x06 | ||
97 | |||
98 | #define AVM_STATUS0 0x02 | ||
99 | |||
100 | #define AVM_STATUS0_IRQ_ISAC 0x01 | ||
101 | #define AVM_STATUS0_IRQ_HDLC 0x02 | ||
102 | #define AVM_STATUS0_IRQ_TIMER 0x04 | ||
103 | #define AVM_STATUS0_IRQ_MASK 0x07 | ||
104 | |||
105 | #define AVM_STATUS0_RESET 0x01 | ||
106 | #define AVM_STATUS0_DIS_TIMER 0x02 | ||
107 | #define AVM_STATUS0_RES_TIMER 0x04 | ||
108 | #define AVM_STATUS0_ENA_IRQ 0x08 | ||
109 | #define AVM_STATUS0_TESTBIT 0x10 | ||
110 | |||
111 | #define AVM_STATUS1 0x03 | ||
112 | #define AVM_STATUS1_ENA_IOM 0x80 | ||
113 | |||
114 | #define HDLC_FIFO 0x0 | ||
115 | #define HDLC_STATUS 0x4 | ||
116 | #define HDLC_CTRL 0x4 | ||
117 | |||
118 | #define HDLC_MODE_ITF_FLG 0x01 | ||
119 | #define HDLC_MODE_TRANS 0x02 | ||
120 | #define HDLC_MODE_CCR_7 0x04 | ||
121 | #define HDLC_MODE_CCR_16 0x08 | ||
122 | #define HDLC_MODE_TESTLOOP 0x80 | ||
123 | |||
124 | #define HDLC_INT_XPR 0x80 | ||
125 | #define HDLC_INT_XDU 0x40 | ||
126 | #define HDLC_INT_RPR 0x20 | ||
127 | #define HDLC_INT_MASK 0xE0 | ||
128 | |||
129 | #define HDLC_STAT_RME 0x01 | ||
130 | #define HDLC_STAT_RDO 0x10 | ||
131 | #define HDLC_STAT_CRCVFRRAB 0x0E | ||
132 | #define HDLC_STAT_CRCVFR 0x06 | ||
133 | #define HDLC_STAT_RML_MASK 0xff00 | ||
134 | |||
135 | #define HDLC_CMD_XRS 0x80 | ||
136 | #define HDLC_CMD_XME 0x01 | ||
137 | #define HDLC_CMD_RRS 0x20 | ||
138 | #define HDLC_CMD_XML_MASK 0xff00 | ||
139 | |||
140 | #define AVM_HDLC_FIFO_1 0x10 | ||
141 | #define AVM_HDLC_FIFO_2 0x18 | ||
142 | |||
143 | #define AVM_HDLC_STATUS_1 0x14 | ||
144 | #define AVM_HDLC_STATUS_2 0x1c | ||
145 | |||
146 | #define AVM_ISACSX_INDEX 0x04 | ||
147 | #define AVM_ISACSX_DATA 0x08 | ||
148 | |||
149 | // ---------------------------------------------------------------------- | ||
150 | // Fritz!PCI | ||
151 | |||
152 | static unsigned char fcpci_read_isac(struct isac *isac, unsigned char offset) | ||
153 | { | ||
154 | struct fritz_adapter *adapter = isac->priv; | ||
155 | unsigned char idx = (offset > 0x2f) ? | ||
156 | AVM_IDX_ISAC_REG_HIGH : AVM_IDX_ISAC_REG_LOW; | ||
157 | unsigned char val; | ||
158 | unsigned long flags; | ||
159 | |||
160 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
161 | outb(idx, adapter->io + AVM_INDEX); | ||
162 | val = inb(adapter->io + AVM_DATA + (offset & 0xf)); | ||
163 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
164 | DBG(0x1000, " port %#x, value %#x", | ||
165 | offset, val); | ||
166 | return val; | ||
167 | } | ||
168 | |||
169 | static void fcpci_write_isac(struct isac *isac, unsigned char offset, | ||
170 | unsigned char value) | ||
171 | { | ||
172 | struct fritz_adapter *adapter = isac->priv; | ||
173 | unsigned char idx = (offset > 0x2f) ? | ||
174 | AVM_IDX_ISAC_REG_HIGH : AVM_IDX_ISAC_REG_LOW; | ||
175 | unsigned long flags; | ||
176 | |||
177 | DBG(0x1000, " port %#x, value %#x", | ||
178 | offset, value); | ||
179 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
180 | outb(idx, adapter->io + AVM_INDEX); | ||
181 | outb(value, adapter->io + AVM_DATA + (offset & 0xf)); | ||
182 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
183 | } | ||
184 | |||
185 | static void fcpci_read_isac_fifo(struct isac *isac, unsigned char * data, | ||
186 | int size) | ||
187 | { | ||
188 | struct fritz_adapter *adapter = isac->priv; | ||
189 | unsigned long flags; | ||
190 | |||
191 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
192 | outb(AVM_IDX_ISAC_FIFO, adapter->io + AVM_INDEX); | ||
193 | insb(adapter->io + AVM_DATA, data, size); | ||
194 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
195 | } | ||
196 | |||
197 | static void fcpci_write_isac_fifo(struct isac *isac, unsigned char * data, | ||
198 | int size) | ||
199 | { | ||
200 | struct fritz_adapter *adapter = isac->priv; | ||
201 | unsigned long flags; | ||
202 | |||
203 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
204 | outb(AVM_IDX_ISAC_FIFO, adapter->io + AVM_INDEX); | ||
205 | outsb(adapter->io + AVM_DATA, data, size); | ||
206 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
207 | } | ||
208 | |||
209 | static u32 fcpci_read_hdlc_status(struct fritz_adapter *adapter, int nr) | ||
210 | { | ||
211 | u32 val; | ||
212 | int idx = nr ? AVM_IDX_HDLC_2 : AVM_IDX_HDLC_1; | ||
213 | unsigned long flags; | ||
214 | |||
215 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
216 | outl(idx, adapter->io + AVM_INDEX); | ||
217 | val = inl(adapter->io + AVM_DATA + HDLC_STATUS); | ||
218 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
219 | return val; | ||
220 | } | ||
221 | |||
222 | static void __fcpci_write_ctrl(struct fritz_bcs *bcs, int which) | ||
223 | { | ||
224 | struct fritz_adapter *adapter = bcs->adapter; | ||
225 | int idx = bcs->channel ? AVM_IDX_HDLC_2 : AVM_IDX_HDLC_1; | ||
226 | |||
227 | DBG(0x40, "hdlc %c wr%x ctrl %x", | ||
228 | 'A' + bcs->channel, which, bcs->ctrl.ctrl); | ||
229 | |||
230 | outl(idx, adapter->io + AVM_INDEX); | ||
231 | outl(bcs->ctrl.ctrl, adapter->io + AVM_DATA + HDLC_CTRL); | ||
232 | } | ||
233 | |||
234 | static void fcpci_write_ctrl(struct fritz_bcs *bcs, int which) | ||
235 | { | ||
236 | struct fritz_adapter *adapter = bcs->adapter; | ||
237 | unsigned long flags; | ||
238 | |||
239 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
240 | __fcpci_write_ctrl(bcs, which); | ||
241 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
242 | } | ||
243 | |||
244 | // ---------------------------------------------------------------------- | ||
245 | // Fritz!PCI v2 | ||
246 | |||
247 | static unsigned char fcpci2_read_isac(struct isac *isac, unsigned char offset) | ||
248 | { | ||
249 | struct fritz_adapter *adapter = isac->priv; | ||
250 | unsigned char val; | ||
251 | unsigned long flags; | ||
252 | |||
253 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
254 | outl(offset, adapter->io + AVM_ISACSX_INDEX); | ||
255 | val = inl(adapter->io + AVM_ISACSX_DATA); | ||
256 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
257 | DBG(0x1000, " port %#x, value %#x", | ||
258 | offset, val); | ||
259 | |||
260 | return val; | ||
261 | } | ||
262 | |||
263 | static void fcpci2_write_isac(struct isac *isac, unsigned char offset, | ||
264 | unsigned char value) | ||
265 | { | ||
266 | struct fritz_adapter *adapter = isac->priv; | ||
267 | unsigned long flags; | ||
268 | |||
269 | DBG(0x1000, " port %#x, value %#x", | ||
270 | offset, value); | ||
271 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
272 | outl(offset, adapter->io + AVM_ISACSX_INDEX); | ||
273 | outl(value, adapter->io + AVM_ISACSX_DATA); | ||
274 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
275 | } | ||
276 | |||
277 | static void fcpci2_read_isac_fifo(struct isac *isac, unsigned char * data, | ||
278 | int size) | ||
279 | { | ||
280 | struct fritz_adapter *adapter = isac->priv; | ||
281 | int i; | ||
282 | unsigned long flags; | ||
283 | |||
284 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
285 | outl(0, adapter->io + AVM_ISACSX_INDEX); | ||
286 | for (i = 0; i < size; i++) | ||
287 | data[i] = inl(adapter->io + AVM_ISACSX_DATA); | ||
288 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
289 | } | ||
290 | |||
291 | static void fcpci2_write_isac_fifo(struct isac *isac, unsigned char * data, | ||
292 | int size) | ||
293 | { | ||
294 | struct fritz_adapter *adapter = isac->priv; | ||
295 | int i; | ||
296 | unsigned long flags; | ||
297 | |||
298 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
299 | outl(0, adapter->io + AVM_ISACSX_INDEX); | ||
300 | for (i = 0; i < size; i++) | ||
301 | outl(data[i], adapter->io + AVM_ISACSX_DATA); | ||
302 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
303 | } | ||
304 | |||
305 | static u32 fcpci2_read_hdlc_status(struct fritz_adapter *adapter, int nr) | ||
306 | { | ||
307 | int offset = nr ? AVM_HDLC_STATUS_2 : AVM_HDLC_STATUS_1; | ||
308 | |||
309 | return inl(adapter->io + offset); | ||
310 | } | ||
311 | |||
312 | static void fcpci2_write_ctrl(struct fritz_bcs *bcs, int which) | ||
313 | { | ||
314 | struct fritz_adapter *adapter = bcs->adapter; | ||
315 | int offset = bcs->channel ? AVM_HDLC_STATUS_2 : AVM_HDLC_STATUS_1; | ||
316 | |||
317 | DBG(0x40, "hdlc %c wr%x ctrl %x", | ||
318 | 'A' + bcs->channel, which, bcs->ctrl.ctrl); | ||
319 | |||
320 | outl(bcs->ctrl.ctrl, adapter->io + offset); | ||
321 | } | ||
322 | |||
323 | // ---------------------------------------------------------------------- | ||
324 | // Fritz!PnP (ISAC access as for Fritz!PCI) | ||
325 | |||
326 | static u32 fcpnp_read_hdlc_status(struct fritz_adapter *adapter, int nr) | ||
327 | { | ||
328 | unsigned char idx = nr ? AVM_IDX_HDLC_2 : AVM_IDX_HDLC_1; | ||
329 | u32 val; | ||
330 | unsigned long flags; | ||
331 | |||
332 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
333 | outb(idx, adapter->io + AVM_INDEX); | ||
334 | val = inb(adapter->io + AVM_DATA + HDLC_STATUS); | ||
335 | if (val & HDLC_INT_RPR) | ||
336 | val |= inb(adapter->io + AVM_DATA + HDLC_STATUS + 1) << 8; | ||
337 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
338 | return val; | ||
339 | } | ||
340 | |||
341 | static void __fcpnp_write_ctrl(struct fritz_bcs *bcs, int which) | ||
342 | { | ||
343 | struct fritz_adapter *adapter = bcs->adapter; | ||
344 | unsigned char idx = bcs->channel ? AVM_IDX_HDLC_2 : AVM_IDX_HDLC_1; | ||
345 | |||
346 | DBG(0x40, "hdlc %c wr%x ctrl %x", | ||
347 | 'A' + bcs->channel, which, bcs->ctrl.ctrl); | ||
348 | |||
349 | outb(idx, adapter->io + AVM_INDEX); | ||
350 | if (which & 4) | ||
351 | outb(bcs->ctrl.sr.mode, | ||
352 | adapter->io + AVM_DATA + HDLC_STATUS + 2); | ||
353 | if (which & 2) | ||
354 | outb(bcs->ctrl.sr.xml, | ||
355 | adapter->io + AVM_DATA + HDLC_STATUS + 1); | ||
356 | if (which & 1) | ||
357 | outb(bcs->ctrl.sr.cmd, | ||
358 | adapter->io + AVM_DATA + HDLC_STATUS + 0); | ||
359 | } | ||
360 | |||
361 | static void fcpnp_write_ctrl(struct fritz_bcs *bcs, int which) | ||
362 | { | ||
363 | struct fritz_adapter *adapter = bcs->adapter; | ||
364 | unsigned long flags; | ||
365 | |||
366 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
367 | __fcpnp_write_ctrl(bcs, which); | ||
368 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
369 | } | ||
370 | |||
371 | // ---------------------------------------------------------------------- | ||
372 | |||
373 | static inline void B_L1L2(struct fritz_bcs *bcs, int pr, void *arg) | ||
374 | { | ||
375 | struct hisax_if *ifc = (struct hisax_if *) &bcs->b_if; | ||
376 | |||
377 | DBG(2, "pr %#x", pr); | ||
378 | ifc->l1l2(ifc, pr, arg); | ||
379 | } | ||
380 | |||
381 | static void hdlc_fill_fifo(struct fritz_bcs *bcs) | ||
382 | { | ||
383 | struct fritz_adapter *adapter = bcs->adapter; | ||
384 | struct sk_buff *skb = bcs->tx_skb; | ||
385 | int count; | ||
386 | unsigned long flags; | ||
387 | unsigned char *p; | ||
388 | |||
389 | DBG(0x40, "hdlc_fill_fifo"); | ||
390 | |||
391 | if (skb->len == 0) | ||
392 | BUG(); | ||
393 | |||
394 | bcs->ctrl.sr.cmd &= ~HDLC_CMD_XME; | ||
395 | if (bcs->tx_skb->len > bcs->fifo_size) { | ||
396 | count = bcs->fifo_size; | ||
397 | } else { | ||
398 | count = bcs->tx_skb->len; | ||
399 | if (bcs->mode != L1_MODE_TRANS) | ||
400 | bcs->ctrl.sr.cmd |= HDLC_CMD_XME; | ||
401 | } | ||
402 | DBG(0x40, "hdlc_fill_fifo %d/%d", count, bcs->tx_skb->len); | ||
403 | p = bcs->tx_skb->data; | ||
404 | skb_pull(bcs->tx_skb, count); | ||
405 | bcs->tx_cnt += count; | ||
406 | bcs->ctrl.sr.xml = ((count == bcs->fifo_size) ? 0 : count); | ||
407 | |||
408 | switch (adapter->type) { | ||
409 | case AVM_FRITZ_PCI: | ||
410 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
411 | // sets the correct AVM_INDEX, too | ||
412 | __fcpci_write_ctrl(bcs, 3); | ||
413 | outsl(adapter->io + AVM_DATA + HDLC_FIFO, | ||
414 | p, (count + 3) / 4); | ||
415 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
416 | break; | ||
417 | case AVM_FRITZ_PCIV2: | ||
418 | fcpci2_write_ctrl(bcs, 3); | ||
419 | outsl(adapter->io + | ||
420 | (bcs->channel ? AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1), | ||
421 | p, (count + 3) / 4); | ||
422 | break; | ||
423 | case AVM_FRITZ_PNP: | ||
424 | spin_lock_irqsave(&adapter->hw_lock, flags); | ||
425 | // sets the correct AVM_INDEX, too | ||
426 | __fcpnp_write_ctrl(bcs, 3); | ||
427 | outsb(adapter->io + AVM_DATA, p, count); | ||
428 | spin_unlock_irqrestore(&adapter->hw_lock, flags); | ||
429 | break; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | static inline void hdlc_empty_fifo(struct fritz_bcs *bcs, int count) | ||
434 | { | ||
435 | struct fritz_adapter *adapter = bcs->adapter; | ||
436 | unsigned char *p; | ||
437 | unsigned char idx = bcs->channel ? AVM_IDX_HDLC_2 : AVM_IDX_HDLC_1; | ||
438 | |||
439 | DBG(0x10, "hdlc_empty_fifo %d", count); | ||
440 | if (bcs->rcvidx + count > HSCX_BUFMAX) { | ||
441 | DBG(0x10, "hdlc_empty_fifo: incoming packet too large"); | ||
442 | return; | ||
443 | } | ||
444 | p = bcs->rcvbuf + bcs->rcvidx; | ||
445 | bcs->rcvidx += count; | ||
446 | switch (adapter->type) { | ||
447 | case AVM_FRITZ_PCI: | ||
448 | spin_lock(&adapter->hw_lock); | ||
449 | outl(idx, adapter->io + AVM_INDEX); | ||
450 | insl(adapter->io + AVM_DATA + HDLC_FIFO, | ||
451 | p, (count + 3) / 4); | ||
452 | spin_unlock(&adapter->hw_lock); | ||
453 | break; | ||
454 | case AVM_FRITZ_PCIV2: | ||
455 | insl(adapter->io + | ||
456 | (bcs->channel ? AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1), | ||
457 | p, (count + 3) / 4); | ||
458 | break; | ||
459 | case AVM_FRITZ_PNP: | ||
460 | spin_lock(&adapter->hw_lock); | ||
461 | outb(idx, adapter->io + AVM_INDEX); | ||
462 | insb(adapter->io + AVM_DATA, p, count); | ||
463 | spin_unlock(&adapter->hw_lock); | ||
464 | break; | ||
465 | } | ||
466 | } | ||
467 | |||
468 | static inline void hdlc_rpr_irq(struct fritz_bcs *bcs, u32 stat) | ||
469 | { | ||
470 | struct fritz_adapter *adapter = bcs->adapter; | ||
471 | struct sk_buff *skb; | ||
472 | int len; | ||
473 | |||
474 | if (stat & HDLC_STAT_RDO) { | ||
475 | DBG(0x10, "RDO"); | ||
476 | bcs->ctrl.sr.xml = 0; | ||
477 | bcs->ctrl.sr.cmd |= HDLC_CMD_RRS; | ||
478 | adapter->write_ctrl(bcs, 1); | ||
479 | bcs->ctrl.sr.cmd &= ~HDLC_CMD_RRS; | ||
480 | adapter->write_ctrl(bcs, 1); | ||
481 | bcs->rcvidx = 0; | ||
482 | return; | ||
483 | } | ||
484 | |||
485 | len = (stat & HDLC_STAT_RML_MASK) >> 8; | ||
486 | if (len == 0) | ||
487 | len = bcs->fifo_size; | ||
488 | |||
489 | hdlc_empty_fifo(bcs, len); | ||
490 | |||
491 | if ((stat & HDLC_STAT_RME) || (bcs->mode == L1_MODE_TRANS)) { | ||
492 | if (((stat & HDLC_STAT_CRCVFRRAB)== HDLC_STAT_CRCVFR) || | ||
493 | (bcs->mode == L1_MODE_TRANS)) { | ||
494 | skb = dev_alloc_skb(bcs->rcvidx); | ||
495 | if (!skb) { | ||
496 | printk(KERN_WARNING "HDLC: receive out of memory\n"); | ||
497 | } else { | ||
498 | memcpy(skb_put(skb, bcs->rcvidx), bcs->rcvbuf, | ||
499 | bcs->rcvidx); | ||
500 | DBG_SKB(1, skb); | ||
501 | B_L1L2(bcs, PH_DATA | INDICATION, skb); | ||
502 | } | ||
503 | bcs->rcvidx = 0; | ||
504 | } else { | ||
505 | DBG(0x10, "ch%d invalid frame %#x", | ||
506 | bcs->channel, stat); | ||
507 | bcs->rcvidx = 0; | ||
508 | } | ||
509 | } | ||
510 | } | ||
511 | |||
512 | static inline void hdlc_xdu_irq(struct fritz_bcs *bcs) | ||
513 | { | ||
514 | struct fritz_adapter *adapter = bcs->adapter; | ||
515 | |||
516 | |||
517 | /* Here we lost an TX interrupt, so | ||
518 | * restart transmitting the whole frame. | ||
519 | */ | ||
520 | bcs->ctrl.sr.xml = 0; | ||
521 | bcs->ctrl.sr.cmd |= HDLC_CMD_XRS; | ||
522 | adapter->write_ctrl(bcs, 1); | ||
523 | bcs->ctrl.sr.cmd &= ~HDLC_CMD_XRS; | ||
524 | |||
525 | if (!bcs->tx_skb) { | ||
526 | DBG(0x10, "XDU without skb"); | ||
527 | adapter->write_ctrl(bcs, 1); | ||
528 | return; | ||
529 | } | ||
530 | /* only hdlc restarts the frame, transparent mode must continue */ | ||
531 | if (bcs->mode == L1_MODE_HDLC) { | ||
532 | skb_push(bcs->tx_skb, bcs->tx_cnt); | ||
533 | bcs->tx_cnt = 0; | ||
534 | } | ||
535 | } | ||
536 | |||
537 | static inline void hdlc_xpr_irq(struct fritz_bcs *bcs) | ||
538 | { | ||
539 | struct sk_buff *skb; | ||
540 | |||
541 | skb = bcs->tx_skb; | ||
542 | if (!skb) | ||
543 | return; | ||
544 | |||
545 | if (skb->len) { | ||
546 | hdlc_fill_fifo(bcs); | ||
547 | return; | ||
548 | } | ||
549 | bcs->tx_cnt = 0; | ||
550 | bcs->tx_skb = NULL; | ||
551 | B_L1L2(bcs, PH_DATA | CONFIRM, (void *) skb->truesize); | ||
552 | dev_kfree_skb_irq(skb); | ||
553 | } | ||
554 | |||
555 | static void hdlc_irq_one(struct fritz_bcs *bcs, u32 stat) | ||
556 | { | ||
557 | DBG(0x10, "ch%d stat %#x", bcs->channel, stat); | ||
558 | if (stat & HDLC_INT_RPR) { | ||
559 | DBG(0x10, "RPR"); | ||
560 | hdlc_rpr_irq(bcs, stat); | ||
561 | } | ||
562 | if (stat & HDLC_INT_XDU) { | ||
563 | DBG(0x10, "XDU"); | ||
564 | hdlc_xdu_irq(bcs); | ||
565 | hdlc_xpr_irq(bcs); | ||
566 | return; | ||
567 | } | ||
568 | if (stat & HDLC_INT_XPR) { | ||
569 | DBG(0x10, "XPR"); | ||
570 | hdlc_xpr_irq(bcs); | ||
571 | } | ||
572 | } | ||
573 | |||
574 | static inline void hdlc_irq(struct fritz_adapter *adapter) | ||
575 | { | ||
576 | int nr; | ||
577 | u32 stat; | ||
578 | |||
579 | for (nr = 0; nr < 2; nr++) { | ||
580 | stat = adapter->read_hdlc_status(adapter, nr); | ||
581 | DBG(0x10, "HDLC %c stat %#x", 'A' + nr, stat); | ||
582 | if (stat & HDLC_INT_MASK) | ||
583 | hdlc_irq_one(&adapter->bcs[nr], stat); | ||
584 | } | ||
585 | } | ||
586 | |||
587 | static void modehdlc(struct fritz_bcs *bcs, int mode) | ||
588 | { | ||
589 | struct fritz_adapter *adapter = bcs->adapter; | ||
590 | |||
591 | DBG(0x40, "hdlc %c mode %d --> %d", | ||
592 | 'A' + bcs->channel, bcs->mode, mode); | ||
593 | |||
594 | if (bcs->mode == mode) | ||
595 | return; | ||
596 | |||
597 | bcs->fifo_size = 32; | ||
598 | bcs->ctrl.ctrl = 0; | ||
599 | bcs->ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS; | ||
600 | switch (mode) { | ||
601 | case L1_MODE_NULL: | ||
602 | bcs->ctrl.sr.mode = HDLC_MODE_TRANS; | ||
603 | adapter->write_ctrl(bcs, 5); | ||
604 | break; | ||
605 | case L1_MODE_TRANS: | ||
606 | case L1_MODE_HDLC: | ||
607 | bcs->rcvidx = 0; | ||
608 | bcs->tx_cnt = 0; | ||
609 | bcs->tx_skb = NULL; | ||
610 | if (mode == L1_MODE_TRANS) { | ||
611 | bcs->ctrl.sr.mode = HDLC_MODE_TRANS; | ||
612 | } else { | ||
613 | bcs->ctrl.sr.mode = HDLC_MODE_ITF_FLG; | ||
614 | } | ||
615 | adapter->write_ctrl(bcs, 5); | ||
616 | bcs->ctrl.sr.cmd = HDLC_CMD_XRS; | ||
617 | adapter->write_ctrl(bcs, 1); | ||
618 | bcs->ctrl.sr.cmd = 0; | ||
619 | break; | ||
620 | } | ||
621 | bcs->mode = mode; | ||
622 | } | ||
623 | |||
624 | static void fritz_b_l2l1(struct hisax_if *ifc, int pr, void *arg) | ||
625 | { | ||
626 | struct fritz_bcs *bcs = ifc->priv; | ||
627 | struct sk_buff *skb = arg; | ||
628 | int mode; | ||
629 | |||
630 | DBG(0x10, "pr %#x", pr); | ||
631 | |||
632 | switch (pr) { | ||
633 | case PH_DATA | REQUEST: | ||
634 | if (bcs->tx_skb) | ||
635 | BUG(); | ||
636 | |||
637 | bcs->tx_skb = skb; | ||
638 | DBG_SKB(1, skb); | ||
639 | hdlc_fill_fifo(bcs); | ||
640 | break; | ||
641 | case PH_ACTIVATE | REQUEST: | ||
642 | mode = (int) arg; | ||
643 | DBG(4,"B%d,PH_ACTIVATE_REQUEST %d", bcs->channel + 1, mode); | ||
644 | modehdlc(bcs, mode); | ||
645 | B_L1L2(bcs, PH_ACTIVATE | INDICATION, NULL); | ||
646 | break; | ||
647 | case PH_DEACTIVATE | REQUEST: | ||
648 | DBG(4,"B%d,PH_DEACTIVATE_REQUEST", bcs->channel + 1); | ||
649 | modehdlc(bcs, L1_MODE_NULL); | ||
650 | B_L1L2(bcs, PH_DEACTIVATE | INDICATION, NULL); | ||
651 | break; | ||
652 | } | ||
653 | } | ||
654 | |||
655 | // ---------------------------------------------------------------------- | ||
656 | |||
657 | static irqreturn_t | ||
658 | fcpci2_irq(int intno, void *dev, struct pt_regs *regs) | ||
659 | { | ||
660 | struct fritz_adapter *adapter = dev; | ||
661 | unsigned char val; | ||
662 | |||
663 | val = inb(adapter->io + AVM_STATUS0); | ||
664 | if (!(val & AVM_STATUS0_IRQ_MASK)) | ||
665 | /* hopefully a shared IRQ reqest */ | ||
666 | return IRQ_NONE; | ||
667 | DBG(2, "STATUS0 %#x", val); | ||
668 | if (val & AVM_STATUS0_IRQ_ISAC) | ||
669 | isacsx_irq(&adapter->isac); | ||
670 | if (val & AVM_STATUS0_IRQ_HDLC) | ||
671 | hdlc_irq(adapter); | ||
672 | if (val & AVM_STATUS0_IRQ_ISAC) | ||
673 | isacsx_irq(&adapter->isac); | ||
674 | return IRQ_HANDLED; | ||
675 | } | ||
676 | |||
677 | static irqreturn_t | ||
678 | fcpci_irq(int intno, void *dev, struct pt_regs *regs) | ||
679 | { | ||
680 | struct fritz_adapter *adapter = dev; | ||
681 | unsigned char sval; | ||
682 | |||
683 | sval = inb(adapter->io + 2); | ||
684 | if ((sval & AVM_STATUS0_IRQ_MASK) == AVM_STATUS0_IRQ_MASK) | ||
685 | /* possibly a shared IRQ reqest */ | ||
686 | return IRQ_NONE; | ||
687 | DBG(2, "sval %#x", sval); | ||
688 | if (!(sval & AVM_STATUS0_IRQ_ISAC)) | ||
689 | isac_irq(&adapter->isac); | ||
690 | |||
691 | if (!(sval & AVM_STATUS0_IRQ_HDLC)) | ||
692 | hdlc_irq(adapter); | ||
693 | return IRQ_HANDLED; | ||
694 | } | ||
695 | |||
696 | // ---------------------------------------------------------------------- | ||
697 | |||
698 | static inline void fcpci2_init(struct fritz_adapter *adapter) | ||
699 | { | ||
700 | outb(AVM_STATUS0_RES_TIMER, adapter->io + AVM_STATUS0); | ||
701 | outb(AVM_STATUS0_ENA_IRQ, adapter->io + AVM_STATUS0); | ||
702 | |||
703 | } | ||
704 | |||
705 | static inline void fcpci_init(struct fritz_adapter *adapter) | ||
706 | { | ||
707 | outb(AVM_STATUS0_DIS_TIMER | AVM_STATUS0_RES_TIMER | | ||
708 | AVM_STATUS0_ENA_IRQ, adapter->io + AVM_STATUS0); | ||
709 | |||
710 | outb(AVM_STATUS1_ENA_IOM | adapter->irq, | ||
711 | adapter->io + AVM_STATUS1); | ||
712 | mdelay(10); | ||
713 | } | ||
714 | |||
715 | // ---------------------------------------------------------------------- | ||
716 | |||
717 | static int __devinit fcpcipnp_setup(struct fritz_adapter *adapter) | ||
718 | { | ||
719 | u32 val = 0; | ||
720 | int retval; | ||
721 | |||
722 | DBG(1,""); | ||
723 | |||
724 | isac_init(&adapter->isac); // FIXME is this okay now | ||
725 | |||
726 | retval = -EBUSY; | ||
727 | if (!request_region(adapter->io, 32, "fcpcipnp")) | ||
728 | goto err; | ||
729 | |||
730 | switch (adapter->type) { | ||
731 | case AVM_FRITZ_PCIV2: | ||
732 | retval = request_irq(adapter->irq, fcpci2_irq, SA_SHIRQ, | ||
733 | "fcpcipnp", adapter); | ||
734 | break; | ||
735 | case AVM_FRITZ_PCI: | ||
736 | retval = request_irq(adapter->irq, fcpci_irq, SA_SHIRQ, | ||
737 | "fcpcipnp", adapter); | ||
738 | break; | ||
739 | case AVM_FRITZ_PNP: | ||
740 | retval = request_irq(adapter->irq, fcpci_irq, 0, | ||
741 | "fcpcipnp", adapter); | ||
742 | break; | ||
743 | } | ||
744 | if (retval) | ||
745 | goto err_region; | ||
746 | |||
747 | switch (adapter->type) { | ||
748 | case AVM_FRITZ_PCIV2: | ||
749 | case AVM_FRITZ_PCI: | ||
750 | val = inl(adapter->io); | ||
751 | break; | ||
752 | case AVM_FRITZ_PNP: | ||
753 | val = inb(adapter->io); | ||
754 | val |= inb(adapter->io + 1) << 8; | ||
755 | break; | ||
756 | } | ||
757 | |||
758 | DBG(1, "stat %#x Class %X Rev %d", | ||
759 | val, val & 0xff, (val>>8) & 0xff); | ||
760 | |||
761 | spin_lock_init(&adapter->hw_lock); | ||
762 | adapter->isac.priv = adapter; | ||
763 | switch (adapter->type) { | ||
764 | case AVM_FRITZ_PCIV2: | ||
765 | adapter->isac.read_isac = &fcpci2_read_isac; | ||
766 | adapter->isac.write_isac = &fcpci2_write_isac; | ||
767 | adapter->isac.read_isac_fifo = &fcpci2_read_isac_fifo; | ||
768 | adapter->isac.write_isac_fifo = &fcpci2_write_isac_fifo; | ||
769 | |||
770 | adapter->read_hdlc_status = &fcpci2_read_hdlc_status; | ||
771 | adapter->write_ctrl = &fcpci2_write_ctrl; | ||
772 | break; | ||
773 | case AVM_FRITZ_PCI: | ||
774 | adapter->isac.read_isac = &fcpci_read_isac; | ||
775 | adapter->isac.write_isac = &fcpci_write_isac; | ||
776 | adapter->isac.read_isac_fifo = &fcpci_read_isac_fifo; | ||
777 | adapter->isac.write_isac_fifo = &fcpci_write_isac_fifo; | ||
778 | |||
779 | adapter->read_hdlc_status = &fcpci_read_hdlc_status; | ||
780 | adapter->write_ctrl = &fcpci_write_ctrl; | ||
781 | break; | ||
782 | case AVM_FRITZ_PNP: | ||
783 | adapter->isac.read_isac = &fcpci_read_isac; | ||
784 | adapter->isac.write_isac = &fcpci_write_isac; | ||
785 | adapter->isac.read_isac_fifo = &fcpci_read_isac_fifo; | ||
786 | adapter->isac.write_isac_fifo = &fcpci_write_isac_fifo; | ||
787 | |||
788 | adapter->read_hdlc_status = &fcpnp_read_hdlc_status; | ||
789 | adapter->write_ctrl = &fcpnp_write_ctrl; | ||
790 | break; | ||
791 | } | ||
792 | |||
793 | // Reset | ||
794 | outb(0, adapter->io + AVM_STATUS0); | ||
795 | mdelay(10); | ||
796 | outb(AVM_STATUS0_RESET, adapter->io + AVM_STATUS0); | ||
797 | mdelay(10); | ||
798 | outb(0, adapter->io + AVM_STATUS0); | ||
799 | mdelay(10); | ||
800 | |||
801 | switch (adapter->type) { | ||
802 | case AVM_FRITZ_PCIV2: | ||
803 | fcpci2_init(adapter); | ||
804 | isacsx_setup(&adapter->isac); | ||
805 | break; | ||
806 | case AVM_FRITZ_PCI: | ||
807 | case AVM_FRITZ_PNP: | ||
808 | fcpci_init(adapter); | ||
809 | isac_setup(&adapter->isac); | ||
810 | break; | ||
811 | } | ||
812 | val = adapter->read_hdlc_status(adapter, 0); | ||
813 | DBG(0x20, "HDLC A STA %x", val); | ||
814 | val = adapter->read_hdlc_status(adapter, 1); | ||
815 | DBG(0x20, "HDLC B STA %x", val); | ||
816 | |||
817 | adapter->bcs[0].mode = -1; | ||
818 | adapter->bcs[1].mode = -1; | ||
819 | modehdlc(&adapter->bcs[0], L1_MODE_NULL); | ||
820 | modehdlc(&adapter->bcs[1], L1_MODE_NULL); | ||
821 | |||
822 | return 0; | ||
823 | |||
824 | err_region: | ||
825 | release_region(adapter->io, 32); | ||
826 | err: | ||
827 | return retval; | ||
828 | } | ||
829 | |||
830 | static void __devexit fcpcipnp_release(struct fritz_adapter *adapter) | ||
831 | { | ||
832 | DBG(1,""); | ||
833 | |||
834 | outb(0, adapter->io + AVM_STATUS0); | ||
835 | free_irq(adapter->irq, adapter); | ||
836 | release_region(adapter->io, 32); | ||
837 | } | ||
838 | |||
839 | // ---------------------------------------------------------------------- | ||
840 | |||
841 | static struct fritz_adapter * __devinit | ||
842 | new_adapter(void) | ||
843 | { | ||
844 | struct fritz_adapter *adapter; | ||
845 | struct hisax_b_if *b_if[2]; | ||
846 | int i; | ||
847 | |||
848 | adapter = kmalloc(sizeof(struct fritz_adapter), GFP_KERNEL); | ||
849 | if (!adapter) | ||
850 | return NULL; | ||
851 | |||
852 | memset(adapter, 0, sizeof(struct fritz_adapter)); | ||
853 | |||
854 | adapter->isac.hisax_d_if.owner = THIS_MODULE; | ||
855 | adapter->isac.hisax_d_if.ifc.priv = &adapter->isac; | ||
856 | adapter->isac.hisax_d_if.ifc.l2l1 = isac_d_l2l1; | ||
857 | |||
858 | for (i = 0; i < 2; i++) { | ||
859 | adapter->bcs[i].adapter = adapter; | ||
860 | adapter->bcs[i].channel = i; | ||
861 | adapter->bcs[i].b_if.ifc.priv = &adapter->bcs[i]; | ||
862 | adapter->bcs[i].b_if.ifc.l2l1 = fritz_b_l2l1; | ||
863 | } | ||
864 | |||
865 | for (i = 0; i < 2; i++) | ||
866 | b_if[i] = &adapter->bcs[i].b_if; | ||
867 | |||
868 | hisax_register(&adapter->isac.hisax_d_if, b_if, "fcpcipnp", protocol); | ||
869 | |||
870 | return adapter; | ||
871 | } | ||
872 | |||
873 | static void delete_adapter(struct fritz_adapter *adapter) | ||
874 | { | ||
875 | hisax_unregister(&adapter->isac.hisax_d_if); | ||
876 | kfree(adapter); | ||
877 | } | ||
878 | |||
879 | static int __devinit fcpci_probe(struct pci_dev *pdev, | ||
880 | const struct pci_device_id *ent) | ||
881 | { | ||
882 | struct fritz_adapter *adapter; | ||
883 | int retval; | ||
884 | |||
885 | retval = -ENOMEM; | ||
886 | adapter = new_adapter(); | ||
887 | if (!adapter) | ||
888 | goto err; | ||
889 | |||
890 | pci_set_drvdata(pdev, adapter); | ||
891 | |||
892 | if (pdev->device == PCI_DEVICE_ID_AVM_A1_V2) | ||
893 | adapter->type = AVM_FRITZ_PCIV2; | ||
894 | else | ||
895 | adapter->type = AVM_FRITZ_PCI; | ||
896 | |||
897 | retval = pci_enable_device(pdev); | ||
898 | if (retval) | ||
899 | goto err_free; | ||
900 | |||
901 | adapter->io = pci_resource_start(pdev, 1); | ||
902 | adapter->irq = pdev->irq; | ||
903 | |||
904 | printk(KERN_INFO "hisax_fcpcipnp: found adapter %s at %s\n", | ||
905 | (char *) ent->driver_data, pci_name(pdev)); | ||
906 | |||
907 | retval = fcpcipnp_setup(adapter); | ||
908 | if (retval) | ||
909 | goto err_free; | ||
910 | |||
911 | return 0; | ||
912 | |||
913 | err_free: | ||
914 | delete_adapter(adapter); | ||
915 | err: | ||
916 | return retval; | ||
917 | } | ||
918 | |||
919 | #ifdef __ISAPNP__ | ||
920 | static int __devinit fcpnp_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) | ||
921 | { | ||
922 | struct fritz_adapter *adapter; | ||
923 | int retval; | ||
924 | |||
925 | if (!pdev) | ||
926 | return(-ENODEV); | ||
927 | |||
928 | retval = -ENOMEM; | ||
929 | adapter = new_adapter(); | ||
930 | if (!adapter) | ||
931 | goto err; | ||
932 | |||
933 | pnp_set_drvdata(pdev, adapter); | ||
934 | |||
935 | adapter->type = AVM_FRITZ_PNP; | ||
936 | |||
937 | pnp_disable_dev(pdev); | ||
938 | retval = pnp_activate_dev(pdev); | ||
939 | if (retval < 0) { | ||
940 | printk(KERN_WARNING "%s: pnp_activate_dev(%s) ret(%d)\n", __FUNCTION__, | ||
941 | (char *)dev_id->driver_data, retval); | ||
942 | goto err_free; | ||
943 | } | ||
944 | adapter->io = pnp_port_start(pdev, 0); | ||
945 | adapter->irq = pnp_irq(pdev, 0); | ||
946 | |||
947 | printk(KERN_INFO "hisax_fcpcipnp: found adapter %s at IO %#x irq %d\n", | ||
948 | (char *) dev_id->driver_data, adapter->io, adapter->irq); | ||
949 | |||
950 | retval = fcpcipnp_setup(adapter); | ||
951 | if (retval) | ||
952 | goto err_free; | ||
953 | |||
954 | return 0; | ||
955 | |||
956 | err_free: | ||
957 | delete_adapter(adapter); | ||
958 | err: | ||
959 | return retval; | ||
960 | } | ||
961 | |||
962 | static void __devexit fcpnp_remove(struct pnp_dev *pdev) | ||
963 | { | ||
964 | struct fritz_adapter *adapter = pnp_get_drvdata(pdev); | ||
965 | |||
966 | if (adapter) { | ||
967 | fcpcipnp_release(adapter); | ||
968 | delete_adapter(adapter); | ||
969 | } | ||
970 | pnp_disable_dev(pdev); | ||
971 | } | ||
972 | |||
973 | static struct pnp_driver fcpnp_driver = { | ||
974 | .name = "fcpnp", | ||
975 | .probe = fcpnp_probe, | ||
976 | .remove = __devexit_p(fcpnp_remove), | ||
977 | .id_table = fcpnp_ids, | ||
978 | }; | ||
979 | #endif | ||
980 | |||
981 | static void __devexit fcpci_remove(struct pci_dev *pdev) | ||
982 | { | ||
983 | struct fritz_adapter *adapter = pci_get_drvdata(pdev); | ||
984 | |||
985 | fcpcipnp_release(adapter); | ||
986 | pci_disable_device(pdev); | ||
987 | delete_adapter(adapter); | ||
988 | } | ||
989 | |||
990 | static struct pci_driver fcpci_driver = { | ||
991 | .name = "fcpci", | ||
992 | .probe = fcpci_probe, | ||
993 | .remove = __devexit_p(fcpci_remove), | ||
994 | .id_table = fcpci_ids, | ||
995 | }; | ||
996 | |||
997 | static int __init hisax_fcpcipnp_init(void) | ||
998 | { | ||
999 | int retval; | ||
1000 | |||
1001 | printk(KERN_INFO "hisax_fcpcipnp: Fritz!Card PCI/PCIv2/PnP ISDN driver v0.0.1\n"); | ||
1002 | |||
1003 | retval = pci_register_driver(&fcpci_driver); | ||
1004 | if (retval) | ||
1005 | goto out; | ||
1006 | #ifdef __ISAPNP__ | ||
1007 | retval = pnp_register_driver(&fcpnp_driver); | ||
1008 | if (retval < 0) | ||
1009 | goto out_unregister_pci; | ||
1010 | #endif | ||
1011 | return 0; | ||
1012 | |||
1013 | out_unregister_pci: | ||
1014 | pci_unregister_driver(&fcpci_driver); | ||
1015 | out: | ||
1016 | return retval; | ||
1017 | } | ||
1018 | |||
1019 | static void __exit hisax_fcpcipnp_exit(void) | ||
1020 | { | ||
1021 | #ifdef __ISAPNP__ | ||
1022 | pnp_unregister_driver(&fcpnp_driver); | ||
1023 | #endif | ||
1024 | pci_unregister_driver(&fcpci_driver); | ||
1025 | } | ||
1026 | |||
1027 | module_init(hisax_fcpcipnp_init); | ||
1028 | module_exit(hisax_fcpcipnp_exit); | ||