/* SPDX-License-Identifier: GPL-2.0 */ /* Driver for ETAS GmbH ES58X USB CAN(-FD) Bus Interfaces. * * File es581_4.h: Definitions and declarations specific to ETAS * ES581.4. * * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved. * Copyright (c) 2020 ETAS K.K.. All rights reserved. * Copyright (c) 2020, 2021 Vincent Mailhol <[email protected]> */ #ifndef __ES581_4_H__ #define __ES581_4_H__ #include <linux/types.h> #define ES581_4_NUM_CAN_CH … #define ES581_4_CHANNEL_IDX_OFFSET … #define ES581_4_TX_BULK_MAX … #define ES581_4_RX_BULK_MAX … #define ES581_4_ECHO_BULK_MAX … enum es581_4_cmd_type { … }; enum es581_4_cmd_id { … }; enum es581_4_rx_type { … }; /** * struct es581_4_tx_conf_msg - Channel configuration. * @bitrate: Bitrate. * @sample_point: Sample point is in percent [0..100]. * @samples_per_bit: type enum es58x_samples_per_bit. * @bit_time: Number of time quanta in one bit. * @sjw: Synchronization Jump Width. * @sync_edge: type enum es58x_sync_edge. * @physical_layer: type enum es58x_physical_layer. * @echo_mode: type enum es58x_echo_mode. * @channel_no: Channel number, starting from 1. Not to be confused * with channed_idx of the ES58X FD which starts from 0. */ struct es581_4_tx_conf_msg { … } __packed; struct es581_4_tx_can_msg { … } __packed; /* The ES581.4 allows bulk transfer. */ struct es581_4_bulk_tx_can_msg { … } __packed; struct es581_4_echo_msg { … } __packed; struct es581_4_bulk_echo_msg { … } __packed; /* Normal Rx CAN Message */ struct es581_4_rx_can_msg { … } __packed; struct es581_4_rx_err_msg { … } __packed; struct es581_4_rx_event_msg { … } __packed; struct es581_4_tx_ack_msg { … } __packed; struct es581_4_rx_cmd_ret { … } __packed; /** * struct es581_4_urb_cmd - Commands received from or sent to the * ES581.4 device. * @SOF: Start of Frame. * @cmd_type: Command Type (type: enum es581_4_cmd_type). The CRC * calculation starts at this position. * @cmd_id: Command ID (type: enum es581_4_cmd_id). * @msg_len: Length of the message, excluding CRC (i.e. length of the * union). * @tx_conf_msg: Channel configuration. * @bulk_tx_can_msg: Tx messages. * @rx_can_msg: Array of Rx messages. * @bulk_echo_msg: Tx message being looped back. * @rx_err_msg: Error message. * @rx_event_msg: Event message. * @tx_ack_msg: Tx acknowledgment message. * @rx_cmd_ret: Command return code. * @timestamp: Timestamp reply. * @rx_cmd_ret_u8: Rx 8 bits return code (type: enum * es58x_cmd_ret_code_u8). * @raw_msg: Message raw payload. * @reserved_for_crc16_do_not_use: The structure ends with a * CRC16. Because the structures in above union are of variable * lengths, we can not predict the offset of the CRC in * advance. Use functions es58x_get_crc() and es58x_set_crc() to * manipulate it. */ struct es581_4_urb_cmd { … } __packed; #define ES581_4_URB_CMD_HEADER_LEN … #define ES581_4_TX_URB_CMD_MAX_LEN … #define ES581_4_RX_URB_CMD_MAX_LEN … #endif /* __ES581_4_H__ */