1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * ISHTP bus layer messages handling
5 * Copyright (c) 2003-2016, Intel Corporation.
11 #include <linux/uuid.h>
20 #define ISHTP_INTEROP_TIMEOUT 7 /* Timeout on ready message */
22 #define ISHTP_CL_CONNECT_TIMEOUT 15 /* HPS: Client Connect Timeout */
27 #define HBM_MINOR_VERSION 0
28 #define HBM_MAJOR_VERSION 1
30 /* Host bus message command opcode */
31 #define ISHTP_HBM_CMD_OP_MSK 0x7f
32 /* Host bus message command RESPONSE */
33 #define ISHTP_HBM_CMD_RES_MSK 0x80
36 * ISHTP Bus Message Command IDs
38 #define HOST_START_REQ_CMD 0x01
39 #define HOST_START_RES_CMD 0x81
41 #define HOST_STOP_REQ_CMD 0x02
42 #define HOST_STOP_RES_CMD 0x82
44 #define FW_STOP_REQ_CMD 0x03
46 #define HOST_ENUM_REQ_CMD 0x04
47 #define HOST_ENUM_RES_CMD 0x84
49 #define HOST_CLIENT_PROPERTIES_REQ_CMD 0x05
50 #define HOST_CLIENT_PROPERTIES_RES_CMD 0x85
52 #define CLIENT_CONNECT_REQ_CMD 0x06
53 #define CLIENT_CONNECT_RES_CMD 0x86
55 #define CLIENT_DISCONNECT_REQ_CMD 0x07
56 #define CLIENT_DISCONNECT_RES_CMD 0x87
58 #define ISHTP_FLOW_CONTROL_CMD 0x08
60 #define DMA_BUFFER_ALLOC_NOTIFY 0x11
61 #define DMA_BUFFER_ALLOC_RESPONSE 0x91
64 #define DMA_XFER_ACK 0x92
68 * used by hbm_host_stop_request.reason
70 #define DRIVER_STOP_REQUEST 0x00
73 * ISHTP BUS Interface Section
75 struct ishtp_msg_hdr {
80 uint32_t msg_complete:1;
83 struct ishtp_bus_message {
89 * struct hbm_cl_cmd - client specific host bus command
90 * CONNECT, DISCONNECT, and FlOW CONTROL
92 * @hbm_cmd - bus message command header
93 * @fw_addr - address of the fw client
94 * @host_addr - address of the client in the driver
97 struct ishtp_hbm_cl_cmd {
105 uint8_t minor_version;
106 uint8_t major_version;
109 struct hbm_host_version_request {
112 struct hbm_version host_version;
115 struct hbm_host_version_response {
117 uint8_t host_version_supported;
118 struct hbm_version fw_max_version;
121 struct hbm_host_stop_request {
127 struct hbm_host_stop_response {
132 struct hbm_host_enum_request {
137 struct hbm_host_enum_response {
140 uint8_t valid_addresses[32];
143 struct ishtp_client_properties {
144 guid_t protocol_name;
145 uint8_t protocol_version;
146 uint8_t max_number_of_connections;
147 uint8_t fixed_address;
148 uint8_t single_recv_buf;
149 uint32_t max_msg_length;
151 #define ISHTP_CLIENT_DMA_ENABLED 0x80
157 struct hbm_props_request {
163 struct hbm_props_response {
168 struct ishtp_client_properties client_properties;
172 * struct hbm_client_connect_request - connect/disconnect request
174 * @hbm_cmd - bus message command header
175 * @fw_addr - address of the fw client
176 * @host_addr - address of the client in the driver
179 struct hbm_client_connect_request {
187 * struct hbm_client_connect_response - connect/disconnect response
189 * @hbm_cmd - bus message command header
190 * @fw_addr - address of the fw client
191 * @host_addr - address of the client in the driver
192 * @status - status of the request
194 struct hbm_client_connect_response {
202 #define ISHTP_FC_MESSAGE_RESERVED_LENGTH 5
204 struct hbm_flow_control {
208 uint8_t reserved[ISHTP_FC_MESSAGE_RESERVED_LENGTH];
211 struct dma_alloc_notify {
216 uint64_t buf_address;
217 /* [...] May come more size/address pairs */
220 struct dma_xfer_hbm {
222 uint8_t fw_client_id;
223 uint8_t host_client_id;
231 #define ISHTP_SYSTEM_STATE_CLIENT_ADDR 13
233 #define SYSTEM_STATE_SUBSCRIBE 0x1
234 #define SYSTEM_STATE_STATUS 0x2
235 #define SYSTEM_STATE_QUERY_SUBSCRIBERS 0x3
236 #define SYSTEM_STATE_STATE_CHANGE_REQ 0x4
237 /*indicates suspend and resume states*/
238 #define SUSPEND_STATE_BIT (1<<1)
240 struct ish_system_states_header {
242 uint32_t cmd_status; /*responses will have this set*/
245 struct ish_system_states_subscribe {
246 struct ish_system_states_header hdr;
250 struct ish_system_states_status {
251 struct ish_system_states_header hdr;
252 uint32_t supported_states;
253 uint32_t states_status;
256 struct ish_system_states_query_subscribers {
257 struct ish_system_states_header hdr;
260 struct ish_system_states_state_change_req {
261 struct ish_system_states_header hdr;
262 uint32_t requested_states;
263 uint32_t states_status;
267 * enum ishtp_hbm_state - host bus message protocol state
269 * @ISHTP_HBM_IDLE : protocol not started
270 * @ISHTP_HBM_START : start request message was sent
271 * @ISHTP_HBM_ENUM_CLIENTS : enumeration request was sent
272 * @ISHTP_HBM_CLIENT_PROPERTIES : acquiring clients properties
274 enum ishtp_hbm_state {
278 ISHTP_HBM_ENUM_CLIENTS,
279 ISHTP_HBM_CLIENT_PROPERTIES,
284 static inline void ishtp_hbm_hdr(struct ishtp_msg_hdr *hdr, size_t length)
288 hdr->length = length;
289 hdr->msg_complete = 1;
293 int ishtp_hbm_start_req(struct ishtp_device *dev);
294 int ishtp_hbm_start_wait(struct ishtp_device *dev);
295 int ishtp_hbm_cl_flow_control_req(struct ishtp_device *dev,
296 struct ishtp_cl *cl);
297 int ishtp_hbm_cl_disconnect_req(struct ishtp_device *dev, struct ishtp_cl *cl);
298 int ishtp_hbm_cl_connect_req(struct ishtp_device *dev, struct ishtp_cl *cl);
299 void ishtp_hbm_enum_clients_req(struct ishtp_device *dev);
300 void bh_hbm_work_fn(struct work_struct *work);
301 void recv_hbm(struct ishtp_device *dev, struct ishtp_msg_hdr *ishtp_hdr);
302 void recv_fixed_cl_msg(struct ishtp_device *dev,
303 struct ishtp_msg_hdr *ishtp_hdr);
304 void ishtp_hbm_dispatch(struct ishtp_device *dev,
305 struct ishtp_bus_message *hdr);
307 void ishtp_query_subscribers(struct ishtp_device *dev);
310 void ishtp_send_suspend(struct ishtp_device *dev);
311 void ishtp_send_resume(struct ishtp_device *dev);
313 #endif /* _ISHTP_HBM_H_ */