]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/S3SmbusLib.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Library / S3SmbusLib.h
CommitLineData
fe69ac84 1/** @file\r
2 Smbus Library Services that conduct SMBus transactions and enable the operatation\r
3 to be replayed during an S3 resume. This library class maps directly on top\r
4 of the SmbusLib class.\r
5\r
9095d37b 6 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
fe69ac84 7\r
9344f092 8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
fe69ac84 9\r
10**/\r
11\r
12#ifndef __S3_SMBUS_LIB_H__\r
13#define __S3_SMBUS_LIB_H__\r
14\r
15/**\r
16 Executes an SMBUS quick read command, and saves the value in the S3 script to be replayed\r
17 on S3 resume.\r
18\r
19 Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.\r
20 Only the SMBUS slave address field of SmBusAddress is required.\r
21 If Status is not NULL, then the status of the executed command is returned in Status.\r
22 If PEC is set in SmBusAddress, then ASSERT().\r
23 If Command in SmBusAddress is not zero, then ASSERT().\r
24 If Length in SmBusAddress is not zero, then ASSERT().\r
25 If any reserved bits of SmBusAddress are set, then ASSERT().\r
26\r
27 @param[in] SmBusAddress The address that encodes the SMBUS Slave Address,\r
28 SMBUS Command, SMBUS Data Length, and PEC.\r
29 @param[out] Status The return status for the executed command.\r
30 This is an optional parameter and may be NULL.\r
9095d37b
LG
31 RETURN_SUCCESS The SMBUS command was executed.\r
32 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
fe69ac84 33 RETURN_DEVICE_ERROR The request was not completed because a failure\r
34 was recorded in the Host Status Register bit. Device errors are a result\r
35 of a transaction collision, illegal command field, unclaimed cycle\r
36 (host initiated), or bus error (collision).\r
9095d37b 37 RETURN_UNSUPPORTED The SMBus operation is not supported.\r
fe69ac84 38\r
39**/\r
40VOID\r
41EFIAPI\r
42S3SmBusQuickRead (\r
43 IN UINTN SmBusAddress,\r
44 OUT RETURN_STATUS *Status OPTIONAL\r
45 );\r
46\r
47/**\r
48 Executes an SMBUS quick write command, and saves the value in the S3 script to be replayed\r
49 on S3 resume.\r
50\r
51 Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.\r
52 Only the SMBUS slave address field of SmBusAddress is required.\r
53 If Status is not NULL, then the status of the executed command is returned in Status.\r
54 If PEC is set in SmBusAddress, then ASSERT().\r
55 If Command in SmBusAddress is not zero, then ASSERT().\r
56 If Length in SmBusAddress is not zero, then ASSERT().\r
57 If any reserved bits of SmBusAddress are set, then ASSERT().\r
58\r
59 @param[in] SmBusAddress The address that encodes the SMBUS Slave Address,\r
60 SMBUS Command, SMBUS Data Length, and PEC.\r
61 @param[out] Status The return status for the executed command.\r
62 This is an optional parameter and may be NULL.\r
9095d37b
LG
63 RETURN_SUCCESS The SMBUS command was executed.\r
64 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
fe69ac84 65 RETURN_DEVICE_ERROR The request was not completed because a failure\r
66 was recorded in the Host Status Register bit. Device errors are a result\r
67 of a transaction collision, illegal command field, unclaimed cycle\r
68 (host initiated), or bus error (collision).\r
9095d37b 69 RETURN_UNSUPPORTED The SMBus operation is not supported.\r
fe69ac84 70\r
71**/\r
72VOID\r
73EFIAPI\r
74S3SmBusQuickWrite (\r
75 IN UINTN SmBusAddress,\r
76 OUT RETURN_STATUS *Status OPTIONAL\r
77 );\r
78\r
79/**\r
80 Executes an SMBUS receive byte command, and saves the value in the S3 script to be replayed\r
81 on S3 resume.\r
82\r
83 Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.\r
84 Only the SMBUS slave address field of SmBusAddress is required.\r
85 The byte received from the SMBUS is returned.\r
86 If Status is not NULL, then the status of the executed command is returned in Status.\r
87 If Command in SmBusAddress is not zero, then ASSERT().\r
88 If Length in SmBusAddress is not zero, then ASSERT().\r
89 If any reserved bits of SmBusAddress are set, then ASSERT().\r
90\r
91 @param[in] SmBusAddress The address that encodes the SMBUS Slave Address,\r
92 SMBUS Command, SMBUS Data Length, and PEC.\r
93 @param[out] Status The return status for the executed command.\r
94 This is an optional parameter and may be NULL.\r
9095d37b
LG
95 RETURN_SUCCESS The SMBUS command was executed.\r
96 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
fe69ac84 97 RETURN_DEVICE_ERROR The request was not completed because a failure\r
98 was recorded in the Host Status Register bit. Device errors are a result\r
99 of a transaction collision, illegal command field, unclaimed cycle\r
100 (host initiated), or bus error (collision).\r
101 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect).\r
9095d37b 102 RETURN_UNSUPPORTED The SMBus operation is not supported.\r
fe69ac84 103\r
104 @return The byte received from the SMBUS.\r
105\r
106**/\r
107UINT8\r
108EFIAPI\r
109S3SmBusReceiveByte (\r
110 IN UINTN SmBusAddress,\r
111 OUT RETURN_STATUS *Status OPTIONAL\r
112 );\r
113\r
114/**\r
115 Executes an SMBUS send byte command, and saves the value in the S3 script to be replayed\r
116 on S3 resume.\r
117\r
118 Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.\r
119 The byte specified by Value is sent.\r
120 Only the SMBUS slave address field of SmBusAddress is required. Value is returned.\r
121 If Status is not NULL, then the status of the executed command is returned in Status.\r
122 If Command in SmBusAddress is not zero, then ASSERT().\r
123 If Length in SmBusAddress is not zero, then ASSERT().\r
124 If any reserved bits of SmBusAddress are set, then ASSERT().\r
125\r
126 @param[in] SmBusAddress The address that encodes the SMBUS Slave Address,\r
127 SMBUS Command, SMBUS Data Length, and PEC.\r
128 @param[in] Value The 8-bit value to send.\r
129 @param[out] Status The return status for the executed command.\r
130 This is an optional parameter and may be NULL.\r
131 RETURN_SUCCESS The SMBUS command was executed.\r
132 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
133 RETURN_DEVICE_ERROR The request was not completed because a failure\r
134 was recorded in the Host Status Register bit. Device errors are a result\r
135 of a transaction collision, illegal command field, unclaimed cycle\r
136 (host initiated), or bus errors (collisions).\r
137 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect).\r
138 RETURN_UNSUPPORTED The SMBus operation is not supported.\r
139\r
140 @return The parameter of Value.\r
141\r
142**/\r
143UINT8\r
144EFIAPI\r
145S3SmBusSendByte (\r
146 IN UINTN SmBusAddress,\r
147 IN UINT8 Value,\r
148 OUT RETURN_STATUS *Status OPTIONAL\r
149 );\r
150\r
151/**\r
152 Executes an SMBUS read data byte command, and saves the value in the S3 script to be replayed\r
153 on S3 resume.\r
154\r
155 Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.\r
156 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
157 The 8-bit value read from the SMBUS is returned.\r
158 If Status is not NULL, then the status of the executed command is returned in Status.\r
159 If Length in SmBusAddress is not zero, then ASSERT().\r
160 If any reserved bits of SmBusAddress are set, then ASSERT().\r
161\r
162 @param[in] SmBusAddress The address that encodes the SMBUS Slave Address,\r
163 SMBUS Command, SMBUS Data Length, and PEC.\r
164 @param[out] Status The return status for the executed command.\r
165 This is an optional parameter and may be NULL.\r
166 RETURN_SUCCESS The SMBUS command was executed.\r
167 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
168 RETURN_DEVICE_ERROR The request was not completed because a failure\r
169 was recorded in the Host Status Register bit. Device errors are a result\r
170 of a transaction collision, illegal command field, unclaimed cycle\r
171 (host initiated), or bus error (collision).\r
172 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect).\r
173 RETURN_UNSUPPORTED The SMBus operation is not supported.\r
174\r
175 @return The byte read from the SMBUS.\r
176\r
177**/\r
178UINT8\r
179EFIAPI\r
180S3SmBusReadDataByte (\r
181 IN UINTN SmBusAddress,\r
182 OUT RETURN_STATUS *Status OPTIONAL\r
183 );\r
184\r
185/**\r
186 Executes an SMBUS write data byte command, and saves the value in the S3 script to be replayed\r
187 on S3 resume.\r
188\r
189 Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.\r
190 The 8-bit value specified by Value is written.\r
191 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
192 Value is returned.\r
193 If Status is not NULL, then the status of the executed command is returned in Status.\r
194 If Length in SmBusAddress is not zero, then ASSERT().\r
195 If any reserved bits of SmBusAddress are set, then ASSERT().\r
196\r
197 @param[in] SmBusAddress The address that encodes the SMBUS Slave Address,\r
198 SMBUS Command, SMBUS Data Length, and PEC.\r
199 @param[in] Value The 8-bit value to write.\r
200 @param[out] Status The return status for the executed command.\r
201 This is an optional parameter and may be NULL.\r
202 RETURN_SUCCESS The SMBUS command was executed.\r
203 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
204 RETURN_DEVICE_ERROR The request was not completed because a failure\r
205 was recorded in the Host Status Register bit. Device errors are a result\r
206 of a transaction collision, illegal command field, unclaimed cycle\r
207 (host initiated), or bus error (collision).\r
208 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect).\r
209 RETURN_UNSUPPORTED The SMBus operation is not supported.\r
210\r
211 @return The parameter of Value.\r
212\r
213**/\r
214UINT8\r
215EFIAPI\r
216S3SmBusWriteDataByte (\r
217 IN UINTN SmBusAddress,\r
218 IN UINT8 Value,\r
219 OUT RETURN_STATUS *Status OPTIONAL\r
220 );\r
221\r
222/**\r
223 Executes an SMBUS read data word command, and saves the value in the S3 script to be replayed\r
224 on S3 resume.\r
225\r
226 Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.\r
227 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
228 The 16-bit value read from the SMBUS is returned.\r
229 If Status is not NULL, then the status of the executed command is returned in Status.\r
230 If Length in SmBusAddress is not zero, then ASSERT().\r
231 If any reserved bits of SmBusAddress are set, then ASSERT().\r
232\r
233 @param[in] SmBusAddress The address that encodes the SMBUS Slave Address,\r
234 SMBUS Command, SMBUS Data Length, and PEC.\r
235 @param[out] Status The return status for the executed command.\r
236 This is an optional parameter and may be NULL.\r
237 RETURN_SUCCESS The SMBUS command was executed.\r
238 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
239 RETURN_DEVICE_ERROR The request was not completed because a failure\r
240 was recorded in the Host Status Register bit. Device errors are a result\r
241 of a transaction collision, illegal command field, unclaimed cycle\r
242 (host initiated), or bus error (collision).\r
243 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect).\r
244 RETURN_UNSUPPORTED The SMBus operation is not supported.\r
245\r
246 @return The byte read from the SMBUS.\r
247\r
248**/\r
249UINT16\r
250EFIAPI\r
251S3SmBusReadDataWord (\r
252 IN UINTN SmBusAddress,\r
253 OUT RETURN_STATUS *Status OPTIONAL\r
254 );\r
255\r
256/**\r
257 Executes an SMBUS write data word command, and saves the value in the S3 script to be replayed\r
258 on S3 resume.\r
259\r
260 Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.\r
261 The 16-bit value specified by Value is written.\r
262 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
263 Value is returned.\r
264 If Status is not NULL, then the status of the executed command is returned in Status.\r
265 If Length in SmBusAddress is not zero, then ASSERT().\r
266 If any reserved bits of SmBusAddress are set, then ASSERT().\r
267\r
268 @param[in] SmBusAddress The address that encodes the SMBUS Slave Address,\r
269 SMBUS Command, SMBUS Data Length, and PEC.\r
270 @param[in] Value The 16-bit value to write.\r
271 @param[out] Status The return status for the executed command.\r
272 This is an optional parameter and may be NULL.\r
273 RETURN_SUCCESS The SMBUS command was executed.\r
274 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
275 RETURN_DEVICE_ERROR The request was not completed because a failure\r
276 was recorded in the Host Status Register bit. Device errors are a result\r
277 of a transaction collision, illegal command field, unclaimed cycle\r
278 (host initiated), or bus error (collision).\r
279 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect).\r
280 RETURN_UNSUPPORTED The SMBus operation is not supported.\r
281\r
282 @return The parameter of Value.\r
283\r
284**/\r
285UINT16\r
286EFIAPI\r
287S3SmBusWriteDataWord (\r
288 IN UINTN SmBusAddress,\r
289 IN UINT16 Value,\r
290 OUT RETURN_STATUS *Status OPTIONAL\r
291 );\r
292\r
293/**\r
294 Executes an SMBUS process call command, and saves the value in the S3 script to be replayed\r
295 on S3 resume.\r
296\r
297 Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.\r
298 The 16-bit value specified by Value is written.\r
299 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
300 The 16-bit value returned by the process call command is returned.\r
301 If Status is not NULL, then the status of the executed command is returned in Status.\r
302 If Length in SmBusAddress is not zero, then ASSERT().\r
303 If any reserved bits of SmBusAddress are set, then ASSERT().\r
304\r
305 @param[in] SmBusAddress The address that encodes the SMBUS Slave Address,\r
306 SMBUS Command, SMBUS Data Length, and PEC.\r
307 @param[in] Value The 16-bit value to write.\r
308 @param[out] Status The return status for the executed command.\r
309 This is an optional parameter and may be NULL.\r
310 RETURN_SUCCESS The SMBUS command was executed.\r
311 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
312 RETURN_DEVICE_ERROR The request was not completed because a failure\r
313 was recorded in the Host Status Register bit. Device errors are a result\r
314 of a transaction collision, illegal command field, unclaimed cycle\r
315 (host initiated), or bus error (collision).\r
316 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect).\r
317 RETURN_UNSUPPORTED The SMBus operation is not supported.\r
318\r
319 @return The 16-bit value returned by the process call command.\r
320\r
321**/\r
322UINT16\r
323EFIAPI\r
324S3SmBusProcessCall (\r
325 IN UINTN SmBusAddress,\r
326 IN UINT16 Value,\r
327 OUT RETURN_STATUS *Status OPTIONAL\r
328 );\r
329\r
330/**\r
331 Executes an SMBUS read block command, and saves the value in the S3 script to be replayed\r
332 on S3 resume.\r
333\r
334 Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.\r
335 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
336 Bytes are read from the SMBUS and stored in Buffer.\r
337 The number of bytes read is returned, and will never return a value larger than 32-bytes.\r
338 If Status is not NULL, then the status of the executed command is returned in Status.\r
339 It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.\r
340 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
341 If Length in SmBusAddress is not zero, then ASSERT().\r
342 If Buffer is NULL, then ASSERT().\r
343 If any reserved bits of SmBusAddress are set, then ASSERT().\r
344\r
345 @param[in] SmBusAddress The address that encodes the SMBUS Slave Address,\r
346 SMBUS Command, SMBUS Data Length, and PEC.\r
347 @param[out] Buffer The pointer to the buffer to store the bytes read from the SMBUS.\r
348 @param[out] Status The return status for the executed command.\r
349 This is an optional parameter and may be NULL.\r
350 RETURN_SUCCESS The SMBUS command was executed.\r
351 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
352 RETURN_DEVICE_ERROR The request was not completed because a failure\r
353 was recorded in the Host Status Register bit. Device errors are a result\r
354 of a transaction collision, illegal command field, unclaimed cycle\r
355 (host initiated), or bus error (collision).\r
356 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect).\r
357 RETURN_UNSUPPORTED The SMBus operation is not supported.\r
358\r
359 @return The number of bytes read.\r
360\r
361**/\r
362UINTN\r
363EFIAPI\r
364S3SmBusReadBlock (\r
365 IN UINTN SmBusAddress,\r
366 OUT VOID *Buffer,\r
367 OUT RETURN_STATUS *Status OPTIONAL\r
368 );\r
369\r
370/**\r
371 Executes an SMBUS write block command, and saves the value in the S3 script to be replayed\r
372 on S3 resume.\r
373\r
374 Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.\r
375 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
376 Bytes are written to the SMBUS from Buffer.\r
377 The number of bytes written is returned, and will never return a value larger than 32-bytes.\r
378 If Status is not NULL, then the status of the executed command is returned in Status.\r
379 If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
380 If Buffer is NULL, then ASSERT().\r
381 If any reserved bits of SmBusAddress are set, then ASSERT().\r
382\r
383 @param[in] SmBusAddress The address that encodes the SMBUS Slave Address,\r
384 SMBUS Command, SMBUS Data Length, and PEC.\r
385 @param[out] Buffer The pointer to the buffer to store the bytes read from the SMBUS.\r
386 @param[out] Status The return status for the executed command.\r
387 This is an optional parameter and may be NULL.\r
388 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
389 RETURN_DEVICE_ERROR The request was not completed because a failure\r
390 was recorded in the Host Status Register bit. Device errors are a result\r
391 of a transaction collision, illegal command field, unclaimed cycle\r
392 (host initiated), or bus error (collision).\r
393 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect).\r
394 RETURN_UNSUPPORTED The SMBus operation is not supported.\r
395\r
396 @return The number of bytes written.\r
397\r
398**/\r
399UINTN\r
400EFIAPI\r
401S3SmBusWriteBlock (\r
402 IN UINTN SmBusAddress,\r
403 OUT VOID *Buffer,\r
404 OUT RETURN_STATUS *Status OPTIONAL\r
405 );\r
406\r
407/**\r
408 Executes an SMBUS block process call command, and saves the value in the S3 script to be replayed\r
409 on S3 resume.\r
410\r
411 Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.\r
412 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
413 Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer.\r
414 If Status is not NULL, then the status of the executed command is returned in Status.\r
415 It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.\r
416 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
417 If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
418 If WriteBuffer is NULL, then ASSERT().\r
419 If ReadBuffer is NULL, then ASSERT().\r
420 If any reserved bits of SmBusAddress are set, then ASSERT().\r
421\r
422 @param[in] SmBusAddress The address that encodes the SMBUS Slave Address,\r
423 SMBUS Command, SMBUS Data Length, and PEC.\r
424 @param[in] WriteBuffer The pointer to the buffer of bytes to write to the SMBUS.\r
425 @param[out] ReadBuffer The pointer to the buffer of bytes to read from the SMBUS.\r
426 @param[out] Status The return status for the executed command.\r
427 This is an optional parameter and may be NULL.\r
428 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
429 RETURN_DEVICE_ERROR The request was not completed because a failure\r
430 was recorded in the Host Status Register bit. Device errors are a result\r
431 of a transaction collision, illegal command field, unclaimed cycle\r
432 (host initiated), or bus error (collision).\r
433 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect).\r
434 RETURN_UNSUPPORTED The SMBus operation is not supported.\r
435\r
436 @return The number of bytes written.\r
437\r
438**/\r
439UINTN\r
440EFIAPI\r
441S3SmBusBlockProcessCall (\r
442 IN UINTN SmBusAddress,\r
443 IN VOID *WriteBuffer,\r
444 OUT VOID *ReadBuffer,\r
445 OUT RETURN_STATUS *Status OPTIONAL\r
446 );\r
447\r
448#endif\r