Skip to content

Commit f00b534

Browse files
Stephane Grosjeanmarckleinebudde
authored andcommitted
can: peak: Add support for PCAN-USB X6 USB interface
This adds support for PEAK-System PCAN-USB X6 USB to CAN interface. The CAN FD adapter PCAN-USB X6 allows the connection of up to 6 CAN FD or CAN networks to a computer via USB. The interface is installed in an aluminum profile casing and is shipped in versions with D-Sub connectors or M12 circular connectors. The PCAN-USB X6 registers in the USB sub-system as if 3x PCAN-USB-Pro FD adapters were plugged. So, this patch: - updates the PEAK_USB entry of the corresponding Kconfig file - defines and adds the device id. of the PCAN-USB X6 (0x0014) into the table of supported device ids - defines and adds the new software structure implementing the PCAN-USB X6, which is obviously a clone of the software structure implementing the PCAN-USB Pro FD. Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com> Tested-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent fe5b406 commit f00b534

3 files changed

Lines changed: 76 additions & 0 deletions

File tree

drivers/net/can/usb/peak_usb/pcan_usb_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static struct usb_device_id peak_usb_table[] = {
3939
{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)},
4040
{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)},
4141
{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)},
42+
{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBX6_PRODUCT_ID)},
4243
{} /* Terminating entry */
4344
};
4445

@@ -50,6 +51,7 @@ static const struct peak_usb_adapter *const peak_usb_adapters_list[] = {
5051
&pcan_usb_pro,
5152
&pcan_usb_fd,
5253
&pcan_usb_pro_fd,
54+
&pcan_usb_x6,
5355
};
5456

5557
/*

drivers/net/can/usb/peak_usb/pcan_usb_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define PCAN_USBPRO_PRODUCT_ID 0x000d
2828
#define PCAN_USBPROFD_PRODUCT_ID 0x0011
2929
#define PCAN_USBFD_PRODUCT_ID 0x0012
30+
#define PCAN_USBX6_PRODUCT_ID 0x0014
3031

3132
#define PCAN_USB_DRIVER_NAME "peak_usb"
3233

@@ -90,6 +91,7 @@ extern const struct peak_usb_adapter pcan_usb;
9091
extern const struct peak_usb_adapter pcan_usb_pro;
9192
extern const struct peak_usb_adapter pcan_usb_fd;
9293
extern const struct peak_usb_adapter pcan_usb_pro_fd;
94+
extern const struct peak_usb_adapter pcan_usb_x6;
9395

9496
struct peak_time_ref {
9597
struct timeval tv_host_0, tv_host;

drivers/net/can/usb/peak_usb/pcan_usb_fd.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,3 +1132,75 @@ const struct peak_usb_adapter pcan_usb_pro_fd = {
11321132

11331133
.do_get_berr_counter = pcan_usb_fd_get_berr_counter,
11341134
};
1135+
1136+
/* describes the PCAN-USB X6 adapter */
1137+
static const struct can_bittiming_const pcan_usb_x6_const = {
1138+
.name = "pcan_usb_x6",
1139+
.tseg1_min = 1,
1140+
.tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
1141+
.tseg2_min = 1,
1142+
.tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
1143+
.sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
1144+
.brp_min = 1,
1145+
.brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
1146+
.brp_inc = 1,
1147+
};
1148+
1149+
static const struct can_bittiming_const pcan_usb_x6_data_const = {
1150+
.name = "pcan_usb_x6",
1151+
.tseg1_min = 1,
1152+
.tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
1153+
.tseg2_min = 1,
1154+
.tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
1155+
.sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
1156+
.brp_min = 1,
1157+
.brp_max = (1 << PUCAN_TFAST_BRP_BITS),
1158+
.brp_inc = 1,
1159+
};
1160+
1161+
const struct peak_usb_adapter pcan_usb_x6 = {
1162+
.name = "PCAN-USB X6",
1163+
.device_id = PCAN_USBX6_PRODUCT_ID,
1164+
.ctrl_count = PCAN_USBPROFD_CHANNEL_COUNT,
1165+
.ctrlmode_supported = CAN_CTRLMODE_FD |
1166+
CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY,
1167+
.clock = {
1168+
.freq = PCAN_UFD_CRYSTAL_HZ,
1169+
},
1170+
.bittiming_const = &pcan_usb_x6_const,
1171+
.data_bittiming_const = &pcan_usb_x6_data_const,
1172+
1173+
/* size of device private data */
1174+
.sizeof_dev_private = sizeof(struct pcan_usb_fd_device),
1175+
1176+
/* timestamps usage */
1177+
.ts_used_bits = 32,
1178+
.ts_period = 1000000, /* calibration period in ts. */
1179+
.us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
1180+
.us_per_ts_shift = 0,
1181+
1182+
/* give here messages in/out endpoints */
1183+
.ep_msg_in = PCAN_USBPRO_EP_MSGIN,
1184+
.ep_msg_out = {PCAN_USBPRO_EP_MSGOUT_0, PCAN_USBPRO_EP_MSGOUT_1},
1185+
1186+
/* size of rx/tx usb buffers */
1187+
.rx_buffer_size = PCAN_UFD_RX_BUFFER_SIZE,
1188+
.tx_buffer_size = PCAN_UFD_TX_BUFFER_SIZE,
1189+
1190+
/* device callbacks */
1191+
.intf_probe = pcan_usb_pro_probe, /* same as PCAN-USB Pro */
1192+
.dev_init = pcan_usb_fd_init,
1193+
1194+
.dev_exit = pcan_usb_fd_exit,
1195+
.dev_free = pcan_usb_fd_free,
1196+
.dev_set_bus = pcan_usb_fd_set_bus,
1197+
.dev_set_bittiming = pcan_usb_fd_set_bittiming_slow,
1198+
.dev_set_data_bittiming = pcan_usb_fd_set_bittiming_fast,
1199+
.dev_decode_buf = pcan_usb_fd_decode_buf,
1200+
.dev_start = pcan_usb_fd_start,
1201+
.dev_stop = pcan_usb_fd_stop,
1202+
.dev_restart_async = pcan_usb_fd_restart_async,
1203+
.dev_encode_msg = pcan_usb_fd_encode_msg,
1204+
1205+
.do_get_berr_counter = pcan_usb_fd_get_berr_counter,
1206+
};

0 commit comments

Comments
 (0)