Lines Matching refs:dev
66 static int set_protocol_running(struct pcbit_dev * dev);
68 static void pcbit_clear_msn(struct pcbit_dev *dev);
69 static void pcbit_set_msn(struct pcbit_dev *dev, char *list);
70 static int pcbit_check_msn(struct pcbit_dev *dev, char *msn);
77 struct pcbit_dev *dev; in pcbit_init_dev() local
80 if ((dev=kmalloc(sizeof(struct pcbit_dev), GFP_KERNEL)) == NULL) in pcbit_init_dev()
86 dev_pcbit[board] = dev; in pcbit_init_dev()
87 memset(dev, 0, sizeof(struct pcbit_dev)); in pcbit_init_dev()
88 init_waitqueue_head(&dev->set_running_wq); in pcbit_init_dev()
91 dev->ph_mem = mem_base; in pcbit_init_dev()
92 if (check_mem_region(dev->ph_mem, 4096)) { in pcbit_init_dev()
95 dev->ph_mem, dev->ph_mem + 4096); in pcbit_init_dev()
96 kfree(dev); in pcbit_init_dev()
100 request_mem_region(dev->ph_mem, 4096, "PCBIT mem"); in pcbit_init_dev()
102 dev->sh_mem = (unsigned char*)ioremap(dev->ph_mem, 4096); in pcbit_init_dev()
107 kfree(dev); in pcbit_init_dev()
112 dev->b1 = kmalloc(sizeof(struct pcbit_chan), GFP_KERNEL); in pcbit_init_dev()
113 if (!dev->b1) { in pcbit_init_dev()
115 iounmap((unsigned char*)dev->sh_mem); in pcbit_init_dev()
116 release_mem_region(dev->ph_mem, 4096); in pcbit_init_dev()
117 kfree(dev); in pcbit_init_dev()
121 dev->b2 = kmalloc(sizeof(struct pcbit_chan), GFP_KERNEL); in pcbit_init_dev()
122 if (!dev->b2) { in pcbit_init_dev()
124 kfree(dev->b1); in pcbit_init_dev()
125 iounmap((unsigned char*)dev->sh_mem); in pcbit_init_dev()
126 release_mem_region(dev->ph_mem, 4096); in pcbit_init_dev()
127 kfree(dev); in pcbit_init_dev()
131 memset(dev->b1, 0, sizeof(struct pcbit_chan)); in pcbit_init_dev()
132 memset(dev->b2, 0, sizeof(struct pcbit_chan)); in pcbit_init_dev()
133 dev->b2->id = 1; in pcbit_init_dev()
135 dev->qdelivery.sync = 0; in pcbit_init_dev()
136 dev->qdelivery.routine = pcbit_deliver; in pcbit_init_dev()
137 dev->qdelivery.data = dev; in pcbit_init_dev()
143 if (request_irq(irq, &pcbit_irq_handler, 0, pcbit_devname[board], dev) != 0) in pcbit_init_dev()
145 kfree(dev->b1); in pcbit_init_dev()
146 kfree(dev->b2); in pcbit_init_dev()
147 iounmap((unsigned char*)dev->sh_mem); in pcbit_init_dev()
148 release_mem_region(dev->ph_mem, 4096); in pcbit_init_dev()
149 kfree(dev); in pcbit_init_dev()
154 dev->irq = irq; in pcbit_init_dev()
157 dev->rcv_seq = 0; in pcbit_init_dev()
158 dev->send_seq = 0; in pcbit_init_dev()
159 dev->unack_seq = 0; in pcbit_init_dev()
161 dev->hl_hdrlen = 16; in pcbit_init_dev()
166 free_irq(irq, dev); in pcbit_init_dev()
167 kfree(dev->b1); in pcbit_init_dev()
168 kfree(dev->b2); in pcbit_init_dev()
169 iounmap((unsigned char*)dev->sh_mem); in pcbit_init_dev()
170 release_mem_region(dev->ph_mem, 4096); in pcbit_init_dev()
171 kfree(dev); in pcbit_init_dev()
176 dev->dev_if = dev_if; in pcbit_init_dev()
197 free_irq(irq, dev); in pcbit_init_dev()
198 kfree(dev->b1); in pcbit_init_dev()
199 kfree(dev->b2); in pcbit_init_dev()
200 iounmap((unsigned char*)dev->sh_mem); in pcbit_init_dev()
201 release_mem_region(dev->ph_mem, 4096); in pcbit_init_dev()
202 kfree(dev); in pcbit_init_dev()
207 dev->id = dev_if->channels; in pcbit_init_dev()
210 dev->l2_state = L2_DOWN; in pcbit_init_dev()
211 dev->free = 511; in pcbit_init_dev()
223 struct pcbit_dev * dev; in pcbit_terminate() local
225 dev = dev_pcbit[board]; in pcbit_terminate()
227 if (dev) { in pcbit_terminate()
229 free_irq(dev->irq, dev); in pcbit_terminate()
230 pcbit_clear_msn(dev); in pcbit_terminate()
231 kfree(dev->dev_if); in pcbit_terminate()
232 if (dev->b1->fsm_timer.function) in pcbit_terminate()
233 del_timer(&dev->b1->fsm_timer); in pcbit_terminate()
234 if (dev->b2->fsm_timer.function) in pcbit_terminate()
235 del_timer(&dev->b2->fsm_timer); in pcbit_terminate()
236 kfree(dev->b1); in pcbit_terminate()
237 kfree(dev->b2); in pcbit_terminate()
238 iounmap((unsigned char*)dev->sh_mem); in pcbit_terminate()
239 release_mem_region(dev->ph_mem, 4096); in pcbit_terminate()
240 kfree(dev); in pcbit_terminate()
247 struct pcbit_dev *dev; in pcbit_command() local
251 dev = finddev(ctl->driver); in pcbit_command()
253 if (!dev) in pcbit_command()
259 chan = (ctl->arg & 0x0F) ? dev->b2 : dev->b1; in pcbit_command()
269 pcbit_fsm_event(dev, chan, EV_USR_SETUP_REQ, &info); in pcbit_command()
272 pcbit_fsm_event(dev, chan, EV_USR_SETUP_RESP, NULL); in pcbit_command()
278 pcbit_fsm_event(dev, chan, EV_USR_RELEASE_REQ, NULL); in pcbit_command()
293 pcbit_clear_msn(dev); in pcbit_command()
296 pcbit_set_msn(dev, ctl->parm.num); in pcbit_command()
328 struct pcbit_dev * dev; in pcbit_block_timer() local
333 dev = chan2dev(chan); in pcbit_block_timer()
335 if (dev == NULL) { in pcbit_block_timer()
347 ictl.driver = dev->id; in pcbit_block_timer()
350 dev->dev_if->statcallb(&ictl); in pcbit_block_timer()
359 struct pcbit_dev *dev; in pcbit_xmit() local
361 dev = finddev(driver); in pcbit_xmit()
362 if (dev == NULL) in pcbit_xmit()
368 chan = chnum ? dev->b2 : dev->b1; in pcbit_xmit()
408 pcbit_l2_write(dev, MSG_TDATA_REQ, refnum, skb, hdrlen); in pcbit_xmit()
415 struct pcbit_dev * dev; in pcbit_writecmd() local
422 dev = finddev(driver); in pcbit_writecmd()
424 if (!dev) in pcbit_writecmd()
430 switch(dev->l2_state) { in pcbit_writecmd()
449 memcpy_toio(dev->sh_mem, cbuf, len); in pcbit_writecmd()
453 memcpy_toio(dev->sh_mem, buf, len); in pcbit_writecmd()
476 if (!(readb(dev->sh_mem + dev->loadptr))) in pcbit_writecmd()
485 writeb(loadbuf[i], dev->sh_mem + dev->loadptr + 1); in pcbit_writecmd()
486 writeb(0x01, dev->sh_mem + dev->loadptr); in pcbit_writecmd()
488 dev->loadptr += 2; in pcbit_writecmd()
489 if (dev->loadptr > LOAD_ZONE_END) in pcbit_writecmd()
490 dev->loadptr = LOAD_ZONE_START; in pcbit_writecmd()
507 void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, in pcbit_l3_receive() argument
521 if (!(chan = capi_channel(dev, skb))) { in pcbit_l3_receive()
529 dev->dev_if->rcvcallb_skb(dev->id, chan->id, skb); in pcbit_l3_receive()
532 pcbit_l2_write(dev, MSG_TDATA_RESP, refnum, in pcbit_l3_receive()
537 if (!(chan = capi_channel(dev, skb))) { in pcbit_l3_receive()
557 ictl.driver = dev->id; in pcbit_l3_receive()
560 dev->dev_if->statcallb(&ictl); in pcbit_l3_receive()
569 if (!dev->b1->fsm_state) in pcbit_l3_receive()
570 chan = dev->b1; in pcbit_l3_receive()
571 else if (!dev->b2->fsm_state) in pcbit_l3_receive()
572 chan = dev->b2; in pcbit_l3_receive()
578 pcbit_l2_write(dev, MSG_DISC_REQ, refnum, skb2, len); in pcbit_l3_receive()
588 pcbit_fsm_event(dev, chan, EV_NET_SETUP, NULL); in pcbit_l3_receive()
590 if (pcbit_check_msn(dev, cbdata.data.setup.CallingPN)) in pcbit_l3_receive()
591 pcbit_fsm_event(dev, chan, EV_USR_PROCED_REQ, &cbdata); in pcbit_l3_receive()
593 pcbit_fsm_event(dev, chan, EV_USR_RELEASE_REQ, NULL); in pcbit_l3_receive()
609 dev->b1->s_refnum, in pcbit_l3_receive()
610 dev->b2->s_refnum); in pcbit_l3_receive()
614 if (dev->b1->fsm_state == ST_CALL_INIT) in pcbit_l3_receive()
615 chan = dev->b1; in pcbit_l3_receive()
617 if (dev->b2->s_refnum == ST_CALL_INIT) in pcbit_l3_receive()
618 chan = dev->b2; in pcbit_l3_receive()
627 pcbit_fsm_event(dev, chan, EV_ERROR, NULL); in pcbit_l3_receive()
631 pcbit_fsm_event(dev, chan, EV_NET_CALL_PROC, NULL); in pcbit_l3_receive()
633 pcbit_fsm_event(dev, chan, EV_NET_SETUP_ACK, NULL); in pcbit_l3_receive()
637 if (!(chan = capi_channel(dev, skb))) { in pcbit_l3_receive()
649 pcbit_fsm_event(dev, chan, EV_NET_CONN, NULL); in pcbit_l3_receive()
653 if (!(chan = capi_channel(dev, skb))) { in pcbit_l3_receive()
660 pcbit_fsm_event(dev, chan, EV_NET_CONN_ACK, NULL); in pcbit_l3_receive()
668 if (!(chan = capi_channel(dev, skb))) { in pcbit_l3_receive()
675 pcbit_fsm_event(dev, chan, EV_NET_SELP_RESP, NULL); in pcbit_l3_receive()
682 if (!(chan = capi_channel(dev, skb))) { in pcbit_l3_receive()
689 pcbit_fsm_event(dev, chan, EV_NET_ACTV_RESP, NULL); in pcbit_l3_receive()
694 if (!(chan = capi_channel(dev, skb))) { in pcbit_l3_receive()
701 pcbit_fsm_event(dev, chan, EV_NET_DISC, NULL); in pcbit_l3_receive()
706 if (!(chan = capi_channel(dev, skb))) { in pcbit_l3_receive()
713 pcbit_fsm_event(dev, chan, EV_NET_RELEASE, NULL); in pcbit_l3_receive()
803 static void pcbit_logstat(struct pcbit_dev *dev, char *str) in pcbit_logstat() argument
817 ictl.driver=dev->id; in pcbit_logstat()
819 dev->dev_if->statcallb(&ictl); in pcbit_logstat()
826 void pcbit_state_change(struct pcbit_dev * dev, struct pcbit_chan * chan, in pcbit_state_change() argument
832 dev->id, chan->id, in pcbit_state_change()
840 pcbit_logstat(dev, buf); in pcbit_state_change()
845 struct pcbit_dev * dev; in set_running_timeout() local
850 dev = (struct pcbit_dev *) ptr; in set_running_timeout()
852 wake_up_interruptible(&dev->set_running_wq); in set_running_timeout()
855 static int set_protocol_running(struct pcbit_dev * dev) in set_protocol_running() argument
859 init_timer(&dev->set_running_timer); in set_protocol_running()
861 dev->set_running_timer.function = &set_running_timeout; in set_protocol_running()
862 dev->set_running_timer.data = (ulong) dev; in set_protocol_running()
863 dev->set_running_timer.expires = jiffies + SET_RUN_TIMEOUT; in set_protocol_running()
867 dev->l2_state = L2_STARTING; in set_protocol_running()
869 writeb((0x80U | ((dev->rcv_seq & 0x07) << 3) | (dev->send_seq & 0x07)), in set_protocol_running()
870 dev->sh_mem + BANK4); in set_protocol_running()
872 add_timer(&dev->set_running_timer); in set_protocol_running()
874 interruptible_sleep_on(&dev->set_running_wq); in set_protocol_running()
876 del_timer(&dev->set_running_timer); in set_protocol_running()
878 if (dev->l2_state == L2_RUNNING) in set_protocol_running()
882 dev->unack_seq = dev->send_seq; in set_protocol_running()
884 dev->writeptr = dev->sh_mem; in set_protocol_running()
885 dev->readptr = dev->sh_mem + BANK2; in set_protocol_running()
888 ctl.driver = dev->id; in set_protocol_running()
891 dev->dev_if->statcallb(&ctl); in set_protocol_running()
898 dev->l2_state = L2_DOWN; in set_protocol_running()
902 readb(dev->sh_mem + BANK3)); in set_protocol_running()
904 *(dev->sh_mem + BANK4) = 0x40U; in set_protocol_running()
907 ctl.driver = dev->id; in set_protocol_running()
910 dev->dev_if->statcallb(&ctl); in set_protocol_running()
920 struct pcbit_dev * dev; in pcbit_ioctl() local
923 dev = finddev(ctl->driver); in pcbit_ioctl()
925 if (!dev) in pcbit_ioctl()
935 cmd->info.l2_status = dev->l2_state; in pcbit_ioctl()
939 if (dev->l2_state == L2_RUNNING) in pcbit_ioctl()
942 dev->unack_seq = dev->send_seq = dev->rcv_seq = 0; in pcbit_ioctl()
944 dev->writeptr = dev->sh_mem; in pcbit_ioctl()
945 dev->readptr = dev->sh_mem + BANK2; in pcbit_ioctl()
947 dev->l2_state = L2_LOADING; in pcbit_ioctl()
951 if (dev->l2_state != L2_LOADING) in pcbit_ioctl()
954 dev->l2_state = L2_LWMODE; in pcbit_ioctl()
958 if (dev->l2_state == L2_RUNNING) in pcbit_ioctl()
960 dev->loadptr = LOAD_ZONE_START; in pcbit_ioctl()
961 dev->l2_state = L2_FWMODE; in pcbit_ioctl()
965 if (dev->l2_state == L2_RUNNING) in pcbit_ioctl()
967 dev->l2_state = L2_DOWN; in pcbit_ioctl()
971 if (dev->l2_state == L2_RUNNING) in pcbit_ioctl()
978 writeb(cmd->info.rdp_byte.value, dev->sh_mem + cmd->info.rdp_byte.addr); in pcbit_ioctl()
981 if (dev->l2_state == L2_RUNNING) in pcbit_ioctl()
992 cmd->info.rdp_byte.value = readb(dev->sh_mem + cmd->info.rdp_byte.addr); in pcbit_ioctl()
995 if (dev->l2_state == L2_RUNNING) in pcbit_ioctl()
997 return set_protocol_running(dev); in pcbit_ioctl()
1000 if (dev->l2_state != L2_LOADING) in pcbit_ioctl()
1002 pcbit_l2_write(dev, MSG_WATCH188, 0x0001, NULL, 0); in pcbit_ioctl()
1005 if (dev->l2_state != L2_LOADING) in pcbit_ioctl()
1007 pcbit_l2_write(dev, MSG_PING188_REQ, 0x0001, NULL, 0); in pcbit_ioctl()
1010 if (dev->l2_state != L2_LOADING) in pcbit_ioctl()
1012 pcbit_l2_write(dev, MSG_API_ON, 0x0001, NULL, 0); in pcbit_ioctl()
1015 dev->l2_state = L2_DOWN; in pcbit_ioctl()
1016 writeb(0x40, dev->sh_mem + BANK4); in pcbit_ioctl()
1017 dev->rcv_seq = 0; in pcbit_ioctl()
1018 dev->send_seq = 0; in pcbit_ioctl()
1019 dev->unack_seq = 0; in pcbit_ioctl()
1035 static void pcbit_clear_msn(struct pcbit_dev *dev) in pcbit_clear_msn() argument
1039 for (ptr=dev->msn_list; ptr; ) in pcbit_clear_msn()
1046 dev->msn_list = NULL; in pcbit_clear_msn()
1049 static void pcbit_set_msn(struct pcbit_dev *dev, char *list) in pcbit_set_msn() argument
1065 ptr->next = dev->msn_list; in pcbit_set_msn()
1066 dev->msn_list = ptr; in pcbit_set_msn()
1071 if (dev->msn_list) in pcbit_set_msn()
1072 for (back=dev->msn_list; back->next; back=back->next); in pcbit_set_msn()
1103 if (dev->msn_list == NULL) in pcbit_set_msn()
1104 dev->msn_list = ptr; in pcbit_set_msn()
1115 static int pcbit_check_msn(struct pcbit_dev *dev, char *msn) in pcbit_check_msn() argument
1119 for (ptr=dev->msn_list; ptr; ptr=ptr->next) { in pcbit_check_msn()