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 |
|
---|
134 | return 0;
|
---|
135 | }
|
---|
136 |
|
---|
137 | /**
|
---|
138 | Executes an SMBUS send byte command.
|
---|
139 |
|
---|
140 | Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.
|
---|
141 | The byte specified by Value is sent.
|
---|
142 | Only the SMBUS slave address field of SmBusAddress is required. Value is returned.
|
---|
143 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
144 | If Command in SmBusAddress is not zero, then ASSERT().
|
---|
145 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
146 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
147 |
|
---|
148 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
149 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
150 | @param Value The 8-bit value to send.
|
---|
151 | @param Status Return status for the executed command.
|
---|
152 | This is an optional parameter and may be NULL.
|
---|
153 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
154 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
155 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
156 | reflected in the Host Status Register bit. Device errors are a result
|
---|
157 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
158 | (host initiated), or bus errors (collisions).
|
---|
159 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
160 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
161 |
|
---|
162 | @return The parameter of Value.
|
---|
163 |
|
---|
164 | **/
|
---|
165 | UINT8
|
---|
166 | EFIAPI
|
---|
167 | SmBusSendByte (
|
---|
168 | IN UINTN SmBusAddress,
|
---|
169 | IN UINT8 Value,
|
---|
170 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
171 | )
|
---|
172 | {
|
---|
173 | ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
|
---|
174 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
175 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
176 | if (Status != NULL) {
|
---|
177 | *Status = RETURN_UNSUPPORTED;
|
---|
178 | }
|
---|
179 |
|
---|
180 | return 0;
|
---|
181 | }
|
---|
182 |
|
---|
183 | /**
|
---|
184 | Executes an SMBUS read data byte command.
|
---|
185 |
|
---|
186 | Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.
|
---|
187 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
|
---|
188 | The 8-bit value read from the SMBUS is returned.
|
---|
189 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
190 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
191 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
192 |
|
---|
193 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
194 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
195 | @param Status Return status for the executed command.
|
---|
196 | This is an optional parameter and may be NULL.
|
---|
197 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
198 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
199 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
200 | reflected in the Host Status Register bit. Device errors are a result
|
---|
201 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
202 | (host initiated), or bus errors (collisions).
|
---|
203 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
204 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
205 |
|
---|
206 | @return The byte read from the SMBUS.
|
---|
207 |
|
---|
208 | **/
|
---|
209 | UINT8
|
---|
210 | EFIAPI
|
---|
211 | SmBusReadDataByte (
|
---|
212 | IN UINTN SmBusAddress,
|
---|
213 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
214 | )
|
---|
215 | {
|
---|
216 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
217 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
218 | if (Status != NULL) {
|
---|
219 | *Status = RETURN_UNSUPPORTED;
|
---|
220 | }
|
---|
221 |
|
---|
222 | return 0;
|
---|
223 | }
|
---|
224 |
|
---|
225 | /**
|
---|
226 | Executes an SMBUS write data byte command.
|
---|
227 |
|
---|
228 | Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.
|
---|
229 | The 8-bit value specified by Value is written.
|
---|
230 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
|
---|
231 | Value is returned.
|
---|
232 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
233 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
234 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
235 |
|
---|
236 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
237 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
238 | @param Value The 8-bit value to write.
|
---|
239 | @param Status Return status for the executed command.
|
---|
240 | This is an optional parameter and may be NULL.
|
---|
241 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
242 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
243 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
244 | reflected in the Host Status Register bit. Device errors are a result
|
---|
245 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
246 | (host initiated), or bus errors (collisions).
|
---|
247 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
248 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
249 |
|
---|
250 | @return The parameter of Value.
|
---|
251 |
|
---|
252 | **/
|
---|
253 | UINT8
|
---|
254 | EFIAPI
|
---|
255 | SmBusWriteDataByte (
|
---|
256 | IN UINTN SmBusAddress,
|
---|
257 | IN UINT8 Value,
|
---|
258 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
259 | )
|
---|
260 | {
|
---|
261 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
262 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
263 | if (Status != NULL) {
|
---|
264 | *Status = RETURN_UNSUPPORTED;
|
---|
265 | }
|
---|
266 |
|
---|
267 | return 0;
|
---|
268 | }
|
---|
269 |
|
---|
270 | /**
|
---|
271 | Executes an SMBUS read data word command.
|
---|
272 |
|
---|
273 | Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.
|
---|
274 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
|
---|
275 | The 16-bit value read from the SMBUS is returned.
|
---|
276 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
277 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
278 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
279 |
|
---|
280 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
281 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
282 | @param Status Return status for the executed command.
|
---|
283 | This is an optional parameter and may be NULL.
|
---|
284 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
285 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
286 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
287 | reflected in the Host Status Register bit. Device errors are a result
|
---|
288 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
289 | (host initiated), or bus errors (collisions).
|
---|
290 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
291 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
292 |
|
---|
293 | @return The byte read from the SMBUS.
|
---|
294 |
|
---|
295 | **/
|
---|
296 | UINT16
|
---|
297 | EFIAPI
|
---|
298 | SmBusReadDataWord (
|
---|
299 | IN UINTN SmBusAddress,
|
---|
300 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
301 | )
|
---|
302 | {
|
---|
303 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
304 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
305 | if (Status != NULL) {
|
---|
306 | *Status = RETURN_UNSUPPORTED;
|
---|
307 | }
|
---|
308 |
|
---|
309 | return 0;
|
---|
310 | }
|
---|
311 |
|
---|
312 | /**
|
---|
313 | Executes an SMBUS write data word command.
|
---|
314 |
|
---|
315 | Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.
|
---|
316 | The 16-bit value specified by Value is written.
|
---|
317 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
|
---|
318 | Value is returned.
|
---|
319 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
320 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
321 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
322 |
|
---|
323 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
324 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
325 | @param Value The 16-bit value to write.
|
---|
326 | @param Status Return status for the executed command.
|
---|
327 | This is an optional parameter and may be NULL.
|
---|
328 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
329 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
330 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
331 | reflected in the Host Status Register bit. Device errors are a result
|
---|
332 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
333 | (host initiated), or bus errors (collisions).
|
---|
334 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
335 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
336 |
|
---|
337 | @return The parameter of Value.
|
---|
338 |
|
---|
339 | **/
|
---|
340 | UINT16
|
---|
341 | EFIAPI
|
---|
342 | SmBusWriteDataWord (
|
---|
343 | IN UINTN SmBusAddress,
|
---|
344 | IN UINT16 Value,
|
---|
345 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
346 | )
|
---|
347 | {
|
---|
348 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
349 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
350 | if (Status != NULL) {
|
---|
351 | *Status = RETURN_UNSUPPORTED;
|
---|
352 | }
|
---|
353 |
|
---|
354 | return 0;
|
---|
355 | }
|
---|
356 |
|
---|
357 | /**
|
---|
358 | Executes an SMBUS process call command.
|
---|
359 |
|
---|
360 | Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.
|
---|
361 | The 16-bit value specified by Value is written.
|
---|
362 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
|
---|
363 | The 16-bit value returned by the process call command is returned.
|
---|
364 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
365 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
366 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
367 |
|
---|
368 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
369 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
370 | @param Value The 16-bit value to write.
|
---|
371 | @param Status Return status for the executed command.
|
---|
372 | This is an optional parameter and may be NULL.
|
---|
373 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
374 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
375 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
376 | reflected in the Host Status Register bit. Device errors are a result
|
---|
377 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
378 | (host initiated), or bus errors (collisions).
|
---|
379 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
380 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
381 |
|
---|
382 | @return The 16-bit value returned by the process call command.
|
---|
383 |
|
---|
384 | **/
|
---|
385 | UINT16
|
---|
386 | EFIAPI
|
---|
387 | SmBusProcessCall (
|
---|
388 | IN UINTN SmBusAddress,
|
---|
389 | IN UINT16 Value,
|
---|
390 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
391 | )
|
---|
392 | {
|
---|
393 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
394 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
395 | if (Status != NULL) {
|
---|
396 | *Status = RETURN_UNSUPPORTED;
|
---|
397 | }
|
---|
398 |
|
---|
399 | return 0;
|
---|
400 | }
|
---|
401 |
|
---|
402 | /**
|
---|
403 | Executes an SMBUS read block command.
|
---|
404 |
|
---|
405 | Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.
|
---|
406 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
|
---|
407 | Bytes are read from the SMBUS and stored in Buffer.
|
---|
408 | The number of bytes read is returned, and will never return a value larger than 32-bytes.
|
---|
409 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
410 | It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
|
---|
411 | SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
|
---|
412 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
413 | If Buffer is NULL, then ASSERT().
|
---|
414 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
415 |
|
---|
416 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
417 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
418 | @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
|
---|
419 | @param Status Return status for the executed command.
|
---|
420 | This is an optional parameter and may be NULL.
|
---|
421 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
422 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
423 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
424 | reflected in the Host Status Register bit. Device errors are a result
|
---|
425 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
426 | (host initiated), or bus errors (collisions).
|
---|
427 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
428 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
429 |
|
---|
430 | @return The number of bytes read.
|
---|
431 |
|
---|
432 | **/
|
---|
433 | UINTN
|
---|
434 | EFIAPI
|
---|
435 | SmBusReadBlock (
|
---|
436 | IN UINTN SmBusAddress,
|
---|
437 | OUT VOID *Buffer,
|
---|
438 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
439 | )
|
---|
440 | {
|
---|
441 | ASSERT (Buffer != NULL);
|
---|
442 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
443 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
444 | if (Status != NULL) {
|
---|
445 | *Status = RETURN_UNSUPPORTED;
|
---|
446 | }
|
---|
447 |
|
---|
448 | return 0;
|
---|
449 | }
|
---|
450 |
|
---|
451 | /**
|
---|
452 | Executes an SMBUS write block command.
|
---|
453 |
|
---|
454 | Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.
|
---|
455 | The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
|
---|
456 | Bytes are written to the SMBUS from Buffer.
|
---|
457 | The number of bytes written is returned, and will never return a value larger than 32-bytes.
|
---|
458 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
459 | If Length in SmBusAddress is zero or greater than 32, then ASSERT().
|
---|
460 | If Buffer is NULL, then ASSERT().
|
---|
461 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
462 |
|
---|
463 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
464 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
465 | @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
|
---|
466 | @param Status Return status for the executed command.
|
---|
467 | This is an optional parameter and may be NULL.
|
---|
468 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
469 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
470 | reflected in the Host Status Register bit. Device errors are a result
|
---|
471 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
472 | (host initiated), or bus errors (collisions).
|
---|
473 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
474 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
475 |
|
---|
476 | @return The number of bytes written.
|
---|
477 |
|
---|
478 | **/
|
---|
479 | UINTN
|
---|
480 | EFIAPI
|
---|
481 | SmBusWriteBlock (
|
---|
482 | IN UINTN SmBusAddress,
|
---|
483 | OUT VOID *Buffer,
|
---|
484 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
485 | )
|
---|
486 | {
|
---|
487 | ASSERT (Buffer != NULL);
|
---|
488 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
|
---|
489 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
|
---|
490 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
491 | if (Status != NULL) {
|
---|
492 | *Status = RETURN_UNSUPPORTED;
|
---|
493 | }
|
---|
494 |
|
---|
495 | return 0;
|
---|
496 | }
|
---|
497 |
|
---|
498 | /**
|
---|
499 | Executes an SMBUS block process call command.
|
---|
500 |
|
---|
501 | Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.
|
---|
502 | The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
|
---|
503 | Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer.
|
---|
504 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
505 | It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.
|
---|
506 | SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
|
---|
507 | If Length in SmBusAddress is zero or greater than 32, then ASSERT().
|
---|
508 | If WriteBuffer is NULL, then ASSERT().
|
---|
509 | If ReadBuffer is NULL, then ASSERT().
|
---|
510 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
511 |
|
---|
512 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
513 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
514 | @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS.
|
---|
515 | @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS.
|
---|
516 | @param Status Return status for the executed command.
|
---|
517 | This is an optional parameter and may be NULL.
|
---|
518 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
519 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
520 | reflected in the Host Status Register bit. Device errors are a result
|
---|
521 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
522 | (host initiated), or bus errors (collisions).
|
---|
523 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
524 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
525 |
|
---|
526 | @return The number of bytes written.
|
---|
527 |
|
---|
528 | **/
|
---|
529 | UINTN
|
---|
530 | EFIAPI
|
---|
531 | SmBusBlockProcessCall (
|
---|
532 | IN UINTN SmBusAddress,
|
---|
533 | IN VOID *WriteBuffer,
|
---|
534 | OUT VOID *ReadBuffer,
|
---|
535 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
536 | )
|
---|
537 | {
|
---|
538 | ASSERT (WriteBuffer != NULL);
|
---|
539 | ASSERT (ReadBuffer != NULL);
|
---|
540 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
|
---|
541 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
|
---|
542 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
543 | if (Status != NULL) {
|
---|
544 | *Status = RETURN_UNSUPPORTED;
|
---|
545 | }
|
---|
546 |
|
---|
547 | return 0;
|
---|
548 | }
|
---|