Lines Matching refs:dev

62 extern void pcbit_l3_receive(struct pcbit_dev *dev, ulong msg,
71 static void pcbit_transmit(struct pcbit_dev *dev);
73 static void pcbit_recv_ack(struct pcbit_dev *dev, unsigned char ack);
75 static void pcbit_l2_error(struct pcbit_dev *dev);
76 static void pcbit_l2_active_conf(struct pcbit_dev *dev, u_char info);
79 static void pcbit_firmware_bug(struct pcbit_dev *dev);
82 pcbit_sched_delivery(struct pcbit_dev *dev) in pcbit_sched_delivery() argument
84 queue_task(&dev->qdelivery, &tq_immediate); in pcbit_sched_delivery()
94 pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum, in pcbit_l2_write() argument
101 if (dev->l2_state != L2_RUNNING && dev->l2_state != L2_LOADING) { in pcbit_l2_write()
128 if (dev->write_queue == NULL) { in pcbit_l2_write()
129 dev->write_queue = frame; in pcbit_l2_write()
131 pcbit_transmit(dev); in pcbit_l2_write()
133 for (ptr = dev->write_queue; ptr->next; ptr = ptr->next); in pcbit_l2_write()
142 pcbit_tx_update(struct pcbit_dev *dev, ushort len) in pcbit_tx_update() argument
146 dev->send_seq = (dev->send_seq + 1) % 8; in pcbit_tx_update()
148 dev->fsize[dev->send_seq] = len; in pcbit_tx_update()
150 info |= dev->rcv_seq << 3; in pcbit_tx_update()
151 info |= dev->send_seq; in pcbit_tx_update()
153 writeb(info, dev->sh_mem + BANK4); in pcbit_tx_update()
162 pcbit_transmit(struct pcbit_dev *dev) in pcbit_transmit() argument
173 if (dev->l2_state != L2_RUNNING && dev->l2_state != L2_LOADING) in pcbit_transmit()
176 unacked = (dev->send_seq + (8 - dev->unack_seq)) & 0x07; in pcbit_transmit()
181 if (dev->free > 16 && dev->write_queue && unacked < 7) { in pcbit_transmit()
183 if (!dev->w_busy) in pcbit_transmit()
184 dev->w_busy = 1; in pcbit_transmit()
191 frame = dev->write_queue; in pcbit_transmit()
192 free = dev->free; in pcbit_transmit()
216 pcbit_writew(dev, flen - FRAME_HDR_LEN); in pcbit_transmit()
218 pcbit_writeb(dev, GET_MSG_CPU(msg)); in pcbit_transmit()
220 pcbit_writeb(dev, GET_MSG_PROC(msg)); in pcbit_transmit()
223 pcbit_writew(dev, frame->hdr_len + PREHDR_LEN); in pcbit_transmit()
226 pcbit_writew(dev, frame->dt_len); in pcbit_transmit()
234 pcbit_writew(dev, frame->hdr_len + PREHDR_LEN); in pcbit_transmit()
237 pcbit_writew(dev, 0); in pcbit_transmit()
240 pcbit_writeb(dev, GET_MSG_CMD(msg)); in pcbit_transmit()
241 pcbit_writeb(dev, GET_MSG_SCMD(msg)); in pcbit_transmit()
244 pcbit_writew(dev, frame->refnum); in pcbit_transmit()
257 pcbit_writew(dev, tt); in pcbit_transmit()
267 memcpy_topcbit(dev, frame->skb->data + frame->copied, in pcbit_transmit()
272 dev->free -= flen; in pcbit_transmit()
273 pcbit_tx_update(dev, flen); in pcbit_transmit()
281 dev->write_queue = frame->next; in pcbit_transmit()
289 dev->w_busy = 0; in pcbit_transmit()
295 unacked, dev->free, dev->write_queue ? "not empty" : in pcbit_transmit()
311 struct pcbit_dev *dev = (struct pcbit_dev *) data; in pcbit_deliver() local
316 while ((frame = dev->read_queue)) { in pcbit_deliver()
317 dev->read_queue = frame->next; in pcbit_deliver()
330 pcbit_l3_receive(dev, frame->msg, frame->skb, frame->hdr_len, in pcbit_deliver()
347 pcbit_receive(struct pcbit_dev *dev) in pcbit_receive() argument
356 if (dev->l2_state != L2_RUNNING && dev->l2_state != L2_LOADING) in pcbit_receive()
359 tt = pcbit_readw(dev); in pcbit_receive()
364 pcbit_l2_error(dev); in pcbit_receive()
370 if (dev->read_frame) { in pcbit_receive()
373 if (dev->read_frame->skb) in pcbit_receive()
374 kfree_skb(dev->read_frame->skb); in pcbit_receive()
375 kfree(dev->read_frame); in pcbit_receive()
376 dev->read_frame = NULL; in pcbit_receive()
386 cpu = pcbit_readb(dev); in pcbit_receive()
387 proc = pcbit_readb(dev); in pcbit_receive()
393 pcbit_l2_error(dev); in pcbit_receive()
401 frame->hdr_len = pcbit_readw(dev); in pcbit_receive()
402 frame->dt_len = pcbit_readw(dev); in pcbit_receive()
416 pcbit_firmware_bug(dev); in pcbit_receive()
427 pcbit_l2_error(dev); in pcbit_receive()
450 if (!(frame = dev->read_frame)) { in pcbit_receive()
453 dev->readptr += tt; in pcbit_receive()
454 if (dev->readptr > dev->sh_mem + BANK2 + BANKLEN) in pcbit_receive()
455 dev->readptr -= BANKLEN; in pcbit_receive()
461 memcpy_frompcbit(dev, skb_put(frame->skb, tt), tt); in pcbit_receive()
471 dev->read_frame = NULL; in pcbit_receive()
473 if (dev->read_queue) { in pcbit_receive()
475 for (ptr = dev->read_queue; ptr->next; ptr = ptr->next); in pcbit_receive()
478 dev->read_queue = frame; in pcbit_receive()
485 dev->read_frame = frame; in pcbit_receive()
497 pcbit_fake_conf(struct pcbit_dev *dev, struct pcbit_chan *chan) in pcbit_fake_conf() argument
504 ictl.driver = dev->id; in pcbit_fake_conf()
507 dev->dev_if->statcallb(&ictl); in pcbit_fake_conf()
512 pcbit_firmware_bug(struct pcbit_dev *dev) in pcbit_firmware_bug() argument
516 chan = dev->b1; in pcbit_firmware_bug()
519 pcbit_fake_conf(dev, chan); in pcbit_firmware_bug()
521 chan = dev->b2; in pcbit_firmware_bug()
524 pcbit_fake_conf(dev, chan); in pcbit_firmware_bug()
531 struct pcbit_dev *dev; in pcbit_irq_handler() local
536 dev = (struct pcbit_dev *) devptr; in pcbit_irq_handler()
538 if (!dev) { in pcbit_irq_handler()
542 if (dev->interrupt) { in pcbit_irq_handler()
546 dev->interrupt = 1; in pcbit_irq_handler()
548 info = readb(dev->sh_mem + BANK3); in pcbit_irq_handler()
550 if (dev->l2_state == L2_STARTING || dev->l2_state == L2_ERROR) { in pcbit_irq_handler()
551 pcbit_l2_active_conf(dev, info); in pcbit_irq_handler()
552 dev->interrupt = 0; in pcbit_irq_handler()
559 pcbit_l2_error(dev); in pcbit_irq_handler()
560 dev->interrupt = 0; in pcbit_irq_handler()
563 if (dev->l2_state != L2_RUNNING && dev->l2_state != L2_LOADING) { in pcbit_irq_handler()
564 dev->interrupt = 0; in pcbit_irq_handler()
570 dev->interrupt = 0; in pcbit_irq_handler()
572 if (read_seq != dev->rcv_seq) { in pcbit_irq_handler()
573 while (read_seq != dev->rcv_seq) { in pcbit_irq_handler()
574 pcbit_receive(dev); in pcbit_irq_handler()
575 dev->rcv_seq = (dev->rcv_seq + 1) % 8; in pcbit_irq_handler()
577 pcbit_sched_delivery(dev); in pcbit_irq_handler()
579 if (ack_seq != dev->unack_seq) { in pcbit_irq_handler()
580 pcbit_recv_ack(dev, ack_seq); in pcbit_irq_handler()
582 info = dev->rcv_seq << 3; in pcbit_irq_handler()
583 info |= dev->send_seq; in pcbit_irq_handler()
585 writeb(info, dev->sh_mem + BANK4); in pcbit_irq_handler()
590 pcbit_l2_active_conf(struct pcbit_dev *dev, u_char info) in pcbit_l2_active_conf() argument
594 state = dev->l2_state; in pcbit_l2_active_conf()
602 dev->rcv_seq = info & 0x07U; in pcbit_l2_active_conf()
603 dev->l2_state = L2_RUNNING; in pcbit_l2_active_conf()
605 dev->l2_state = L2_DOWN; in pcbit_l2_active_conf()
608 wake_up_interruptible(&dev->set_running_wq); in pcbit_l2_active_conf()
610 if (state == L2_ERROR && dev->l2_state == L2_RUNNING) { in pcbit_l2_active_conf()
611 pcbit_transmit(dev); in pcbit_l2_active_conf()
619 struct pcbit_dev *dev; in pcbit_l2_err_recover() local
622 dev = (struct pcbit_dev *) data; in pcbit_l2_err_recover()
624 del_timer(&dev->error_recover_timer); in pcbit_l2_err_recover()
625 if (dev->w_busy || dev->r_busy) { in pcbit_l2_err_recover()
626 init_timer(&dev->error_recover_timer); in pcbit_l2_err_recover()
627 dev->error_recover_timer.expires = jiffies + ERRTIME; in pcbit_l2_err_recover()
628 add_timer(&dev->error_recover_timer); in pcbit_l2_err_recover()
631 dev->w_busy = dev->r_busy = 1; in pcbit_l2_err_recover()
633 if (dev->read_frame) { in pcbit_l2_err_recover()
634 if (dev->read_frame->skb) in pcbit_l2_err_recover()
635 kfree_skb(dev->read_frame->skb); in pcbit_l2_err_recover()
636 kfree(dev->read_frame); in pcbit_l2_err_recover()
637 dev->read_frame = NULL; in pcbit_l2_err_recover()
639 if (dev->write_queue) { in pcbit_l2_err_recover()
640 frame = dev->write_queue; in pcbit_l2_err_recover()
642 dev->write_queue = dev->write_queue->next; in pcbit_l2_err_recover()
652 dev->rcv_seq = dev->send_seq = dev->unack_seq = 0; in pcbit_l2_err_recover()
653 dev->free = 511; in pcbit_l2_err_recover()
654 dev->l2_state = L2_ERROR; in pcbit_l2_err_recover()
657 pcbit_firmware_bug(dev); in pcbit_l2_err_recover()
659 dev->writeptr = dev->sh_mem; in pcbit_l2_err_recover()
660 dev->readptr = dev->sh_mem + BANK2; in pcbit_l2_err_recover()
662 writeb((0x80U | ((dev->rcv_seq & 0x07) << 3) | (dev->send_seq & 0x07)), in pcbit_l2_err_recover()
663 dev->sh_mem + BANK4); in pcbit_l2_err_recover()
664 dev->w_busy = dev->r_busy = 0; in pcbit_l2_err_recover()
669 pcbit_l2_error(struct pcbit_dev *dev) in pcbit_l2_error() argument
671 if (dev->l2_state == L2_RUNNING) { in pcbit_l2_error()
676 log_state(dev); in pcbit_l2_error()
679 dev->l2_state = L2_DOWN; in pcbit_l2_error()
681 init_timer(&dev->error_recover_timer); in pcbit_l2_error()
682 dev->error_recover_timer.function = &pcbit_l2_err_recover; in pcbit_l2_error()
683 dev->error_recover_timer.data = (ulong) dev; in pcbit_l2_error()
684 dev->error_recover_timer.expires = jiffies + ERRTIME; in pcbit_l2_error()
685 add_timer(&dev->error_recover_timer); in pcbit_l2_error()
697 pcbit_recv_ack(struct pcbit_dev *dev, unsigned char ack) in pcbit_recv_ack() argument
703 unacked = (dev->send_seq + (8 - dev->unack_seq)) & 0x07; in pcbit_recv_ack()
709 if (dev->send_seq > dev->unack_seq) { in pcbit_recv_ack()
710 if (ack <= dev->unack_seq || ack > dev->send_seq) { in pcbit_recv_ack()
713 dev->id); in pcbit_recv_ack()
715 pcbit_l2_error(dev); in pcbit_recv_ack()
716 } else if (ack > dev->send_seq && ack <= dev->unack_seq) { in pcbit_recv_ack()
719 dev->id); in pcbit_recv_ack()
720 pcbit_l2_error(dev); in pcbit_recv_ack()
726 i = dev->unack_seq; in pcbit_recv_ack()
729 dev->unack_seq = i = (i + 1) % 8; in pcbit_recv_ack()
730 dev->free += dev->fsize[i]; in pcbit_recv_ack()
734 while (count < 7 && dev->write_queue) { in pcbit_recv_ack()
735 u8 lsend_seq = dev->send_seq; in pcbit_recv_ack()
737 pcbit_transmit(dev); in pcbit_recv_ack()
739 if (dev->send_seq == lsend_seq) in pcbit_recv_ack()