linux/drivers/net/can/usb/etas_es58x/es58x_fd.h

/* SPDX-License-Identifier: GPL-2.0 */

/* Driver for ETAS GmbH ES58X USB CAN(-FD) Bus Interfaces.
 *
 * File es58x_fd.h: Definitions and declarations specific to ETAS
 * ES582.1 and ES584.1 (naming convention: we use the term "ES58X FD"
 * when referring to those two variants together).
 *
 * 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 __ES58X_FD_H__
#define __ES58X_FD_H__

#include <linux/types.h>

#define ES582_1_NUM_CAN_CH
#define ES584_1_NUM_CAN_CH
#define ES58X_FD_NUM_CAN_CH
#define ES58X_FD_CHANNEL_IDX_OFFSET

#define ES58X_FD_TX_BULK_MAX
#define ES58X_FD_RX_BULK_MAX
#define ES58X_FD_ECHO_BULK_MAX

enum es58x_fd_cmd_type {};

/* Command IDs for ES58X_FD_CMD_TYPE_{CAN,CANFD}. */
enum es58x_fd_can_cmd_id {};

/* Command IDs for ES58X_FD_CMD_TYPE_DEVICE. */
enum es58x_fd_dev_cmd_id {};

/**
 * enum es58x_fd_ctrlmode - Controller mode.
 * @ES58X_FD_CTRLMODE_ACTIVE: send and receive messages.
 * @ES58X_FD_CTRLMODE_PASSIVE: only receive messages (monitor). Do not
 *	send anything, not even the acknowledgment bit.
 * @ES58X_FD_CTRLMODE_FD: CAN FD according to ISO11898-1.
 * @ES58X_FD_CTRLMODE_FD_NON_ISO: follow Bosch CAN FD Specification
 *	V1.0
 * @ES58X_FD_CTRLMODE_DISABLE_PROTOCOL_EXCEPTION_HANDLING: How to
 *	behave when CAN FD reserved bit is monitored as
 *	dominant. (c.f. ISO 11898-1:2015, section 10.4.2.4 "Control
 *	field", paragraph "r0 bit"). 0 (not disable = enable): send
 *	error frame. 1 (disable): goes into bus integration mode
 *	(c.f. below).
 * @ES58X_FD_CTRLMODE_EDGE_FILTER_DURING_BUS_INTEGRATION: 0: Edge
 *	filtering is disabled. 1: Edge filtering is enabled. Two
 *	consecutive dominant bits required to detect an edge for hard
 *	synchronization.
 */
enum es58x_fd_ctrlmode {};

struct es58x_fd_bittiming {} __packed;

/**
 * struct es58x_fd_tx_conf_msg - Channel configuration.
 * @nominal_bittiming: Nominal bittiming.
 * @samples_per_bit: type enum es58x_samples_per_bit.
 * @sync_edge: type enum es58x_sync_edge.
 * @physical_layer: type enum es58x_physical_layer.
 * @echo_mode: type enum es58x_echo_mode.
 * @ctrlmode: type enum es58x_fd_ctrlmode.
 * @canfd_enabled: boolean (0: Classical CAN, 1: CAN and/or CANFD).
 * @data_bittiming: Bittiming for flexible data-rate transmission.
 * @tdc_enabled: Transmitter Delay Compensation switch (0: TDC is
 *	disabled, 1: TDC is enabled).
 * @tdco: Transmitter Delay Compensation Offset.
 * @tdcf: Transmitter Delay Compensation Filter window.
 *
 * Please refer to the microcontroller datasheet: "SAM E70/S70/V70/V71
 * Family" section 49 "Controller Area Network (MCAN)" for additional
 * information.
 */
struct es58x_fd_tx_conf_msg {} __packed;

#define ES58X_FD_CAN_CONF_LEN
#define ES58X_FD_CANFD_CONF_LEN

struct es58x_fd_tx_can_msg {} __packed;

#define ES58X_FD_CAN_TX_LEN
#define ES58X_FD_CANFD_TX_LEN

struct es58x_fd_rx_can_msg {} __packed;

#define ES58X_FD_CAN_RX_LEN
#define ES58X_FD_CANFD_RX_LEN

struct es58x_fd_echo_msg {} __packed;

struct es58x_fd_rx_event_msg {} __packed;

struct es58x_fd_tx_ack_msg {} __packed;

/**
 * struct es58x_fd_urb_cmd - Commands received from or sent to the
 *	ES58X FD device.
 * @SOF: Start of Frame.
 * @cmd_type: Command Type (type: enum es58x_fd_cmd_type). The CRC
 *	calculation starts at this position.
 * @cmd_id: Command ID (type: enum es58x_fd_cmd_id).
 * @channel_idx: Channel index starting at 0.
 * @msg_len: Length of the message, excluding CRC (i.e. length of the
 *	union).
 * @tx_conf_msg: Channel configuration.
 * @tx_can_msg_buf: Concatenation of Tx messages. Type is "u8[]"
 *	instead of "struct es58x_fd_tx_msg[]" because the structure
 *	has a flexible size.
 * @rx_can_msg_buf: Concatenation Rx messages. Type is "u8[]" instead
 *	of "struct es58x_fd_rx_msg[]" because the structure has a
 *	flexible size.
 * @echo_msg: Array of echo messages (e.g. Tx messages being looped
 *	back).
 * @rx_event_msg: Error or event message.
 * @tx_ack_msg: Tx acknowledgment message.
 * @timestamp: Timestamp reply.
 * @rx_cmd_ret_le32: Rx 32 bits return code (type: enum
 *	es58x_cmd_ret_code_u32).
 * @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 es58x_fd_urb_cmd {} __packed;

#define ES58X_FD_URB_CMD_HEADER_LEN
#define ES58X_FD_TX_URB_CMD_MAX_LEN
#define ES58X_FD_RX_URB_CMD_MAX_LEN

#endif /* __ES58X_FD_H__ */