diff options
author | Stephane Grosjean <s.grosjean@peak-system.com> | 2016-12-01 05:41:12 -0500 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2016-12-01 08:12:20 -0500 |
commit | f00b534ded60bd0a23c2fa8dec4ece52aa7d235f (patch) | |
tree | e551bbf1faf4fafa16e334566bf9a99c47dfee2c | |
parent | fe5b40642f1a2dddfeb84be007b2c975c28d4c6c (diff) |
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>
-rw-r--r-- | drivers/net/can/usb/peak_usb/pcan_usb_core.c | 2 | ||||
-rw-r--r-- | drivers/net/can/usb/peak_usb/pcan_usb_core.h | 2 | ||||
-rw-r--r-- | drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 72 |
3 files changed, 76 insertions, 0 deletions
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c index c06382cdfdfe..f3141ca56bc3 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c | |||
@@ -39,6 +39,7 @@ static struct usb_device_id peak_usb_table[] = { | |||
39 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)}, | 39 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)}, |
40 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)}, | 40 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)}, |
41 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)}, | 41 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)}, |
42 | {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBX6_PRODUCT_ID)}, | ||
42 | {} /* Terminating entry */ | 43 | {} /* Terminating entry */ |
43 | }; | 44 | }; |
44 | 45 | ||
@@ -50,6 +51,7 @@ static const struct peak_usb_adapter *const peak_usb_adapters_list[] = { | |||
50 | &pcan_usb_pro, | 51 | &pcan_usb_pro, |
51 | &pcan_usb_fd, | 52 | &pcan_usb_fd, |
52 | &pcan_usb_pro_fd, | 53 | &pcan_usb_pro_fd, |
54 | &pcan_usb_x6, | ||
53 | }; | 55 | }; |
54 | 56 | ||
55 | /* | 57 | /* |
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h index 506fe506c9d3..3cbfb069893d 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define PCAN_USBPRO_PRODUCT_ID 0x000d | 27 | #define PCAN_USBPRO_PRODUCT_ID 0x000d |
28 | #define PCAN_USBPROFD_PRODUCT_ID 0x0011 | 28 | #define PCAN_USBPROFD_PRODUCT_ID 0x0011 |
29 | #define PCAN_USBFD_PRODUCT_ID 0x0012 | 29 | #define PCAN_USBFD_PRODUCT_ID 0x0012 |
30 | #define PCAN_USBX6_PRODUCT_ID 0x0014 | ||
30 | 31 | ||
31 | #define PCAN_USB_DRIVER_NAME "peak_usb" | 32 | #define PCAN_USB_DRIVER_NAME "peak_usb" |
32 | 33 | ||
@@ -90,6 +91,7 @@ extern const struct peak_usb_adapter pcan_usb; | |||
90 | extern const struct peak_usb_adapter pcan_usb_pro; | 91 | extern const struct peak_usb_adapter pcan_usb_pro; |
91 | extern const struct peak_usb_adapter pcan_usb_fd; | 92 | extern const struct peak_usb_adapter pcan_usb_fd; |
92 | extern const struct peak_usb_adapter pcan_usb_pro_fd; | 93 | extern const struct peak_usb_adapter pcan_usb_pro_fd; |
94 | extern const struct peak_usb_adapter pcan_usb_x6; | ||
93 | 95 | ||
94 | struct peak_time_ref { | 96 | struct peak_time_ref { |
95 | struct timeval tv_host_0, tv_host; | 97 | struct timeval tv_host_0, tv_host; |
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c index 8a316a194cf7..304732550f0a 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c | |||
@@ -1132,3 +1132,75 @@ const struct peak_usb_adapter pcan_usb_pro_fd = { | |||
1132 | 1132 | ||
1133 | .do_get_berr_counter = pcan_usb_fd_get_berr_counter, | 1133 | .do_get_berr_counter = pcan_usb_fd_get_berr_counter, |
1134 | }; | 1134 | }; |
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 | }; | ||