hw.h 12 KB

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