1 | /** @file
|
---|
2 | Null implementation of SmBusLib class library.
|
---|
3 |
|
---|
4 | Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #include <Base.h>
|
---|
10 | #include <Library/SmbusLib.h>
|
---|
11 | #include <Library/DebugLib.h>
|
---|
12 |
|
---|
13 | /**
|
---|
14 | Executes an SMBUS quick read command.
|
---|
15 |
|
---|
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().
|
---|
23 |
|
---|
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.
|
---|
35 |
|
---|
36 | **/
|
---|
37 | VOID
|
---|
38 | EFIAPI
|
---|
39 | SmBusQuickRead (
|
---|
40 | IN UINTN SmBusAddress,
|
---|
41 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
42 | )
|
---|
43 | {
|
---|
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);
|
---|
48 | if (Status != NULL) {
|
---|
49 | *Status = RETURN_UNSUPPORTED;
|
---|
50 | }
|
---|
51 | }
|
---|
52 |
|
---|
53 | /**
|
---|
54 | Executes an SMBUS quick write command.
|
---|
55 |
|
---|
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().
|
---|
63 |
|
---|
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.
|
---|
75 |
|
---|
76 | **/
|
---|
77 | VOID
|
---|
78 | EFIAPI
|
---|
79 | SmBusQuickWrite (
|
---|
80 | IN UINTN SmBusAddress,
|
---|
81 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
82 | )
|
---|
83 | {
|
---|
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);
|
---|
88 | if (Status != NULL) {
|
---|
89 | *Status = RETURN_UNSUPPORTED;
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|
93 | /**
|
---|
94 | Executes an SMBUS receive byte command.
|
---|
95 |
|
---|
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().
|
---|
103 |
|
---|
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.
|
---|
116 |
|
---|
117 | @return The byte received from the SMBUS.
|
---|
118 |
|
---|
119 | **/
|
---|
120 | UINT8
|
---|
121 | EFIAPI
|
---|
122 | SmBusReceiveByte (
|
---|
123 | IN UINTN SmBusAddress,
|
---|
124 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
125 | )
|
---|
126 | {
|
---|
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;
|
---|
132 | }
|
---|
133 | return 0;
|
---|
134 | }
|
---|
135 |
|
---|
136 | /**
|
---|
137 | Executes an SMBUS send byte command.
|
---|
138 |
|
---|
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().
|
---|
146 |
|
---|
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.
|
---|
160 |
|
---|
161 | @return The parameter of Value.
|
---|
162 |
|
---|
163 | **/
|
---|
164 | UINT8
|
---|
165 | EFIAPI
|
---|
166 | SmBusSendByte (
|
---|
167 | IN UINTN SmBusAddress,
|
---|
168 | IN UINT8 Value,
|
---|
169 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
170 | )
|
---|
171 | {
|
---|
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;
|
---|
177 | }
|
---|
178 | return 0;
|
---|
179 | }
|
---|
180 |
|
---|
181 | /**
|
---|
182 | Executes an SMBUS read data byte command.
|
---|
183 |
|
---|
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().
|
---|
190 |
|
---|
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.
|
---|
203 |
|
---|
204 | @return The byte read from the SMBUS.
|
---|
205 |
|
---|
206 | **/
|
---|
207 | UINT8
|
---|
208 | EFIAPI
|
---|
209 | SmBusReadDataByte (
|
---|
210 | IN UINTN SmBusAddress,
|
---|
211 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
212 | )
|
---|
213 | {
|
---|
214 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
215 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
216 | if (Status != NULL) {
|
---|
217 | *Status = RETURN_UNSUPPORTED;
|
---|
218 | }
|
---|
219 | return 0;
|
---|
220 | }
|
---|
221 |
|
---|
222 | /**
|
---|
223 | Executes an SMBUS write data byte command.
|
---|
224 |
|
---|
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.
|
---|
228 | Value is returned.
|
---|
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().
|
---|
232 |
|
---|
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.
|
---|
246 |
|
---|
247 | @return The parameter of Value.
|
---|
248 |
|
---|
249 | **/
|
---|
250 | UINT8
|
---|
251 | EFIAPI
|
---|
252 | SmBusWriteDataByte (
|
---|
253 | IN UINTN SmBusAddress,
|
---|
254 | IN UINT8 Value,
|
---|
255 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
256 | )
|
---|
257 | {
|
---|
258 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
259 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
260 | if (Status != NULL) {
|
---|
261 | *Status = RETURN_UNSUPPORTED;
|
---|
262 | }
|
---|
263 | return 0;
|
---|
264 | }
|
---|
265 |
|
---|
266 | /**
|
---|
267 | Executes an SMBUS read data word command.
|
---|
268 |
|
---|
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().
|
---|
275 |
|
---|
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.
|
---|
288 |
|
---|
289 | @return The byte read from the SMBUS.
|
---|
290 |
|
---|
291 | **/
|
---|
292 | UINT16
|
---|
293 | EFIAPI
|
---|
294 | SmBusReadDataWord (
|
---|
295 | IN UINTN SmBusAddress,
|
---|
296 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
297 | )
|
---|
298 | {
|
---|
299 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
300 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
301 | if (Status != NULL) {
|
---|
302 | *Status = RETURN_UNSUPPORTED;
|
---|
303 | }
|
---|
304 | return 0;
|
---|
305 | }
|
---|
306 |
|
---|
307 | /**
|
---|
308 | Executes an SMBUS write data word command.
|
---|
309 |
|
---|
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.
|
---|
313 | Value is returned.
|
---|
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().
|
---|
317 |
|
---|
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.
|
---|
331 |
|
---|
332 | @return The parameter of Value.
|
---|
333 |
|
---|
334 | **/
|
---|
335 | UINT16
|
---|
336 | EFIAPI
|
---|
337 | SmBusWriteDataWord (
|
---|
338 | IN UINTN SmBusAddress,
|
---|
339 | IN UINT16 Value,
|
---|
340 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
341 | )
|
---|
342 | {
|
---|
343 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
344 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
345 | if (Status != NULL) {
|
---|
346 | *Status = RETURN_UNSUPPORTED;
|
---|
347 | }
|
---|
348 | return 0;
|
---|
349 | }
|
---|
350 |
|
---|
351 | /**
|
---|
352 | Executes an SMBUS process call command.
|
---|
353 |
|
---|
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().
|
---|
361 |
|
---|
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.
|
---|
375 |
|
---|
376 | @return The 16-bit value returned by the process call command.
|
---|
377 |
|
---|
378 | **/
|
---|
379 | UINT16
|
---|
380 | EFIAPI
|
---|
381 | SmBusProcessCall (
|
---|
382 | IN UINTN SmBusAddress,
|
---|
383 | IN UINT16 Value,
|
---|
384 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
385 | )
|
---|
386 | {
|
---|
387 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
388 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
389 | if (Status != NULL) {
|
---|
390 | *Status = RETURN_UNSUPPORTED;
|
---|
391 | }
|
---|
392 | return 0;
|
---|
393 | }
|
---|
394 |
|
---|
395 | /**
|
---|
396 | Executes an SMBUS read block command.
|
---|
397 |
|
---|
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().
|
---|
408 |
|
---|
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.
|
---|
422 |
|
---|
423 | @return The number of bytes read.
|
---|
424 |
|
---|
425 | **/
|
---|
426 | UINTN
|
---|
427 | EFIAPI
|
---|
428 | SmBusReadBlock (
|
---|
429 | IN UINTN SmBusAddress,
|
---|
430 | OUT VOID *Buffer,
|
---|
431 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
432 | )
|
---|
433 | {
|
---|
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;
|
---|
439 | }
|
---|
440 | return 0;
|
---|
441 | }
|
---|
442 |
|
---|
443 | /**
|
---|
444 | Executes an SMBUS write block command.
|
---|
445 |
|
---|
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().
|
---|
454 |
|
---|
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.
|
---|
467 |
|
---|
468 | @return The number of bytes written.
|
---|
469 |
|
---|
470 | **/
|
---|
471 | UINTN
|
---|
472 | EFIAPI
|
---|
473 | SmBusWriteBlock (
|
---|
474 | IN UINTN SmBusAddress,
|
---|
475 | OUT VOID *Buffer,
|
---|
476 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
477 | )
|
---|
478 | {
|
---|
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;
|
---|
485 | }
|
---|
486 | return 0;
|
---|
487 | }
|
---|
488 |
|
---|
489 | /**
|
---|
490 | Executes an SMBUS block process call command.
|
---|
491 |
|
---|
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().
|
---|
502 |
|
---|
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.
|
---|
516 |
|
---|
517 | @return The number of bytes written.
|
---|
518 |
|
---|
519 | **/
|
---|
520 | UINTN
|
---|
521 | EFIAPI
|
---|
522 | SmBusBlockProcessCall (
|
---|
523 | IN UINTN SmBusAddress,
|
---|
524 | IN VOID *WriteBuffer,
|
---|
525 | OUT VOID *ReadBuffer,
|
---|
526 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
527 | )
|
---|
528 | {
|
---|
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;
|
---|
536 | }
|
---|
537 | return 0;
|
---|
538 | }
|
---|