xref: /linux/drivers/misc/mei/hw.h (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
1 /*
2  *
3  * Intel Management Engine Interface (Intel MEI) Linux driver
4  * Copyright (c) 2003-2012, Intel Corporation.
5  *
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.
9  *
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
13  * more details.
14  *
15  */
16 
17 #ifndef _MEI_HW_TYPES_H_
18 #define _MEI_HW_TYPES_H_
19 
20 #include <linux/uuid.h>
21 
22 /*
23  * Timeouts in Seconds
24  */
25 #define MEI_HW_READY_TIMEOUT        2  /* Timeout on ready message */
26 #define MEI_CONNECT_TIMEOUT         3  /* HPS: at least 2 seconds */
27 
28 #define MEI_CL_CONNECT_TIMEOUT     15  /* HPS: Client Connect Timeout */
29 #define MEI_CLIENTS_INIT_TIMEOUT   15  /* HPS: Clients Enumeration Timeout */
30 
31 #define MEI_IAMTHIF_STALL_TIMER    12  /* HPS */
32 #define MEI_IAMTHIF_READ_TIMER     10  /* HPS */
33 
34 #define MEI_PGI_TIMEOUT             1  /* PG Isolation time response 1 sec */
35 #define MEI_D0I3_TIMEOUT            5  /* D0i3 set/unset max response time */
36 #define MEI_HBM_TIMEOUT             1  /* 1 second */
37 
38 /*
39  * MEI Version
40  */
41 #define HBM_MINOR_VERSION                   0
42 #define HBM_MAJOR_VERSION                   2
43 
44 /*
45  * MEI version with PGI support
46  */
47 #define HBM_MINOR_VERSION_PGI               1
48 #define HBM_MAJOR_VERSION_PGI               1
49 
50 /*
51  * MEI version with Dynamic clients support
52  */
53 #define HBM_MINOR_VERSION_DC               0
54 #define HBM_MAJOR_VERSION_DC               2
55 
56 /*
57  * MEI version with disconnect on connection timeout support
58  */
59 #define HBM_MINOR_VERSION_DOT              0
60 #define HBM_MAJOR_VERSION_DOT              2
61 
62 /*
63  * MEI version with notifcation support
64  */
65 #define HBM_MINOR_VERSION_EV               0
66 #define HBM_MAJOR_VERSION_EV               2
67 
68 /* Host bus message command opcode */
69 #define MEI_HBM_CMD_OP_MSK                  0x7f
70 /* Host bus message command RESPONSE */
71 #define MEI_HBM_CMD_RES_MSK                 0x80
72 
73 /*
74  * MEI Bus Message Command IDs
75  */
76 #define HOST_START_REQ_CMD                  0x01
77 #define HOST_START_RES_CMD                  0x81
78 
79 #define HOST_STOP_REQ_CMD                   0x02
80 #define HOST_STOP_RES_CMD                   0x82
81 
82 #define ME_STOP_REQ_CMD                     0x03
83 
84 #define HOST_ENUM_REQ_CMD                   0x04
85 #define HOST_ENUM_RES_CMD                   0x84
86 
87 #define HOST_CLIENT_PROPERTIES_REQ_CMD      0x05
88 #define HOST_CLIENT_PROPERTIES_RES_CMD      0x85
89 
90 #define CLIENT_CONNECT_REQ_CMD              0x06
91 #define CLIENT_CONNECT_RES_CMD              0x86
92 
93 #define CLIENT_DISCONNECT_REQ_CMD           0x07
94 #define CLIENT_DISCONNECT_RES_CMD           0x87
95 
96 #define MEI_FLOW_CONTROL_CMD                0x08
97 
98 #define MEI_PG_ISOLATION_ENTRY_REQ_CMD      0x0a
99 #define MEI_PG_ISOLATION_ENTRY_RES_CMD      0x8a
100 #define MEI_PG_ISOLATION_EXIT_REQ_CMD       0x0b
101 #define MEI_PG_ISOLATION_EXIT_RES_CMD       0x8b
102 
103 #define MEI_HBM_ADD_CLIENT_REQ_CMD          0x0f
104 #define MEI_HBM_ADD_CLIENT_RES_CMD          0x8f
105 
106 #define MEI_HBM_NOTIFY_REQ_CMD              0x10
107 #define MEI_HBM_NOTIFY_RES_CMD              0x90
108 #define MEI_HBM_NOTIFICATION_CMD            0x11
109 
110 /*
111  * MEI Stop Reason
112  * used by hbm_host_stop_request.reason
113  */
114 enum mei_stop_reason_types {
115 	DRIVER_STOP_REQUEST = 0x00,
116 	DEVICE_D1_ENTRY = 0x01,
117 	DEVICE_D2_ENTRY = 0x02,
118 	DEVICE_D3_ENTRY = 0x03,
119 	SYSTEM_S1_ENTRY = 0x04,
120 	SYSTEM_S2_ENTRY = 0x05,
121 	SYSTEM_S3_ENTRY = 0x06,
122 	SYSTEM_S4_ENTRY = 0x07,
123 	SYSTEM_S5_ENTRY = 0x08
124 };
125 
126 
127 /**
128  * enum mei_hbm_status  - mei host bus messages return values
129  *
130  * @MEI_HBMS_SUCCESS           : status success
131  * @MEI_HBMS_CLIENT_NOT_FOUND  : client not found
132  * @MEI_HBMS_ALREADY_EXISTS    : connection already established
133  * @MEI_HBMS_REJECTED          : connection is rejected
134  * @MEI_HBMS_INVALID_PARAMETER : invalid parameter
135  * @MEI_HBMS_NOT_ALLOWED       : operation not allowed
136  * @MEI_HBMS_ALREADY_STARTED   : system is already started
137  * @MEI_HBMS_NOT_STARTED       : system not started
138  *
139  * @MEI_HBMS_MAX               : sentinel
140  */
141 enum mei_hbm_status {
142 	MEI_HBMS_SUCCESS           = 0,
143 	MEI_HBMS_CLIENT_NOT_FOUND  = 1,
144 	MEI_HBMS_ALREADY_EXISTS    = 2,
145 	MEI_HBMS_REJECTED          = 3,
146 	MEI_HBMS_INVALID_PARAMETER = 4,
147 	MEI_HBMS_NOT_ALLOWED       = 5,
148 	MEI_HBMS_ALREADY_STARTED   = 6,
149 	MEI_HBMS_NOT_STARTED       = 7,
150 
151 	MEI_HBMS_MAX
152 };
153 
154 
155 /*
156  * Client Connect Status
157  * used by hbm_client_connect_response.status
158  */
159 enum mei_cl_connect_status {
160 	MEI_CL_CONN_SUCCESS          = MEI_HBMS_SUCCESS,
161 	MEI_CL_CONN_NOT_FOUND        = MEI_HBMS_CLIENT_NOT_FOUND,
162 	MEI_CL_CONN_ALREADY_STARTED  = MEI_HBMS_ALREADY_EXISTS,
163 	MEI_CL_CONN_OUT_OF_RESOURCES = MEI_HBMS_REJECTED,
164 	MEI_CL_CONN_MESSAGE_SMALL    = MEI_HBMS_INVALID_PARAMETER,
165 	MEI_CL_CONN_NOT_ALLOWED      = MEI_HBMS_NOT_ALLOWED,
166 };
167 
168 /*
169  * Client Disconnect Status
170  */
171 enum  mei_cl_disconnect_status {
172 	MEI_CL_DISCONN_SUCCESS = MEI_HBMS_SUCCESS
173 };
174 
175 /*
176  *  MEI BUS Interface Section
177  */
178 struct mei_msg_hdr {
179 	u32 me_addr:8;
180 	u32 host_addr:8;
181 	u32 length:9;
182 	u32 reserved:5;
183 	u32 internal:1;
184 	u32 msg_complete:1;
185 } __packed;
186 
187 
188 struct mei_bus_message {
189 	u8 hbm_cmd;
190 	u8 data[0];
191 } __packed;
192 
193 /**
194  * struct hbm_cl_cmd - client specific host bus command
195  *	CONNECT, DISCONNECT, and FlOW CONTROL
196  *
197  * @hbm_cmd: bus message command header
198  * @me_addr: address of the client in ME
199  * @host_addr: address of the client in the driver
200  * @data: generic data
201  */
202 struct mei_hbm_cl_cmd {
203 	u8 hbm_cmd;
204 	u8 me_addr;
205 	u8 host_addr;
206 	u8 data;
207 };
208 
209 struct hbm_version {
210 	u8 minor_version;
211 	u8 major_version;
212 } __packed;
213 
214 struct hbm_host_version_request {
215 	u8 hbm_cmd;
216 	u8 reserved;
217 	struct hbm_version host_version;
218 } __packed;
219 
220 struct hbm_host_version_response {
221 	u8 hbm_cmd;
222 	u8 host_version_supported;
223 	struct hbm_version me_max_version;
224 } __packed;
225 
226 struct hbm_host_stop_request {
227 	u8 hbm_cmd;
228 	u8 reason;
229 	u8 reserved[2];
230 } __packed;
231 
232 struct hbm_host_stop_response {
233 	u8 hbm_cmd;
234 	u8 reserved[3];
235 } __packed;
236 
237 struct hbm_me_stop_request {
238 	u8 hbm_cmd;
239 	u8 reason;
240 	u8 reserved[2];
241 } __packed;
242 
243 /**
244  * struct hbm_host_enum_request -  enumeration request from host to fw
245  *
246  * @hbm_cmd: bus message command header
247  * @allow_add: allow dynamic clients add HBM version >= 2.0
248  * @reserved: reserved
249  */
250 struct hbm_host_enum_request {
251 	u8 hbm_cmd;
252 	u8 allow_add;
253 	u8 reserved[2];
254 } __packed;
255 
256 struct hbm_host_enum_response {
257 	u8 hbm_cmd;
258 	u8 reserved[3];
259 	u8 valid_addresses[32];
260 } __packed;
261 
262 struct mei_client_properties {
263 	uuid_le protocol_name;
264 	u8 protocol_version;
265 	u8 max_number_of_connections;
266 	u8 fixed_address;
267 	u8 single_recv_buf;
268 	u32 max_msg_length;
269 } __packed;
270 
271 struct hbm_props_request {
272 	u8 hbm_cmd;
273 	u8 me_addr;
274 	u8 reserved[2];
275 } __packed;
276 
277 struct hbm_props_response {
278 	u8 hbm_cmd;
279 	u8 me_addr;
280 	u8 status;
281 	u8 reserved[1];
282 	struct mei_client_properties client_properties;
283 } __packed;
284 
285 /**
286  * struct hbm_add_client_request - request to add a client
287  *     might be sent by fw after enumeration has already completed
288  *
289  * @hbm_cmd: bus message command header
290  * @me_addr: address of the client in ME
291  * @reserved: reserved
292  * @client_properties: client properties
293  */
294 struct hbm_add_client_request {
295 	u8 hbm_cmd;
296 	u8 me_addr;
297 	u8 reserved[2];
298 	struct mei_client_properties client_properties;
299 } __packed;
300 
301 /**
302  * struct hbm_add_client_response - response to add a client
303  *     sent by the host to report client addition status to fw
304  *
305  * @hbm_cmd: bus message command header
306  * @me_addr: address of the client in ME
307  * @status: if HBMS_SUCCESS then the client can now accept connections.
308  * @reserved: reserved
309  */
310 struct hbm_add_client_response {
311 	u8 hbm_cmd;
312 	u8 me_addr;
313 	u8 status;
314 	u8 reserved[1];
315 } __packed;
316 
317 /**
318  * struct hbm_power_gate - power gate request/response
319  *
320  * @hbm_cmd: bus message command header
321  * @reserved: reserved
322  */
323 struct hbm_power_gate {
324 	u8 hbm_cmd;
325 	u8 reserved[3];
326 } __packed;
327 
328 /**
329  * struct hbm_client_connect_request - connect/disconnect request
330  *
331  * @hbm_cmd: bus message command header
332  * @me_addr: address of the client in ME
333  * @host_addr: address of the client in the driver
334  * @reserved: reserved
335  */
336 struct hbm_client_connect_request {
337 	u8 hbm_cmd;
338 	u8 me_addr;
339 	u8 host_addr;
340 	u8 reserved;
341 } __packed;
342 
343 /**
344  * struct hbm_client_connect_response - connect/disconnect response
345  *
346  * @hbm_cmd: bus message command header
347  * @me_addr: address of the client in ME
348  * @host_addr: address of the client in the driver
349  * @status: status of the request
350  */
351 struct hbm_client_connect_response {
352 	u8 hbm_cmd;
353 	u8 me_addr;
354 	u8 host_addr;
355 	u8 status;
356 } __packed;
357 
358 
359 #define MEI_FC_MESSAGE_RESERVED_LENGTH           5
360 
361 struct hbm_flow_control {
362 	u8 hbm_cmd;
363 	u8 me_addr;
364 	u8 host_addr;
365 	u8 reserved[MEI_FC_MESSAGE_RESERVED_LENGTH];
366 } __packed;
367 
368 #define MEI_HBM_NOTIFICATION_START 1
369 #define MEI_HBM_NOTIFICATION_STOP  0
370 /**
371  * struct hbm_notification_request - start/stop notification request
372  *
373  * @hbm_cmd: bus message command header
374  * @me_addr: address of the client in ME
375  * @host_addr: address of the client in the driver
376  * @start:  start = 1 or stop = 0 asynchronous notifications
377  */
378 struct hbm_notification_request {
379 	u8 hbm_cmd;
380 	u8 me_addr;
381 	u8 host_addr;
382 	u8 start;
383 } __packed;
384 
385 /**
386  * struct hbm_notification_response - start/stop notification response
387  *
388  * @hbm_cmd: bus message command header
389  * @me_addr: address of the client in ME
390  * @host_addr: - address of the client in the driver
391  * @status: (mei_hbm_status) response status for the request
392  *  - MEI_HBMS_SUCCESS: successful stop/start
393  *  - MEI_HBMS_CLIENT_NOT_FOUND: if the connection could not be found.
394  *  - MEI_HBMS_ALREADY_STARTED: for start requests for a previously
395  *                         started notification.
396  *  - MEI_HBMS_NOT_STARTED: for stop request for a connected client for whom
397  *                         asynchronous notifications are currently disabled.
398  *
399  * @start:  start = 1 or stop = 0 asynchronous notifications
400  * @reserved: reserved
401  */
402 struct hbm_notification_response {
403 	u8 hbm_cmd;
404 	u8 me_addr;
405 	u8 host_addr;
406 	u8 status;
407 	u8 start;
408 	u8 reserved[3];
409 } __packed;
410 
411 /**
412  * struct hbm_notification - notification event
413  *
414  * @hbm_cmd: bus message command header
415  * @me_addr:  address of the client in ME
416  * @host_addr:  address of the client in the driver
417  * @reserved: reserved for alignment
418  */
419 struct hbm_notification {
420 	u8 hbm_cmd;
421 	u8 me_addr;
422 	u8 host_addr;
423 	u8 reserved[1];
424 } __packed;
425 
426 #endif
427