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