• Home
  • Raw
  • Download

Lines Matching refs:mcs

133 static int mcs_set_reg(struct mcs_cb *mcs, __u16 reg, __u16 val)  in mcs_set_reg()  argument
135 struct usb_device *dev = mcs->usbdev; in mcs_set_reg()
142 static int mcs_get_reg(struct mcs_cb *mcs, __u16 reg, __u16 * val) in mcs_get_reg() argument
144 struct usb_device *dev = mcs->usbdev; in mcs_get_reg()
159 static inline int mcs_setup_transceiver_vishay(struct mcs_cb *mcs) in mcs_setup_transceiver_vishay() argument
165 ret = mcs_get_reg(mcs, MCS_XCVR_REG, &rval); in mcs_setup_transceiver_vishay()
179 ret = mcs_set_reg(mcs, MCS_XCVR_REG, rval); in mcs_setup_transceiver_vishay()
184 ret = mcs_set_reg(mcs, MCS_XCVR_REG, rval); in mcs_setup_transceiver_vishay()
189 ret = mcs_set_reg(mcs, MCS_XCVR_REG, rval); in mcs_setup_transceiver_vishay()
199 static inline int mcs_setup_transceiver_agilent(struct mcs_cb *mcs) in mcs_setup_transceiver_agilent() argument
206 static inline int mcs_setup_transceiver_sharp(struct mcs_cb *mcs) in mcs_setup_transceiver_sharp() argument
213 static inline int mcs_setup_transceiver(struct mcs_cb *mcs) in mcs_setup_transceiver() argument
224 ret = mcs_get_reg(mcs, MCS_MODE_REG, &rval); in mcs_setup_transceiver()
228 ret = mcs_set_reg(mcs, MCS_MODE_REG, rval); in mcs_setup_transceiver()
233 ret = mcs_set_reg(mcs, MCS_MINRXPW_REG, rval); in mcs_setup_transceiver()
237 ret = mcs_get_reg(mcs, MCS_MODE_REG, &rval); in mcs_setup_transceiver()
242 if(mcs->sir_tweak) in mcs_setup_transceiver()
252 mcs->speed = 9600; in mcs_setup_transceiver()
253 mcs->new_speed = 0; /* new_speed is set to 0 */ in mcs_setup_transceiver()
261 ret = mcs_set_reg(mcs, MCS_MODE_REG, rval); in mcs_setup_transceiver()
266 switch (mcs->transceiver_type) { in mcs_setup_transceiver()
268 ret = mcs_setup_transceiver_vishay(mcs); in mcs_setup_transceiver()
272 ret = mcs_setup_transceiver_sharp(mcs); in mcs_setup_transceiver()
276 ret = mcs_setup_transceiver_agilent(mcs); in mcs_setup_transceiver()
281 mcs->transceiver_type); in mcs_setup_transceiver()
290 if (mcs->transceiver_type != MCS_TSC_SHARP) { in mcs_setup_transceiver()
292 ret = mcs_get_reg(mcs, MCS_XCVR_REG, &rval); in mcs_setup_transceiver()
295 if (mcs->receive_mode) in mcs_setup_transceiver()
299 ret = mcs_set_reg(mcs, MCS_XCVR_REG, rval); in mcs_setup_transceiver()
306 ret = mcs_get_reg(mcs, MCS_MODE_REG, &rval); in mcs_setup_transceiver()
312 ret = mcs_set_reg(mcs, MCS_MODE_REG, rval); in mcs_setup_transceiver()
391 static void mcs_unwrap_mir(struct mcs_cb *mcs, __u8 *buf, int len) in mcs_unwrap_mir() argument
404 mcs->netdev->name, new_len); in mcs_unwrap_mir()
405 ++mcs->netdev->stats.rx_errors; in mcs_unwrap_mir()
406 ++mcs->netdev->stats.rx_length_errors; in mcs_unwrap_mir()
415 mcs->netdev->stats.rx_errors++; in mcs_unwrap_mir()
416 mcs->netdev->stats.rx_crc_errors++; in mcs_unwrap_mir()
422 ++mcs->netdev->stats.rx_dropped; in mcs_unwrap_mir()
431 skb->dev = mcs->netdev; in mcs_unwrap_mir()
435 mcs->netdev->stats.rx_packets++; in mcs_unwrap_mir()
436 mcs->netdev->stats.rx_bytes += new_len; in mcs_unwrap_mir()
443 static void mcs_unwrap_fir(struct mcs_cb *mcs, __u8 *buf, int len) in mcs_unwrap_fir() argument
457 mcs->netdev->name, new_len); in mcs_unwrap_fir()
458 ++mcs->netdev->stats.rx_errors; in mcs_unwrap_fir()
459 ++mcs->netdev->stats.rx_length_errors; in mcs_unwrap_fir()
466 mcs->netdev->stats.rx_errors++; in mcs_unwrap_fir()
467 mcs->netdev->stats.rx_crc_errors++; in mcs_unwrap_fir()
473 ++mcs->netdev->stats.rx_dropped; in mcs_unwrap_fir()
482 skb->dev = mcs->netdev; in mcs_unwrap_fir()
486 mcs->netdev->stats.rx_packets++; in mcs_unwrap_fir()
487 mcs->netdev->stats.rx_bytes += new_len; in mcs_unwrap_fir()
495 static inline int mcs_setup_urbs(struct mcs_cb *mcs) in mcs_setup_urbs() argument
497 mcs->rx_urb = NULL; in mcs_setup_urbs()
499 mcs->tx_urb = usb_alloc_urb(0, GFP_KERNEL); in mcs_setup_urbs()
500 if (!mcs->tx_urb) in mcs_setup_urbs()
503 mcs->rx_urb = usb_alloc_urb(0, GFP_KERNEL); in mcs_setup_urbs()
504 if (!mcs->rx_urb) in mcs_setup_urbs()
514 static inline int mcs_receive_start(struct mcs_cb *mcs) in mcs_receive_start() argument
516 mcs->rx_buff.in_frame = FALSE; in mcs_receive_start()
517 mcs->rx_buff.state = OUTSIDE_FRAME; in mcs_receive_start()
519 usb_fill_bulk_urb(mcs->rx_urb, mcs->usbdev, in mcs_receive_start()
520 usb_rcvbulkpipe(mcs->usbdev, mcs->ep_in), in mcs_receive_start()
521 mcs->in_buf, 4096, mcs_receive_irq, mcs); in mcs_receive_start()
523 mcs->rx_urb->status = 0; in mcs_receive_start()
524 return usb_submit_urb(mcs->rx_urb, GFP_KERNEL); in mcs_receive_start()
528 static inline int mcs_find_endpoints(struct mcs_cb *mcs, in mcs_find_endpoints() argument
541 mcs->ep_in = ep[i].desc.bEndpointAddress; in mcs_find_endpoints()
543 mcs->ep_out = ep[i].desc.bEndpointAddress; in mcs_find_endpoints()
548 if ((mcs->ep_in != 0) && (mcs->ep_out != 0)) { in mcs_find_endpoints()
559 struct mcs_cb *mcs = container_of(work, struct mcs_cb, work); in mcs_speed_work() local
560 struct net_device *netdev = mcs->netdev; in mcs_speed_work()
562 mcs_speed_change(mcs); in mcs_speed_work()
569 static int mcs_speed_change(struct mcs_cb *mcs) in mcs_speed_change() argument
577 nspeed = mcs_speed_set[(mcs->new_speed >> 8) & 0x0f]; in mcs_speed_change()
580 mcs_get_reg(mcs, MCS_RESV_REG, &rval); in mcs_speed_change()
589 mcs_get_reg(mcs, MCS_MODE_REG, &rval); in mcs_speed_change()
592 if (mcs->new_speed <= 115200) { in mcs_speed_change()
595 if ((rst = (mcs->speed > 115200))) in mcs_speed_change()
596 mcs_set_reg(mcs, MCS_MINRXPW_REG, 0); in mcs_speed_change()
598 } else if (mcs->new_speed <= 1152000) { in mcs_speed_change()
601 if ((rst = !(mcs->speed == 576000 || mcs->speed == 1152000))) in mcs_speed_change()
602 mcs_set_reg(mcs, MCS_MINRXPW_REG, 5); in mcs_speed_change()
607 if ((rst = (mcs->speed != 4000000))) in mcs_speed_change()
608 mcs_set_reg(mcs, MCS_MINRXPW_REG, 5); in mcs_speed_change()
615 ret = mcs_set_reg(mcs, MCS_MODE_REG, rval); in mcs_speed_change()
620 switch (mcs->transceiver_type) { in mcs_speed_change()
622 ret = mcs_setup_transceiver_vishay(mcs); in mcs_speed_change()
626 ret = mcs_setup_transceiver_sharp(mcs); in mcs_speed_change()
630 ret = mcs_setup_transceiver_agilent(mcs); in mcs_speed_change()
636 mcs->transceiver_type); in mcs_speed_change()
641 mcs_get_reg(mcs, MCS_MODE_REG, &rval); in mcs_speed_change()
643 ret = mcs_set_reg(mcs, MCS_MODE_REG, rval); in mcs_speed_change()
645 mcs->speed = mcs->new_speed; in mcs_speed_change()
647 mcs->new_speed = 0; in mcs_speed_change()
670 struct mcs_cb *mcs = netdev_priv(netdev); in mcs_net_close() local
675 kfree_skb(mcs->rx_buff.skb); in mcs_net_close()
678 usb_kill_urb(mcs->rx_urb); in mcs_net_close()
679 usb_free_urb(mcs->rx_urb); in mcs_net_close()
680 usb_kill_urb(mcs->tx_urb); in mcs_net_close()
681 usb_free_urb(mcs->tx_urb); in mcs_net_close()
684 if (mcs->irlap) in mcs_net_close()
685 irlap_close(mcs->irlap); in mcs_net_close()
687 mcs->irlap = NULL; in mcs_net_close()
694 struct mcs_cb *mcs = netdev_priv(netdev); in mcs_net_open() local
698 ret = usb_clear_halt(mcs->usbdev, in mcs_net_open()
699 usb_sndbulkpipe(mcs->usbdev, mcs->ep_in)); in mcs_net_open()
702 ret = usb_clear_halt(mcs->usbdev, in mcs_net_open()
703 usb_rcvbulkpipe(mcs->usbdev, mcs->ep_out)); in mcs_net_open()
707 ret = mcs_setup_transceiver(mcs); in mcs_net_open()
714 mcs->receiving = 0; in mcs_net_open()
715 mcs->rx_buff.truesize = IRDA_SKB_MAX_MTU; in mcs_net_open()
716 mcs->rx_buff.skb = dev_alloc_skb(IRDA_SKB_MAX_MTU); in mcs_net_open()
717 if (!mcs->rx_buff.skb) in mcs_net_open()
720 skb_reserve(mcs->rx_buff.skb, 1); in mcs_net_open()
721 mcs->rx_buff.head = mcs->rx_buff.skb->data; in mcs_net_open()
722 do_gettimeofday(&mcs->rx_time); in mcs_net_open()
729 sprintf(hwname, "usb#%d", mcs->usbdev->devnum); in mcs_net_open()
730 mcs->irlap = irlap_open(netdev, &mcs->qos, hwname); in mcs_net_open()
731 if (!mcs->irlap) { in mcs_net_open()
736 if (!mcs_setup_urbs(mcs)) in mcs_net_open()
739 ret = mcs_receive_start(mcs); in mcs_net_open()
747 irlap_close(mcs->irlap); in mcs_net_open()
749 kfree_skb(mcs->rx_buff.skb); in mcs_net_open()
758 struct mcs_cb *mcs = urb->context; in mcs_receive_irq() local
762 if (!netif_running(mcs->netdev)) in mcs_receive_irq()
775 if(mcs->speed < 576000) { in mcs_receive_irq()
776 async_unwrap_char(mcs->netdev, &mcs->netdev->stats, in mcs_receive_irq()
777 &mcs->rx_buff, 0xc0); in mcs_receive_irq()
780 async_unwrap_char(mcs->netdev, &mcs->netdev->stats, in mcs_receive_irq()
781 &mcs->rx_buff, bytes[i]); in mcs_receive_irq()
783 async_unwrap_char(mcs->netdev, &mcs->netdev->stats, in mcs_receive_irq()
784 &mcs->rx_buff, 0xc1); in mcs_receive_irq()
787 else if(mcs->speed == 576000 || mcs->speed == 1152000) { in mcs_receive_irq()
788 mcs_unwrap_mir(mcs, urb->transfer_buffer, in mcs_receive_irq()
793 mcs_unwrap_fir(mcs, urb->transfer_buffer, in mcs_receive_irq()
796 do_gettimeofday(&mcs->rx_time); in mcs_receive_irq()
805 struct mcs_cb *mcs = urb->context; in mcs_send_irq() local
806 struct net_device *ndev = mcs->netdev; in mcs_send_irq()
808 if (unlikely(mcs->new_speed)) in mcs_send_irq()
809 schedule_work(&mcs->work); in mcs_send_irq()
819 struct mcs_cb *mcs; in mcs_hard_xmit() local
824 mcs = netdev_priv(ndev); in mcs_hard_xmit()
826 spin_lock_irqsave(&mcs->lock, flags); in mcs_hard_xmit()
828 mcs->new_speed = irda_get_next_speed(skb); in mcs_hard_xmit()
829 if (likely(mcs->new_speed == mcs->speed)) in mcs_hard_xmit()
830 mcs->new_speed = 0; in mcs_hard_xmit()
833 if(mcs->speed < 576000) { in mcs_hard_xmit()
834 wraplen = mcs_wrap_sir_skb(skb, mcs->out_buf); in mcs_hard_xmit()
837 else if(mcs->speed == 576000 || mcs->speed == 1152000) { in mcs_hard_xmit()
838 wraplen = mcs_wrap_mir_skb(skb, mcs->out_buf); in mcs_hard_xmit()
842 wraplen = mcs_wrap_fir_skb(skb, mcs->out_buf); in mcs_hard_xmit()
844 usb_fill_bulk_urb(mcs->tx_urb, mcs->usbdev, in mcs_hard_xmit()
845 usb_sndbulkpipe(mcs->usbdev, mcs->ep_out), in mcs_hard_xmit()
846 mcs->out_buf, wraplen, mcs_send_irq, mcs); in mcs_hard_xmit()
848 if ((ret = usb_submit_urb(mcs->tx_urb, GFP_ATOMIC))) { in mcs_hard_xmit()
855 mcs->netdev->stats.tx_errors++; in mcs_hard_xmit()
859 mcs->netdev->stats.tx_packets++; in mcs_hard_xmit()
860 mcs->netdev->stats.tx_bytes += skb->len; in mcs_hard_xmit()
864 spin_unlock_irqrestore(&mcs->lock, flags); in mcs_hard_xmit()
884 struct mcs_cb *mcs; in mcs_probe() local
887 ndev = alloc_irdadev(sizeof(*mcs)); in mcs_probe()
901 mcs = netdev_priv(ndev); in mcs_probe()
902 mcs->usbdev = udev; in mcs_probe()
903 mcs->netdev = ndev; in mcs_probe()
904 spin_lock_init(&mcs->lock); in mcs_probe()
907 irda_init_max_qos_capabilies(&mcs->qos); in mcs_probe()
910 mcs->qos.baud_rate.bits &= in mcs_probe()
915 mcs->qos.min_turn_time.bits &= qos_mtt_bits; in mcs_probe()
916 irda_qos_bits_to_value(&mcs->qos); in mcs_probe()
919 INIT_WORK(&mcs->work, mcs_speed_work); in mcs_probe()
928 ret = mcs_find_endpoints(mcs, intf->cur_altsetting->endpoint, in mcs_probe()
942 mcs->transceiver_type = transceiver_type; in mcs_probe()
943 mcs->sir_tweak = sir_tweak; in mcs_probe()
944 mcs->receive_mode = receive_mode; in mcs_probe()
946 usb_set_intfdata(intf, mcs); in mcs_probe()
959 struct mcs_cb *mcs = usb_get_intfdata(intf); in mcs_disconnect() local
961 if (!mcs) in mcs_disconnect()
964 cancel_work_sync(&mcs->work); in mcs_disconnect()
966 unregister_netdev(mcs->netdev); in mcs_disconnect()
967 free_netdev(mcs->netdev); in mcs_disconnect()