2 * ISHTP bus layer messages handling
4 * Copyright (c) 2003-2016, Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 #include <linux/uuid.h>
28 #define ISHTP_INTEROP_TIMEOUT 7 /* Timeout on ready message */
30 #define ISHTP_CL_CONNECT_TIMEOUT 15 /* HPS: Client Connect Timeout */
35 #define HBM_MINOR_VERSION 0
36 #define HBM_MAJOR_VERSION 1
38 /* Host bus message command opcode */
39 #define ISHTP_HBM_CMD_OP_MSK 0x7f
40 /* Host bus message command RESPONSE */
41 #define ISHTP_HBM_CMD_RES_MSK 0x80
44 * ISHTP Bus Message Command IDs
46 #define HOST_START_REQ_CMD 0x01
47 #define HOST_START_RES_CMD 0x81
49 #define HOST_STOP_REQ_CMD 0x02
50 #define HOST_STOP_RES_CMD 0x82
52 #define FW_STOP_REQ_CMD 0x03
54 #define HOST_ENUM_REQ_CMD 0x04
55 #define HOST_ENUM_RES_CMD 0x84
57 #define HOST_CLIENT_PROPERTIES_REQ_CMD 0x05
58 #define HOST_CLIENT_PROPERTIES_RES_CMD 0x85
60 #define CLIENT_CONNECT_REQ_CMD 0x06
61 #define CLIENT_CONNECT_RES_CMD 0x86
63 #define CLIENT_DISCONNECT_REQ_CMD 0x07
64 #define CLIENT_DISCONNECT_RES_CMD 0x87
66 #define ISHTP_FLOW_CONTROL_CMD 0x08
68 #define DMA_BUFFER_ALLOC_NOTIFY 0x11
69 #define DMA_BUFFER_ALLOC_RESPONSE 0x91
72 #define DMA_XFER_ACK 0x92
76 * used by hbm_host_stop_request.reason
78 #define DRIVER_STOP_REQUEST 0x00
81 * ISHTP BUS Interface Section
83 struct ishtp_msg_hdr
{
88 uint32_t msg_complete
:1;
91 struct ishtp_bus_message
{
97 * struct hbm_cl_cmd - client specific host bus command
98 * CONNECT, DISCONNECT, and FlOW CONTROL
100 * @hbm_cmd - bus message command header
101 * @fw_addr - address of the fw client
102 * @host_addr - address of the client in the driver
105 struct ishtp_hbm_cl_cmd
{
113 uint8_t minor_version
;
114 uint8_t major_version
;
117 struct hbm_host_version_request
{
120 struct hbm_version host_version
;
123 struct hbm_host_version_response
{
125 uint8_t host_version_supported
;
126 struct hbm_version fw_max_version
;
129 struct hbm_host_stop_request
{
135 struct hbm_host_stop_response
{
140 struct hbm_host_enum_request
{
145 struct hbm_host_enum_response
{
148 uint8_t valid_addresses
[32];
151 struct ishtp_client_properties
{
152 uuid_le protocol_name
;
153 uint8_t protocol_version
;
154 uint8_t max_number_of_connections
;
155 uint8_t fixed_address
;
156 uint8_t single_recv_buf
;
157 uint32_t max_msg_length
;
159 #define ISHTP_CLIENT_DMA_ENABLED 0x80
165 struct hbm_props_request
{
171 struct hbm_props_response
{
176 struct ishtp_client_properties client_properties
;
180 * struct hbm_client_connect_request - connect/disconnect request
182 * @hbm_cmd - bus message command header
183 * @fw_addr - address of the fw client
184 * @host_addr - address of the client in the driver
187 struct hbm_client_connect_request
{
195 * struct hbm_client_connect_response - connect/disconnect response
197 * @hbm_cmd - bus message command header
198 * @fw_addr - address of the fw client
199 * @host_addr - address of the client in the driver
200 * @status - status of the request
202 struct hbm_client_connect_response
{
210 #define ISHTP_FC_MESSAGE_RESERVED_LENGTH 5
212 struct hbm_flow_control
{
216 uint8_t reserved
[ISHTP_FC_MESSAGE_RESERVED_LENGTH
];
219 struct dma_alloc_notify
{
224 uint64_t buf_address
;
225 /* [...] May come more size/address pairs */
228 struct dma_xfer_hbm
{
230 uint8_t fw_client_id
;
231 uint8_t host_client_id
;
239 #define ISHTP_SYSTEM_STATE_CLIENT_ADDR 13
241 #define SYSTEM_STATE_SUBSCRIBE 0x1
242 #define SYSTEM_STATE_STATUS 0x2
243 #define SYSTEM_STATE_QUERY_SUBSCRIBERS 0x3
244 #define SYSTEM_STATE_STATE_CHANGE_REQ 0x4
245 /*indicates suspend and resume states*/
246 #define SUSPEND_STATE_BIT (1<<1)
248 struct ish_system_states_header
{
250 uint32_t cmd_status
; /*responses will have this set*/
253 struct ish_system_states_subscribe
{
254 struct ish_system_states_header hdr
;
258 struct ish_system_states_status
{
259 struct ish_system_states_header hdr
;
260 uint32_t supported_states
;
261 uint32_t states_status
;
264 struct ish_system_states_query_subscribers
{
265 struct ish_system_states_header hdr
;
268 struct ish_system_states_state_change_req
{
269 struct ish_system_states_header hdr
;
270 uint32_t requested_states
;
271 uint32_t states_status
;
275 * enum ishtp_hbm_state - host bus message protocol state
277 * @ISHTP_HBM_IDLE : protocol not started
278 * @ISHTP_HBM_START : start request message was sent
279 * @ISHTP_HBM_ENUM_CLIENTS : enumeration request was sent
280 * @ISHTP_HBM_CLIENT_PROPERTIES : acquiring clients properties
282 enum ishtp_hbm_state
{
286 ISHTP_HBM_ENUM_CLIENTS
,
287 ISHTP_HBM_CLIENT_PROPERTIES
,
292 static inline void ishtp_hbm_hdr(struct ishtp_msg_hdr
*hdr
, size_t length
)
296 hdr
->length
= length
;
297 hdr
->msg_complete
= 1;
301 int ishtp_hbm_start_req(struct ishtp_device
*dev
);
302 int ishtp_hbm_start_wait(struct ishtp_device
*dev
);
303 int ishtp_hbm_cl_flow_control_req(struct ishtp_device
*dev
,
304 struct ishtp_cl
*cl
);
305 int ishtp_hbm_cl_disconnect_req(struct ishtp_device
*dev
, struct ishtp_cl
*cl
);
306 int ishtp_hbm_cl_connect_req(struct ishtp_device
*dev
, struct ishtp_cl
*cl
);
307 void ishtp_hbm_enum_clients_req(struct ishtp_device
*dev
);
308 void bh_hbm_work_fn(struct work_struct
*work
);
309 void recv_hbm(struct ishtp_device
*dev
, struct ishtp_msg_hdr
*ishtp_hdr
);
310 void recv_fixed_cl_msg(struct ishtp_device
*dev
,
311 struct ishtp_msg_hdr
*ishtp_hdr
);
312 void ishtp_hbm_dispatch(struct ishtp_device
*dev
,
313 struct ishtp_bus_message
*hdr
);
315 void ishtp_query_subscribers(struct ishtp_device
*dev
);
318 void ishtp_send_suspend(struct ishtp_device
*dev
);
319 void ishtp_send_resume(struct ishtp_device
*dev
);
321 #endif /* _ISHTP_HBM_H_ */