Lines Matching +full:cmd +full:- +full:cnt +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-only
66 char name[MISDN_MAX_IDLEN]; member
95 card->isac.dch.debug = debug; in _set_debug()
96 card->bc[0].bch.debug = debug; in _set_debug()
97 card->bc[1].bch.debug = debug; in _set_debug()
126 outb(0, card->base + NJ_IRQMASK0); in nj_disable_hwirq()
127 outb(0, card->base + NJ_IRQMASK1); in nj_disable_hwirq()
137 card->auxd &= 0xfc; in ReadISAC_nj()
138 card->auxd |= (offset >> 4) & 3; in ReadISAC_nj()
139 outb(card->auxd, card->base + NJ_AUXDATA); in ReadISAC_nj()
140 ret = inb(card->base + NJ_ISAC_OFF + ((offset & 0x0f) << 2)); in ReadISAC_nj()
149 card->auxd &= 0xfc; in WriteISAC_nj()
150 card->auxd |= (offset >> 4) & 3; in WriteISAC_nj()
151 outb(card->auxd, card->base + NJ_AUXDATA); in WriteISAC_nj()
152 outb(value, card->base + NJ_ISAC_OFF + ((offset & 0x0f) << 2)); in WriteISAC_nj()
160 card->auxd &= 0xfc; in ReadFiFoISAC_nj()
161 outb(card->auxd, card->base + NJ_AUXDATA); in ReadFiFoISAC_nj()
162 insb(card->base + NJ_ISAC_OFF, data, size); in ReadFiFoISAC_nj()
170 card->auxd &= 0xfc; in WriteFiFoISAC_nj()
171 outb(card->auxd, card->base + NJ_AUXDATA); in WriteFiFoISAC_nj()
172 outsb(card->base + NJ_ISAC_OFF, data, size); in WriteFiFoISAC_nj()
176 fill_mem(struct tiger_ch *bc, u32 idx, u32 cnt, u32 fill) in fill_mem() argument
178 struct tiger_hw *card = bc->bch.hw; in fill_mem()
181 pr_debug("%s: B%1d fill %02x len %d idx %d/%d\n", card->name, in fill_mem()
182 bc->bch.nr, fill, cnt, idx, card->send.idx); in fill_mem()
183 if (bc->bch.nr & 2) { in fill_mem()
188 while (cnt--) { in fill_mem()
189 val = card->send.start[idx]; in fill_mem()
192 card->send.start[idx++] = val; in fill_mem()
193 if (idx >= card->send.size) in fill_mem()
201 struct tiger_hw *card = bc->bch.hw; in mode_tiger()
203 pr_debug("%s: B%1d protocol %x-->%x\n", card->name, in mode_tiger()
204 bc->bch.nr, bc->bch.state, protocol); in mode_tiger()
207 if (bc->bch.state == ISDN_P_NONE) in mode_tiger()
209 fill_mem(bc, 0, card->send.size, 0xff); in mode_tiger()
210 bc->bch.state = protocol; in mode_tiger()
212 if ((card->bc[0].bch.state == ISDN_P_NONE) && in mode_tiger()
213 (card->bc[1].bch.state == ISDN_P_NONE)) { in mode_tiger()
214 card->dmactrl = 0; in mode_tiger()
215 outb(card->dmactrl, card->base + NJ_DMACTRL); in mode_tiger()
216 outb(0, card->base + NJ_IRQMASK0); in mode_tiger()
218 test_and_clear_bit(FLG_HDLC, &bc->bch.Flags); in mode_tiger()
219 test_and_clear_bit(FLG_TRANSPARENT, &bc->bch.Flags); in mode_tiger()
220 bc->txstate = 0; in mode_tiger()
221 bc->rxstate = 0; in mode_tiger()
222 bc->lastrx = -1; in mode_tiger()
225 test_and_set_bit(FLG_TRANSPARENT, &bc->bch.Flags); in mode_tiger()
226 bc->bch.state = protocol; in mode_tiger()
227 bc->idx = 0; in mode_tiger()
228 bc->free = card->send.size / 2; in mode_tiger()
229 bc->rxstate = 0; in mode_tiger()
230 bc->txstate = TX_INIT | TX_IDLE; in mode_tiger()
231 bc->lastrx = -1; in mode_tiger()
232 if (!card->dmactrl) { in mode_tiger()
233 card->dmactrl = 1; in mode_tiger()
234 outb(card->dmactrl, card->base + NJ_DMACTRL); in mode_tiger()
235 outb(0x0f, card->base + NJ_IRQMASK0); in mode_tiger()
239 test_and_set_bit(FLG_HDLC, &bc->bch.Flags); in mode_tiger()
240 bc->bch.state = protocol; in mode_tiger()
241 bc->idx = 0; in mode_tiger()
242 bc->free = card->send.size / 2; in mode_tiger()
243 bc->rxstate = 0; in mode_tiger()
244 bc->txstate = TX_INIT | TX_IDLE; in mode_tiger()
245 isdnhdlc_rcv_init(&bc->hrecv, 0); in mode_tiger()
246 isdnhdlc_out_init(&bc->hsend, 0); in mode_tiger()
247 bc->lastrx = -1; in mode_tiger()
248 if (!card->dmactrl) { in mode_tiger()
249 card->dmactrl = 1; in mode_tiger()
250 outb(card->dmactrl, card->base + NJ_DMACTRL); in mode_tiger()
251 outb(0x0f, card->base + NJ_IRQMASK0); in mode_tiger()
255 pr_info("%s: %s protocol %x not handled\n", card->name, in mode_tiger()
257 return -ENOPROTOOPT; in mode_tiger()
259 card->send.dmacur = inl(card->base + NJ_DMA_READ_ADR); in mode_tiger()
260 card->recv.dmacur = inl(card->base + NJ_DMA_WRITE_ADR); in mode_tiger()
261 card->send.idx = (card->send.dmacur - card->send.dmastart) >> 2; in mode_tiger()
262 card->recv.idx = (card->recv.dmacur - card->recv.dmastart) >> 2; in mode_tiger()
264 card->name, __func__, in mode_tiger()
265 inb(card->base + NJ_DMACTRL), in mode_tiger()
266 inb(card->base + NJ_IRQMASK0), in mode_tiger()
267 inb(card->base + NJ_IRQSTAT0), in mode_tiger()
268 card->send.idx, in mode_tiger()
269 card->recv.idx); in mode_tiger()
276 outb(0xff, card->base + NJ_CTRL); /* Reset On */ in nj_reset()
281 if (card->typ == NETJET_S_TJ320) /* TJ320 */ in nj_reset()
282 card->ctrlreg = 0x40; /* Reset Off and status read clear */ in nj_reset()
284 card->ctrlreg = 0x00; /* Reset Off and status read clear */ in nj_reset()
285 outb(card->ctrlreg, card->base + NJ_CTRL); in nj_reset()
289 card->auxd = 0; in nj_reset()
290 card->dmactrl = 0; in nj_reset()
291 outb(~NJ_ISACIRQ, card->base + NJ_AUXCTRL); in nj_reset()
292 outb(NJ_ISACIRQ, card->base + NJ_IRQMASK1); in nj_reset()
293 outb(card->auxd, card->base + NJ_AUXDATA); in nj_reset()
301 card->dma_p = dma_alloc_coherent(&card->pdev->dev, NJ_DMA_SIZE, in inittiger()
302 &card->dma, GFP_ATOMIC); in inittiger()
303 if (!card->dma_p) { in inittiger()
304 pr_info("%s: No DMA memory\n", card->name); in inittiger()
305 return -ENOMEM; in inittiger()
307 if ((u64)card->dma > 0xffffffff) { in inittiger()
308 pr_info("%s: DMA outside 32 bit\n", card->name); in inittiger()
309 return -ENOMEM; in inittiger()
312 card->bc[i].hsbuf = kmalloc(NJ_DMA_TXSIZE, GFP_ATOMIC); in inittiger()
313 if (!card->bc[i].hsbuf) { in inittiger()
314 pr_info("%s: no B%d send buffer\n", card->name, i + 1); in inittiger()
315 return -ENOMEM; in inittiger()
317 card->bc[i].hrbuf = kmalloc(NJ_DMA_RXSIZE, GFP_ATOMIC); in inittiger()
318 if (!card->bc[i].hrbuf) { in inittiger()
319 pr_info("%s: no B%d recv buffer\n", card->name, i + 1); in inittiger()
320 return -ENOMEM; in inittiger()
323 memset(card->dma_p, 0xff, NJ_DMA_SIZE); in inittiger()
325 card->send.start = card->dma_p; in inittiger()
326 card->send.dmastart = (u32)card->dma; in inittiger()
327 card->send.dmaend = card->send.dmastart + in inittiger()
328 (4 * (NJ_DMA_TXSIZE - 1)); in inittiger()
329 card->send.dmairq = card->send.dmastart + in inittiger()
330 (4 * ((NJ_DMA_TXSIZE / 2) - 1)); in inittiger()
331 card->send.size = NJ_DMA_TXSIZE; in inittiger()
334 pr_notice("%s: send buffer phy %#x - %#x - %#x virt %p" in inittiger()
335 " size %zu u32\n", card->name, in inittiger()
336 card->send.dmastart, card->send.dmairq, in inittiger()
337 card->send.dmaend, card->send.start, card->send.size); in inittiger()
339 outl(card->send.dmastart, card->base + NJ_DMA_READ_START); in inittiger()
340 outl(card->send.dmairq, card->base + NJ_DMA_READ_IRQ); in inittiger()
341 outl(card->send.dmaend, card->base + NJ_DMA_READ_END); in inittiger()
343 card->recv.start = card->dma_p + (NJ_DMA_SIZE / 2); in inittiger()
344 card->recv.dmastart = (u32)card->dma + (NJ_DMA_SIZE / 2); in inittiger()
345 card->recv.dmaend = card->recv.dmastart + in inittiger()
346 (4 * (NJ_DMA_RXSIZE - 1)); in inittiger()
347 card->recv.dmairq = card->recv.dmastart + in inittiger()
348 (4 * ((NJ_DMA_RXSIZE / 2) - 1)); in inittiger()
349 card->recv.size = NJ_DMA_RXSIZE; in inittiger()
352 pr_notice("%s: recv buffer phy %#x - %#x - %#x virt %p" in inittiger()
353 " size %zu u32\n", card->name, in inittiger()
354 card->recv.dmastart, card->recv.dmairq, in inittiger()
355 card->recv.dmaend, card->recv.start, card->recv.size); in inittiger()
357 outl(card->recv.dmastart, card->base + NJ_DMA_WRITE_START); in inittiger()
358 outl(card->recv.dmairq, card->base + NJ_DMA_WRITE_IRQ); in inittiger()
359 outl(card->recv.dmaend, card->base + NJ_DMA_WRITE_END); in inittiger()
364 read_dma(struct tiger_ch *bc, u32 idx, int cnt) in read_dma() argument
366 struct tiger_hw *card = bc->bch.hw; in read_dma()
371 if (bc->lastrx == idx) { in read_dma()
372 bc->rxstate |= RX_OVERRUN; in read_dma()
373 pr_info("%s: B%1d overrun at idx %d\n", card->name, in read_dma()
374 bc->bch.nr, idx); in read_dma()
376 bc->lastrx = idx; in read_dma()
377 if (test_bit(FLG_RX_OFF, &bc->bch.Flags)) { in read_dma()
378 bc->bch.dropcnt += cnt; in read_dma()
381 stat = bchannel_get_rxbuf(&bc->bch, cnt); in read_dma()
383 if (stat == -ENOMEM) { in read_dma()
385 card->name, bc->bch.nr, cnt); in read_dma()
388 if (test_bit(FLG_TRANSPARENT, &bc->bch.Flags)) in read_dma()
389 p = skb_put(bc->bch.rx_skb, cnt); in read_dma()
391 p = bc->hrbuf; in read_dma()
393 for (i = 0; i < cnt; i++) { in read_dma()
394 val = card->recv.start[idx++]; in read_dma()
395 if (bc->bch.nr & 2) in read_dma()
397 if (idx >= card->recv.size) in read_dma()
402 if (test_bit(FLG_TRANSPARENT, &bc->bch.Flags)) { in read_dma()
403 recv_Bchannel(&bc->bch, 0, false); in read_dma()
407 pn = bc->hrbuf; in read_dma()
408 while (cnt > 0) { in read_dma()
409 stat = isdnhdlc_decode(&bc->hrecv, pn, cnt, &i, in read_dma()
410 bc->bch.rx_skb->data, bc->bch.maxlen); in read_dma()
412 p = skb_put(bc->bch.rx_skb, stat); in read_dma()
414 snprintf(card->log, LOG_SIZE, in read_dma()
415 "B%1d-recv %s %d ", bc->bch.nr, in read_dma()
416 card->name, stat); in read_dma()
417 print_hex_dump_bytes(card->log, in read_dma()
421 recv_Bchannel(&bc->bch, 0, false); in read_dma()
422 stat = bchannel_get_rxbuf(&bc->bch, bc->bch.maxlen); in read_dma()
425 card->name, bc->bch.nr, cnt); in read_dma()
428 } else if (stat == -HDLC_CRC_ERROR) { in read_dma()
430 card->name, bc->bch.nr); in read_dma()
431 } else if (stat == -HDLC_FRAMING_ERROR) { in read_dma()
433 card->name, bc->bch.nr); in read_dma()
434 } else if (stat == -HDLC_LENGTH_ERROR) { in read_dma()
436 card->name, bc->bch.nr, bc->bch.maxlen); in read_dma()
439 cnt -= i; in read_dma()
447 int cnt = card->recv.size / 2; in recv_tiger() local
450 card->last_is0 &= ~NJ_IRQM0_WR_MASK; in recv_tiger()
451 card->last_is0 |= (irq_stat & NJ_IRQM0_WR_MASK); in recv_tiger()
454 idx = cnt - 1; in recv_tiger()
456 idx = card->recv.size - 1; in recv_tiger()
458 if (test_bit(FLG_ACTIVE, &card->bc[0].bch.Flags)) in recv_tiger()
459 read_dma(&card->bc[0], idx, cnt); in recv_tiger()
460 if (test_bit(FLG_ACTIVE, &card->bc[1].bch.Flags)) in recv_tiger()
461 read_dma(&card->bc[1], idx, cnt); in recv_tiger()
468 card->send.dmacur = inl(card->base | NJ_DMA_READ_ADR); in resync()
469 card->send.idx = (card->send.dmacur - card->send.dmastart) >> 2; in resync()
470 if (bc->free > card->send.size / 2) in resync()
471 bc->free = card->send.size / 2; in resync()
476 if (card->send.idx < ((card->send.size / 2) - 1)) in resync()
477 bc->idx = (card->recv.size / 2) - 1; in resync()
479 bc->idx = card->recv.size - 1; in resync()
480 bc->txstate = TX_RUN; in resync()
481 pr_debug("%s: %s B%1d free %d idx %d/%d\n", card->name, in resync()
482 __func__, bc->bch.nr, bc->free, bc->idx, card->send.idx); in resync()
490 struct tiger_hw *card = bc->bch.hw; in fill_hdlc_flag()
495 if (bc->free == 0) in fill_hdlc_flag()
497 pr_debug("%s: %s B%1d %d state %x idx %d/%d\n", card->name, in fill_hdlc_flag()
498 __func__, bc->bch.nr, bc->free, bc->txstate, in fill_hdlc_flag()
499 bc->idx, card->send.idx); in fill_hdlc_flag()
500 if (bc->txstate & (TX_IDLE | TX_INIT | TX_UNDERRUN)) in fill_hdlc_flag()
502 count = isdnhdlc_encode(&bc->hsend, NULL, 0, &i, in fill_hdlc_flag()
503 bc->hsbuf, bc->free); in fill_hdlc_flag()
504 pr_debug("%s: B%1d hdlc encoded %d flags\n", card->name, in fill_hdlc_flag()
505 bc->bch.nr, count); in fill_hdlc_flag()
506 bc->free -= count; in fill_hdlc_flag()
507 p = bc->hsbuf; in fill_hdlc_flag()
508 m = (bc->bch.nr & 1) ? 0xffffff00 : 0xffff00ff; in fill_hdlc_flag()
510 if (bc->idx >= card->send.size) in fill_hdlc_flag()
511 bc->idx = 0; in fill_hdlc_flag()
512 v = card->send.start[bc->idx]; in fill_hdlc_flag()
514 v |= (bc->bch.nr & 1) ? (u32)(p[i]) : ((u32)(p[i])) << 8; in fill_hdlc_flag()
515 card->send.start[bc->idx++] = v; in fill_hdlc_flag()
518 snprintf(card->log, LOG_SIZE, "B%1d-send %s %d ", in fill_hdlc_flag()
519 bc->bch.nr, card->name, count); in fill_hdlc_flag()
520 print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, p, count); in fill_hdlc_flag()
527 struct tiger_hw *card = bc->bch.hw; in fill_dma()
532 if (bc->free == 0) in fill_dma()
534 if (!bc->bch.tx_skb) { in fill_dma()
535 if (!test_bit(FLG_TX_EMPTY, &bc->bch.Flags)) in fill_dma()
538 count = card->send.size >> 1; in fill_dma()
539 p = bc->bch.fill; in fill_dma()
541 count = bc->bch.tx_skb->len - bc->bch.tx_idx; in fill_dma()
545 card->name, __func__, bc->bch.nr, count, bc->free, in fill_dma()
546 bc->bch.tx_idx, bc->bch.tx_skb->len, bc->txstate, in fill_dma()
547 bc->idx, card->send.idx); in fill_dma()
548 p = bc->bch.tx_skb->data + bc->bch.tx_idx; in fill_dma()
550 if (bc->txstate & (TX_IDLE | TX_INIT | TX_UNDERRUN)) in fill_dma()
552 if (test_bit(FLG_HDLC, &bc->bch.Flags) && !fillempty) { in fill_dma()
553 count = isdnhdlc_encode(&bc->hsend, p, count, &i, in fill_dma()
554 bc->hsbuf, bc->free); in fill_dma()
555 pr_debug("%s: B%1d hdlc encoded %d in %d\n", card->name, in fill_dma()
556 bc->bch.nr, i, count); in fill_dma()
557 bc->bch.tx_idx += i; in fill_dma()
558 bc->free -= count; in fill_dma()
559 p = bc->hsbuf; in fill_dma()
561 if (count > bc->free) in fill_dma()
562 count = bc->free; in fill_dma()
564 bc->bch.tx_idx += count; in fill_dma()
565 bc->free -= count; in fill_dma()
567 m = (bc->bch.nr & 1) ? 0xffffff00 : 0xffff00ff; in fill_dma()
570 if (!(bc->bch.nr & 1)) in fill_dma()
573 if (bc->idx >= card->send.size) in fill_dma()
574 bc->idx = 0; in fill_dma()
575 v = card->send.start[bc->idx]; in fill_dma()
578 card->send.start[bc->idx++] = v; in fill_dma()
582 if (bc->idx >= card->send.size) in fill_dma()
583 bc->idx = 0; in fill_dma()
584 v = card->send.start[bc->idx]; in fill_dma()
587 v |= (bc->bch.nr & 1) ? n : n << 8; in fill_dma()
588 card->send.start[bc->idx++] = v; in fill_dma()
592 snprintf(card->log, LOG_SIZE, "B%1d-send %s %d ", in fill_dma()
593 bc->bch.nr, card->name, count); in fill_dma()
594 print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, p, count); in fill_dma()
596 if (bc->free) in fill_dma()
606 if (bc->bch.tx_skb && bc->bch.tx_idx < bc->bch.tx_skb->len) { in bc_next_frame()
609 dev_kfree_skb(bc->bch.tx_skb); in bc_next_frame()
610 if (get_next_bframe(&bc->bch)) { in bc_next_frame()
612 test_and_clear_bit(FLG_TX_EMPTY, &bc->bch.Flags); in bc_next_frame()
613 } else if (test_bit(FLG_TX_EMPTY, &bc->bch.Flags)) { in bc_next_frame()
615 } else if (test_bit(FLG_FILLEMPTY, &bc->bch.Flags)) { in bc_next_frame()
616 test_and_set_bit(FLG_TX_EMPTY, &bc->bch.Flags); in bc_next_frame()
630 bc->free += card->send.size / 2; in send_tiger_bc()
631 if (bc->free >= card->send.size) { in send_tiger_bc()
632 if (!(bc->txstate & (TX_UNDERRUN | TX_INIT))) { in send_tiger_bc()
633 pr_info("%s: B%1d TX underrun state %x\n", card->name, in send_tiger_bc()
634 bc->bch.nr, bc->txstate); in send_tiger_bc()
635 bc->txstate |= TX_UNDERRUN; in send_tiger_bc()
637 bc->free = card->send.size; in send_tiger_bc()
641 if (test_bit(FLG_HDLC, &bc->bch.Flags)) { in send_tiger_bc()
645 pr_debug("%s: B%1d TX no data free %d idx %d/%d\n", card->name, in send_tiger_bc()
646 bc->bch.nr, bc->free, bc->idx, card->send.idx); in send_tiger_bc()
647 if (!(bc->txstate & (TX_IDLE | TX_INIT))) { in send_tiger_bc()
648 fill_mem(bc, bc->idx, bc->free, 0xff); in send_tiger_bc()
649 if (bc->free == card->send.size) in send_tiger_bc()
650 bc->txstate |= TX_IDLE; in send_tiger_bc()
661 if ((irq_stat & card->last_is0) & NJ_IRQM0_RD_MASK) { in send_tiger()
663 card->name, irq_stat, card->last_is0); in send_tiger()
666 card->last_is0 &= ~NJ_IRQM0_RD_MASK; in send_tiger()
667 card->last_is0 |= (irq_stat & NJ_IRQM0_RD_MASK); in send_tiger()
670 if (test_bit(FLG_ACTIVE, &card->bc[i].bch.Flags)) in send_tiger()
671 send_tiger_bc(card, &card->bc[i]); in send_tiger()
681 spin_lock(&card->lock); in nj_irq()
682 s0val = inb(card->base | NJ_IRQSTAT0); in nj_irq()
683 s1val = inb(card->base | NJ_IRQSTAT1); in nj_irq()
686 spin_unlock(&card->lock); in nj_irq()
689 pr_debug("%s: IRQSTAT0 %02x IRQSTAT1 %02x\n", card->name, s0val, s1val); in nj_irq()
690 card->irqcnt++; in nj_irq()
694 mISDNisac_irq(&card->isac, val); in nj_irq()
699 outb(s0val, card->base | NJ_IRQSTAT0); in nj_irq()
704 card->recv.dmacur = inl(card->base | NJ_DMA_WRITE_ADR); in nj_irq()
705 card->recv.idx = (card->recv.dmacur - card->recv.dmastart) >> 2; in nj_irq()
706 if (card->recv.dmacur < card->recv.dmairq) in nj_irq()
711 card->send.dmacur = inl(card->base | NJ_DMA_READ_ADR); in nj_irq()
712 card->send.idx = (card->send.dmacur - card->send.dmastart) >> 2; in nj_irq()
713 if (card->send.dmacur < card->send.dmairq) in nj_irq()
718 pr_debug("%s: DMA Status %02x/%02x/%02x %d/%d\n", card->name, in nj_irq()
719 s1val, s0val, card->last_is0, in nj_irq()
720 card->recv.idx, card->send.idx); in nj_irq()
722 if (s0val != card->last_is0) { in nj_irq()
724 (card->last_is0 & NJ_IRQM0_RD_MASK)) in nj_irq()
728 (card->last_is0 & NJ_IRQM0_WR_MASK)) in nj_irq()
733 spin_unlock(&card->lock); in nj_irq()
740 int ret = -EINVAL; in nj_l2l1B()
743 struct tiger_hw *card = bch->hw; in nj_l2l1B()
747 switch (hh->prim) { in nj_l2l1B()
749 spin_lock_irqsave(&card->lock, flags); in nj_l2l1B()
755 spin_unlock_irqrestore(&card->lock, flags); in nj_l2l1B()
758 spin_lock_irqsave(&card->lock, flags); in nj_l2l1B()
759 if (!test_and_set_bit(FLG_ACTIVE, &bch->Flags)) in nj_l2l1B()
760 ret = mode_tiger(bc, ch->protocol); in nj_l2l1B()
763 spin_unlock_irqrestore(&card->lock, flags); in nj_l2l1B()
769 spin_lock_irqsave(&card->lock, flags); in nj_l2l1B()
772 spin_unlock_irqrestore(&card->lock, flags); in nj_l2l1B()
786 return mISDN_ctrl_bchannel(&bc->bch, cq); in channel_bctrl()
790 nj_bctrl(struct mISDNchannel *ch, u32 cmd, void *arg) in nj_bctrl() argument
794 struct tiger_hw *card = bch->hw; in nj_bctrl()
795 int ret = -EINVAL; in nj_bctrl()
798 pr_debug("%s: %s cmd:%x %p\n", card->name, __func__, cmd, arg); in nj_bctrl()
799 switch (cmd) { in nj_bctrl()
801 test_and_clear_bit(FLG_OPEN, &bch->Flags); in nj_bctrl()
802 cancel_work_sync(&bch->workq); in nj_bctrl()
803 spin_lock_irqsave(&card->lock, flags); in nj_bctrl()
806 spin_unlock_irqrestore(&card->lock, flags); in nj_bctrl()
807 ch->protocol = ISDN_P_NONE; in nj_bctrl()
808 ch->peer = NULL; in nj_bctrl()
816 pr_info("%s: %s unknown prim(%x)\n", card->name, __func__, cmd); in nj_bctrl()
826 switch (cq->op) { in channel_ctrl()
828 cq->op = MISDN_CTRL_LOOP | MISDN_CTRL_L1_TIMER3; in channel_ctrl()
831 /* cq->channel: 0 disable, 1 B1 loop 2 B2 loop, 3 both */ in channel_ctrl()
832 if (cq->channel < 0 || cq->channel > 3) { in channel_ctrl()
833 ret = -EINVAL; in channel_ctrl()
836 ret = card->isac.ctrl(&card->isac, HW_TESTLOOP, cq->channel); in channel_ctrl()
839 ret = card->isac.ctrl(&card->isac, HW_TIMER3_VALUE, cq->p1); in channel_ctrl()
842 pr_info("%s: %s unknown Op %x\n", card->name, __func__, cq->op); in channel_ctrl()
843 ret = -EINVAL; in channel_ctrl()
854 if (rq->adr.channel == 0 || rq->adr.channel > 2) in open_bchannel()
855 return -EINVAL; in open_bchannel()
856 if (rq->protocol == ISDN_P_NONE) in open_bchannel()
857 return -EINVAL; in open_bchannel()
858 bch = &card->bc[rq->adr.channel - 1].bch; in open_bchannel()
859 if (test_and_set_bit(FLG_OPEN, &bch->Flags)) in open_bchannel()
860 return -EBUSY; /* b-channel can be only open once */ in open_bchannel()
861 test_and_clear_bit(FLG_FILLEMPTY, &bch->Flags); in open_bchannel()
862 bch->ch.protocol = rq->protocol; in open_bchannel()
863 rq->ch = &bch->ch; in open_bchannel()
871 nj_dctrl(struct mISDNchannel *ch, u32 cmd, void *arg) in nj_dctrl() argument
875 struct tiger_hw *card = dch->hw; in nj_dctrl()
879 pr_debug("%s: %s cmd:%x %p\n", card->name, __func__, cmd, arg); in nj_dctrl()
880 switch (cmd) { in nj_dctrl()
883 if (rq->protocol == ISDN_P_TE_S0) in nj_dctrl()
884 err = card->isac.open(&card->isac, rq); in nj_dctrl()
890 pr_info("%s: cannot get module\n", card->name); in nj_dctrl()
893 pr_debug("%s: dev(%d) close from %p\n", card->name, dch->dev.id, in nj_dctrl()
902 card->name, __func__, cmd); in nj_dctrl()
903 return -EINVAL; in nj_dctrl()
914 spin_lock_irqsave(&card->lock, flags); in nj_init_card()
916 spin_unlock_irqrestore(&card->lock, flags); in nj_init_card()
918 card->irq = card->pdev->irq; in nj_init_card()
919 if (request_irq(card->irq, nj_irq, IRQF_SHARED, card->name, card)) { in nj_init_card()
921 card->name, card->irq); in nj_init_card()
922 card->irq = -1; in nj_init_card()
923 return -EIO; in nj_init_card()
926 spin_lock_irqsave(&card->lock, flags); in nj_init_card()
928 ret = card->isac.init(&card->isac); in nj_init_card()
934 mode_tiger(&card->bc[0], ISDN_P_NONE); in nj_init_card()
935 mode_tiger(&card->bc[1], ISDN_P_NONE); in nj_init_card()
937 spin_unlock_irqrestore(&card->lock, flags); in nj_init_card()
948 if (card->base_s) { in nj_release()
949 spin_lock_irqsave(&card->lock, flags); in nj_release()
951 mode_tiger(&card->bc[0], ISDN_P_NONE); in nj_release()
952 mode_tiger(&card->bc[1], ISDN_P_NONE); in nj_release()
953 spin_unlock_irqrestore(&card->lock, flags); in nj_release()
954 card->isac.release(&card->isac); in nj_release()
955 release_region(card->base, card->base_s); in nj_release()
956 card->base_s = 0; in nj_release()
958 if (card->irq > 0) in nj_release()
959 free_irq(card->irq, card); in nj_release()
960 if (device_is_registered(&card->isac.dch.dev.dev)) in nj_release()
961 mISDN_unregister_device(&card->isac.dch.dev); in nj_release()
964 mISDN_freebchannel(&card->bc[i].bch); in nj_release()
965 kfree(card->bc[i].hsbuf); in nj_release()
966 kfree(card->bc[i].hrbuf); in nj_release()
968 if (card->dma_p) in nj_release()
969 dma_free_coherent(&card->pdev->dev, NJ_DMA_SIZE, card->dma_p, in nj_release()
970 card->dma); in nj_release()
972 list_del(&card->list); in nj_release()
974 pci_disable_device(card->pdev); in nj_release()
975 pci_set_drvdata(card->pdev, NULL); in nj_release()
983 card->base = pci_resource_start(card->pdev, 0); in nj_setup()
984 card->base_s = pci_resource_len(card->pdev, 0); in nj_setup()
985 if (!request_region(card->base, card->base_s, card->name)) { in nj_setup()
986 pr_info("%s: NETjet config port %#x-%#x already in use\n", in nj_setup()
987 card->name, card->base, in nj_setup()
988 (u32)(card->base + card->base_s - 1)); in nj_setup()
989 card->base_s = 0; in nj_setup()
990 return -EIO; in nj_setup()
992 ASSIGN_FUNC(nj, ISAC, card->isac); in nj_setup()
1003 snprintf(card->name, MISDN_MAX_IDLEN - 1, "netjet.%d", nj_cnt + 1); in setup_instance()
1005 list_add_tail(&card->list, &Cards); in setup_instance()
1009 card->isac.name = card->name; in setup_instance()
1010 spin_lock_init(&card->lock); in setup_instance()
1011 card->isac.hwlock = &card->lock; in setup_instance()
1012 mISDNisac_init(&card->isac, card); in setup_instance()
1014 card->isac.dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) | in setup_instance()
1016 card->isac.dch.dev.D.ctrl = nj_dctrl; in setup_instance()
1018 card->bc[i].bch.nr = i + 1; in setup_instance()
1019 set_channelmap(i + 1, card->isac.dch.dev.channelmap); in setup_instance()
1020 mISDN_initbchannel(&card->bc[i].bch, MAX_DATA_MEM, in setup_instance()
1022 card->bc[i].bch.hw = card; in setup_instance()
1023 card->bc[i].bch.ch.send = nj_l2l1B; in setup_instance()
1024 card->bc[i].bch.ch.ctrl = nj_bctrl; in setup_instance()
1025 card->bc[i].bch.ch.nr = i + 1; in setup_instance()
1026 list_add(&card->bc[i].bch.ch.list, in setup_instance()
1027 &card->isac.dch.dev.bchannels); in setup_instance()
1028 card->bc[i].bch.hw = card; in setup_instance()
1033 err = mISDN_register_device(&card->isac.dch.dev, &card->pdev->dev, in setup_instance()
1034 card->name); in setup_instance()
1051 int err = -ENOMEM; in nj_probe()
1055 if (pdev->subsystem_vendor == 0x8086 && in nj_probe()
1056 pdev->subsystem_device == 0x0003) { in nj_probe()
1058 return -ENODEV; in nj_probe()
1061 if (pdev->subsystem_vendor == 0x55 && in nj_probe()
1062 pdev->subsystem_device == 0x02) { in nj_probe()
1064 return -ENODEV; in nj_probe()
1067 if (pdev->subsystem_vendor == 0xb100 && in nj_probe()
1068 pdev->subsystem_device == 0x0003) { in nj_probe()
1070 return -ENODEV; in nj_probe()
1079 card->pdev = pdev; in nj_probe()
1098 card->typ = NETJET_S_TJ320; in nj_probe()
1100 card->typ = NETJET_S_TJ300; in nj_probe()
1102 card->base = pci_resource_start(pdev, 0); in nj_probe()
1124 * known other cards which not work with this driver - see probe function */
1133 .name = "netjet",