| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
#ifndef __ES581_4_H__ |
| 14 |
#define __ES581_4_H__ |
| 15 |
|
| 16 |
#include <linux/types.h> |
| 17 |
|
| 18 |
#define ES581_4_NUM_CAN_CH 2 |
| 19 |
#define ES581_4_CHANNEL_IDX_OFFSET 1 |
| 20 |
|
| 21 |
#define ES581_4_TX_BULK_MAX 25 |
| 22 |
#define ES581_4_RX_BULK_MAX 30 |
| 23 |
#define ES581_4_ECHO_BULK_MAX 30 |
| 24 |
|
| 25 |
enum es581_4_cmd_type { |
| 26 |
ES581_4_CAN_COMMAND_TYPE = 0x45 |
| 27 |
}; |
| 28 |
|
| 29 |
enum es581_4_cmd_id { |
| 30 |
ES581_4_CMD_ID_OPEN_CHANNEL = 0x01, |
| 31 |
ES581_4_CMD_ID_CLOSE_CHANNEL = 0x02, |
| 32 |
ES581_4_CMD_ID_SET_BITTIMING = 0x03, |
| 33 |
ES581_4_CMD_ID_ENABLE_CHANNEL = 0x04, |
| 34 |
ES581_4_CMD_ID_TX_MSG = 0x05, |
| 35 |
ES581_4_CMD_ID_RX_MSG = 0x06, |
| 36 |
ES581_4_CMD_ID_RESET_RX = 0x0A, |
| 37 |
ES581_4_CMD_ID_RESET_TX = 0x0B, |
| 38 |
ES581_4_CMD_ID_DISABLE_CHANNEL = 0x0C, |
| 39 |
ES581_4_CMD_ID_TIMESTAMP = 0x0E, |
| 40 |
ES581_4_CMD_ID_RESET_DEVICE = 0x28, |
| 41 |
ES581_4_CMD_ID_ECHO = 0x71, |
| 42 |
ES581_4_CMD_ID_DEVICE_ERR = 0x72 |
| 43 |
}; |
| 44 |
|
| 45 |
enum es581_4_rx_type { |
| 46 |
ES581_4_RX_TYPE_MESSAGE = 1, |
| 47 |
ES581_4_RX_TYPE_ERROR = 3, |
| 48 |
ES581_4_RX_TYPE_EVENT = 4 |
| 49 |
}; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
struct es581_4_tx_conf_msg { |
| 65 |
__le32 bitrate; |
| 66 |
__le32 sample_point; |
| 67 |
__le32 samples_per_bit; |
| 68 |
__le32 bit_time; |
| 69 |
__le32 sjw; |
| 70 |
__le32 sync_edge; |
| 71 |
__le32 physical_layer; |
| 72 |
__le32 echo_mode; |
| 73 |
u8 channel_no; |
| 74 |
} __packed; |
| 75 |
|
| 76 |
struct es581_4_tx_can_msg { |
| 77 |
__le32 can_id; |
| 78 |
__le32 packet_idx; |
| 79 |
__le16 flags; |
| 80 |
u8 channel_no; |
| 81 |
u8 dlc; |
| 82 |
u8 data[CAN_MAX_DLEN]; |
| 83 |
} __packed; |
| 84 |
|
| 85 |
|
| 86 |
struct es581_4_bulk_tx_can_msg { |
| 87 |
u8 num_can_msg; |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
u8 tx_can_msg_buf[ES581_4_TX_BULK_MAX * |
| 92 |
sizeof(struct es581_4_tx_can_msg)]; |
| 93 |
} __packed; |
| 94 |
|
| 95 |
struct es581_4_echo_msg { |
| 96 |
__le64 timestamp; |
| 97 |
__le32 packet_idx; |
| 98 |
} __packed; |
| 99 |
|
| 100 |
struct es581_4_bulk_echo_msg { |
| 101 |
u8 channel_no; |
| 102 |
struct es581_4_echo_msg echo_msg[ES581_4_ECHO_BULK_MAX]; |
| 103 |
} __packed; |
| 104 |
|
| 105 |
|
| 106 |
struct es581_4_rx_can_msg { |
| 107 |
__le64 timestamp; |
| 108 |
u8 rx_type; |
| 109 |
u8 flags; |
| 110 |
u8 channel_no; |
| 111 |
u8 dlc; |
| 112 |
__le32 can_id; |
| 113 |
u8 data[CAN_MAX_DLEN]; |
| 114 |
} __packed; |
| 115 |
|
| 116 |
struct es581_4_rx_err_msg { |
| 117 |
__le64 timestamp; |
| 118 |
__le16 rx_type; |
| 119 |
__le16 flags; |
| 120 |
u8 channel_no; |
| 121 |
u8 __padding[2]; |
| 122 |
u8 dlc; |
| 123 |
__le32 tag; |
| 124 |
__le32 can_id; |
| 125 |
__le32 error; |
| 126 |
__le32 destination; |
| 127 |
} __packed; |
| 128 |
|
| 129 |
struct es581_4_rx_event_msg { |
| 130 |
__le64 timestamp; |
| 131 |
__le16 rx_type; |
| 132 |
u8 channel_no; |
| 133 |
u8 __padding; |
| 134 |
__le32 tag; |
| 135 |
__le32 event; |
| 136 |
__le32 destination; |
| 137 |
} __packed; |
| 138 |
|
| 139 |
struct es581_4_tx_ack_msg { |
| 140 |
__le16 tx_free_entries; |
| 141 |
u8 channel_no; |
| 142 |
u8 rx_cmd_ret_u8; |
| 143 |
} __packed; |
| 144 |
|
| 145 |
struct es581_4_rx_cmd_ret { |
| 146 |
__le32 rx_cmd_ret_le32; |
| 147 |
u8 channel_no; |
| 148 |
u8 __padding[3]; |
| 149 |
} __packed; |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
struct es581_4_urb_cmd { |
| 179 |
__le16 SOF; |
| 180 |
u8 cmd_type; |
| 181 |
u8 cmd_id; |
| 182 |
__le16 msg_len; |
| 183 |
|
| 184 |
union { |
| 185 |
struct es581_4_tx_conf_msg tx_conf_msg; |
| 186 |
struct es581_4_bulk_tx_can_msg bulk_tx_can_msg; |
| 187 |
struct es581_4_rx_can_msg rx_can_msg[ES581_4_RX_BULK_MAX]; |
| 188 |
struct es581_4_bulk_echo_msg bulk_echo_msg; |
| 189 |
struct es581_4_rx_err_msg rx_err_msg; |
| 190 |
struct es581_4_rx_event_msg rx_event_msg; |
| 191 |
struct es581_4_tx_ack_msg tx_ack_msg; |
| 192 |
struct es581_4_rx_cmd_ret rx_cmd_ret; |
| 193 |
__le64 timestamp; |
| 194 |
u8 rx_cmd_ret_u8; |
| 195 |
DECLARE_FLEX_ARRAY(u8, raw_msg); |
| 196 |
} __packed; |
| 197 |
|
| 198 |
__le16 reserved_for_crc16_do_not_use; |
| 199 |
} __packed; |
| 200 |
|
| 201 |
#define ES581_4_URB_CMD_HEADER_LEN (offsetof(struct es581_4_urb_cmd, raw_msg)) |
| 202 |
#define ES581_4_TX_URB_CMD_MAX_LEN \ |
| 203 |
ES58X_SIZEOF_URB_CMD(struct es581_4_urb_cmd, bulk_tx_can_msg) |
| 204 |
#define ES581_4_RX_URB_CMD_MAX_LEN \ |
| 205 |
ES58X_SIZEOF_URB_CMD(struct es581_4_urb_cmd, rx_can_msg) |
| 206 |
|
| 207 |
#endif |