2 * CAN driver for PEAK System PCAN-USB adapter
3 * Derived from the PCAN project file driver/src/pcan_usb.c
5 * Copyright (C) 2003-2010 PEAK System-Technik GmbH
6 * Copyright (C) 2011-2012 Stephane Grosjean <s.grosjean@peak-system.com>
8 * Many thanks to Klaus Hitschler <klaus.hitschler@gmx.de>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published
12 * by the Free Software Foundation; version 2 of the License.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 #include <linux/netdevice.h>
20 #include <linux/usb.h>
21 #include <linux/module.h>
23 #include <linux/can.h>
24 #include <linux/can/dev.h>
25 #include <linux/can/error.h>
27 #include "pcan_usb_core.h"
29 MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB adapter");
31 /* PCAN-USB Endpoints */
32 #define PCAN_USB_EP_CMDOUT 1
33 #define PCAN_USB_EP_CMDIN (PCAN_USB_EP_CMDOUT | USB_DIR_IN)
34 #define PCAN_USB_EP_MSGOUT 2
35 #define PCAN_USB_EP_MSGIN (PCAN_USB_EP_MSGOUT | USB_DIR_IN)
37 /* PCAN-USB command struct */
38 #define PCAN_USB_CMD_FUNC 0
39 #define PCAN_USB_CMD_NUM 1
40 #define PCAN_USB_CMD_ARGS 2
41 #define PCAN_USB_CMD_ARGS_LEN 14
42 #define PCAN_USB_CMD_LEN (PCAN_USB_CMD_ARGS + \
43 PCAN_USB_CMD_ARGS_LEN)
45 /* PCAN-USB command timeout (ms.) */
46 #define PCAN_USB_COMMAND_TIMEOUT 1000
48 /* PCAN-USB startup timeout (ms.) */
49 #define PCAN_USB_STARTUP_TIMEOUT 10
51 /* PCAN-USB rx/tx buffers size */
52 #define PCAN_USB_RX_BUFFER_SIZE 64
53 #define PCAN_USB_TX_BUFFER_SIZE 64
55 #define PCAN_USB_MSG_HEADER_LEN 2
57 /* PCAN-USB adapter internal clock (MHz) */
58 #define PCAN_USB_CRYSTAL_HZ 16000000
60 /* PCAN-USB USB message record status/len field */
61 #define PCAN_USB_STATUSLEN_TIMESTAMP (1 << 7)
62 #define PCAN_USB_STATUSLEN_INTERNAL (1 << 6)
63 #define PCAN_USB_STATUSLEN_EXT_ID (1 << 5)
64 #define PCAN_USB_STATUSLEN_RTR (1 << 4)
65 #define PCAN_USB_STATUSLEN_DLC (0xf)
67 /* PCAN-USB error flags */
68 #define PCAN_USB_ERROR_TXFULL 0x01
69 #define PCAN_USB_ERROR_RXQOVR 0x02
70 #define PCAN_USB_ERROR_BUS_LIGHT 0x04
71 #define PCAN_USB_ERROR_BUS_HEAVY 0x08
72 #define PCAN_USB_ERROR_BUS_OFF 0x10
73 #define PCAN_USB_ERROR_RXQEMPTY 0x20
74 #define PCAN_USB_ERROR_QOVR 0x40
75 #define PCAN_USB_ERROR_TXQFULL 0x80
78 #define SJA1000_MODE_NORMAL 0x00
79 #define SJA1000_MODE_INIT 0x01
82 * tick duration = 42.666 us =>
83 * (tick_number * 44739243) >> 20 ~ (tick_number * 42666) / 1000
86 #define PCAN_USB_TS_DIV_SHIFTER 20
87 #define PCAN_USB_TS_US_PER_TICK 44739243
89 /* PCAN-USB messages record types */
90 #define PCAN_USB_REC_ERROR 1
91 #define PCAN_USB_REC_ANALOG 2
92 #define PCAN_USB_REC_BUSLOAD 3
93 #define PCAN_USB_REC_TS 4
94 #define PCAN_USB_REC_BUSEVT 5
96 /* private to PCAN-USB adapter */
98 struct peak_usb_device dev;
99 struct peak_time_ref time_ref;
100 struct timer_list restart_timer;
103 /* incoming message context for decoding */
104 struct pcan_usb_msg_context {
112 struct net_device *netdev;
113 struct pcan_usb *pdev;
119 static int pcan_usb_send_cmd(struct peak_usb_device *dev, u8 f, u8 n, u8 *p)
124 /* usb device unregistered? */
125 if (!(dev->state & PCAN_USB_STATE_CONNECTED))
128 dev->cmd_buf[PCAN_USB_CMD_FUNC] = f;
129 dev->cmd_buf[PCAN_USB_CMD_NUM] = n;
132 memcpy(dev->cmd_buf + PCAN_USB_CMD_ARGS,
133 p, PCAN_USB_CMD_ARGS_LEN);
135 err = usb_bulk_msg(dev->udev,
136 usb_sndbulkpipe(dev->udev, PCAN_USB_EP_CMDOUT),
137 dev->cmd_buf, PCAN_USB_CMD_LEN, &actual_length,
138 PCAN_USB_COMMAND_TIMEOUT);
140 netdev_err(dev->netdev,
141 "sending cmd f=0x%x n=0x%x failure: %d\n",
147 * send a command then wait for its response
149 static int pcan_usb_wait_rsp(struct peak_usb_device *dev, u8 f, u8 n, u8 *p)
154 /* usb device unregistered? */
155 if (!(dev->state & PCAN_USB_STATE_CONNECTED))
158 /* first, send command */
159 err = pcan_usb_send_cmd(dev, f, n, NULL);
163 err = usb_bulk_msg(dev->udev,
164 usb_rcvbulkpipe(dev->udev, PCAN_USB_EP_CMDIN),
165 dev->cmd_buf, PCAN_USB_CMD_LEN, &actual_length,
166 PCAN_USB_COMMAND_TIMEOUT);
168 netdev_err(dev->netdev,
169 "waiting rsp f=0x%x n=0x%x failure: %d\n", f, n, err);
171 memcpy(p, dev->cmd_buf + PCAN_USB_CMD_ARGS,
172 PCAN_USB_CMD_ARGS_LEN);
177 static int pcan_usb_set_sja1000(struct peak_usb_device *dev, u8 mode)
179 u8 args[PCAN_USB_CMD_ARGS_LEN] = {
183 return pcan_usb_send_cmd(dev, 9, 2, args);
186 static int pcan_usb_set_bus(struct peak_usb_device *dev, u8 onoff)
188 u8 args[PCAN_USB_CMD_ARGS_LEN] = {
192 return pcan_usb_send_cmd(dev, 3, 2, args);
195 static int pcan_usb_set_silent(struct peak_usb_device *dev, u8 onoff)
197 u8 args[PCAN_USB_CMD_ARGS_LEN] = {
201 return pcan_usb_send_cmd(dev, 3, 3, args);
204 static int pcan_usb_set_ext_vcc(struct peak_usb_device *dev, u8 onoff)
206 u8 args[PCAN_USB_CMD_ARGS_LEN] = {
210 return pcan_usb_send_cmd(dev, 10, 2, args);
214 * set bittiming value to can
216 static int pcan_usb_set_bittiming(struct peak_usb_device *dev,
217 struct can_bittiming *bt)
219 u8 args[PCAN_USB_CMD_ARGS_LEN];
222 btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6);
223 btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) |
224 (((bt->phase_seg2 - 1) & 0x7) << 4);
225 if (dev->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
228 netdev_info(dev->netdev, "setting BTR0=0x%02x BTR1=0x%02x\n",
234 return pcan_usb_send_cmd(dev, 1, 2, args);
240 static int pcan_usb_write_mode(struct peak_usb_device *dev, u8 onoff)
244 err = pcan_usb_set_bus(dev, onoff);
249 err = pcan_usb_set_sja1000(dev, SJA1000_MODE_INIT);
251 /* the PCAN-USB needs time to init */
252 set_current_state(TASK_INTERRUPTIBLE);
253 schedule_timeout(msecs_to_jiffies(PCAN_USB_STARTUP_TIMEOUT));
260 * handle end of waiting for the device to reset
262 static void pcan_usb_restart(unsigned long arg)
264 /* notify candev and netdev */
265 peak_usb_restart_complete((struct peak_usb_device *)arg);
269 * handle the submission of the restart urb
271 static void pcan_usb_restart_pending(struct urb *urb)
273 struct pcan_usb *pdev = urb->context;
275 /* the PCAN-USB needs time to restart */
276 mod_timer(&pdev->restart_timer,
277 jiffies + msecs_to_jiffies(PCAN_USB_STARTUP_TIMEOUT));
279 /* can delete usb resources */
280 peak_usb_async_complete(urb);
284 * handle asynchronous restart
286 static int pcan_usb_restart_async(struct peak_usb_device *dev, struct urb *urb,
289 struct pcan_usb *pdev = container_of(dev, struct pcan_usb, dev);
291 if (timer_pending(&pdev->restart_timer))
295 buf[PCAN_USB_CMD_FUNC] = 3;
296 buf[PCAN_USB_CMD_NUM] = 2;
297 buf[PCAN_USB_CMD_ARGS] = 1;
299 usb_fill_bulk_urb(urb, dev->udev,
300 usb_sndbulkpipe(dev->udev, PCAN_USB_EP_CMDOUT),
301 buf, PCAN_USB_CMD_LEN,
302 pcan_usb_restart_pending, pdev);
304 return usb_submit_urb(urb, GFP_ATOMIC);
308 * read serial number from device
310 static int pcan_usb_get_serial(struct peak_usb_device *dev, u32 *serial_number)
312 u8 args[PCAN_USB_CMD_ARGS_LEN];
315 err = pcan_usb_wait_rsp(dev, 6, 1, args);
317 netdev_err(dev->netdev, "getting serial failure: %d\n", err);
318 } else if (serial_number) {
321 memcpy(&tmp32, args, 4);
322 *serial_number = le32_to_cpu(tmp32);
329 * read device id from device
331 static int pcan_usb_get_device_id(struct peak_usb_device *dev, u32 *device_id)
333 u8 args[PCAN_USB_CMD_ARGS_LEN];
336 err = pcan_usb_wait_rsp(dev, 4, 1, args);
338 netdev_err(dev->netdev, "getting device id failure: %d\n", err);
340 *device_id = args[0];
346 * update current time ref with received timestamp
348 static int pcan_usb_update_ts(struct pcan_usb_msg_context *mc)
352 if ((mc->ptr+2) > mc->end)
355 memcpy(&tmp16, mc->ptr, 2);
357 mc->ts16 = le16_to_cpu(tmp16);
360 peak_usb_update_ts_now(&mc->pdev->time_ref, mc->ts16);
362 peak_usb_set_ts_now(&mc->pdev->time_ref, mc->ts16);
368 * decode received timestamp
370 static int pcan_usb_decode_ts(struct pcan_usb_msg_context *mc, u8 first_packet)
372 /* only 1st packet supplies a word timestamp */
376 if ((mc->ptr + 2) > mc->end)
379 memcpy(&tmp16, mc->ptr, 2);
382 mc->ts16 = le16_to_cpu(tmp16);
383 mc->prev_ts8 = mc->ts16 & 0x00ff;
387 if ((mc->ptr + 1) > mc->end)
392 if (ts8 < mc->prev_ts8)
403 static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
407 struct can_frame *cf;
409 enum can_state new_state;
411 /* ignore this error until 1st ts received */
412 if (n == PCAN_USB_ERROR_QOVR)
413 if (!mc->pdev->time_ref.tick_count)
416 new_state = mc->pdev->dev.can.state;
418 switch (mc->pdev->dev.can.state) {
419 case CAN_STATE_ERROR_ACTIVE:
420 if (n & PCAN_USB_ERROR_BUS_LIGHT) {
421 new_state = CAN_STATE_ERROR_WARNING;
425 case CAN_STATE_ERROR_WARNING:
426 if (n & PCAN_USB_ERROR_BUS_HEAVY) {
427 new_state = CAN_STATE_ERROR_PASSIVE;
430 if (n & PCAN_USB_ERROR_BUS_OFF) {
431 new_state = CAN_STATE_BUS_OFF;
434 if (n & (PCAN_USB_ERROR_RXQOVR | PCAN_USB_ERROR_QOVR)) {
436 * trick to bypass next comparison and process other
439 new_state = CAN_STATE_MAX;
442 if ((n & PCAN_USB_ERROR_BUS_LIGHT) == 0) {
443 /* no error (back to active state) */
444 new_state = CAN_STATE_ERROR_ACTIVE;
449 case CAN_STATE_ERROR_PASSIVE:
450 if (n & PCAN_USB_ERROR_BUS_OFF) {
451 new_state = CAN_STATE_BUS_OFF;
454 if (n & PCAN_USB_ERROR_BUS_LIGHT) {
455 new_state = CAN_STATE_ERROR_WARNING;
458 if (n & (PCAN_USB_ERROR_RXQOVR | PCAN_USB_ERROR_QOVR)) {
460 * trick to bypass next comparison and process other
463 new_state = CAN_STATE_MAX;
467 if ((n & PCAN_USB_ERROR_BUS_HEAVY) == 0) {
468 /* no error (back to warning state) */
469 new_state = CAN_STATE_ERROR_WARNING;
475 /* do nothing waiting for restart */
479 /* donot post any error if current state didn't change */
480 if (mc->pdev->dev.can.state == new_state)
483 /* allocate an skb to store the error frame */
484 skb = alloc_can_err_skb(mc->netdev, &cf);
489 case CAN_STATE_BUS_OFF:
490 cf->can_id |= CAN_ERR_BUSOFF;
491 mc->pdev->dev.can.can_stats.bus_off++;
492 can_bus_off(mc->netdev);
495 case CAN_STATE_ERROR_PASSIVE:
496 cf->can_id |= CAN_ERR_CRTL;
497 cf->data[1] |= CAN_ERR_CRTL_TX_PASSIVE |
498 CAN_ERR_CRTL_RX_PASSIVE;
499 mc->pdev->dev.can.can_stats.error_passive++;
502 case CAN_STATE_ERROR_WARNING:
503 cf->can_id |= CAN_ERR_CRTL;
504 cf->data[1] |= CAN_ERR_CRTL_TX_WARNING |
505 CAN_ERR_CRTL_RX_WARNING;
506 mc->pdev->dev.can.can_stats.error_warning++;
509 case CAN_STATE_ERROR_ACTIVE:
510 cf->can_id |= CAN_ERR_CRTL;
511 cf->data[1] = CAN_ERR_CRTL_ACTIVE;
515 /* CAN_STATE_MAX (trick to handle other errors) */
516 cf->can_id |= CAN_ERR_CRTL;
517 cf->data[1] |= CAN_ERR_CRTL_RX_OVERFLOW;
518 mc->netdev->stats.rx_over_errors++;
519 mc->netdev->stats.rx_errors++;
521 new_state = mc->pdev->dev.can.state;
525 mc->pdev->dev.can.state = new_state;
527 if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) {
528 struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb);
530 peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
531 hwts->hwtstamp = timeval_to_ktime(tv);
534 mc->netdev->stats.rx_packets++;
535 mc->netdev->stats.rx_bytes += cf->can_dlc;
542 * decode non-data usb message
544 static int pcan_usb_decode_status(struct pcan_usb_msg_context *mc,
547 u8 rec_len = status_len & PCAN_USB_STATUSLEN_DLC;
551 /* check whether function and number can be read */
552 if ((mc->ptr + 2) > mc->end)
555 f = mc->ptr[PCAN_USB_CMD_FUNC];
556 n = mc->ptr[PCAN_USB_CMD_NUM];
557 mc->ptr += PCAN_USB_CMD_ARGS;
559 if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) {
560 int err = pcan_usb_decode_ts(mc, !mc->rec_ts_idx);
565 /* Next packet in the buffer will have a timestamp on a single
572 case PCAN_USB_REC_ERROR:
573 err = pcan_usb_decode_error(mc, n, status_len);
578 case PCAN_USB_REC_ANALOG:
579 /* analog values (ignored) */
583 case PCAN_USB_REC_BUSLOAD:
584 /* bus load (ignored) */
588 case PCAN_USB_REC_TS:
590 if (pcan_usb_update_ts(mc))
594 case PCAN_USB_REC_BUSEVT:
595 /* error frame/bus event */
596 if (n & PCAN_USB_ERROR_TXQFULL)
597 netdev_dbg(mc->netdev, "device Tx queue full)\n");
600 netdev_err(mc->netdev, "unexpected function %u\n", f);
604 if ((mc->ptr + rec_len) > mc->end)
613 * decode data usb message
615 static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
617 u8 rec_len = status_len & PCAN_USB_STATUSLEN_DLC;
619 struct can_frame *cf;
621 struct skb_shared_hwtstamps *hwts;
623 skb = alloc_can_skb(mc->netdev, &cf);
627 if (status_len & PCAN_USB_STATUSLEN_EXT_ID) {
630 if ((mc->ptr + 4) > mc->end)
633 memcpy(&tmp32, mc->ptr, 4);
636 cf->can_id = (le32_to_cpu(tmp32) >> 3) | CAN_EFF_FLAG;
640 if ((mc->ptr + 2) > mc->end)
643 memcpy(&tmp16, mc->ptr, 2);
646 cf->can_id = le16_to_cpu(tmp16) >> 5;
649 cf->can_dlc = get_can_dlc(rec_len);
651 /* Only first packet timestamp is a word */
652 if (pcan_usb_decode_ts(mc, !mc->rec_ts_idx))
655 /* Next packet in the buffer will have a timestamp on a single byte */
659 memset(cf->data, 0x0, sizeof(cf->data));
660 if (status_len & PCAN_USB_STATUSLEN_RTR) {
661 cf->can_id |= CAN_RTR_FLAG;
663 if ((mc->ptr + rec_len) > mc->end)
666 memcpy(cf->data, mc->ptr, cf->can_dlc);
670 /* convert timestamp into kernel time */
671 peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
672 hwts = skb_hwtstamps(skb);
673 hwts->hwtstamp = timeval_to_ktime(tv);
675 /* update statistics */
676 mc->netdev->stats.rx_packets++;
677 mc->netdev->stats.rx_bytes += cf->can_dlc;
689 * process incoming message
691 static int pcan_usb_decode_msg(struct peak_usb_device *dev, u8 *ibuf, u32 lbuf)
693 struct pcan_usb_msg_context mc = {
695 .ptr = ibuf + PCAN_USB_MSG_HEADER_LEN,
697 .netdev = dev->netdev,
698 .pdev = container_of(dev, struct pcan_usb, dev),
702 for (err = 0; mc.rec_idx < mc.rec_cnt && !err; mc.rec_idx++) {
705 /* handle status and error frames here */
706 if (sl & PCAN_USB_STATUSLEN_INTERNAL) {
707 err = pcan_usb_decode_status(&mc, sl);
708 /* handle normal can frames here */
710 err = pcan_usb_decode_data(&mc, sl);
718 * process any incoming buffer
720 static int pcan_usb_decode_buf(struct peak_usb_device *dev, struct urb *urb)
724 if (urb->actual_length > PCAN_USB_MSG_HEADER_LEN) {
725 err = pcan_usb_decode_msg(dev, urb->transfer_buffer,
728 } else if (urb->actual_length > 0) {
729 netdev_err(dev->netdev, "usb message length error (%u)\n",
738 * process outgoing packet
740 static int pcan_usb_encode_msg(struct peak_usb_device *dev, struct sk_buff *skb,
741 u8 *obuf, size_t *size)
743 struct net_device *netdev = dev->netdev;
744 struct net_device_stats *stats = &netdev->stats;
745 struct can_frame *cf = (struct can_frame *)skb->data;
751 pc = obuf + PCAN_USB_MSG_HEADER_LEN;
753 /* status/len byte */
755 if (cf->can_id & CAN_RTR_FLAG)
756 *pc |= PCAN_USB_STATUSLEN_RTR;
759 if (cf->can_id & CAN_EFF_FLAG) {
760 __le32 tmp32 = cpu_to_le32((cf->can_id & CAN_ERR_MASK) << 3);
762 *pc |= PCAN_USB_STATUSLEN_EXT_ID;
763 memcpy(++pc, &tmp32, 4);
766 __le16 tmp16 = cpu_to_le16((cf->can_id & CAN_ERR_MASK) << 5);
768 memcpy(++pc, &tmp16, 2);
773 if (!(cf->can_id & CAN_RTR_FLAG)) {
774 memcpy(pc, cf->data, cf->can_dlc);
778 obuf[(*size)-1] = (u8)(stats->tx_packets & 0xff);
786 static int pcan_usb_start(struct peak_usb_device *dev)
788 struct pcan_usb *pdev = container_of(dev, struct pcan_usb, dev);
790 /* number of bits used in timestamps read from adapter struct */
791 peak_usb_init_time_ref(&pdev->time_ref, &pcan_usb);
793 /* if revision greater than 3, can put silent mode on/off */
794 if (dev->device_rev > 3) {
797 err = pcan_usb_set_silent(dev,
798 dev->can.ctrlmode & CAN_CTRLMODE_LISTENONLY);
803 return pcan_usb_set_ext_vcc(dev, 0);
806 static int pcan_usb_init(struct peak_usb_device *dev)
808 struct pcan_usb *pdev = container_of(dev, struct pcan_usb, dev);
812 /* initialize a timer needed to wait for hardware restart */
813 init_timer(&pdev->restart_timer);
814 pdev->restart_timer.function = pcan_usb_restart;
815 pdev->restart_timer.data = (unsigned long)dev;
818 * explicit use of dev_xxx() instead of netdev_xxx() here:
819 * information displayed are related to the device itself, not
820 * to the canx netdevice.
822 err = pcan_usb_get_serial(dev, &serial_number);
824 dev_err(dev->netdev->dev.parent,
825 "unable to read %s serial number (err %d)\n",
830 dev_info(dev->netdev->dev.parent,
831 "PEAK-System %s adapter hwrev %u serial %08X (%u channel)\n",
832 pcan_usb.name, dev->device_rev, serial_number,
833 pcan_usb.ctrl_count);
839 * probe function for new PCAN-USB usb interface
841 static int pcan_usb_probe(struct usb_interface *intf)
843 struct usb_host_interface *if_desc;
846 if_desc = intf->altsetting;
848 /* check interface endpoint addresses */
849 for (i = 0; i < if_desc->desc.bNumEndpoints; i++) {
850 struct usb_endpoint_descriptor *ep = &if_desc->endpoint[i].desc;
852 switch (ep->bEndpointAddress) {
853 case PCAN_USB_EP_CMDOUT:
854 case PCAN_USB_EP_CMDIN:
855 case PCAN_USB_EP_MSGOUT:
856 case PCAN_USB_EP_MSGIN:
867 * describe the PCAN-USB adapter
869 static const struct can_bittiming_const pcan_usb_const = {
881 const struct peak_usb_adapter pcan_usb = {
883 .device_id = PCAN_USB_PRODUCT_ID,
885 .ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY,
887 .freq = PCAN_USB_CRYSTAL_HZ / 2 ,
889 .bittiming_const = &pcan_usb_const,
891 /* size of device private data */
892 .sizeof_dev_private = sizeof(struct pcan_usb),
894 /* timestamps usage */
896 .ts_period = 24575, /* calibration period in ts. */
897 .us_per_ts_scale = PCAN_USB_TS_US_PER_TICK, /* us=(ts*scale) */
898 .us_per_ts_shift = PCAN_USB_TS_DIV_SHIFTER, /* >> shift */
900 /* give here messages in/out endpoints */
901 .ep_msg_in = PCAN_USB_EP_MSGIN,
902 .ep_msg_out = {PCAN_USB_EP_MSGOUT},
904 /* size of rx/tx usb buffers */
905 .rx_buffer_size = PCAN_USB_RX_BUFFER_SIZE,
906 .tx_buffer_size = PCAN_USB_TX_BUFFER_SIZE,
908 /* device callbacks */
909 .intf_probe = pcan_usb_probe,
910 .dev_init = pcan_usb_init,
911 .dev_set_bus = pcan_usb_write_mode,
912 .dev_set_bittiming = pcan_usb_set_bittiming,
913 .dev_get_device_id = pcan_usb_get_device_id,
914 .dev_decode_buf = pcan_usb_decode_buf,
915 .dev_encode_msg = pcan_usb_encode_msg,
916 .dev_start = pcan_usb_start,
917 .dev_restart_async = pcan_usb_restart_async,