Skip to content

Commit

Permalink
can: etas_es58x: add support for the ETAS ES58X_FD CAN USB interfaces
Browse files Browse the repository at this point in the history
This patch add support for the ES582.1 and ES584.1 interfaces from
ETAS GmbH (https://www.etas.com/en/products/es58x.php).

Link: https://lore.kernel.org/r/20210410095948.233305-4-mailhol.vincent@wanadoo.fr
Co-developed-by: Arunachalam Santhanam <arunachalam.santhanam@in.bosch.com>
Signed-off-by: Arunachalam Santhanam <arunachalam.santhanam@in.bosch.com>
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Vincent Mailhol authored and Marc Kleine-Budde committed Apr 13, 2021
1 parent 1dfb600 commit c664e21
Show file tree
Hide file tree
Showing 5 changed files with 828 additions and 4 deletions.
2 changes: 1 addition & 1 deletion drivers/net/can/usb/etas_es58x/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_CAN_ETAS_ES58X) += etas_es58x.o
etas_es58x-y = es58x_core.o es581_4.o
etas_es58x-y = es58x_core.o es581_4.o es58x_fd.o
19 changes: 17 additions & 2 deletions drivers/net/can/usb/etas_es58x/es58x_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,28 @@ MODULE_LICENSE("GPL v2");
#define ES58X_MODULE_NAME "etas_es58x"
#define ES58X_VENDOR_ID 0x108C
#define ES581_4_PRODUCT_ID 0x0159
#define ES582_1_PRODUCT_ID 0x0168
#define ES584_1_PRODUCT_ID 0x0169

/* ES58X FD has some interface protocols unsupported by this driver. */
#define ES58X_FD_INTERFACE_PROTOCOL 0

/* Table of devices which work with this driver. */
static const struct usb_device_id es58x_id_table[] = {
{
/* ETAS GmbH ES581.4 USB dual-channel CAN Bus Interface module. */
USB_DEVICE(ES58X_VENDOR_ID, ES581_4_PRODUCT_ID),
.driver_info = ES58X_DUAL_CHANNEL
}, {
/* ETAS GmbH ES582.1 USB dual-channel CAN FD Bus Interface module. */
USB_DEVICE_INTERFACE_PROTOCOL(ES58X_VENDOR_ID, ES582_1_PRODUCT_ID,
ES58X_FD_INTERFACE_PROTOCOL),
.driver_info = ES58X_DUAL_CHANNEL | ES58X_FD_FAMILY
}, {
/* ETAS GmbH ES584.1 USB single-channel CAN FD Bus Interface module. */
USB_DEVICE_INTERFACE_PROTOCOL(ES58X_VENDOR_ID, ES584_1_PRODUCT_ID,
ES58X_FD_INTERFACE_PROTOCOL),
.driver_info = ES58X_FD_FAMILY
}, {
/* Terminating entry */
}
Expand Down Expand Up @@ -2164,8 +2179,8 @@ static int es58x_init_es58x_dev(struct usb_interface *intf,
return ret;

if (driver_info & ES58X_FD_FAMILY) {
return -ENODEV;
/* Place holder for es58x_fd glue code. */
param = &es58x_fd_param;
ops = &es58x_fd_ops;
} else {
param = &es581_4_param;
ops = &es581_4_ops;
Expand Down
6 changes: 5 additions & 1 deletion drivers/net/can/usb/etas_es58x/es58x_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
#include <linux/can/dev.h>

#include "es581_4.h"
#include "es58x_fd.h"

/* Driver constants */
#define ES58X_RX_URBS_MAX 5 /* Empirical value */
#define ES58X_TX_URBS_MAX 6 /* Empirical value */

#define ES58X_MAX(param) (ES581_4_##param)
#define ES58X_MAX(param) \
(ES581_4_##param > ES58X_FD_##param ? \
ES581_4_##param : ES58X_FD_##param)
#define ES58X_TX_BULK_MAX ES58X_MAX(TX_BULK_MAX)
#define ES58X_RX_BULK_MAX ES58X_MAX(RX_BULK_MAX)
#define ES58X_ECHO_BULK_MAX ES58X_MAX(ECHO_BULK_MAX)
Expand Down Expand Up @@ -213,6 +216,7 @@ enum es58x_ret_type {

union es58x_urb_cmd {
struct es581_4_urb_cmd es581_4_urb_cmd;
struct es58x_fd_urb_cmd es58x_fd_urb_cmd;
struct { /* Common header parts of all variants */
__le16 sof;
u8 cmd_type;
Expand Down
Loading

0 comments on commit c664e21

Please sign in to comment.