xref: /OK3568_Linux_fs/kernel/drivers/misc/mei/hw.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (c) 2003-2020, Intel Corporation. All rights reserved
4*4882a593Smuzhiyun  * Intel Management Engine Interface (Intel MEI) Linux driver
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #ifndef _MEI_HW_TYPES_H_
8*4882a593Smuzhiyun #define _MEI_HW_TYPES_H_
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <linux/uuid.h>
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun /*
13*4882a593Smuzhiyun  * Timeouts in Seconds
14*4882a593Smuzhiyun  */
15*4882a593Smuzhiyun #define MEI_HW_READY_TIMEOUT        2  /* Timeout on ready message */
16*4882a593Smuzhiyun #define MEI_CONNECT_TIMEOUT         3  /* HPS: at least 2 seconds */
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun #define MEI_CL_CONNECT_TIMEOUT     15  /* HPS: Client Connect Timeout */
19*4882a593Smuzhiyun #define MEI_CLIENTS_INIT_TIMEOUT   15  /* HPS: Clients Enumeration Timeout */
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun #define MEI_PGI_TIMEOUT             1  /* PG Isolation time response 1 sec */
22*4882a593Smuzhiyun #define MEI_D0I3_TIMEOUT            5  /* D0i3 set/unset max response time */
23*4882a593Smuzhiyun #define MEI_HBM_TIMEOUT             1  /* 1 second */
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun /*
26*4882a593Smuzhiyun  * MEI Version
27*4882a593Smuzhiyun  */
28*4882a593Smuzhiyun #define HBM_MINOR_VERSION                   2
29*4882a593Smuzhiyun #define HBM_MAJOR_VERSION                   2
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun /*
32*4882a593Smuzhiyun  * MEI version with PGI support
33*4882a593Smuzhiyun  */
34*4882a593Smuzhiyun #define HBM_MINOR_VERSION_PGI               1
35*4882a593Smuzhiyun #define HBM_MAJOR_VERSION_PGI               1
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun /*
38*4882a593Smuzhiyun  * MEI version with Dynamic clients support
39*4882a593Smuzhiyun  */
40*4882a593Smuzhiyun #define HBM_MINOR_VERSION_DC               0
41*4882a593Smuzhiyun #define HBM_MAJOR_VERSION_DC               2
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun /*
44*4882a593Smuzhiyun  * MEI version with immediate reply to enum request support
45*4882a593Smuzhiyun  */
46*4882a593Smuzhiyun #define HBM_MINOR_VERSION_IE               0
47*4882a593Smuzhiyun #define HBM_MAJOR_VERSION_IE               2
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun /*
50*4882a593Smuzhiyun  * MEI version with disconnect on connection timeout support
51*4882a593Smuzhiyun  */
52*4882a593Smuzhiyun #define HBM_MINOR_VERSION_DOT              0
53*4882a593Smuzhiyun #define HBM_MAJOR_VERSION_DOT              2
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun /*
56*4882a593Smuzhiyun  * MEI version with notification support
57*4882a593Smuzhiyun  */
58*4882a593Smuzhiyun #define HBM_MINOR_VERSION_EV               0
59*4882a593Smuzhiyun #define HBM_MAJOR_VERSION_EV               2
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun /*
62*4882a593Smuzhiyun  * MEI version with fixed address client support
63*4882a593Smuzhiyun  */
64*4882a593Smuzhiyun #define HBM_MINOR_VERSION_FA               0
65*4882a593Smuzhiyun #define HBM_MAJOR_VERSION_FA               2
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun /*
68*4882a593Smuzhiyun  * MEI version with OS ver message support
69*4882a593Smuzhiyun  */
70*4882a593Smuzhiyun #define HBM_MINOR_VERSION_OS               0
71*4882a593Smuzhiyun #define HBM_MAJOR_VERSION_OS               2
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun /*
74*4882a593Smuzhiyun  * MEI version with dma ring support
75*4882a593Smuzhiyun  */
76*4882a593Smuzhiyun #define HBM_MINOR_VERSION_DR               1
77*4882a593Smuzhiyun #define HBM_MAJOR_VERSION_DR               2
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun /*
80*4882a593Smuzhiyun  * MEI version with vm tag support
81*4882a593Smuzhiyun  */
82*4882a593Smuzhiyun #define HBM_MINOR_VERSION_VT               2
83*4882a593Smuzhiyun #define HBM_MAJOR_VERSION_VT               2
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun /*
86*4882a593Smuzhiyun  * MEI version with capabilities message support
87*4882a593Smuzhiyun  */
88*4882a593Smuzhiyun #define HBM_MINOR_VERSION_CAP              2
89*4882a593Smuzhiyun #define HBM_MAJOR_VERSION_CAP              2
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun /* Host bus message command opcode */
92*4882a593Smuzhiyun #define MEI_HBM_CMD_OP_MSK                  0x7f
93*4882a593Smuzhiyun /* Host bus message command RESPONSE */
94*4882a593Smuzhiyun #define MEI_HBM_CMD_RES_MSK                 0x80
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun /*
97*4882a593Smuzhiyun  * MEI Bus Message Command IDs
98*4882a593Smuzhiyun  */
99*4882a593Smuzhiyun #define HOST_START_REQ_CMD                  0x01
100*4882a593Smuzhiyun #define HOST_START_RES_CMD                  0x81
101*4882a593Smuzhiyun 
102*4882a593Smuzhiyun #define HOST_STOP_REQ_CMD                   0x02
103*4882a593Smuzhiyun #define HOST_STOP_RES_CMD                   0x82
104*4882a593Smuzhiyun 
105*4882a593Smuzhiyun #define ME_STOP_REQ_CMD                     0x03
106*4882a593Smuzhiyun 
107*4882a593Smuzhiyun #define HOST_ENUM_REQ_CMD                   0x04
108*4882a593Smuzhiyun #define HOST_ENUM_RES_CMD                   0x84
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun #define HOST_CLIENT_PROPERTIES_REQ_CMD      0x05
111*4882a593Smuzhiyun #define HOST_CLIENT_PROPERTIES_RES_CMD      0x85
112*4882a593Smuzhiyun 
113*4882a593Smuzhiyun #define CLIENT_CONNECT_REQ_CMD              0x06
114*4882a593Smuzhiyun #define CLIENT_CONNECT_RES_CMD              0x86
115*4882a593Smuzhiyun 
116*4882a593Smuzhiyun #define CLIENT_DISCONNECT_REQ_CMD           0x07
117*4882a593Smuzhiyun #define CLIENT_DISCONNECT_RES_CMD           0x87
118*4882a593Smuzhiyun 
119*4882a593Smuzhiyun #define MEI_FLOW_CONTROL_CMD                0x08
120*4882a593Smuzhiyun 
121*4882a593Smuzhiyun #define MEI_PG_ISOLATION_ENTRY_REQ_CMD      0x0a
122*4882a593Smuzhiyun #define MEI_PG_ISOLATION_ENTRY_RES_CMD      0x8a
123*4882a593Smuzhiyun #define MEI_PG_ISOLATION_EXIT_REQ_CMD       0x0b
124*4882a593Smuzhiyun #define MEI_PG_ISOLATION_EXIT_RES_CMD       0x8b
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun #define MEI_HBM_ADD_CLIENT_REQ_CMD          0x0f
127*4882a593Smuzhiyun #define MEI_HBM_ADD_CLIENT_RES_CMD          0x8f
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun #define MEI_HBM_NOTIFY_REQ_CMD              0x10
130*4882a593Smuzhiyun #define MEI_HBM_NOTIFY_RES_CMD              0x90
131*4882a593Smuzhiyun #define MEI_HBM_NOTIFICATION_CMD            0x11
132*4882a593Smuzhiyun 
133*4882a593Smuzhiyun #define MEI_HBM_DMA_SETUP_REQ_CMD           0x12
134*4882a593Smuzhiyun #define MEI_HBM_DMA_SETUP_RES_CMD           0x92
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun #define MEI_HBM_CAPABILITIES_REQ_CMD        0x13
137*4882a593Smuzhiyun #define MEI_HBM_CAPABILITIES_RES_CMD        0x93
138*4882a593Smuzhiyun 
139*4882a593Smuzhiyun /*
140*4882a593Smuzhiyun  * MEI Stop Reason
141*4882a593Smuzhiyun  * used by hbm_host_stop_request.reason
142*4882a593Smuzhiyun  */
143*4882a593Smuzhiyun enum mei_stop_reason_types {
144*4882a593Smuzhiyun 	DRIVER_STOP_REQUEST = 0x00,
145*4882a593Smuzhiyun 	DEVICE_D1_ENTRY = 0x01,
146*4882a593Smuzhiyun 	DEVICE_D2_ENTRY = 0x02,
147*4882a593Smuzhiyun 	DEVICE_D3_ENTRY = 0x03,
148*4882a593Smuzhiyun 	SYSTEM_S1_ENTRY = 0x04,
149*4882a593Smuzhiyun 	SYSTEM_S2_ENTRY = 0x05,
150*4882a593Smuzhiyun 	SYSTEM_S3_ENTRY = 0x06,
151*4882a593Smuzhiyun 	SYSTEM_S4_ENTRY = 0x07,
152*4882a593Smuzhiyun 	SYSTEM_S5_ENTRY = 0x08
153*4882a593Smuzhiyun };
154*4882a593Smuzhiyun 
155*4882a593Smuzhiyun 
156*4882a593Smuzhiyun /**
157*4882a593Smuzhiyun  * enum mei_hbm_status  - mei host bus messages return values
158*4882a593Smuzhiyun  *
159*4882a593Smuzhiyun  * @MEI_HBMS_SUCCESS           : status success
160*4882a593Smuzhiyun  * @MEI_HBMS_CLIENT_NOT_FOUND  : client not found
161*4882a593Smuzhiyun  * @MEI_HBMS_ALREADY_EXISTS    : connection already established
162*4882a593Smuzhiyun  * @MEI_HBMS_REJECTED          : connection is rejected
163*4882a593Smuzhiyun  * @MEI_HBMS_INVALID_PARAMETER : invalid parameter
164*4882a593Smuzhiyun  * @MEI_HBMS_NOT_ALLOWED       : operation not allowed
165*4882a593Smuzhiyun  * @MEI_HBMS_ALREADY_STARTED   : system is already started
166*4882a593Smuzhiyun  * @MEI_HBMS_NOT_STARTED       : system not started
167*4882a593Smuzhiyun  *
168*4882a593Smuzhiyun  * @MEI_HBMS_MAX               : sentinel
169*4882a593Smuzhiyun  */
170*4882a593Smuzhiyun enum mei_hbm_status {
171*4882a593Smuzhiyun 	MEI_HBMS_SUCCESS           = 0,
172*4882a593Smuzhiyun 	MEI_HBMS_CLIENT_NOT_FOUND  = 1,
173*4882a593Smuzhiyun 	MEI_HBMS_ALREADY_EXISTS    = 2,
174*4882a593Smuzhiyun 	MEI_HBMS_REJECTED          = 3,
175*4882a593Smuzhiyun 	MEI_HBMS_INVALID_PARAMETER = 4,
176*4882a593Smuzhiyun 	MEI_HBMS_NOT_ALLOWED       = 5,
177*4882a593Smuzhiyun 	MEI_HBMS_ALREADY_STARTED   = 6,
178*4882a593Smuzhiyun 	MEI_HBMS_NOT_STARTED       = 7,
179*4882a593Smuzhiyun 
180*4882a593Smuzhiyun 	MEI_HBMS_MAX
181*4882a593Smuzhiyun };
182*4882a593Smuzhiyun 
183*4882a593Smuzhiyun 
184*4882a593Smuzhiyun /*
185*4882a593Smuzhiyun  * Client Connect Status
186*4882a593Smuzhiyun  * used by hbm_client_connect_response.status
187*4882a593Smuzhiyun  */
188*4882a593Smuzhiyun enum mei_cl_connect_status {
189*4882a593Smuzhiyun 	MEI_CL_CONN_SUCCESS          = MEI_HBMS_SUCCESS,
190*4882a593Smuzhiyun 	MEI_CL_CONN_NOT_FOUND        = MEI_HBMS_CLIENT_NOT_FOUND,
191*4882a593Smuzhiyun 	MEI_CL_CONN_ALREADY_STARTED  = MEI_HBMS_ALREADY_EXISTS,
192*4882a593Smuzhiyun 	MEI_CL_CONN_OUT_OF_RESOURCES = MEI_HBMS_REJECTED,
193*4882a593Smuzhiyun 	MEI_CL_CONN_MESSAGE_SMALL    = MEI_HBMS_INVALID_PARAMETER,
194*4882a593Smuzhiyun 	MEI_CL_CONN_NOT_ALLOWED      = MEI_HBMS_NOT_ALLOWED,
195*4882a593Smuzhiyun };
196*4882a593Smuzhiyun 
197*4882a593Smuzhiyun /*
198*4882a593Smuzhiyun  * Client Disconnect Status
199*4882a593Smuzhiyun  */
200*4882a593Smuzhiyun enum mei_cl_disconnect_status {
201*4882a593Smuzhiyun 	MEI_CL_DISCONN_SUCCESS = MEI_HBMS_SUCCESS
202*4882a593Smuzhiyun };
203*4882a593Smuzhiyun 
204*4882a593Smuzhiyun /**
205*4882a593Smuzhiyun  * enum mei_ext_hdr_type - extended header type used in
206*4882a593Smuzhiyun  *    extended header TLV
207*4882a593Smuzhiyun  *
208*4882a593Smuzhiyun  * @MEI_EXT_HDR_NONE: sentinel
209*4882a593Smuzhiyun  * @MEI_EXT_HDR_VTAG: vtag header
210*4882a593Smuzhiyun  */
211*4882a593Smuzhiyun enum mei_ext_hdr_type {
212*4882a593Smuzhiyun 	MEI_EXT_HDR_NONE = 0,
213*4882a593Smuzhiyun 	MEI_EXT_HDR_VTAG = 1,
214*4882a593Smuzhiyun };
215*4882a593Smuzhiyun 
216*4882a593Smuzhiyun /**
217*4882a593Smuzhiyun  * struct mei_ext_hdr - extend header descriptor (TLV)
218*4882a593Smuzhiyun  * @type: enum mei_ext_hdr_type
219*4882a593Smuzhiyun  * @length: length excluding descriptor
220*4882a593Smuzhiyun  * @ext_payload: payload of the specific extended header
221*4882a593Smuzhiyun  * @hdr: place holder for actual header
222*4882a593Smuzhiyun  */
223*4882a593Smuzhiyun struct mei_ext_hdr {
224*4882a593Smuzhiyun 	u8 type;
225*4882a593Smuzhiyun 	u8 length;
226*4882a593Smuzhiyun 	u8 ext_payload[2];
227*4882a593Smuzhiyun 	u8 hdr[];
228*4882a593Smuzhiyun };
229*4882a593Smuzhiyun 
230*4882a593Smuzhiyun /**
231*4882a593Smuzhiyun  * struct mei_ext_meta_hdr - extend header meta data
232*4882a593Smuzhiyun  * @count: number of headers
233*4882a593Smuzhiyun  * @size: total size of the extended header list excluding meta header
234*4882a593Smuzhiyun  * @reserved: reserved
235*4882a593Smuzhiyun  * @hdrs: extended headers TLV list
236*4882a593Smuzhiyun  */
237*4882a593Smuzhiyun struct mei_ext_meta_hdr {
238*4882a593Smuzhiyun 	u8 count;
239*4882a593Smuzhiyun 	u8 size;
240*4882a593Smuzhiyun 	u8 reserved[2];
241*4882a593Smuzhiyun 	struct mei_ext_hdr hdrs[];
242*4882a593Smuzhiyun };
243*4882a593Smuzhiyun 
244*4882a593Smuzhiyun /*
245*4882a593Smuzhiyun  * Extended header iterator functions
246*4882a593Smuzhiyun  */
247*4882a593Smuzhiyun /**
248*4882a593Smuzhiyun  * mei_ext_hdr - extended header iterator begin
249*4882a593Smuzhiyun  *
250*4882a593Smuzhiyun  * @meta: meta header of the extended header list
251*4882a593Smuzhiyun  *
252*4882a593Smuzhiyun  * Return:
253*4882a593Smuzhiyun  *     The first extended header
254*4882a593Smuzhiyun  */
mei_ext_begin(struct mei_ext_meta_hdr * meta)255*4882a593Smuzhiyun static inline struct mei_ext_hdr *mei_ext_begin(struct mei_ext_meta_hdr *meta)
256*4882a593Smuzhiyun {
257*4882a593Smuzhiyun 	return meta->hdrs;
258*4882a593Smuzhiyun }
259*4882a593Smuzhiyun 
260*4882a593Smuzhiyun /**
261*4882a593Smuzhiyun  * mei_ext_last - check if the ext is the last one in the TLV list
262*4882a593Smuzhiyun  *
263*4882a593Smuzhiyun  * @meta: meta header of the extended header list
264*4882a593Smuzhiyun  * @ext: a meta header on the list
265*4882a593Smuzhiyun  *
266*4882a593Smuzhiyun  * Return: true if ext is the last header on the list
267*4882a593Smuzhiyun  */
mei_ext_last(struct mei_ext_meta_hdr * meta,struct mei_ext_hdr * ext)268*4882a593Smuzhiyun static inline bool mei_ext_last(struct mei_ext_meta_hdr *meta,
269*4882a593Smuzhiyun 				struct mei_ext_hdr *ext)
270*4882a593Smuzhiyun {
271*4882a593Smuzhiyun 	return (u8 *)ext >= (u8 *)meta + sizeof(*meta) + (meta->size * 4);
272*4882a593Smuzhiyun }
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun /**
275*4882a593Smuzhiyun  *mei_ext_next - following extended header on the TLV list
276*4882a593Smuzhiyun  *
277*4882a593Smuzhiyun  * @ext: current extend header
278*4882a593Smuzhiyun  *
279*4882a593Smuzhiyun  * Context: The function does not check for the overflows,
280*4882a593Smuzhiyun  *          one should call mei_ext_last before.
281*4882a593Smuzhiyun  *
282*4882a593Smuzhiyun  * Return: The following extend header after @ext
283*4882a593Smuzhiyun  */
mei_ext_next(struct mei_ext_hdr * ext)284*4882a593Smuzhiyun static inline struct mei_ext_hdr *mei_ext_next(struct mei_ext_hdr *ext)
285*4882a593Smuzhiyun {
286*4882a593Smuzhiyun 	return (struct mei_ext_hdr *)(ext->hdr + (ext->length * 4));
287*4882a593Smuzhiyun }
288*4882a593Smuzhiyun 
289*4882a593Smuzhiyun /**
290*4882a593Smuzhiyun  * struct mei_msg_hdr - MEI BUS Interface Section
291*4882a593Smuzhiyun  *
292*4882a593Smuzhiyun  * @me_addr: device address
293*4882a593Smuzhiyun  * @host_addr: host address
294*4882a593Smuzhiyun  * @length: message length
295*4882a593Smuzhiyun  * @reserved: reserved
296*4882a593Smuzhiyun  * @extended: message has extended header
297*4882a593Smuzhiyun  * @dma_ring: message is on dma ring
298*4882a593Smuzhiyun  * @internal: message is internal
299*4882a593Smuzhiyun  * @msg_complete: last packet of the message
300*4882a593Smuzhiyun  * @extension: extension of the header
301*4882a593Smuzhiyun  */
302*4882a593Smuzhiyun struct mei_msg_hdr {
303*4882a593Smuzhiyun 	u32 me_addr:8;
304*4882a593Smuzhiyun 	u32 host_addr:8;
305*4882a593Smuzhiyun 	u32 length:9;
306*4882a593Smuzhiyun 	u32 reserved:3;
307*4882a593Smuzhiyun 	u32 extended:1;
308*4882a593Smuzhiyun 	u32 dma_ring:1;
309*4882a593Smuzhiyun 	u32 internal:1;
310*4882a593Smuzhiyun 	u32 msg_complete:1;
311*4882a593Smuzhiyun 	u32 extension[];
312*4882a593Smuzhiyun } __packed;
313*4882a593Smuzhiyun 
314*4882a593Smuzhiyun /* The length is up to 9 bits */
315*4882a593Smuzhiyun #define MEI_MSG_MAX_LEN_MASK GENMASK(9, 0)
316*4882a593Smuzhiyun 
317*4882a593Smuzhiyun struct mei_bus_message {
318*4882a593Smuzhiyun 	u8 hbm_cmd;
319*4882a593Smuzhiyun 	u8 data[];
320*4882a593Smuzhiyun } __packed;
321*4882a593Smuzhiyun 
322*4882a593Smuzhiyun /**
323*4882a593Smuzhiyun  * struct hbm_cl_cmd - client specific host bus command
324*4882a593Smuzhiyun  *	CONNECT, DISCONNECT, and FlOW CONTROL
325*4882a593Smuzhiyun  *
326*4882a593Smuzhiyun  * @hbm_cmd: bus message command header
327*4882a593Smuzhiyun  * @me_addr: address of the client in ME
328*4882a593Smuzhiyun  * @host_addr: address of the client in the driver
329*4882a593Smuzhiyun  * @data: generic data
330*4882a593Smuzhiyun  */
331*4882a593Smuzhiyun struct mei_hbm_cl_cmd {
332*4882a593Smuzhiyun 	u8 hbm_cmd;
333*4882a593Smuzhiyun 	u8 me_addr;
334*4882a593Smuzhiyun 	u8 host_addr;
335*4882a593Smuzhiyun 	u8 data;
336*4882a593Smuzhiyun };
337*4882a593Smuzhiyun 
338*4882a593Smuzhiyun struct hbm_version {
339*4882a593Smuzhiyun 	u8 minor_version;
340*4882a593Smuzhiyun 	u8 major_version;
341*4882a593Smuzhiyun } __packed;
342*4882a593Smuzhiyun 
343*4882a593Smuzhiyun struct hbm_host_version_request {
344*4882a593Smuzhiyun 	u8 hbm_cmd;
345*4882a593Smuzhiyun 	u8 reserved;
346*4882a593Smuzhiyun 	struct hbm_version host_version;
347*4882a593Smuzhiyun } __packed;
348*4882a593Smuzhiyun 
349*4882a593Smuzhiyun struct hbm_host_version_response {
350*4882a593Smuzhiyun 	u8 hbm_cmd;
351*4882a593Smuzhiyun 	u8 host_version_supported;
352*4882a593Smuzhiyun 	struct hbm_version me_max_version;
353*4882a593Smuzhiyun } __packed;
354*4882a593Smuzhiyun 
355*4882a593Smuzhiyun struct hbm_host_stop_request {
356*4882a593Smuzhiyun 	u8 hbm_cmd;
357*4882a593Smuzhiyun 	u8 reason;
358*4882a593Smuzhiyun 	u8 reserved[2];
359*4882a593Smuzhiyun } __packed;
360*4882a593Smuzhiyun 
361*4882a593Smuzhiyun struct hbm_host_stop_response {
362*4882a593Smuzhiyun 	u8 hbm_cmd;
363*4882a593Smuzhiyun 	u8 reserved[3];
364*4882a593Smuzhiyun } __packed;
365*4882a593Smuzhiyun 
366*4882a593Smuzhiyun struct hbm_me_stop_request {
367*4882a593Smuzhiyun 	u8 hbm_cmd;
368*4882a593Smuzhiyun 	u8 reason;
369*4882a593Smuzhiyun 	u8 reserved[2];
370*4882a593Smuzhiyun } __packed;
371*4882a593Smuzhiyun 
372*4882a593Smuzhiyun /**
373*4882a593Smuzhiyun  * enum hbm_host_enum_flags - enumeration request flags (HBM version >= 2.0)
374*4882a593Smuzhiyun  *
375*4882a593Smuzhiyun  * @MEI_HBM_ENUM_F_ALLOW_ADD: allow dynamic clients add
376*4882a593Smuzhiyun  * @MEI_HBM_ENUM_F_IMMEDIATE_ENUM: allow FW to send answer immediately
377*4882a593Smuzhiyun  */
378*4882a593Smuzhiyun enum hbm_host_enum_flags {
379*4882a593Smuzhiyun 	MEI_HBM_ENUM_F_ALLOW_ADD = BIT(0),
380*4882a593Smuzhiyun 	MEI_HBM_ENUM_F_IMMEDIATE_ENUM = BIT(1),
381*4882a593Smuzhiyun };
382*4882a593Smuzhiyun 
383*4882a593Smuzhiyun /**
384*4882a593Smuzhiyun  * struct hbm_host_enum_request - enumeration request from host to fw
385*4882a593Smuzhiyun  *
386*4882a593Smuzhiyun  * @hbm_cmd : bus message command header
387*4882a593Smuzhiyun  * @flags   : request flags
388*4882a593Smuzhiyun  * @reserved: reserved
389*4882a593Smuzhiyun  */
390*4882a593Smuzhiyun struct hbm_host_enum_request {
391*4882a593Smuzhiyun 	u8 hbm_cmd;
392*4882a593Smuzhiyun 	u8 flags;
393*4882a593Smuzhiyun 	u8 reserved[2];
394*4882a593Smuzhiyun } __packed;
395*4882a593Smuzhiyun 
396*4882a593Smuzhiyun struct hbm_host_enum_response {
397*4882a593Smuzhiyun 	u8 hbm_cmd;
398*4882a593Smuzhiyun 	u8 reserved[3];
399*4882a593Smuzhiyun 	u8 valid_addresses[32];
400*4882a593Smuzhiyun } __packed;
401*4882a593Smuzhiyun 
402*4882a593Smuzhiyun /**
403*4882a593Smuzhiyun  * struct mei_client_properties - mei client properties
404*4882a593Smuzhiyun  *
405*4882a593Smuzhiyun  * @protocol_name: guid of the client
406*4882a593Smuzhiyun  * @protocol_version: client protocol version
407*4882a593Smuzhiyun  * @max_number_of_connections: number of possible connections.
408*4882a593Smuzhiyun  * @fixed_address: fixed me address (0 if the client is dynamic)
409*4882a593Smuzhiyun  * @single_recv_buf: 1 if all connections share a single receive buffer.
410*4882a593Smuzhiyun  * @vt_supported: the client support vtag
411*4882a593Smuzhiyun  * @reserved: reserved
412*4882a593Smuzhiyun  * @max_msg_length: MTU of the client
413*4882a593Smuzhiyun  */
414*4882a593Smuzhiyun struct mei_client_properties {
415*4882a593Smuzhiyun 	uuid_le protocol_name;
416*4882a593Smuzhiyun 	u8 protocol_version;
417*4882a593Smuzhiyun 	u8 max_number_of_connections;
418*4882a593Smuzhiyun 	u8 fixed_address;
419*4882a593Smuzhiyun 	u8 single_recv_buf:1;
420*4882a593Smuzhiyun 	u8 vt_supported:1;
421*4882a593Smuzhiyun 	u8 reserved:6;
422*4882a593Smuzhiyun 	u32 max_msg_length;
423*4882a593Smuzhiyun } __packed;
424*4882a593Smuzhiyun 
425*4882a593Smuzhiyun struct hbm_props_request {
426*4882a593Smuzhiyun 	u8 hbm_cmd;
427*4882a593Smuzhiyun 	u8 me_addr;
428*4882a593Smuzhiyun 	u8 reserved[2];
429*4882a593Smuzhiyun } __packed;
430*4882a593Smuzhiyun 
431*4882a593Smuzhiyun struct hbm_props_response {
432*4882a593Smuzhiyun 	u8 hbm_cmd;
433*4882a593Smuzhiyun 	u8 me_addr;
434*4882a593Smuzhiyun 	u8 status;
435*4882a593Smuzhiyun 	u8 reserved;
436*4882a593Smuzhiyun 	struct mei_client_properties client_properties;
437*4882a593Smuzhiyun } __packed;
438*4882a593Smuzhiyun 
439*4882a593Smuzhiyun /**
440*4882a593Smuzhiyun  * struct hbm_add_client_request - request to add a client
441*4882a593Smuzhiyun  *     might be sent by fw after enumeration has already completed
442*4882a593Smuzhiyun  *
443*4882a593Smuzhiyun  * @hbm_cmd: bus message command header
444*4882a593Smuzhiyun  * @me_addr: address of the client in ME
445*4882a593Smuzhiyun  * @reserved: reserved
446*4882a593Smuzhiyun  * @client_properties: client properties
447*4882a593Smuzhiyun  */
448*4882a593Smuzhiyun struct hbm_add_client_request {
449*4882a593Smuzhiyun 	u8 hbm_cmd;
450*4882a593Smuzhiyun 	u8 me_addr;
451*4882a593Smuzhiyun 	u8 reserved[2];
452*4882a593Smuzhiyun 	struct mei_client_properties client_properties;
453*4882a593Smuzhiyun } __packed;
454*4882a593Smuzhiyun 
455*4882a593Smuzhiyun /**
456*4882a593Smuzhiyun  * struct hbm_add_client_response - response to add a client
457*4882a593Smuzhiyun  *     sent by the host to report client addition status to fw
458*4882a593Smuzhiyun  *
459*4882a593Smuzhiyun  * @hbm_cmd: bus message command header
460*4882a593Smuzhiyun  * @me_addr: address of the client in ME
461*4882a593Smuzhiyun  * @status: if HBMS_SUCCESS then the client can now accept connections.
462*4882a593Smuzhiyun  * @reserved: reserved
463*4882a593Smuzhiyun  */
464*4882a593Smuzhiyun struct hbm_add_client_response {
465*4882a593Smuzhiyun 	u8 hbm_cmd;
466*4882a593Smuzhiyun 	u8 me_addr;
467*4882a593Smuzhiyun 	u8 status;
468*4882a593Smuzhiyun 	u8 reserved;
469*4882a593Smuzhiyun } __packed;
470*4882a593Smuzhiyun 
471*4882a593Smuzhiyun /**
472*4882a593Smuzhiyun  * struct hbm_power_gate - power gate request/response
473*4882a593Smuzhiyun  *
474*4882a593Smuzhiyun  * @hbm_cmd: bus message command header
475*4882a593Smuzhiyun  * @reserved: reserved
476*4882a593Smuzhiyun  */
477*4882a593Smuzhiyun struct hbm_power_gate {
478*4882a593Smuzhiyun 	u8 hbm_cmd;
479*4882a593Smuzhiyun 	u8 reserved[3];
480*4882a593Smuzhiyun } __packed;
481*4882a593Smuzhiyun 
482*4882a593Smuzhiyun /**
483*4882a593Smuzhiyun  * struct hbm_client_connect_request - connect/disconnect request
484*4882a593Smuzhiyun  *
485*4882a593Smuzhiyun  * @hbm_cmd: bus message command header
486*4882a593Smuzhiyun  * @me_addr: address of the client in ME
487*4882a593Smuzhiyun  * @host_addr: address of the client in the driver
488*4882a593Smuzhiyun  * @reserved: reserved
489*4882a593Smuzhiyun  */
490*4882a593Smuzhiyun struct hbm_client_connect_request {
491*4882a593Smuzhiyun 	u8 hbm_cmd;
492*4882a593Smuzhiyun 	u8 me_addr;
493*4882a593Smuzhiyun 	u8 host_addr;
494*4882a593Smuzhiyun 	u8 reserved;
495*4882a593Smuzhiyun } __packed;
496*4882a593Smuzhiyun 
497*4882a593Smuzhiyun /**
498*4882a593Smuzhiyun  * struct hbm_client_connect_response - connect/disconnect response
499*4882a593Smuzhiyun  *
500*4882a593Smuzhiyun  * @hbm_cmd: bus message command header
501*4882a593Smuzhiyun  * @me_addr: address of the client in ME
502*4882a593Smuzhiyun  * @host_addr: address of the client in the driver
503*4882a593Smuzhiyun  * @status: status of the request
504*4882a593Smuzhiyun  */
505*4882a593Smuzhiyun struct hbm_client_connect_response {
506*4882a593Smuzhiyun 	u8 hbm_cmd;
507*4882a593Smuzhiyun 	u8 me_addr;
508*4882a593Smuzhiyun 	u8 host_addr;
509*4882a593Smuzhiyun 	u8 status;
510*4882a593Smuzhiyun } __packed;
511*4882a593Smuzhiyun 
512*4882a593Smuzhiyun 
513*4882a593Smuzhiyun #define MEI_FC_MESSAGE_RESERVED_LENGTH           5
514*4882a593Smuzhiyun 
515*4882a593Smuzhiyun struct hbm_flow_control {
516*4882a593Smuzhiyun 	u8 hbm_cmd;
517*4882a593Smuzhiyun 	u8 me_addr;
518*4882a593Smuzhiyun 	u8 host_addr;
519*4882a593Smuzhiyun 	u8 reserved[MEI_FC_MESSAGE_RESERVED_LENGTH];
520*4882a593Smuzhiyun } __packed;
521*4882a593Smuzhiyun 
522*4882a593Smuzhiyun #define MEI_HBM_NOTIFICATION_START 1
523*4882a593Smuzhiyun #define MEI_HBM_NOTIFICATION_STOP  0
524*4882a593Smuzhiyun /**
525*4882a593Smuzhiyun  * struct hbm_notification_request - start/stop notification request
526*4882a593Smuzhiyun  *
527*4882a593Smuzhiyun  * @hbm_cmd: bus message command header
528*4882a593Smuzhiyun  * @me_addr: address of the client in ME
529*4882a593Smuzhiyun  * @host_addr: address of the client in the driver
530*4882a593Smuzhiyun  * @start:  start = 1 or stop = 0 asynchronous notifications
531*4882a593Smuzhiyun  */
532*4882a593Smuzhiyun struct hbm_notification_request {
533*4882a593Smuzhiyun 	u8 hbm_cmd;
534*4882a593Smuzhiyun 	u8 me_addr;
535*4882a593Smuzhiyun 	u8 host_addr;
536*4882a593Smuzhiyun 	u8 start;
537*4882a593Smuzhiyun } __packed;
538*4882a593Smuzhiyun 
539*4882a593Smuzhiyun /**
540*4882a593Smuzhiyun  * struct hbm_notification_response - start/stop notification response
541*4882a593Smuzhiyun  *
542*4882a593Smuzhiyun  * @hbm_cmd: bus message command header
543*4882a593Smuzhiyun  * @me_addr: address of the client in ME
544*4882a593Smuzhiyun  * @host_addr: - address of the client in the driver
545*4882a593Smuzhiyun  * @status: (mei_hbm_status) response status for the request
546*4882a593Smuzhiyun  *  - MEI_HBMS_SUCCESS: successful stop/start
547*4882a593Smuzhiyun  *  - MEI_HBMS_CLIENT_NOT_FOUND: if the connection could not be found.
548*4882a593Smuzhiyun  *  - MEI_HBMS_ALREADY_STARTED: for start requests for a previously
549*4882a593Smuzhiyun  *                         started notification.
550*4882a593Smuzhiyun  *  - MEI_HBMS_NOT_STARTED: for stop request for a connected client for whom
551*4882a593Smuzhiyun  *                         asynchronous notifications are currently disabled.
552*4882a593Smuzhiyun  *
553*4882a593Smuzhiyun  * @start:  start = 1 or stop = 0 asynchronous notifications
554*4882a593Smuzhiyun  * @reserved: reserved
555*4882a593Smuzhiyun  */
556*4882a593Smuzhiyun struct hbm_notification_response {
557*4882a593Smuzhiyun 	u8 hbm_cmd;
558*4882a593Smuzhiyun 	u8 me_addr;
559*4882a593Smuzhiyun 	u8 host_addr;
560*4882a593Smuzhiyun 	u8 status;
561*4882a593Smuzhiyun 	u8 start;
562*4882a593Smuzhiyun 	u8 reserved[3];
563*4882a593Smuzhiyun } __packed;
564*4882a593Smuzhiyun 
565*4882a593Smuzhiyun /**
566*4882a593Smuzhiyun  * struct hbm_notification - notification event
567*4882a593Smuzhiyun  *
568*4882a593Smuzhiyun  * @hbm_cmd: bus message command header
569*4882a593Smuzhiyun  * @me_addr:  address of the client in ME
570*4882a593Smuzhiyun  * @host_addr:  address of the client in the driver
571*4882a593Smuzhiyun  * @reserved: reserved for alignment
572*4882a593Smuzhiyun  */
573*4882a593Smuzhiyun struct hbm_notification {
574*4882a593Smuzhiyun 	u8 hbm_cmd;
575*4882a593Smuzhiyun 	u8 me_addr;
576*4882a593Smuzhiyun 	u8 host_addr;
577*4882a593Smuzhiyun 	u8 reserved;
578*4882a593Smuzhiyun } __packed;
579*4882a593Smuzhiyun 
580*4882a593Smuzhiyun /**
581*4882a593Smuzhiyun  * struct hbm_dma_mem_dscr - dma ring
582*4882a593Smuzhiyun  *
583*4882a593Smuzhiyun  * @addr_hi: the high 32bits of 64 bit address
584*4882a593Smuzhiyun  * @addr_lo: the low  32bits of 64 bit address
585*4882a593Smuzhiyun  * @size   : size in bytes (must be power of 2)
586*4882a593Smuzhiyun  */
587*4882a593Smuzhiyun struct hbm_dma_mem_dscr {
588*4882a593Smuzhiyun 	u32 addr_hi;
589*4882a593Smuzhiyun 	u32 addr_lo;
590*4882a593Smuzhiyun 	u32 size;
591*4882a593Smuzhiyun } __packed;
592*4882a593Smuzhiyun 
593*4882a593Smuzhiyun enum {
594*4882a593Smuzhiyun 	DMA_DSCR_HOST = 0,
595*4882a593Smuzhiyun 	DMA_DSCR_DEVICE = 1,
596*4882a593Smuzhiyun 	DMA_DSCR_CTRL = 2,
597*4882a593Smuzhiyun 	DMA_DSCR_NUM,
598*4882a593Smuzhiyun };
599*4882a593Smuzhiyun 
600*4882a593Smuzhiyun /**
601*4882a593Smuzhiyun  * struct hbm_dma_setup_request - dma setup request
602*4882a593Smuzhiyun  *
603*4882a593Smuzhiyun  * @hbm_cmd: bus message command header
604*4882a593Smuzhiyun  * @reserved: reserved for alignment
605*4882a593Smuzhiyun  * @dma_dscr: dma descriptor for HOST, DEVICE, and CTRL
606*4882a593Smuzhiyun  */
607*4882a593Smuzhiyun struct hbm_dma_setup_request {
608*4882a593Smuzhiyun 	u8 hbm_cmd;
609*4882a593Smuzhiyun 	u8 reserved[3];
610*4882a593Smuzhiyun 	struct hbm_dma_mem_dscr dma_dscr[DMA_DSCR_NUM];
611*4882a593Smuzhiyun } __packed;
612*4882a593Smuzhiyun 
613*4882a593Smuzhiyun /**
614*4882a593Smuzhiyun  * struct hbm_dma_setup_response - dma setup response
615*4882a593Smuzhiyun  *
616*4882a593Smuzhiyun  * @hbm_cmd: bus message command header
617*4882a593Smuzhiyun  * @status: 0 on success; otherwise DMA setup failed.
618*4882a593Smuzhiyun  * @reserved: reserved for alignment
619*4882a593Smuzhiyun  */
620*4882a593Smuzhiyun struct hbm_dma_setup_response {
621*4882a593Smuzhiyun 	u8 hbm_cmd;
622*4882a593Smuzhiyun 	u8 status;
623*4882a593Smuzhiyun 	u8 reserved[2];
624*4882a593Smuzhiyun } __packed;
625*4882a593Smuzhiyun 
626*4882a593Smuzhiyun /**
627*4882a593Smuzhiyun  * struct mei_dma_ring_ctrl - dma ring control block
628*4882a593Smuzhiyun  *
629*4882a593Smuzhiyun  * @hbuf_wr_idx: host circular buffer write index in slots
630*4882a593Smuzhiyun  * @reserved1: reserved for alignment
631*4882a593Smuzhiyun  * @hbuf_rd_idx: host circular buffer read index in slots
632*4882a593Smuzhiyun  * @reserved2: reserved for alignment
633*4882a593Smuzhiyun  * @dbuf_wr_idx: device circular buffer write index in slots
634*4882a593Smuzhiyun  * @reserved3: reserved for alignment
635*4882a593Smuzhiyun  * @dbuf_rd_idx: device circular buffer read index in slots
636*4882a593Smuzhiyun  * @reserved4: reserved for alignment
637*4882a593Smuzhiyun  */
638*4882a593Smuzhiyun struct hbm_dma_ring_ctrl {
639*4882a593Smuzhiyun 	u32 hbuf_wr_idx;
640*4882a593Smuzhiyun 	u32 reserved1;
641*4882a593Smuzhiyun 	u32 hbuf_rd_idx;
642*4882a593Smuzhiyun 	u32 reserved2;
643*4882a593Smuzhiyun 	u32 dbuf_wr_idx;
644*4882a593Smuzhiyun 	u32 reserved3;
645*4882a593Smuzhiyun 	u32 dbuf_rd_idx;
646*4882a593Smuzhiyun 	u32 reserved4;
647*4882a593Smuzhiyun } __packed;
648*4882a593Smuzhiyun 
649*4882a593Smuzhiyun /* virtual tag supported */
650*4882a593Smuzhiyun #define HBM_CAP_VT BIT(0)
651*4882a593Smuzhiyun 
652*4882a593Smuzhiyun /**
653*4882a593Smuzhiyun  * struct hbm_capability_request - capability request from host to fw
654*4882a593Smuzhiyun  *
655*4882a593Smuzhiyun  * @hbm_cmd : bus message command header
656*4882a593Smuzhiyun  * @capability_requested: bitmask of capabilities requested by host
657*4882a593Smuzhiyun  */
658*4882a593Smuzhiyun struct hbm_capability_request {
659*4882a593Smuzhiyun 	u8 hbm_cmd;
660*4882a593Smuzhiyun 	u8 capability_requested[3];
661*4882a593Smuzhiyun } __packed;
662*4882a593Smuzhiyun 
663*4882a593Smuzhiyun /**
664*4882a593Smuzhiyun  * struct hbm_capability_response - capability response from fw to host
665*4882a593Smuzhiyun  *
666*4882a593Smuzhiyun  * @hbm_cmd : bus message command header
667*4882a593Smuzhiyun  * @capability_granted: bitmask of capabilities granted by FW
668*4882a593Smuzhiyun  */
669*4882a593Smuzhiyun struct hbm_capability_response {
670*4882a593Smuzhiyun 	u8 hbm_cmd;
671*4882a593Smuzhiyun 	u8 capability_granted[3];
672*4882a593Smuzhiyun } __packed;
673*4882a593Smuzhiyun 
674*4882a593Smuzhiyun #endif
675