From 6304cb4939d338fbbce05e7d98dfad44ecce9b1d Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Thu, 30 Dec 2021 14:19:29 +0100 Subject: [PATCH] gs_usb.h: introduce CAN-FD support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CANtact FD and other devices implement a gs-usb compatible USB protocol. The protocol has been extended to support CAN-FD and the changes on the Linux gs_usb driver will be mainlined soon. This patch adds the new GS_CAN_MODE_*, GS_CAN_FEATURE_* and GS_CAN_FLAG_* bits as well as struct gs_host_frame_canfd to the candlelight driver. This is mainly for documentation purpose, as the STM32F042 and STM32F072 don't support CAN-FD. But there are some ports to CAN-FD capable STM32 µC that can make use of these definitions. [1] https://github.com/linklayer/gs_usb_fd/issues/2 --- include/gs_usb.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/include/gs_usb.h b/include/gs_usb.h index 11a13702..0d36aa77 100644 --- a/include/gs_usb.h +++ b/include/gs_usb.h @@ -42,6 +42,7 @@ THE SOFTWARE. /* #define GS_CAN_FEATURE_IDENTIFY (1<<5) */ /* #define GS_CAN_FEATURE_USER_ID (1<<6) */ #define GS_CAN_MODE_PAD_PKTS_TO_MAX_PKT_SIZE (1<<7) +#define GS_CAN_MODE_FD (1<<8) #define GS_CAN_FEATURE_LISTEN_ONLY (1<<0) #define GS_CAN_FEATURE_LOOP_BACK (1<<1) @@ -50,10 +51,13 @@ THE SOFTWARE. #define GS_CAN_FEATURE_HW_TIMESTAMP (1<<4) #define GS_CAN_FEATURE_IDENTIFY (1<<5) #define GS_CAN_FEATURE_USER_ID (1<<6) - #define GS_CAN_FEATURE_PAD_PKTS_TO_MAX_PKT_SIZE (1<<7) +#define GS_CAN_FEATURE_FD (1<<8) -#define GS_CAN_FLAG_OVERFLOW 1 +#define GS_CAN_FLAG_OVERFLOW (1<<0) +#define GS_CAN_FLAG_FD (1<<1) +#define GS_CAN_FLAG_BRS (1<<2) +#define GS_CAN_FLAG_ESI (1<<3) #define CAN_EFF_FLAG 0x80000000U /* EFF/SFF is set in the MSB */ #define CAN_RTR_FLAG 0x40000000U /* remote transmission request */ @@ -229,6 +233,18 @@ struct gs_host_frame { } __packed; +struct gs_host_frame_canfd { + u32 echo_id; + u32 can_id; + + u8 can_dlc; + u8 channel; + u8 flags; + u8 reserved; + + u8 data[64]; +} __packed; + struct gs_tx_context { struct gs_can *dev; unsigned int echo_id;