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