Lines Matching +full:canfd +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2013-2016 Geschwister Schneider Technologie-,
6 * Entwicklungs- und Vertriebs UG (Haftungsbeschränkt).
8 * Copyright (c) 2023 Pengutronix, Marc Kleine-Budde <kernel@pengutronix.de>
28 #include <linux/can/rx-offload.h>
46 #define GS_USB_ENDPOINT_IN 1
49 /* Timestamp 32 bit timer runs at 1 MHz (1 µs tick). Worker accounts
52 #define GS_USB_TIMESTAMP_TIMER_HZ (1 * HZ_PER_MHZ)
109 * Technologie Entwicklungs- und Vertriebs UG exchanges all data
132 #define GS_CAN_MODE_LOOP_BACK BIT(1)
174 #define GS_CAN_FEATURE_LOOP_BACK BIT(1)
189 /* internal quirks - keep in GS_CAN_FEATURE space for now */
232 #define GS_CAN_FLAG_FD BIT(1)
250 struct canfd { struct
277 DECLARE_FLEX_ARRAY(struct canfd, canfd);
334 spinlock_t tc_lock; /* spinlock to guard access tc->cycle_last */
349 spin_lock_irqsave(&dev->tx_ctx_lock, flags); in gs_alloc_tx_context()
352 if (dev->tx_context[i].echo_id == GS_MAX_TX_URBS) { in gs_alloc_tx_context()
353 dev->tx_context[i].echo_id = i; in gs_alloc_tx_context()
354 spin_unlock_irqrestore(&dev->tx_ctx_lock, flags); in gs_alloc_tx_context()
355 return &dev->tx_context[i]; in gs_alloc_tx_context()
359 spin_unlock_irqrestore(&dev->tx_ctx_lock, flags); in gs_alloc_tx_context()
367 txc->echo_id = GS_MAX_TX_URBS; in gs_free_tx_context()
378 spin_lock_irqsave(&dev->tx_ctx_lock, flags); in gs_get_tx_context()
379 if (dev->tx_context[id].echo_id == id) { in gs_get_tx_context()
380 spin_unlock_irqrestore(&dev->tx_ctx_lock, flags); in gs_get_tx_context()
381 return &dev->tx_context[id]; in gs_get_tx_context()
383 spin_unlock_irqrestore(&dev->tx_ctx_lock, flags); in gs_get_tx_context()
394 return usb_control_msg_send(dev->udev, 0, GS_USB_BREQ_MODE, in gs_cmd_reset()
396 dev->channel, 0, &dm, sizeof(dm), 1000, in gs_cmd_reset()
406 rc = usb_control_msg_recv(parent->udev, 0, GS_USB_BREQ_TIMESTAMP, in gs_usb_get_timestamp()
420 static u64 gs_usb_timestamp_read(const struct cyclecounter *cc) __must_hold(&dev->tc_lock) in gs_usb_timestamp_read()
426 lockdep_assert_held(&parent->tc_lock); in gs_usb_timestamp_read()
429 spin_unlock_bh(&parent->tc_lock); in gs_usb_timestamp_read()
431 spin_lock_bh(&parent->tc_lock); in gs_usb_timestamp_read()
433 dev_err(&parent->udev->dev, in gs_usb_timestamp_read()
446 spin_lock_bh(&parent->tc_lock); in gs_usb_timestamp_work()
447 timecounter_read(&parent->tc); in gs_usb_timestamp_work()
448 spin_unlock_bh(&parent->tc_lock); in gs_usb_timestamp_work()
450 schedule_delayed_work(&parent->timestamp, in gs_usb_timestamp_work()
458 struct gs_usb *parent = dev->parent; in gs_usb_skb_set_timestamp()
461 spin_lock_bh(&parent->tc_lock); in gs_usb_skb_set_timestamp()
462 ns = timecounter_cyc2time(&parent->tc, timestamp); in gs_usb_skb_set_timestamp()
463 spin_unlock_bh(&parent->tc_lock); in gs_usb_skb_set_timestamp()
465 hwtstamps->hwtstamp = ns_to_ktime(ns); in gs_usb_skb_set_timestamp()
470 struct cyclecounter *cc = &parent->cc; in gs_usb_timestamp_init()
472 cc->read = gs_usb_timestamp_read; in gs_usb_timestamp_init()
473 cc->mask = CYCLECOUNTER_MASK(32); in gs_usb_timestamp_init()
474 cc->shift = 32 - bits_per(NSEC_PER_SEC / GS_USB_TIMESTAMP_TIMER_HZ); in gs_usb_timestamp_init()
475 cc->mult = clocksource_hz2mult(GS_USB_TIMESTAMP_TIMER_HZ, cc->shift); in gs_usb_timestamp_init()
477 spin_lock_init(&parent->tc_lock); in gs_usb_timestamp_init()
478 spin_lock_bh(&parent->tc_lock); in gs_usb_timestamp_init()
479 timecounter_init(&parent->tc, &parent->cc, ktime_get_real_ns()); in gs_usb_timestamp_init()
480 spin_unlock_bh(&parent->tc_lock); in gs_usb_timestamp_init()
482 INIT_DELAYED_WORK(&parent->timestamp, gs_usb_timestamp_work); in gs_usb_timestamp_init()
483 schedule_delayed_work(&parent->timestamp, in gs_usb_timestamp_init()
489 cancel_delayed_work_sync(&parent->timestamp); in gs_usb_timestamp_stop()
494 struct can_device_stats *can_stats = &dev->can.can_stats; in gs_update_state()
496 if (cf->can_id & CAN_ERR_RESTARTED) { in gs_update_state()
497 dev->can.state = CAN_STATE_ERROR_ACTIVE; in gs_update_state()
498 can_stats->restarts++; in gs_update_state()
499 } else if (cf->can_id & CAN_ERR_BUSOFF) { in gs_update_state()
500 dev->can.state = CAN_STATE_BUS_OFF; in gs_update_state()
501 can_stats->bus_off++; in gs_update_state()
502 } else if (cf->can_id & CAN_ERR_CRTL) { in gs_update_state()
503 if ((cf->data[1] & CAN_ERR_CRTL_TX_WARNING) || in gs_update_state()
504 (cf->data[1] & CAN_ERR_CRTL_RX_WARNING)) { in gs_update_state()
505 dev->can.state = CAN_STATE_ERROR_WARNING; in gs_update_state()
506 can_stats->error_warning++; in gs_update_state()
507 } else if ((cf->data[1] & CAN_ERR_CRTL_TX_PASSIVE) || in gs_update_state()
508 (cf->data[1] & CAN_ERR_CRTL_RX_PASSIVE)) { in gs_update_state()
509 dev->can.state = CAN_STATE_ERROR_PASSIVE; in gs_update_state()
510 can_stats->error_passive++; in gs_update_state()
512 dev->can.state = CAN_STATE_ERROR_ACTIVE; in gs_update_state()
522 if (hf->flags & GS_CAN_FLAG_FD) in gs_usb_set_timestamp()
523 timestamp = le32_to_cpu(hf->canfd_ts->timestamp_us); in gs_usb_set_timestamp()
525 timestamp = le32_to_cpu(hf->classic_can_ts->timestamp_us); in gs_usb_set_timestamp()
536 struct can_rx_offload *offload = &dev->offload; in gs_usb_rx_offload()
539 if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) { in gs_usb_rx_offload()
548 dev->netdev->stats.rx_fifo_errors++; in gs_usb_rx_offload()
555 struct can_rx_offload *offload = &dev->offload; in gs_usb_get_echo_skb()
556 const u32 echo_id = hf->echo_id; in gs_usb_get_echo_skb()
559 if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) { in gs_usb_get_echo_skb()
574 struct gs_usb *parent = urb->context; in gs_usb_receive_bulk_callback()
579 struct gs_host_frame *hf = urb->transfer_buffer; in gs_usb_receive_bulk_callback()
587 switch (urb->status) { in gs_usb_receive_bulk_callback()
590 case -ENOENT: in gs_usb_receive_bulk_callback()
591 case -ESHUTDOWN: in gs_usb_receive_bulk_callback()
599 if (hf->channel >= GS_MAX_INTF) in gs_usb_receive_bulk_callback()
602 dev = parent->canch[hf->channel]; in gs_usb_receive_bulk_callback()
604 netdev = dev->netdev; in gs_usb_receive_bulk_callback()
605 stats = &netdev->stats; in gs_usb_receive_bulk_callback()
613 if (hf->echo_id == -1) { /* normal rx */ in gs_usb_receive_bulk_callback()
614 if (hf->flags & GS_CAN_FLAG_FD) { in gs_usb_receive_bulk_callback()
619 cfd->can_id = le32_to_cpu(hf->can_id); in gs_usb_receive_bulk_callback()
620 cfd->len = can_fd_dlc2len(hf->can_dlc); in gs_usb_receive_bulk_callback()
621 if (hf->flags & GS_CAN_FLAG_BRS) in gs_usb_receive_bulk_callback()
622 cfd->flags |= CANFD_BRS; in gs_usb_receive_bulk_callback()
623 if (hf->flags & GS_CAN_FLAG_ESI) in gs_usb_receive_bulk_callback()
624 cfd->flags |= CANFD_ESI; in gs_usb_receive_bulk_callback()
626 memcpy(cfd->data, hf->canfd->data, cfd->len); in gs_usb_receive_bulk_callback()
632 cf->can_id = le32_to_cpu(hf->can_id); in gs_usb_receive_bulk_callback()
633 can_frame_set_cc_len(cf, hf->can_dlc, dev->can.ctrlmode); in gs_usb_receive_bulk_callback()
635 memcpy(cf->data, hf->classic_can->data, 8); in gs_usb_receive_bulk_callback()
638 if (le32_to_cpu(hf->can_id) & CAN_ERR_FLAG) in gs_usb_receive_bulk_callback()
643 } else { /* echo_id == hf->echo_id */ in gs_usb_receive_bulk_callback()
644 if (hf->echo_id >= GS_MAX_TX_URBS) { in gs_usb_receive_bulk_callback()
647 hf->echo_id); in gs_usb_receive_bulk_callback()
651 txc = gs_get_tx_context(dev, hf->echo_id); in gs_usb_receive_bulk_callback()
657 hf->echo_id); in gs_usb_receive_bulk_callback()
661 skb = dev->can.echo_skb[hf->echo_id]; in gs_usb_receive_bulk_callback()
662 stats->tx_packets++; in gs_usb_receive_bulk_callback()
663 stats->tx_bytes += gs_usb_get_echo_skb(dev, skb, hf); in gs_usb_receive_bulk_callback()
666 atomic_dec(&dev->active_tx_urbs); in gs_usb_receive_bulk_callback()
671 if (hf->flags & GS_CAN_FLAG_OVERFLOW) { in gs_usb_receive_bulk_callback()
672 stats->rx_over_errors++; in gs_usb_receive_bulk_callback()
673 stats->rx_errors++; in gs_usb_receive_bulk_callback()
679 cf->can_id |= CAN_ERR_CRTL; in gs_usb_receive_bulk_callback()
680 cf->len = CAN_ERR_DLC; in gs_usb_receive_bulk_callback()
681 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; in gs_usb_receive_bulk_callback()
686 can_rx_offload_irq_finish(&dev->offload); in gs_usb_receive_bulk_callback()
689 usb_fill_bulk_urb(urb, parent->udev, in gs_usb_receive_bulk_callback()
690 usb_rcvbulkpipe(parent->udev, GS_USB_ENDPOINT_IN), in gs_usb_receive_bulk_callback()
691 hf, dev->parent->hf_size_rx, in gs_usb_receive_bulk_callback()
697 if (rc == -ENODEV) { in gs_usb_receive_bulk_callback()
700 if (parent->canch[rc]) in gs_usb_receive_bulk_callback()
701 netif_device_detach(parent->canch[rc]->netdev); in gs_usb_receive_bulk_callback()
709 struct can_bittiming *bt = &dev->can.bittiming; in gs_usb_set_bittiming()
711 .prop_seg = cpu_to_le32(bt->prop_seg), in gs_usb_set_bittiming()
712 .phase_seg1 = cpu_to_le32(bt->phase_seg1), in gs_usb_set_bittiming()
713 .phase_seg2 = cpu_to_le32(bt->phase_seg2), in gs_usb_set_bittiming()
714 .sjw = cpu_to_le32(bt->sjw), in gs_usb_set_bittiming()
715 .brp = cpu_to_le32(bt->brp), in gs_usb_set_bittiming()
719 return usb_control_msg_send(dev->udev, 0, GS_USB_BREQ_BITTIMING, in gs_usb_set_bittiming()
721 dev->channel, 0, &dbt, sizeof(dbt), 1000, in gs_usb_set_bittiming()
728 struct can_bittiming *bt = &dev->can.data_bittiming; in gs_usb_set_data_bittiming()
730 .prop_seg = cpu_to_le32(bt->prop_seg), in gs_usb_set_data_bittiming()
731 .phase_seg1 = cpu_to_le32(bt->phase_seg1), in gs_usb_set_data_bittiming()
732 .phase_seg2 = cpu_to_le32(bt->phase_seg2), in gs_usb_set_data_bittiming()
733 .sjw = cpu_to_le32(bt->sjw), in gs_usb_set_data_bittiming()
734 .brp = cpu_to_le32(bt->brp), in gs_usb_set_data_bittiming()
738 if (dev->feature & GS_CAN_FEATURE_QUIRK_BREQ_CANTACT_PRO) in gs_usb_set_data_bittiming()
742 return usb_control_msg_send(dev->udev, 0, request, in gs_usb_set_data_bittiming()
744 dev->channel, 0, &dbt, sizeof(dbt), 1000, in gs_usb_set_data_bittiming()
750 struct gs_tx_context *txc = urb->context; in gs_usb_xmit_callback()
751 struct gs_can *dev = txc->dev; in gs_usb_xmit_callback()
752 struct net_device *netdev = dev->netdev; in gs_usb_xmit_callback()
754 if (urb->status) in gs_usb_xmit_callback()
755 netdev_info(netdev, "usb xmit fail %u\n", txc->echo_id); in gs_usb_xmit_callback()
762 struct net_device_stats *stats = &dev->netdev->stats; in gs_can_start_xmit()
784 hf = kmalloc(dev->hf_size_tx, GFP_ATOMIC); in gs_can_start_xmit()
788 idx = txc->echo_id; in gs_can_start_xmit()
795 hf->echo_id = idx; in gs_can_start_xmit()
796 hf->channel = dev->channel; in gs_can_start_xmit()
797 hf->flags = 0; in gs_can_start_xmit()
798 hf->reserved = 0; in gs_can_start_xmit()
801 cfd = (struct canfd_frame *)skb->data; in gs_can_start_xmit()
803 hf->can_id = cpu_to_le32(cfd->can_id); in gs_can_start_xmit()
804 hf->can_dlc = can_fd_len2dlc(cfd->len); in gs_can_start_xmit()
805 hf->flags |= GS_CAN_FLAG_FD; in gs_can_start_xmit()
806 if (cfd->flags & CANFD_BRS) in gs_can_start_xmit()
807 hf->flags |= GS_CAN_FLAG_BRS; in gs_can_start_xmit()
808 if (cfd->flags & CANFD_ESI) in gs_can_start_xmit()
809 hf->flags |= GS_CAN_FLAG_ESI; in gs_can_start_xmit()
811 memcpy(hf->canfd->data, cfd->data, cfd->len); in gs_can_start_xmit()
813 cf = (struct can_frame *)skb->data; in gs_can_start_xmit()
815 hf->can_id = cpu_to_le32(cf->can_id); in gs_can_start_xmit()
816 hf->can_dlc = can_get_cc_dlc(cf, dev->can.ctrlmode); in gs_can_start_xmit()
818 memcpy(hf->classic_can->data, cf->data, cf->len); in gs_can_start_xmit()
821 usb_fill_bulk_urb(urb, dev->udev, in gs_can_start_xmit()
822 usb_sndbulkpipe(dev->udev, GS_USB_ENDPOINT_OUT), in gs_can_start_xmit()
823 hf, dev->hf_size_tx, in gs_can_start_xmit()
826 urb->transfer_flags |= URB_FREE_BUFFER; in gs_can_start_xmit()
827 usb_anchor_urb(urb, &dev->tx_submitted); in gs_can_start_xmit()
831 atomic_inc(&dev->active_tx_urbs); in gs_can_start_xmit()
835 atomic_dec(&dev->active_tx_urbs); in gs_can_start_xmit()
842 if (rc == -ENODEV) { in gs_can_start_xmit()
846 stats->tx_dropped++; in gs_can_start_xmit()
850 if (atomic_read(&dev->active_tx_urbs) >= GS_MAX_TX_URBS) in gs_can_start_xmit()
867 stats->tx_dropped++; in gs_can_start_xmit()
874 struct gs_usb *parent = dev->parent; in gs_can_open()
888 ctrlmode = dev->can.ctrlmode; in gs_can_open()
890 if (dev->feature & GS_CAN_FEATURE_REQ_USB_QUIRK_LPC546XX) in gs_can_open()
891 dev->hf_size_tx = struct_size(hf, canfd_quirk, 1); in gs_can_open()
893 dev->hf_size_tx = struct_size(hf, canfd, 1); in gs_can_open()
895 if (dev->feature & GS_CAN_FEATURE_REQ_USB_QUIRK_LPC546XX) in gs_can_open()
896 dev->hf_size_tx = struct_size(hf, classic_can_quirk, 1); in gs_can_open()
898 dev->hf_size_tx = struct_size(hf, classic_can, 1); in gs_can_open()
901 can_rx_offload_enable(&dev->offload); in gs_can_open()
903 if (!parent->active_channels) { in gs_can_open()
904 if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) in gs_can_open()
913 rc = -ENOMEM; in gs_can_open()
918 buf = kmalloc(dev->parent->hf_size_rx, in gs_can_open()
921 rc = -ENOMEM; in gs_can_open()
927 dev->udev, in gs_can_open()
928 usb_rcvbulkpipe(dev->udev, in gs_can_open()
931 dev->parent->hf_size_rx, in gs_can_open()
933 urb->transfer_flags |= URB_FREE_BUFFER; in gs_can_open()
935 usb_anchor_urb(urb, &parent->rx_submitted); in gs_can_open()
939 if (rc == -ENODEV) in gs_can_open()
940 netif_device_detach(dev->netdev); in gs_can_open()
976 if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) in gs_can_open()
980 dev->can.state = CAN_STATE_ERROR_ACTIVE; in gs_can_open()
982 rc = usb_control_msg_send(dev->udev, 0, GS_USB_BREQ_MODE, in gs_can_open()
984 dev->channel, 0, &dm, sizeof(dm), 1000, in gs_can_open()
988 dev->can.state = CAN_STATE_STOPPED; in gs_can_open()
993 parent->active_channels++; in gs_can_open()
994 if (!(dev->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)) in gs_can_open()
1004 if (!parent->active_channels) { in gs_can_open()
1005 usb_kill_anchored_urbs(&dev->tx_submitted); in gs_can_open()
1007 if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) in gs_can_open()
1011 can_rx_offload_disable(&dev->offload); in gs_can_open()
1025 rc = usb_control_msg_recv(dev->udev, 0, GS_USB_BREQ_GET_STATE, in gs_usb_get_state()
1027 dev->channel, 0, in gs_usb_get_state()
1035 return -EOPNOTSUPP; in gs_usb_get_state()
1038 bec->txerr = le32_to_cpu(ds.txerr); in gs_usb_get_state()
1039 bec->rxerr = le32_to_cpu(ds.rxerr); in gs_usb_get_state()
1056 struct gs_usb *parent = dev->parent; in gs_can_close()
1061 parent->active_channels--; in gs_can_close()
1062 if (!parent->active_channels) { in gs_can_close()
1063 usb_kill_anchored_urbs(&parent->rx_submitted); in gs_can_close()
1065 if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) in gs_can_close()
1070 usb_kill_anchored_urbs(&dev->tx_submitted); in gs_can_close()
1071 atomic_set(&dev->active_tx_urbs, 0); in gs_can_close()
1073 dev->can.state = CAN_STATE_STOPPED; in gs_can_close()
1080 dev->tx_context[rc].dev = dev; in gs_can_close()
1081 dev->tx_context[rc].echo_id = GS_MAX_TX_URBS; in gs_can_close()
1084 can_rx_offload_disable(&dev->offload); in gs_can_close()
1096 if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) in gs_can_eth_ioctl()
1099 return -EOPNOTSUPP; in gs_can_eth_ioctl()
1120 return usb_control_msg_send(dev->udev, 0, GS_USB_BREQ_IDENTIFY, in gs_usb_set_identify()
1122 dev->channel, 0, &imode, sizeof(imode), 100, in gs_usb_set_identify()
1133 if (!(dev->feature & GS_CAN_FEATURE_IDENTIFY)) in gs_usb_set_phys_id()
1134 return -EOPNOTSUPP; in gs_usb_set_phys_id()
1156 if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) in gs_usb_get_ts_info()
1173 rc = usb_control_msg_recv(dev->udev, 0, GS_USB_BREQ_GET_TERMINATION, in gs_usb_get_termination()
1175 dev->channel, 0, in gs_usb_get_termination()
1199 return usb_control_msg_send(dev->udev, 0, GS_USB_BREQ_SET_TERMINATION, in gs_usb_set_termination()
1201 dev->channel, 0, in gs_usb_set_termination()
1230 dev_err(&intf->dev, in gs_make_candev()
1239 dev_err(&intf->dev, "Couldn't allocate candev\n"); in gs_make_candev()
1240 return ERR_PTR(-ENOMEM); in gs_make_candev()
1245 netdev->netdev_ops = &gs_usb_netdev_ops; in gs_make_candev()
1246 netdev->ethtool_ops = &gs_usb_ethtool_ops; in gs_make_candev()
1248 netdev->flags |= IFF_ECHO; /* we support full roundtrip echo */ in gs_make_candev()
1249 netdev->dev_id = channel; in gs_make_candev()
1252 strcpy(dev->bt_const.name, KBUILD_MODNAME); in gs_make_candev()
1253 dev->bt_const.tseg1_min = le32_to_cpu(bt_const.tseg1_min); in gs_make_candev()
1254 dev->bt_const.tseg1_max = le32_to_cpu(bt_const.tseg1_max); in gs_make_candev()
1255 dev->bt_const.tseg2_min = le32_to_cpu(bt_const.tseg2_min); in gs_make_candev()
1256 dev->bt_const.tseg2_max = le32_to_cpu(bt_const.tseg2_max); in gs_make_candev()
1257 dev->bt_const.sjw_max = le32_to_cpu(bt_const.sjw_max); in gs_make_candev()
1258 dev->bt_const.brp_min = le32_to_cpu(bt_const.brp_min); in gs_make_candev()
1259 dev->bt_const.brp_max = le32_to_cpu(bt_const.brp_max); in gs_make_candev()
1260 dev->bt_const.brp_inc = le32_to_cpu(bt_const.brp_inc); in gs_make_candev()
1262 dev->udev = interface_to_usbdev(intf); in gs_make_candev()
1263 dev->netdev = netdev; in gs_make_candev()
1264 dev->channel = channel; in gs_make_candev()
1266 init_usb_anchor(&dev->tx_submitted); in gs_make_candev()
1267 atomic_set(&dev->active_tx_urbs, 0); in gs_make_candev()
1268 spin_lock_init(&dev->tx_ctx_lock); in gs_make_candev()
1270 dev->tx_context[rc].dev = dev; in gs_make_candev()
1271 dev->tx_context[rc].echo_id = GS_MAX_TX_URBS; in gs_make_candev()
1275 dev->can.state = CAN_STATE_STOPPED; in gs_make_candev()
1276 dev->can.clock.freq = le32_to_cpu(bt_const.fclk_can); in gs_make_candev()
1277 dev->can.bittiming_const = &dev->bt_const; in gs_make_candev()
1278 dev->can.do_set_bittiming = gs_usb_set_bittiming; in gs_make_candev()
1280 dev->can.ctrlmode_supported = CAN_CTRLMODE_CC_LEN8_DLC; in gs_make_candev()
1283 dev->feature = FIELD_GET(GS_CAN_FEATURE_MASK, feature); in gs_make_candev()
1285 dev->can.ctrlmode_supported |= CAN_CTRLMODE_LISTENONLY; in gs_make_candev()
1288 dev->can.ctrlmode_supported |= CAN_CTRLMODE_LOOPBACK; in gs_make_candev()
1291 dev->can.ctrlmode_supported |= CAN_CTRLMODE_3_SAMPLES; in gs_make_candev()
1294 dev->can.ctrlmode_supported |= CAN_CTRLMODE_ONE_SHOT; in gs_make_candev()
1297 dev->can.ctrlmode_supported |= CAN_CTRLMODE_FD; in gs_make_candev()
1301 dev->can.data_bittiming_const = &dev->bt_const; in gs_make_candev()
1302 dev->can.do_set_data_bittiming = gs_usb_set_data_bittiming; in gs_make_candev()
1306 rc = gs_usb_get_termination(netdev, &dev->can.termination); in gs_make_candev()
1308 dev->feature &= ~GS_CAN_FEATURE_TERMINATION; in gs_make_candev()
1310 dev_info(&intf->dev, in gs_make_candev()
1314 dev->can.termination_const = gs_usb_termination_const; in gs_make_candev()
1315 dev->can.termination_const_cnt = ARRAY_SIZE(gs_usb_termination_const); in gs_make_candev()
1316 dev->can.do_set_termination = gs_usb_set_termination; in gs_make_candev()
1321 dev->can.ctrlmode_supported |= CAN_CTRLMODE_BERR_REPORTING; in gs_make_candev()
1324 dev->can.do_get_berr_counter = gs_usb_can_get_berr_counter; in gs_make_candev()
1340 if (dev->udev->descriptor.idVendor == cpu_to_le16(USB_GS_USB_1_VENDOR_ID) && in gs_make_candev()
1341 dev->udev->descriptor.idProduct == cpu_to_le16(USB_GS_USB_1_PRODUCT_ID) && in gs_make_candev()
1342 dev->udev->manufacturer && dev->udev->product && in gs_make_candev()
1343 !strcmp(dev->udev->manufacturer, "LinkLayer Labs") && in gs_make_candev()
1344 !strcmp(dev->udev->product, "CANtact Pro") && in gs_make_candev()
1345 (le32_to_cpu(dconf->sw_version) <= 2)) in gs_make_candev()
1346 dev->feature |= GS_CAN_FEATURE_REQ_USB_QUIRK_LPC546XX | in gs_make_candev()
1349 /* GS_CAN_FEATURE_IDENTIFY is only supported for sw_version > 1 */ in gs_make_candev()
1350 if (!(le32_to_cpu(dconf->sw_version) > 1 && in gs_make_candev()
1352 dev->feature &= ~GS_CAN_FEATURE_IDENTIFY; in gs_make_candev()
1366 dev_err(&intf->dev, in gs_make_candev()
1372 strcpy(dev->data_bt_const.name, KBUILD_MODNAME); in gs_make_candev()
1373 dev->data_bt_const.tseg1_min = le32_to_cpu(bt_const_extended.dtseg1_min); in gs_make_candev()
1374 dev->data_bt_const.tseg1_max = le32_to_cpu(bt_const_extended.dtseg1_max); in gs_make_candev()
1375 dev->data_bt_const.tseg2_min = le32_to_cpu(bt_const_extended.dtseg2_min); in gs_make_candev()
1376 dev->data_bt_const.tseg2_max = le32_to_cpu(bt_const_extended.dtseg2_max); in gs_make_candev()
1377 dev->data_bt_const.sjw_max = le32_to_cpu(bt_const_extended.dsjw_max); in gs_make_candev()
1378 dev->data_bt_const.brp_min = le32_to_cpu(bt_const_extended.dbrp_min); in gs_make_candev()
1379 dev->data_bt_const.brp_max = le32_to_cpu(bt_const_extended.dbrp_max); in gs_make_candev()
1380 dev->data_bt_const.brp_inc = le32_to_cpu(bt_const_extended.dbrp_inc); in gs_make_candev()
1382 dev->can.data_bittiming_const = &dev->data_bt_const; in gs_make_candev()
1385 can_rx_offload_add_manual(netdev, &dev->offload, GS_NAPI_WEIGHT); in gs_make_candev()
1386 SET_NETDEV_DEV(netdev, &intf->dev); in gs_make_candev()
1388 rc = register_candev(dev->netdev); in gs_make_candev()
1390 dev_err(&intf->dev, in gs_make_candev()
1399 can_rx_offload_del(&dev->offload); in gs_make_candev()
1401 free_candev(dev->netdev); in gs_make_candev()
1407 unregister_candev(dev->netdev); in gs_destroy_candev()
1408 can_rx_offload_del(&dev->offload); in gs_destroy_candev()
1409 free_candev(dev->netdev); in gs_destroy_candev()
1429 1, intf->cur_altsetting->desc.bInterfaceNumber, in gs_usb_probe()
1433 dev_err(&intf->dev, "Couldn't send data format (err=%d)\n", rc); in gs_usb_probe()
1441 1, intf->cur_altsetting->desc.bInterfaceNumber, in gs_usb_probe()
1445 dev_err(&intf->dev, "Couldn't get device config: (err=%d)\n", in gs_usb_probe()
1450 icount = dconf.icount + 1; in gs_usb_probe()
1451 dev_info(&intf->dev, "Configuring for %u interfaces\n", icount); in gs_usb_probe()
1454 dev_err(&intf->dev, in gs_usb_probe()
1457 return -EINVAL; in gs_usb_probe()
1462 return -ENOMEM; in gs_usb_probe()
1464 init_usb_anchor(&parent->rx_submitted); in gs_usb_probe()
1467 parent->udev = udev; in gs_usb_probe()
1472 parent->canch[i] = gs_make_candev(i, intf, &dconf); in gs_usb_probe()
1473 if (IS_ERR_OR_NULL(parent->canch[i])) { in gs_usb_probe()
1475 rc = PTR_ERR(parent->canch[i]); in gs_usb_probe()
1480 gs_destroy_candev(parent->canch[i]); in gs_usb_probe()
1482 usb_kill_anchored_urbs(&parent->rx_submitted); in gs_usb_probe()
1486 parent->canch[i]->parent = parent; in gs_usb_probe()
1491 if (parent->canch[i]->can.ctrlmode_supported & CAN_CTRLMODE_FD) { in gs_usb_probe()
1492 if (parent->canch[i]->feature & GS_CAN_FEATURE_HW_TIMESTAMP) in gs_usb_probe()
1493 hf_size_rx = struct_size(hf, canfd_ts, 1); in gs_usb_probe()
1495 hf_size_rx = struct_size(hf, canfd, 1); in gs_usb_probe()
1497 if (parent->canch[i]->feature & GS_CAN_FEATURE_HW_TIMESTAMP) in gs_usb_probe()
1498 hf_size_rx = struct_size(hf, classic_can_ts, 1); in gs_usb_probe()
1500 hf_size_rx = struct_size(hf, classic_can, 1); in gs_usb_probe()
1502 parent->hf_size_rx = max(parent->hf_size_rx, hf_size_rx); in gs_usb_probe()
1516 dev_err(&intf->dev, "Disconnect (nodata)\n"); in gs_usb_disconnect()
1521 if (parent->canch[i]) in gs_usb_disconnect()
1522 gs_destroy_candev(parent->canch[i]); in gs_usb_disconnect()
1554 "Socket CAN device driver for Geschwister Schneider Technologie-, "
1555 "Entwicklungs- und Vertriebs UG. USB2.0 to CAN interfaces\n"