]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.c
2 Null implementation of SmBusLib class library.
4 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/SmbusLib.h>
11 #include <Library/DebugLib.h>
14 Executes an SMBUS quick read command.
16 Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.
17 Only the SMBUS slave address field of SmBusAddress is required.
18 If Status is not NULL, then the status of the executed command is returned in Status.
19 If PEC is set in SmBusAddress, then ASSERT().
20 If Command in SmBusAddress is not zero, then ASSERT().
21 If Length in SmBusAddress is not zero, then ASSERT().
22 If any reserved bits of SmBusAddress are set, then ASSERT().
24 @param SmBusAddress Address that encodes the SMBUS Slave Address,
25 SMBUS Command, SMBUS Data Length, and PEC.
26 @param Status Return status for the executed command.
27 This is an optional parameter and may be NULL.
28 RETURN_SUCCESS The SMBUS command was executed.
29 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
30 RETURN_DEVICE_ERROR The request was not completed because a failure
31 reflected in the Host Status Register bit. Device errors are a result
32 of a transaction collision, illegal command field, unclaimed cycle
33 (host initiated), or bus errors (collisions).
34 RETURN_UNSUPPORTED The SMBus operation is not supported.
40 IN UINTN SmBusAddress
,
41 OUT RETURN_STATUS
*Status OPTIONAL
44 ASSERT (!SMBUS_LIB_PEC (SmBusAddress
));
45 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress
) == 0);
46 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
47 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
49 *Status
= RETURN_UNSUPPORTED
;
54 Executes an SMBUS quick write command.
56 Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.
57 Only the SMBUS slave address field of SmBusAddress is required.
58 If Status is not NULL, then the status of the executed command is returned in Status.
59 If PEC is set in SmBusAddress, then ASSERT().
60 If Command in SmBusAddress is not zero, then ASSERT().
61 If Length in SmBusAddress is not zero, then ASSERT().
62 If any reserved bits of SmBusAddress are set, then ASSERT().
64 @param SmBusAddress Address that encodes the SMBUS Slave Address,
65 SMBUS Command, SMBUS Data Length, and PEC.
66 @param Status Return status for the executed command.
67 This is an optional parameter and may be NULL.
68 RETURN_SUCCESS The SMBUS command was executed.
69 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
70 RETURN_DEVICE_ERROR The request was not completed because a failure
71 reflected in the Host Status Register bit. Device errors are a result
72 of a transaction collision, illegal command field, unclaimed cycle
73 (host initiated), or bus errors (collisions).
74 RETURN_UNSUPPORTED The SMBus operation is not supported.
80 IN UINTN SmBusAddress
,
81 OUT RETURN_STATUS
*Status OPTIONAL
84 ASSERT (!SMBUS_LIB_PEC (SmBusAddress
));
85 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress
) == 0);
86 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
87 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
89 *Status
= RETURN_UNSUPPORTED
;
94 Executes an SMBUS receive byte command.
96 Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.
97 Only the SMBUS slave address field of SmBusAddress is required.
98 The byte received from the SMBUS is returned.
99 If Status is not NULL, then the status of the executed command is returned in Status.
100 If Command in SmBusAddress is not zero, then ASSERT().
101 If Length in SmBusAddress is not zero, then ASSERT().
102 If any reserved bits of SmBusAddress are set, then ASSERT().
104 @param SmBusAddress Address that encodes the SMBUS Slave Address,
105 SMBUS Command, SMBUS Data Length, and PEC.
106 @param Status Return status for the executed command.
107 This is an optional parameter and may be NULL.
108 RETURN_SUCCESS The SMBUS command was executed.
109 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
110 RETURN_DEVICE_ERROR The request was not completed because a failure
111 reflected in the Host Status Register bit. Device errors are a result
112 of a transaction collision, illegal command field, unclaimed cycle
113 (host initiated), or bus errors (collisions).
114 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
115 RETURN_UNSUPPORTED The SMBus operation is not supported.
117 @return The byte received from the SMBUS.
123 IN UINTN SmBusAddress
,
124 OUT RETURN_STATUS
*Status OPTIONAL
127 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress
) == 0);
128 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
129 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
130 if (Status
!= NULL
) {
131 *Status
= RETURN_UNSUPPORTED
;
137 Executes an SMBUS send byte command.
139 Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.
140 The byte specified by Value is sent.
141 Only the SMBUS slave address field of SmBusAddress is required. Value is returned.
142 If Status is not NULL, then the status of the executed command is returned in Status.
143 If Command in SmBusAddress is not zero, then ASSERT().
144 If Length in SmBusAddress is not zero, then ASSERT().
145 If any reserved bits of SmBusAddress are set, then ASSERT().
147 @param SmBusAddress Address that encodes the SMBUS Slave Address,
148 SMBUS Command, SMBUS Data Length, and PEC.
149 @param Value The 8-bit value to send.
150 @param Status Return status for the executed command.
151 This is an optional parameter and may be NULL.
152 RETURN_SUCCESS The SMBUS command was executed.
153 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
154 RETURN_DEVICE_ERROR The request was not completed because a failure
155 reflected in the Host Status Register bit. Device errors are a result
156 of a transaction collision, illegal command field, unclaimed cycle
157 (host initiated), or bus errors (collisions).
158 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
159 RETURN_UNSUPPORTED The SMBus operation is not supported.
161 @return The parameter of Value.
167 IN UINTN SmBusAddress
,
169 OUT RETURN_STATUS
*Status OPTIONAL
172 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress
) == 0);
173 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
174 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
175 if (Status
!= NULL
) {
176 *Status
= RETURN_UNSUPPORTED
;
182 Executes an SMBUS read data byte command.
184 Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.
185 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
186 The 8-bit value read from the SMBUS is returned.
187 If Status is not NULL, then the status of the executed command is returned in Status.
188 If Length in SmBusAddress is not zero, then ASSERT().
189 If any reserved bits of SmBusAddress are set, then ASSERT().
191 @param SmBusAddress Address that encodes the SMBUS Slave Address,
192 SMBUS Command, SMBUS Data Length, and PEC.
193 @param Status Return status for the executed command.
194 This is an optional parameter and may be NULL.
195 RETURN_SUCCESS The SMBUS command was executed.
196 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
197 RETURN_DEVICE_ERROR The request was not completed because a failure
198 reflected in the Host Status Register bit. Device errors are a result
199 of a transaction collision, illegal command field, unclaimed cycle
200 (host initiated), or bus errors (collisions).
201 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
202 RETURN_UNSUPPORTED The SMBus operation is not supported.
204 @return The byte read from the SMBUS.
210 IN UINTN SmBusAddress
,
211 OUT RETURN_STATUS
*Status OPTIONAL
214 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
215 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
216 if (Status
!= NULL
) {
217 *Status
= RETURN_UNSUPPORTED
;
223 Executes an SMBUS write data byte command.
225 Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.
226 The 8-bit value specified by Value is written.
227 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
229 If Status is not NULL, then the status of the executed command is returned in Status.
230 If Length in SmBusAddress is not zero, then ASSERT().
231 If any reserved bits of SmBusAddress are set, then ASSERT().
233 @param SmBusAddress Address that encodes the SMBUS Slave Address,
234 SMBUS Command, SMBUS Data Length, and PEC.
235 @param Value The 8-bit value to write.
236 @param Status Return status for the executed command.
237 This is an optional parameter and may be NULL.
238 RETURN_SUCCESS The SMBUS command was executed.
239 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
240 RETURN_DEVICE_ERROR The request was not completed because a failure
241 reflected in the Host Status Register bit. Device errors are a result
242 of a transaction collision, illegal command field, unclaimed cycle
243 (host initiated), or bus errors (collisions).
244 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
245 RETURN_UNSUPPORTED The SMBus operation is not supported.
247 @return The parameter of Value.
253 IN UINTN SmBusAddress
,
255 OUT RETURN_STATUS
*Status OPTIONAL
258 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
259 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
260 if (Status
!= NULL
) {
261 *Status
= RETURN_UNSUPPORTED
;
267 Executes an SMBUS read data word command.
269 Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.
270 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
271 The 16-bit value read from the SMBUS is returned.
272 If Status is not NULL, then the status of the executed command is returned in Status.
273 If Length in SmBusAddress is not zero, then ASSERT().
274 If any reserved bits of SmBusAddress are set, then ASSERT().
276 @param SmBusAddress Address that encodes the SMBUS Slave Address,
277 SMBUS Command, SMBUS Data Length, and PEC.
278 @param Status Return status for the executed command.
279 This is an optional parameter and may be NULL.
280 RETURN_SUCCESS The SMBUS command was executed.
281 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
282 RETURN_DEVICE_ERROR The request was not completed because a failure
283 reflected in the Host Status Register bit. Device errors are a result
284 of a transaction collision, illegal command field, unclaimed cycle
285 (host initiated), or bus errors (collisions).
286 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
287 RETURN_UNSUPPORTED The SMBus operation is not supported.
289 @return The byte read from the SMBUS.
295 IN UINTN SmBusAddress
,
296 OUT RETURN_STATUS
*Status OPTIONAL
299 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
300 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
301 if (Status
!= NULL
) {
302 *Status
= RETURN_UNSUPPORTED
;
308 Executes an SMBUS write data word command.
310 Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.
311 The 16-bit value specified by Value is written.
312 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
314 If Status is not NULL, then the status of the executed command is returned in Status.
315 If Length in SmBusAddress is not zero, then ASSERT().
316 If any reserved bits of SmBusAddress are set, then ASSERT().
318 @param SmBusAddress Address that encodes the SMBUS Slave Address,
319 SMBUS Command, SMBUS Data Length, and PEC.
320 @param Value The 16-bit value to write.
321 @param Status Return status for the executed command.
322 This is an optional parameter and may be NULL.
323 RETURN_SUCCESS The SMBUS command was executed.
324 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
325 RETURN_DEVICE_ERROR The request was not completed because a failure
326 reflected in the Host Status Register bit. Device errors are a result
327 of a transaction collision, illegal command field, unclaimed cycle
328 (host initiated), or bus errors (collisions).
329 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
330 RETURN_UNSUPPORTED The SMBus operation is not supported.
332 @return The parameter of Value.
338 IN UINTN SmBusAddress
,
340 OUT RETURN_STATUS
*Status OPTIONAL
343 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
344 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
345 if (Status
!= NULL
) {
346 *Status
= RETURN_UNSUPPORTED
;
352 Executes an SMBUS process call command.
354 Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.
355 The 16-bit value specified by Value is written.
356 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
357 The 16-bit value returned by the process call command is returned.
358 If Status is not NULL, then the status of the executed command is returned in Status.
359 If Length in SmBusAddress is not zero, then ASSERT().
360 If any reserved bits of SmBusAddress are set, then ASSERT().
362 @param SmBusAddress Address that encodes the SMBUS Slave Address,
363 SMBUS Command, SMBUS Data Length, and PEC.
364 @param Value The 16-bit value to write.
365 @param Status Return status for the executed command.
366 This is an optional parameter and may be NULL.
367 RETURN_SUCCESS The SMBUS command was executed.
368 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
369 RETURN_DEVICE_ERROR The request was not completed because a failure
370 reflected in the Host Status Register bit. Device errors are a result
371 of a transaction collision, illegal command field, unclaimed cycle
372 (host initiated), or bus errors (collisions).
373 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
374 RETURN_UNSUPPORTED The SMBus operation is not supported.
376 @return The 16-bit value returned by the process call command.
382 IN UINTN SmBusAddress
,
384 OUT RETURN_STATUS
*Status OPTIONAL
387 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
388 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
389 if (Status
!= NULL
) {
390 *Status
= RETURN_UNSUPPORTED
;
396 Executes an SMBUS read block command.
398 Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.
399 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
400 Bytes are read from the SMBUS and stored in Buffer.
401 The number of bytes read is returned, and will never return a value larger than 32-bytes.
402 If Status is not NULL, then the status of the executed command is returned in Status.
403 It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
404 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
405 If Length in SmBusAddress is not zero, then ASSERT().
406 If Buffer is NULL, then ASSERT().
407 If any reserved bits of SmBusAddress are set, then ASSERT().
409 @param SmBusAddress Address that encodes the SMBUS Slave Address,
410 SMBUS Command, SMBUS Data Length, and PEC.
411 @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
412 @param Status Return status for the executed command.
413 This is an optional parameter and may be NULL.
414 RETURN_SUCCESS The SMBUS command was executed.
415 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
416 RETURN_DEVICE_ERROR The request was not completed because a failure
417 reflected in the Host Status Register bit. Device errors are a result
418 of a transaction collision, illegal command field, unclaimed cycle
419 (host initiated), or bus errors (collisions).
420 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
421 RETURN_UNSUPPORTED The SMBus operation is not supported.
423 @return The number of bytes read.
429 IN UINTN SmBusAddress
,
431 OUT RETURN_STATUS
*Status OPTIONAL
434 ASSERT (Buffer
!= NULL
);
435 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
436 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
437 if (Status
!= NULL
) {
438 *Status
= RETURN_UNSUPPORTED
;
444 Executes an SMBUS write block command.
446 Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.
447 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
448 Bytes are written to the SMBUS from Buffer.
449 The number of bytes written is returned, and will never return a value larger than 32-bytes.
450 If Status is not NULL, then the status of the executed command is returned in Status.
451 If Length in SmBusAddress is zero or greater than 32, then ASSERT().
452 If Buffer is NULL, then ASSERT().
453 If any reserved bits of SmBusAddress are set, then ASSERT().
455 @param SmBusAddress Address that encodes the SMBUS Slave Address,
456 SMBUS Command, SMBUS Data Length, and PEC.
457 @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
458 @param Status Return status for the executed command.
459 This is an optional parameter and may be NULL.
460 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
461 RETURN_DEVICE_ERROR The request was not completed because a failure
462 reflected in the Host Status Register bit. Device errors are a result
463 of a transaction collision, illegal command field, unclaimed cycle
464 (host initiated), or bus errors (collisions).
465 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
466 RETURN_UNSUPPORTED The SMBus operation is not supported.
468 @return The number of bytes written.
474 IN UINTN SmBusAddress
,
476 OUT RETURN_STATUS
*Status OPTIONAL
479 ASSERT (Buffer
!= NULL
);
480 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) >= 1);
481 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) <= 32);
482 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
483 if (Status
!= NULL
) {
484 *Status
= RETURN_UNSUPPORTED
;
490 Executes an SMBUS block process call command.
492 Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.
493 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
494 Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer.
495 If Status is not NULL, then the status of the executed command is returned in Status.
496 It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.
497 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
498 If Length in SmBusAddress is zero or greater than 32, then ASSERT().
499 If WriteBuffer is NULL, then ASSERT().
500 If ReadBuffer is NULL, then ASSERT().
501 If any reserved bits of SmBusAddress are set, then ASSERT().
503 @param SmBusAddress Address that encodes the SMBUS Slave Address,
504 SMBUS Command, SMBUS Data Length, and PEC.
505 @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS.
506 @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS.
507 @param Status Return status for the executed command.
508 This is an optional parameter and may be NULL.
509 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
510 RETURN_DEVICE_ERROR The request was not completed because a failure
511 reflected in the Host Status Register bit. Device errors are a result
512 of a transaction collision, illegal command field, unclaimed cycle
513 (host initiated), or bus errors (collisions).
514 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
515 RETURN_UNSUPPORTED The SMBus operation is not supported.
517 @return The number of bytes written.
522 SmBusBlockProcessCall (
523 IN UINTN SmBusAddress
,
524 IN VOID
*WriteBuffer
,
525 OUT VOID
*ReadBuffer
,
526 OUT RETURN_STATUS
*Status OPTIONAL
529 ASSERT (WriteBuffer
!= NULL
);
530 ASSERT (ReadBuffer
!= NULL
);
531 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) >= 1);
532 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) <= 32);
533 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
534 if (Status
!= NULL
) {
535 *Status
= RETURN_UNSUPPORTED
;