blob: da13b07cd8568e4503ee1d337e5e198d69d47d1f [file] [log] [blame]
Karsten Keila9008452009-07-23 10:03:05 +02001/*
2 * NETJet mISDN driver
3 *
4 * Author Karsten Keil <keil@isdn4linux.de>
5 *
6 * Copyright 2009 by Karsten Keil <keil@isdn4linux.de>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
Alexey Dobriyana6b7a402011-06-06 10:43:46 +000023#include <linux/interrupt.h>
Karsten Keila9008452009-07-23 10:03:05 +020024#include <linux/module.h>
25#include <linux/pci.h>
26#include <linux/delay.h>
27#include <linux/mISDNhw.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090028#include <linux/slab.h>
Karsten Keila9008452009-07-23 10:03:05 +020029#include "ipac.h"
30#include "iohelper.h"
31#include "netjet.h"
32#include <linux/isdn/hdlc.h>
33
34#define NETJET_REV "2.0"
35
36enum nj_types {
37 NETJET_S_TJ300,
38 NETJET_S_TJ320,
39 ENTERNOW__TJ320,
40};
41
42struct tiger_dma {
43 size_t size;
44 u32 *start;
45 int idx;
46 u32 dmastart;
47 u32 dmairq;
48 u32 dmaend;
49 u32 dmacur;
50};
51
52struct tiger_hw;
53
54struct tiger_ch {
55 struct bchannel bch;
56 struct tiger_hw *nj;
57 int idx;
58 int free;
59 int lastrx;
60 u16 rxstate;
61 u16 txstate;
62 struct isdnhdlc_vars hsend;
63 struct isdnhdlc_vars hrecv;
64 u8 *hsbuf;
65 u8 *hrbuf;
66};
67
68#define TX_INIT 0x0001
69#define TX_IDLE 0x0002
70#define TX_RUN 0x0004
71#define TX_UNDERRUN 0x0100
72#define RX_OVERRUN 0x0100
73
74#define LOG_SIZE 64
75
76struct tiger_hw {
77 struct list_head list;
78 struct pci_dev *pdev;
79 char name[MISDN_MAX_IDLEN];
80 enum nj_types typ;
81 int irq;
82 u32 irqcnt;
83 u32 base;
84 size_t base_s;
85 dma_addr_t dma;
86 void *dma_p;
87 spinlock_t lock; /* lock HW */
88 struct isac_hw isac;
89 struct tiger_dma send;
90 struct tiger_dma recv;
91 struct tiger_ch bc[2];
92 u8 ctrlreg;
93 u8 dmactrl;
94 u8 auxd;
95 u8 last_is0;
96 u8 irqmask0;
97 char log[LOG_SIZE];
98};
99
100static LIST_HEAD(Cards);
101static DEFINE_RWLOCK(card_lock); /* protect Cards */
102static u32 debug;
103static int nj_cnt;
104
105static void
106_set_debug(struct tiger_hw *card)
107{
108 card->isac.dch.debug = debug;
109 card->bc[0].bch.debug = debug;
110 card->bc[1].bch.debug = debug;
111}
112
113static int
114set_debug(const char *val, struct kernel_param *kp)
115{
116 int ret;
117 struct tiger_hw *card;
118
119 ret = param_set_uint(val, kp);
120 if (!ret) {
121 read_lock(&card_lock);
122 list_for_each_entry(card, &Cards, list)
123 _set_debug(card);
124 read_unlock(&card_lock);
125 }
126 return ret;
127}
128
129MODULE_AUTHOR("Karsten Keil");
130MODULE_LICENSE("GPL v2");
131MODULE_VERSION(NETJET_REV);
132module_param_call(debug, set_debug, param_get_uint, &debug, S_IRUGO | S_IWUSR);
133MODULE_PARM_DESC(debug, "Netjet debug mask");
134
135static void
136nj_disable_hwirq(struct tiger_hw *card)
137{
138 outb(0, card->base + NJ_IRQMASK0);
139 outb(0, card->base + NJ_IRQMASK1);
140}
141
142
143static u8
144ReadISAC_nj(void *p, u8 offset)
145{
146 struct tiger_hw *card = p;
147 u8 ret;
148
149 card->auxd &= 0xfc;
150 card->auxd |= (offset >> 4) & 3;
151 outb(card->auxd, card->base + NJ_AUXDATA);
152 ret = inb(card->base + NJ_ISAC_OFF + ((offset & 0x0f) << 2));
153 return ret;
154}
155
156static void
157WriteISAC_nj(void *p, u8 offset, u8 value)
158{
159 struct tiger_hw *card = p;
160
161 card->auxd &= 0xfc;
162 card->auxd |= (offset >> 4) & 3;
163 outb(card->auxd, card->base + NJ_AUXDATA);
164 outb(value, card->base + NJ_ISAC_OFF + ((offset & 0x0f) << 2));
165}
166
167static void
168ReadFiFoISAC_nj(void *p, u8 offset, u8 *data, int size)
169{
170 struct tiger_hw *card = p;
171
172 card->auxd &= 0xfc;
173 outb(card->auxd, card->base + NJ_AUXDATA);
174 insb(card->base + NJ_ISAC_OFF, data, size);
175}
176
177static void
178WriteFiFoISAC_nj(void *p, u8 offset, u8 *data, int size)
179{
180 struct tiger_hw *card = p;
181
182 card->auxd &= 0xfc;
183 outb(card->auxd, card->base + NJ_AUXDATA);
184 outsb(card->base + NJ_ISAC_OFF, data, size);
185}
186
187static void
188fill_mem(struct tiger_ch *bc, u32 idx, u32 cnt, u32 fill)
189{
190 struct tiger_hw *card = bc->bch.hw;
191 u32 mask = 0xff, val;
192
193 pr_debug("%s: B%1d fill %02x len %d idx %d/%d\n", card->name,
Joe Perches475be4d2012-02-19 19:52:38 -0800194 bc->bch.nr, fill, cnt, idx, card->send.idx);
Karsten Keila9008452009-07-23 10:03:05 +0200195 if (bc->bch.nr & 2) {
196 fill <<= 8;
197 mask <<= 8;
198 }
199 mask ^= 0xffffffff;
200 while (cnt--) {
201 val = card->send.start[idx];
202 val &= mask;
203 val |= fill;
204 card->send.start[idx++] = val;
205 if (idx >= card->send.size)
206 idx = 0;
207 }
208}
209
210static int
211mode_tiger(struct tiger_ch *bc, u32 protocol)
212{
213 struct tiger_hw *card = bc->bch.hw;
214
215 pr_debug("%s: B%1d protocol %x-->%x\n", card->name,
Joe Perches475be4d2012-02-19 19:52:38 -0800216 bc->bch.nr, bc->bch.state, protocol);
Karsten Keila9008452009-07-23 10:03:05 +0200217 switch (protocol) {
218 case ISDN_P_NONE:
219 if (bc->bch.state == ISDN_P_NONE)
220 break;
221 fill_mem(bc, 0, card->send.size, 0xff);
222 bc->bch.state = protocol;
223 /* only stop dma and interrupts if both channels NULL */
224 if ((card->bc[0].bch.state == ISDN_P_NONE) &&
225 (card->bc[1].bch.state == ISDN_P_NONE)) {
226 card->dmactrl = 0;
227 outb(card->dmactrl, card->base + NJ_DMACTRL);
228 outb(0, card->base + NJ_IRQMASK0);
229 }
230 test_and_clear_bit(FLG_HDLC, &bc->bch.Flags);
231 test_and_clear_bit(FLG_TRANSPARENT, &bc->bch.Flags);
232 bc->txstate = 0;
233 bc->rxstate = 0;
234 bc->lastrx = -1;
235 break;
236 case ISDN_P_B_RAW:
237 test_and_set_bit(FLG_TRANSPARENT, &bc->bch.Flags);
238 bc->bch.state = protocol;
239 bc->idx = 0;
Joe Perches475be4d2012-02-19 19:52:38 -0800240 bc->free = card->send.size / 2;
Karsten Keila9008452009-07-23 10:03:05 +0200241 bc->rxstate = 0;
242 bc->txstate = TX_INIT | TX_IDLE;
243 bc->lastrx = -1;
244 if (!card->dmactrl) {
245 card->dmactrl = 1;
246 outb(card->dmactrl, card->base + NJ_DMACTRL);
247 outb(0x0f, card->base + NJ_IRQMASK0);
248 }
249 break;
250 case ISDN_P_B_HDLC:
251 test_and_set_bit(FLG_HDLC, &bc->bch.Flags);
252 bc->bch.state = protocol;
253 bc->idx = 0;
Joe Perches475be4d2012-02-19 19:52:38 -0800254 bc->free = card->send.size / 2;
Karsten Keila9008452009-07-23 10:03:05 +0200255 bc->rxstate = 0;
256 bc->txstate = TX_INIT | TX_IDLE;
257 isdnhdlc_rcv_init(&bc->hrecv, 0);
258 isdnhdlc_out_init(&bc->hsend, 0);
259 bc->lastrx = -1;
260 if (!card->dmactrl) {
261 card->dmactrl = 1;
262 outb(card->dmactrl, card->base + NJ_DMACTRL);
263 outb(0x0f, card->base + NJ_IRQMASK0);
264 }
265 break;
266 default:
267 pr_info("%s: %s protocol %x not handled\n", card->name,
268 __func__, protocol);
269 return -ENOPROTOOPT;
270 }
271 card->send.dmacur = inl(card->base + NJ_DMA_READ_ADR);
272 card->recv.dmacur = inl(card->base + NJ_DMA_WRITE_ADR);
273 card->send.idx = (card->send.dmacur - card->send.dmastart) >> 2;
274 card->recv.idx = (card->recv.dmacur - card->recv.dmastart) >> 2;
275 pr_debug("%s: %s ctrl %x irq %02x/%02x idx %d/%d\n",
Joe Perches475be4d2012-02-19 19:52:38 -0800276 card->name, __func__,
277 inb(card->base + NJ_DMACTRL),
278 inb(card->base + NJ_IRQMASK0),
279 inb(card->base + NJ_IRQSTAT0),
280 card->send.idx,
281 card->recv.idx);
Karsten Keila9008452009-07-23 10:03:05 +0200282 return 0;
283}
284
285static void
286nj_reset(struct tiger_hw *card)
287{
288 outb(0xff, card->base + NJ_CTRL); /* Reset On */
289 mdelay(1);
290
291 /* now edge triggered for TJ320 GE 13/07/00 */
292 /* see comment in IRQ function */
293 if (card->typ == NETJET_S_TJ320) /* TJ320 */
294 card->ctrlreg = 0x40; /* Reset Off and status read clear */
295 else
296 card->ctrlreg = 0x00; /* Reset Off and status read clear */
297 outb(card->ctrlreg, card->base + NJ_CTRL);
298 mdelay(10);
299
300 /* configure AUX pins (all output except ISAC IRQ pin) */
301 card->auxd = 0;
302 card->dmactrl = 0;
303 outb(~NJ_ISACIRQ, card->base + NJ_AUXCTRL);
304 outb(NJ_ISACIRQ, card->base + NJ_IRQMASK1);
305 outb(card->auxd, card->base + NJ_AUXDATA);
306}
307
308static int
309inittiger(struct tiger_hw *card)
310{
311 int i;
312
313 card->dma_p = pci_alloc_consistent(card->pdev, NJ_DMA_SIZE,
Joe Perches475be4d2012-02-19 19:52:38 -0800314 &card->dma);
Karsten Keila9008452009-07-23 10:03:05 +0200315 if (!card->dma_p) {
316 pr_info("%s: No DMA memory\n", card->name);
317 return -ENOMEM;
318 }
319 if ((u64)card->dma > 0xffffffff) {
320 pr_info("%s: DMA outside 32 bit\n", card->name);
321 return -ENOMEM;
322 }
323 for (i = 0; i < 2; i++) {
Julia Lawallb42d9162010-06-01 00:26:06 -0700324 card->bc[i].hsbuf = kmalloc(NJ_DMA_TXSIZE, GFP_ATOMIC);
Karsten Keila9008452009-07-23 10:03:05 +0200325 if (!card->bc[i].hsbuf) {
326 pr_info("%s: no B%d send buffer\n", card->name, i + 1);
327 return -ENOMEM;
328 }
Julia Lawallb42d9162010-06-01 00:26:06 -0700329 card->bc[i].hrbuf = kmalloc(NJ_DMA_RXSIZE, GFP_ATOMIC);
Karsten Keila9008452009-07-23 10:03:05 +0200330 if (!card->bc[i].hrbuf) {
331 pr_info("%s: no B%d recv buffer\n", card->name, i + 1);
332 return -ENOMEM;
333 }
334 }
335 memset(card->dma_p, 0xff, NJ_DMA_SIZE);
336
337 card->send.start = card->dma_p;
338 card->send.dmastart = (u32)card->dma;
339 card->send.dmaend = card->send.dmastart +
340 (4 * (NJ_DMA_TXSIZE - 1));
341 card->send.dmairq = card->send.dmastart +
342 (4 * ((NJ_DMA_TXSIZE / 2) - 1));
343 card->send.size = NJ_DMA_TXSIZE;
344
345 if (debug & DEBUG_HW)
346 pr_notice("%s: send buffer phy %#x - %#x - %#x virt %p"
Joe Perches475be4d2012-02-19 19:52:38 -0800347 " size %zu u32\n", card->name,
348 card->send.dmastart, card->send.dmairq,
349 card->send.dmaend, card->send.start, card->send.size);
Karsten Keila9008452009-07-23 10:03:05 +0200350
351 outl(card->send.dmastart, card->base + NJ_DMA_READ_START);
352 outl(card->send.dmairq, card->base + NJ_DMA_READ_IRQ);
353 outl(card->send.dmaend, card->base + NJ_DMA_READ_END);
354
355 card->recv.start = card->dma_p + (NJ_DMA_SIZE / 2);
356 card->recv.dmastart = (u32)card->dma + (NJ_DMA_SIZE / 2);
357 card->recv.dmaend = card->recv.dmastart +
358 (4 * (NJ_DMA_RXSIZE - 1));
359 card->recv.dmairq = card->recv.dmastart +
360 (4 * ((NJ_DMA_RXSIZE / 2) - 1));
361 card->recv.size = NJ_DMA_RXSIZE;
362
363 if (debug & DEBUG_HW)
364 pr_notice("%s: recv buffer phy %#x - %#x - %#x virt %p"
Joe Perches475be4d2012-02-19 19:52:38 -0800365 " size %zu u32\n", card->name,
366 card->recv.dmastart, card->recv.dmairq,
367 card->recv.dmaend, card->recv.start, card->recv.size);
Karsten Keila9008452009-07-23 10:03:05 +0200368
369 outl(card->recv.dmastart, card->base + NJ_DMA_WRITE_START);
370 outl(card->recv.dmairq, card->base + NJ_DMA_WRITE_IRQ);
371 outl(card->recv.dmaend, card->base + NJ_DMA_WRITE_END);
372 return 0;
373}
374
375static void
376read_dma(struct tiger_ch *bc, u32 idx, int cnt)
377{
378 struct tiger_hw *card = bc->bch.hw;
379 int i, stat;
380 u32 val;
381 u8 *p, *pn;
382
383 if (bc->lastrx == idx) {
384 bc->rxstate |= RX_OVERRUN;
385 pr_info("%s: B%1d overrun at idx %d\n", card->name,
386 bc->bch.nr, idx);
387 }
388 bc->lastrx = idx;
389 if (!bc->bch.rx_skb) {
390 bc->bch.rx_skb = mI_alloc_skb(bc->bch.maxlen, GFP_ATOMIC);
391 if (!bc->bch.rx_skb) {
392 pr_info("%s: B%1d receive out of memory\n",
393 card->name, bc->bch.nr);
394 return;
395 }
396 }
397
398 if (test_bit(FLG_TRANSPARENT, &bc->bch.Flags)) {
399 if ((bc->bch.rx_skb->len + cnt) > bc->bch.maxlen) {
400 pr_debug("%s: B%1d overrun %d\n", card->name,
Joe Perches475be4d2012-02-19 19:52:38 -0800401 bc->bch.nr, bc->bch.rx_skb->len + cnt);
Karsten Keila9008452009-07-23 10:03:05 +0200402 skb_trim(bc->bch.rx_skb, 0);
403 return;
404 }
405 p = skb_put(bc->bch.rx_skb, cnt);
406 } else
407 p = bc->hrbuf;
408
409 for (i = 0; i < cnt; i++) {
410 val = card->recv.start[idx++];
411 if (bc->bch.nr & 2)
412 val >>= 8;
413 if (idx >= card->recv.size)
414 idx = 0;
415 p[i] = val & 0xff;
416 }
417 pn = bc->hrbuf;
418next_frame:
419 if (test_bit(FLG_HDLC, &bc->bch.Flags)) {
420 stat = isdnhdlc_decode(&bc->hrecv, pn, cnt, &i,
Joe Perches475be4d2012-02-19 19:52:38 -0800421 bc->bch.rx_skb->data, bc->bch.maxlen);
422 if (stat > 0) /* valid frame received */
Karsten Keila9008452009-07-23 10:03:05 +0200423 p = skb_put(bc->bch.rx_skb, stat);
424 else if (stat == -HDLC_CRC_ERROR)
425 pr_info("%s: B%1d receive frame CRC error\n",
426 card->name, bc->bch.nr);
427 else if (stat == -HDLC_FRAMING_ERROR)
428 pr_info("%s: B%1d receive framing error\n",
429 card->name, bc->bch.nr);
430 else if (stat == -HDLC_LENGTH_ERROR)
431 pr_info("%s: B%1d receive frame too long (> %d)\n",
432 card->name, bc->bch.nr, bc->bch.maxlen);
433 } else
Joe Perches475be4d2012-02-19 19:52:38 -0800434 stat = cnt;
Karsten Keila9008452009-07-23 10:03:05 +0200435
436 if (stat > 0) {
437 if (debug & DEBUG_HW_BFIFO) {
438 snprintf(card->log, LOG_SIZE, "B%1d-recv %s %d ",
Joe Perches475be4d2012-02-19 19:52:38 -0800439 bc->bch.nr, card->name, stat);
Karsten Keila9008452009-07-23 10:03:05 +0200440 print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET,
Joe Perches475be4d2012-02-19 19:52:38 -0800441 p, stat);
Karsten Keila9008452009-07-23 10:03:05 +0200442 }
443 recv_Bchannel(&bc->bch, 0);
444 }
445 if (test_bit(FLG_HDLC, &bc->bch.Flags)) {
446 pn += i;
447 cnt -= i;
448 if (!bc->bch.rx_skb) {
449 bc->bch.rx_skb = mI_alloc_skb(bc->bch.maxlen,
Joe Perches475be4d2012-02-19 19:52:38 -0800450 GFP_ATOMIC);
Karsten Keila9008452009-07-23 10:03:05 +0200451 if (!bc->bch.rx_skb) {
452 pr_info("%s: B%1d receive out of memory\n",
453 card->name, bc->bch.nr);
454 return;
455 }
456 }
457 if (cnt > 0)
458 goto next_frame;
459 }
460}
461
462static void
463recv_tiger(struct tiger_hw *card, u8 irq_stat)
464{
465 u32 idx;
466 int cnt = card->recv.size / 2;
467
468 /* Note receive is via the WRITE DMA channel */
469 card->last_is0 &= ~NJ_IRQM0_WR_MASK;
470 card->last_is0 |= (irq_stat & NJ_IRQM0_WR_MASK);
471
472 if (irq_stat & NJ_IRQM0_WR_END)
473 idx = cnt - 1;
474 else
475 idx = card->recv.size - 1;
476
477 if (test_bit(FLG_ACTIVE, &card->bc[0].bch.Flags))
478 read_dma(&card->bc[0], idx, cnt);
479 if (test_bit(FLG_ACTIVE, &card->bc[1].bch.Flags))
480 read_dma(&card->bc[1], idx, cnt);
481}
482
483/* sync with current DMA address at start or after exception */
484static void
485resync(struct tiger_ch *bc, struct tiger_hw *card)
486{
487 card->send.dmacur = inl(card->base | NJ_DMA_READ_ADR);
488 card->send.idx = (card->send.dmacur - card->send.dmastart) >> 2;
489 if (bc->free > card->send.size / 2)
490 bc->free = card->send.size / 2;
491 /* currently we simple sync to the next complete free area
492 * this hast the advantage that we have always maximum time to
493 * handle TX irq
494 */
495 if (card->send.idx < ((card->send.size / 2) - 1))
496 bc->idx = (card->recv.size / 2) - 1;
497 else
498 bc->idx = card->recv.size - 1;
499 bc->txstate = TX_RUN;
500 pr_debug("%s: %s B%1d free %d idx %d/%d\n", card->name,
Joe Perches475be4d2012-02-19 19:52:38 -0800501 __func__, bc->bch.nr, bc->free, bc->idx, card->send.idx);
Karsten Keila9008452009-07-23 10:03:05 +0200502}
503
504static int bc_next_frame(struct tiger_ch *);
505
506static void
507fill_hdlc_flag(struct tiger_ch *bc)
508{
509 struct tiger_hw *card = bc->bch.hw;
510 int count, i;
511 u32 m, v;
512 u8 *p;
513
514 if (bc->free == 0)
515 return;
516 pr_debug("%s: %s B%1d %d state %x idx %d/%d\n", card->name,
Joe Perches475be4d2012-02-19 19:52:38 -0800517 __func__, bc->bch.nr, bc->free, bc->txstate,
518 bc->idx, card->send.idx);
Karsten Keila9008452009-07-23 10:03:05 +0200519 if (bc->txstate & (TX_IDLE | TX_INIT | TX_UNDERRUN))
520 resync(bc, card);
521 count = isdnhdlc_encode(&bc->hsend, NULL, 0, &i,
Joe Perches475be4d2012-02-19 19:52:38 -0800522 bc->hsbuf, bc->free);
Karsten Keila9008452009-07-23 10:03:05 +0200523 pr_debug("%s: B%1d hdlc encoded %d flags\n", card->name,
Joe Perches475be4d2012-02-19 19:52:38 -0800524 bc->bch.nr, count);
Karsten Keila9008452009-07-23 10:03:05 +0200525 bc->free -= count;
526 p = bc->hsbuf;
527 m = (bc->bch.nr & 1) ? 0xffffff00 : 0xffff00ff;
528 for (i = 0; i < count; i++) {
529 if (bc->idx >= card->send.size)
530 bc->idx = 0;
531 v = card->send.start[bc->idx];
532 v &= m;
533 v |= (bc->bch.nr & 1) ? (u32)(p[i]) : ((u32)(p[i])) << 8;
534 card->send.start[bc->idx++] = v;
535 }
536 if (debug & DEBUG_HW_BFIFO) {
537 snprintf(card->log, LOG_SIZE, "B%1d-send %s %d ",
Joe Perches475be4d2012-02-19 19:52:38 -0800538 bc->bch.nr, card->name, count);
Karsten Keila9008452009-07-23 10:03:05 +0200539 print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, p, count);
540 }
541}
542
543static void
544fill_dma(struct tiger_ch *bc)
545{
546 struct tiger_hw *card = bc->bch.hw;
547 int count, i;
548 u32 m, v;
549 u8 *p;
550
551 if (bc->free == 0)
552 return;
553 count = bc->bch.tx_skb->len - bc->bch.tx_idx;
554 if (count <= 0)
555 return;
556 pr_debug("%s: %s B%1d %d/%d/%d/%d state %x idx %d/%d\n", card->name,
Joe Perches475be4d2012-02-19 19:52:38 -0800557 __func__, bc->bch.nr, count, bc->free, bc->bch.tx_idx,
558 bc->bch.tx_skb->len, bc->txstate, bc->idx, card->send.idx);
Karsten Keila9008452009-07-23 10:03:05 +0200559 if (bc->txstate & (TX_IDLE | TX_INIT | TX_UNDERRUN))
560 resync(bc, card);
561 p = bc->bch.tx_skb->data + bc->bch.tx_idx;
562 if (test_bit(FLG_HDLC, &bc->bch.Flags)) {
563 count = isdnhdlc_encode(&bc->hsend, p, count, &i,
Joe Perches475be4d2012-02-19 19:52:38 -0800564 bc->hsbuf, bc->free);
Karsten Keila9008452009-07-23 10:03:05 +0200565 pr_debug("%s: B%1d hdlc encoded %d in %d\n", card->name,
Joe Perches475be4d2012-02-19 19:52:38 -0800566 bc->bch.nr, i, count);
Karsten Keila9008452009-07-23 10:03:05 +0200567 bc->bch.tx_idx += i;
568 bc->free -= count;
569 p = bc->hsbuf;
570 } else {
571 if (count > bc->free)
572 count = bc->free;
573 bc->bch.tx_idx += count;
574 bc->free -= count;
575 }
576 m = (bc->bch.nr & 1) ? 0xffffff00 : 0xffff00ff;
577 for (i = 0; i < count; i++) {
578 if (bc->idx >= card->send.size)
579 bc->idx = 0;
580 v = card->send.start[bc->idx];
581 v &= m;
582 v |= (bc->bch.nr & 1) ? (u32)(p[i]) : ((u32)(p[i])) << 8;
583 card->send.start[bc->idx++] = v;
584 }
585 if (debug & DEBUG_HW_BFIFO) {
586 snprintf(card->log, LOG_SIZE, "B%1d-send %s %d ",
Joe Perches475be4d2012-02-19 19:52:38 -0800587 bc->bch.nr, card->name, count);
Karsten Keila9008452009-07-23 10:03:05 +0200588 print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, p, count);
589 }
590 if (bc->free)
591 bc_next_frame(bc);
592}
593
594
595static int
596bc_next_frame(struct tiger_ch *bc)
597{
Karsten Keil8bfddfb2012-05-15 23:51:02 +0000598 if (bc->bch.tx_skb && bc->bch.tx_idx < bc->bch.tx_skb->len) {
Karsten Keila9008452009-07-23 10:03:05 +0200599 fill_dma(bc);
Karsten Keil8bfddfb2012-05-15 23:51:02 +0000600 } else {
601 if (bc->bch.tx_skb)
Karsten Keila9008452009-07-23 10:03:05 +0200602 dev_kfree_skb(bc->bch.tx_skb);
Karsten Keila9008452009-07-23 10:03:05 +0200603 if (get_next_bframe(&bc->bch))
604 fill_dma(bc);
605 else
606 return 0;
607 }
608 return 1;
609}
610
611static void
612send_tiger_bc(struct tiger_hw *card, struct tiger_ch *bc)
613{
614 int ret;
615
616 bc->free += card->send.size / 2;
617 if (bc->free >= card->send.size) {
618 if (!(bc->txstate & (TX_UNDERRUN | TX_INIT))) {
619 pr_info("%s: B%1d TX underrun state %x\n", card->name,
620 bc->bch.nr, bc->txstate);
621 bc->txstate |= TX_UNDERRUN;
622 }
623 bc->free = card->send.size;
624 }
625 ret = bc_next_frame(bc);
626 if (!ret) {
627 if (test_bit(FLG_HDLC, &bc->bch.Flags)) {
628 fill_hdlc_flag(bc);
629 return;
630 }
631 pr_debug("%s: B%1d TX no data free %d idx %d/%d\n", card->name,
Joe Perches475be4d2012-02-19 19:52:38 -0800632 bc->bch.nr, bc->free, bc->idx, card->send.idx);
Karsten Keila9008452009-07-23 10:03:05 +0200633 if (!(bc->txstate & (TX_IDLE | TX_INIT))) {
634 fill_mem(bc, bc->idx, bc->free, 0xff);
635 if (bc->free == card->send.size)
636 bc->txstate |= TX_IDLE;
637 }
638 }
639}
640
641static void
642send_tiger(struct tiger_hw *card, u8 irq_stat)
643{
644 int i;
645
646 /* Note send is via the READ DMA channel */
647 if ((irq_stat & card->last_is0) & NJ_IRQM0_RD_MASK) {
648 pr_info("%s: tiger warn write double dma %x/%x\n",
649 card->name, irq_stat, card->last_is0);
650 return;
651 } else {
652 card->last_is0 &= ~NJ_IRQM0_RD_MASK;
653 card->last_is0 |= (irq_stat & NJ_IRQM0_RD_MASK);
654 }
655 for (i = 0; i < 2; i++) {
656 if (test_bit(FLG_ACTIVE, &card->bc[i].bch.Flags))
657 send_tiger_bc(card, &card->bc[i]);
658 }
659}
660
661static irqreturn_t
662nj_irq(int intno, void *dev_id)
663{
664 struct tiger_hw *card = dev_id;
665 u8 val, s1val, s0val;
666
667 spin_lock(&card->lock);
668 s0val = inb(card->base | NJ_IRQSTAT0);
669 s1val = inb(card->base | NJ_IRQSTAT1);
670 if ((s1val & NJ_ISACIRQ) && (s0val == 0)) {
671 /* shared IRQ */
672 spin_unlock(&card->lock);
673 return IRQ_NONE;
674 }
675 pr_debug("%s: IRQSTAT0 %02x IRQSTAT1 %02x\n", card->name, s0val, s1val);
676 card->irqcnt++;
677 if (!(s1val & NJ_ISACIRQ)) {
678 val = ReadISAC_nj(card, ISAC_ISTA);
679 if (val)
680 mISDNisac_irq(&card->isac, val);
681 }
682
683 if (s0val)
684 /* write to clear */
685 outb(s0val, card->base | NJ_IRQSTAT0);
686 else
687 goto end;
688 s1val = s0val;
689 /* set bits in sval to indicate which page is free */
690 card->recv.dmacur = inl(card->base | NJ_DMA_WRITE_ADR);
691 card->recv.idx = (card->recv.dmacur - card->recv.dmastart) >> 2;
692 if (card->recv.dmacur < card->recv.dmairq)
693 s0val = 0x08; /* the 2nd write area is free */
694 else
695 s0val = 0x04; /* the 1st write area is free */
696
697 card->send.dmacur = inl(card->base | NJ_DMA_READ_ADR);
698 card->send.idx = (card->send.dmacur - card->send.dmastart) >> 2;
699 if (card->send.dmacur < card->send.dmairq)
700 s0val |= 0x02; /* the 2nd read area is free */
701 else
702 s0val |= 0x01; /* the 1st read area is free */
703
704 pr_debug("%s: DMA Status %02x/%02x/%02x %d/%d\n", card->name,
Joe Perches475be4d2012-02-19 19:52:38 -0800705 s1val, s0val, card->last_is0,
706 card->recv.idx, card->send.idx);
Karsten Keila9008452009-07-23 10:03:05 +0200707 /* test if we have a DMA interrupt */
708 if (s0val != card->last_is0) {
709 if ((s0val & NJ_IRQM0_RD_MASK) !=
710 (card->last_is0 & NJ_IRQM0_RD_MASK))
711 /* got a write dma int */
712 send_tiger(card, s0val);
713 if ((s0val & NJ_IRQM0_WR_MASK) !=
714 (card->last_is0 & NJ_IRQM0_WR_MASK))
715 /* got a read dma int */
716 recv_tiger(card, s0val);
717 }
718end:
719 spin_unlock(&card->lock);
720 return IRQ_HANDLED;
721}
722
723static int
724nj_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb)
725{
726 int ret = -EINVAL;
727 struct bchannel *bch = container_of(ch, struct bchannel, ch);
728 struct tiger_ch *bc = container_of(bch, struct tiger_ch, bch);
729 struct tiger_hw *card = bch->hw;
730 struct mISDNhead *hh = mISDN_HEAD_P(skb);
Karsten Keil8bfddfb2012-05-15 23:51:02 +0000731 unsigned long flags;
Karsten Keila9008452009-07-23 10:03:05 +0200732
733 switch (hh->prim) {
734 case PH_DATA_REQ:
735 spin_lock_irqsave(&card->lock, flags);
736 ret = bchannel_senddata(bch, skb);
737 if (ret > 0) { /* direct TX */
Karsten Keila9008452009-07-23 10:03:05 +0200738 fill_dma(bc);
739 ret = 0;
Karsten Keil8bfddfb2012-05-15 23:51:02 +0000740 }
741 spin_unlock_irqrestore(&card->lock, flags);
Karsten Keila9008452009-07-23 10:03:05 +0200742 return ret;
743 case PH_ACTIVATE_REQ:
744 spin_lock_irqsave(&card->lock, flags);
745 if (!test_and_set_bit(FLG_ACTIVE, &bch->Flags))
746 ret = mode_tiger(bc, ch->protocol);
747 else
748 ret = 0;
749 spin_unlock_irqrestore(&card->lock, flags);
750 if (!ret)
751 _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, 0,
Joe Perches475be4d2012-02-19 19:52:38 -0800752 NULL, GFP_KERNEL);
Karsten Keila9008452009-07-23 10:03:05 +0200753 break;
754 case PH_DEACTIVATE_REQ:
755 spin_lock_irqsave(&card->lock, flags);
756 mISDN_clear_bchannel(bch);
757 mode_tiger(bc, ISDN_P_NONE);
758 spin_unlock_irqrestore(&card->lock, flags);
759 _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0,
Joe Perches475be4d2012-02-19 19:52:38 -0800760 NULL, GFP_KERNEL);
Karsten Keila9008452009-07-23 10:03:05 +0200761 ret = 0;
762 break;
763 }
764 if (!ret)
765 dev_kfree_skb(skb);
766 return ret;
767}
768
769static int
770channel_bctrl(struct tiger_ch *bc, struct mISDN_ctrl_req *cq)
771{
772 int ret = 0;
773 struct tiger_hw *card = bc->bch.hw;
774
775 switch (cq->op) {
776 case MISDN_CTRL_GETOP:
777 cq->op = 0;
778 break;
Joe Perches475be4d2012-02-19 19:52:38 -0800779 /* Nothing implemented yet */
Karsten Keila9008452009-07-23 10:03:05 +0200780 case MISDN_CTRL_FILL_EMPTY:
781 default:
782 pr_info("%s: %s unknown Op %x\n", card->name, __func__, cq->op);
783 ret = -EINVAL;
784 break;
785 }
786 return ret;
787}
788
789static int
790nj_bctrl(struct mISDNchannel *ch, u32 cmd, void *arg)
791{
792 struct bchannel *bch = container_of(ch, struct bchannel, ch);
793 struct tiger_ch *bc = container_of(bch, struct tiger_ch, bch);
794 struct tiger_hw *card = bch->hw;
795 int ret = -EINVAL;
796 u_long flags;
797
798 pr_debug("%s: %s cmd:%x %p\n", card->name, __func__, cmd, arg);
799 switch (cmd) {
800 case CLOSE_CHANNEL:
801 test_and_clear_bit(FLG_OPEN, &bch->Flags);
Karsten Keil13681122012-05-15 23:51:01 +0000802 spin_lock_irqsave(&card->lock, flags);
803 mISDN_freebchannel(bch);
804 mode_tiger(bc, ISDN_P_NONE);
805 spin_unlock_irqrestore(&card->lock, flags);
Karsten Keila9008452009-07-23 10:03:05 +0200806 ch->protocol = ISDN_P_NONE;
807 ch->peer = NULL;
808 module_put(THIS_MODULE);
809 ret = 0;
810 break;
811 case CONTROL_CHANNEL:
812 ret = channel_bctrl(bc, arg);
813 break;
814 default:
815 pr_info("%s: %s unknown prim(%x)\n", card->name, __func__, cmd);
816 }
817 return ret;
818}
819
820static int
821channel_ctrl(struct tiger_hw *card, struct mISDN_ctrl_req *cq)
822{
823 int ret = 0;
824
825 switch (cq->op) {
826 case MISDN_CTRL_GETOP:
Karsten Keilc626c122012-05-04 04:15:33 +0000827 cq->op = MISDN_CTRL_LOOP | MISDN_CTRL_L1_TIMER3;
Karsten Keila9008452009-07-23 10:03:05 +0200828 break;
829 case MISDN_CTRL_LOOP:
830 /* cq->channel: 0 disable, 1 B1 loop 2 B2 loop, 3 both */
831 if (cq->channel < 0 || cq->channel > 3) {
832 ret = -EINVAL;
833 break;
834 }
835 ret = card->isac.ctrl(&card->isac, HW_TESTLOOP, cq->channel);
836 break;
Karsten Keilc626c122012-05-04 04:15:33 +0000837 case MISDN_CTRL_L1_TIMER3:
838 ret = card->isac.ctrl(&card->isac, HW_TIMER3_VALUE, cq->p1);
839 break;
Karsten Keila9008452009-07-23 10:03:05 +0200840 default:
841 pr_info("%s: %s unknown Op %x\n", card->name, __func__, cq->op);
842 ret = -EINVAL;
843 break;
844 }
845 return ret;
846}
847
848static int
849open_bchannel(struct tiger_hw *card, struct channel_req *rq)
850{
851 struct bchannel *bch;
852
Dan Carpenter819a1002012-03-26 21:20:48 +0000853 if (rq->adr.channel == 0 || rq->adr.channel > 2)
Karsten Keila9008452009-07-23 10:03:05 +0200854 return -EINVAL;
855 if (rq->protocol == ISDN_P_NONE)
856 return -EINVAL;
857 bch = &card->bc[rq->adr.channel - 1].bch;
858 if (test_and_set_bit(FLG_OPEN, &bch->Flags))
859 return -EBUSY; /* b-channel can be only open once */
860 test_and_clear_bit(FLG_FILLEMPTY, &bch->Flags);
861 bch->ch.protocol = rq->protocol;
862 rq->ch = &bch->ch;
863 return 0;
864}
865
866/*
867 * device control function
868 */
869static int
870nj_dctrl(struct mISDNchannel *ch, u32 cmd, void *arg)
871{
872 struct mISDNdevice *dev = container_of(ch, struct mISDNdevice, D);
873 struct dchannel *dch = container_of(dev, struct dchannel, dev);
874 struct tiger_hw *card = dch->hw;
875 struct channel_req *rq;
876 int err = 0;
877
878 pr_debug("%s: %s cmd:%x %p\n", card->name, __func__, cmd, arg);
879 switch (cmd) {
880 case OPEN_CHANNEL:
881 rq = arg;
882 if (rq->protocol == ISDN_P_TE_S0)
883 err = card->isac.open(&card->isac, rq);
884 else
885 err = open_bchannel(card, rq);
886 if (err)
887 break;
888 if (!try_module_get(THIS_MODULE))
889 pr_info("%s: cannot get module\n", card->name);
890 break;
891 case CLOSE_CHANNEL:
892 pr_debug("%s: dev(%d) close from %p\n", card->name, dch->dev.id,
Joe Perches475be4d2012-02-19 19:52:38 -0800893 __builtin_return_address(0));
Karsten Keila9008452009-07-23 10:03:05 +0200894 module_put(THIS_MODULE);
895 break;
896 case CONTROL_CHANNEL:
897 err = channel_ctrl(card, arg);
898 break;
899 default:
900 pr_debug("%s: %s unknown command %x\n",
Joe Perches475be4d2012-02-19 19:52:38 -0800901 card->name, __func__, cmd);
Karsten Keila9008452009-07-23 10:03:05 +0200902 return -EINVAL;
903 }
904 return err;
905}
906
907static int
908nj_init_card(struct tiger_hw *card)
909{
910 u_long flags;
911 int ret;
912
913 spin_lock_irqsave(&card->lock, flags);
914 nj_disable_hwirq(card);
915 spin_unlock_irqrestore(&card->lock, flags);
916
917 card->irq = card->pdev->irq;
918 if (request_irq(card->irq, nj_irq, IRQF_SHARED, card->name, card)) {
919 pr_info("%s: couldn't get interrupt %d\n",
920 card->name, card->irq);
921 card->irq = -1;
922 return -EIO;
923 }
924
925 spin_lock_irqsave(&card->lock, flags);
926 nj_reset(card);
927 ret = card->isac.init(&card->isac);
928 if (ret)
929 goto error;
930 ret = inittiger(card);
931 if (ret)
932 goto error;
933 mode_tiger(&card->bc[0], ISDN_P_NONE);
934 mode_tiger(&card->bc[1], ISDN_P_NONE);
935error:
936 spin_unlock_irqrestore(&card->lock, flags);
937 return ret;
938}
939
940
941static void
942nj_release(struct tiger_hw *card)
943{
944 u_long flags;
945 int i;
946
947 if (card->base_s) {
948 spin_lock_irqsave(&card->lock, flags);
949 nj_disable_hwirq(card);
950 mode_tiger(&card->bc[0], ISDN_P_NONE);
951 mode_tiger(&card->bc[1], ISDN_P_NONE);
952 card->isac.release(&card->isac);
953 spin_unlock_irqrestore(&card->lock, flags);
954 release_region(card->base, card->base_s);
955 card->base_s = 0;
956 }
957 if (card->irq > 0)
958 free_irq(card->irq, card);
959 if (card->isac.dch.dev.dev.class)
960 mISDN_unregister_device(&card->isac.dch.dev);
Joe Perches475be4d2012-02-19 19:52:38 -0800961
Karsten Keila9008452009-07-23 10:03:05 +0200962 for (i = 0; i < 2; i++) {
963 mISDN_freebchannel(&card->bc[i].bch);
964 kfree(card->bc[i].hsbuf);
965 kfree(card->bc[i].hrbuf);
966 }
967 if (card->dma_p)
968 pci_free_consistent(card->pdev, NJ_DMA_SIZE,
Joe Perches475be4d2012-02-19 19:52:38 -0800969 card->dma_p, card->dma);
Karsten Keila9008452009-07-23 10:03:05 +0200970 write_lock_irqsave(&card_lock, flags);
971 list_del(&card->list);
972 write_unlock_irqrestore(&card_lock, flags);
973 pci_clear_master(card->pdev);
974 pci_disable_device(card->pdev);
975 pci_set_drvdata(card->pdev, NULL);
976 kfree(card);
977}
978
979
980static int
981nj_setup(struct tiger_hw *card)
982{
983 card->base = pci_resource_start(card->pdev, 0);
984 card->base_s = pci_resource_len(card->pdev, 0);
985 if (!request_region(card->base, card->base_s, card->name)) {
986 pr_info("%s: NETjet config port %#x-%#x already in use\n",
987 card->name, card->base,
988 (u32)(card->base + card->base_s - 1));
989 card->base_s = 0;
990 return -EIO;
991 }
992 ASSIGN_FUNC(nj, ISAC, card->isac);
993 return 0;
994}
995
996
997static int __devinit
998setup_instance(struct tiger_hw *card)
999{
1000 int i, err;
1001 u_long flags;
1002
1003 snprintf(card->name, MISDN_MAX_IDLEN - 1, "netjet.%d", nj_cnt + 1);
1004 write_lock_irqsave(&card_lock, flags);
1005 list_add_tail(&card->list, &Cards);
1006 write_unlock_irqrestore(&card_lock, flags);
1007
1008 _set_debug(card);
1009 card->isac.name = card->name;
1010 spin_lock_init(&card->lock);
1011 card->isac.hwlock = &card->lock;
1012 mISDNisac_init(&card->isac, card);
1013
1014 card->isac.dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
1015 (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
1016 card->isac.dch.dev.D.ctrl = nj_dctrl;
1017 for (i = 0; i < 2; i++) {
1018 card->bc[i].bch.nr = i + 1;
1019 set_channelmap(i + 1, card->isac.dch.dev.channelmap);
1020 mISDN_initbchannel(&card->bc[i].bch, MAX_DATA_MEM);
1021 card->bc[i].bch.hw = card;
1022 card->bc[i].bch.ch.send = nj_l2l1B;
1023 card->bc[i].bch.ch.ctrl = nj_bctrl;
1024 card->bc[i].bch.ch.nr = i + 1;
1025 list_add(&card->bc[i].bch.ch.list,
Joe Perches475be4d2012-02-19 19:52:38 -08001026 &card->isac.dch.dev.bchannels);
Karsten Keila9008452009-07-23 10:03:05 +02001027 card->bc[i].bch.hw = card;
1028 }
1029 err = nj_setup(card);
1030 if (err)
1031 goto error;
1032 err = mISDN_register_device(&card->isac.dch.dev, &card->pdev->dev,
Joe Perches475be4d2012-02-19 19:52:38 -08001033 card->name);
Karsten Keila9008452009-07-23 10:03:05 +02001034 if (err)
1035 goto error;
1036 err = nj_init_card(card);
1037 if (!err) {
1038 nj_cnt++;
1039 pr_notice("Netjet %d cards installed\n", nj_cnt);
1040 return 0;
1041 }
1042error:
1043 nj_release(card);
1044 return err;
1045}
1046
1047static int __devinit
1048nj_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1049{
1050 int err = -ENOMEM;
1051 int cfg;
1052 struct tiger_hw *card;
1053
1054 if (pdev->subsystem_vendor == 0x8086 &&
1055 pdev->subsystem_device == 0x0003) {
1056 pr_notice("Netjet: Digium X100P/X101P not handled\n");
1057 return -ENODEV;
1058 }
1059
1060 if (pdev->subsystem_vendor == 0x55 &&
1061 pdev->subsystem_device == 0x02) {
1062 pr_notice("Netjet: Enter!Now not handled yet\n");
1063 return -ENODEV;
1064 }
1065
Prarit Bhargava367bbf22011-05-25 02:12:23 +00001066 if (pdev->subsystem_vendor == 0xb100 &&
Joe Perches475be4d2012-02-19 19:52:38 -08001067 pdev->subsystem_device == 0x0003) {
Prarit Bhargava367bbf22011-05-25 02:12:23 +00001068 pr_notice("Netjet: Digium TDM400P not handled yet\n");
1069 return -ENODEV;
1070 }
1071
Karsten Keila9008452009-07-23 10:03:05 +02001072 card = kzalloc(sizeof(struct tiger_hw), GFP_ATOMIC);
1073 if (!card) {
1074 pr_info("No kmem for Netjet\n");
1075 return err;
1076 }
1077
1078 card->pdev = pdev;
1079
1080 err = pci_enable_device(pdev);
1081 if (err) {
1082 kfree(card);
1083 return err;
1084 }
1085
1086 printk(KERN_INFO "nj_probe(mISDN): found adapter at %s\n",
Joe Perches475be4d2012-02-19 19:52:38 -08001087 pci_name(pdev));
Karsten Keila9008452009-07-23 10:03:05 +02001088
1089 pci_set_master(pdev);
1090
1091 /* the TJ300 and TJ320 must be detected, the IRQ handling is different
1092 * unfortunately the chips use the same device ID, but the TJ320 has
1093 * the bit20 in status PCI cfg register set
1094 */
1095 pci_read_config_dword(pdev, 0x04, &cfg);
1096 if (cfg & 0x00100000)
1097 card->typ = NETJET_S_TJ320;
1098 else
1099 card->typ = NETJET_S_TJ300;
1100
1101 card->base = pci_resource_start(pdev, 0);
1102 card->irq = pdev->irq;
1103 pci_set_drvdata(pdev, card);
1104 err = setup_instance(card);
1105 if (err)
1106 pci_set_drvdata(pdev, NULL);
1107
1108 return err;
1109}
1110
1111
1112static void __devexit nj_remove(struct pci_dev *pdev)
1113{
1114 struct tiger_hw *card = pci_get_drvdata(pdev);
1115
1116 if (card)
1117 nj_release(card);
1118 else
1119 pr_info("%s drvdata already removed\n", __func__);
1120}
1121
1122/* We cannot select cards with PCI_SUB... IDs, since here are cards with
1123 * SUB IDs set to PCI_ANY_ID, so we need to match all and reject
1124 * known other cards which not work with this driver - see probe function */
1125static struct pci_device_id nj_pci_ids[] __devinitdata = {
1126 { PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300,
1127 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1128 { }
1129};
1130MODULE_DEVICE_TABLE(pci, nj_pci_ids);
1131
1132static struct pci_driver nj_driver = {
1133 .name = "netjet",
1134 .probe = nj_probe,
1135 .remove = __devexit_p(nj_remove),
1136 .id_table = nj_pci_ids,
1137};
1138
1139static int __init nj_init(void)
1140{
1141 int err;
1142
1143 pr_notice("Netjet PCI driver Rev. %s\n", NETJET_REV);
1144 err = pci_register_driver(&nj_driver);
1145 return err;
1146}
1147
1148static void __exit nj_cleanup(void)
1149{
1150 pci_unregister_driver(&nj_driver);
1151}
1152
1153module_init(nj_init);
1154module_exit(nj_cleanup);