1 | /** @file
|
---|
2 | Null implementation of SmBusLib class library.
|
---|
3 |
|
---|
4 | Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
|
---|
5 | This program and the accompanying materials
|
---|
6 | are licensed and made available under the terms and conditions of the BSD License
|
---|
7 | which accompanies this distribution. The full text of the license may be found at
|
---|
8 | http://opensource.org/licenses/bsd-license.php.
|
---|
9 |
|
---|
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
12 |
|
---|
13 | **/
|
---|
14 |
|
---|
15 | #include <Base.h>
|
---|
16 | #include <Library/SmbusLib.h>
|
---|
17 | #include <Library/DebugLib.h>
|
---|
18 |
|
---|
19 | /**
|
---|
20 | Executes an SMBUS quick read command.
|
---|
21 |
|
---|
22 | Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.
|
---|
23 | Only the SMBUS slave address field of SmBusAddress is required.
|
---|
24 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
25 | If PEC is set in SmBusAddress, then ASSERT().
|
---|
26 | If Command in SmBusAddress is not zero, then ASSERT().
|
---|
27 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
28 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
29 |
|
---|
30 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
31 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
32 | @param Status Return status for the executed command.
|
---|
33 | This is an optional parameter and may be NULL.
|
---|
34 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
35 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
36 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
37 | reflected in the Host Status Register bit. Device errors are a result
|
---|
38 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
39 | (host initiated), or bus errors (collisions).
|
---|
40 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
41 |
|
---|
42 | **/
|
---|
43 | VOID
|
---|
44 | EFIAPI
|
---|
45 | SmBusQuickRead (
|
---|
46 | IN UINTN SmBusAddress,
|
---|
47 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
48 | )
|
---|
49 | {
|
---|
50 | ASSERT (!SMBUS_LIB_PEC (SmBusAddress));
|
---|
51 | ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
|
---|
52 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
53 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
54 | if (Status != NULL) {
|
---|
55 | *Status = RETURN_UNSUPPORTED;
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | /**
|
---|
60 | Executes an SMBUS quick write command.
|
---|
61 |
|
---|
62 | Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.
|
---|
63 | Only the SMBUS slave address field of SmBusAddress is required.
|
---|
64 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
65 | If PEC is set in SmBusAddress, then ASSERT().
|
---|
66 | If Command in SmBusAddress is not zero, then ASSERT().
|
---|
67 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
68 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
69 |
|
---|
70 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
71 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
72 | @param Status Return status for the executed command.
|
---|
73 | This is an optional parameter and may be NULL.
|
---|
74 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
75 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
76 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
77 | reflected in the Host Status Register bit. Device errors are a result
|
---|
78 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
79 | (host initiated), or bus errors (collisions).
|
---|
80 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
81 |
|
---|
82 | **/
|
---|
83 | VOID
|
---|
84 | EFIAPI
|
---|
85 | SmBusQuickWrite (
|
---|
86 | IN UINTN SmBusAddress,
|
---|
87 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
88 | )
|
---|
89 | {
|
---|
90 | ASSERT (!SMBUS_LIB_PEC (SmBusAddress));
|
---|
91 | ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
|
---|
92 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
93 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
94 | if (Status != NULL) {
|
---|
95 | *Status = RETURN_UNSUPPORTED;
|
---|
96 | }
|
---|
97 | }
|
---|
98 |
|
---|
99 | /**
|
---|
100 | Executes an SMBUS receive byte command.
|
---|
101 |
|
---|
102 | Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.
|
---|
103 | Only the SMBUS slave address field of SmBusAddress is required.
|
---|
104 | The byte received from the SMBUS is returned.
|
---|
105 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
106 | If Command in SmBusAddress is not zero, then ASSERT().
|
---|
107 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
108 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
109 |
|
---|
110 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
111 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
112 | @param Status Return status for the executed command.
|
---|
113 | This is an optional parameter and may be NULL.
|
---|
114 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
115 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
116 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
117 | reflected in the Host Status Register bit. Device errors are a result
|
---|
118 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
119 | (host initiated), or bus errors (collisions).
|
---|
120 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
121 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
122 |
|
---|
123 | @return The byte received from the SMBUS.
|
---|
124 |
|
---|
125 | **/
|
---|
126 | UINT8
|
---|
127 | EFIAPI
|
---|
128 | SmBusReceiveByte (
|
---|
129 | IN UINTN SmBusAddress,
|
---|
130 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
131 | )
|
---|
132 | {
|
---|
133 | ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
|
---|
134 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
135 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
136 | if (Status != NULL) {
|
---|
137 | *Status = RETURN_UNSUPPORTED;
|
---|
138 | }
|
---|
139 | return 0;
|
---|
140 | }
|
---|
141 |
|
---|
142 | /**
|
---|
143 | Executes an SMBUS send byte command.
|
---|
144 |
|
---|
145 | Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.
|
---|
146 | The byte specified by Value is sent.
|
---|
147 | Only the SMBUS slave address field of SmBusAddress is required. Value is returned.
|
---|
148 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
149 | If Command in SmBusAddress is not zero, then ASSERT().
|
---|
150 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
151 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
152 |
|
---|
153 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
154 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
155 | @param Value The 8-bit value to send.
|
---|
156 | @param Status Return status for the executed command.
|
---|
157 | This is an optional parameter and may be NULL.
|
---|
158 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
159 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
160 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
161 | reflected in the Host Status Register bit. Device errors are a result
|
---|
162 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
163 | (host initiated), or bus errors (collisions).
|
---|
164 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
165 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
166 |
|
---|
167 | @return The parameter of Value.
|
---|
168 |
|
---|
169 | **/
|
---|
170 | UINT8
|
---|
171 | EFIAPI
|
---|
172 | SmBusSendByte (
|
---|
173 | IN UINTN SmBusAddress,
|
---|
174 | IN UINT8 Value,
|
---|
175 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
176 | )
|
---|
177 | {
|
---|
178 | ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
|
---|
179 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
180 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
181 | if (Status != NULL) {
|
---|
182 | *Status = RETURN_UNSUPPORTED;
|
---|
183 | }
|
---|
184 | return 0;
|
---|
185 | }
|
---|
186 |
|
---|
187 | /**
|
---|
188 | Executes an SMBUS read data byte command.
|
---|
189 |
|
---|
190 | Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.
|
---|
191 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
|
---|
192 | The 8-bit value read from the SMBUS is returned.
|
---|
193 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
194 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
195 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
196 |
|
---|
197 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
198 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
199 | @param Status Return status for the executed command.
|
---|
200 | This is an optional parameter and may be NULL.
|
---|
201 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
202 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
203 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
204 | reflected in the Host Status Register bit. Device errors are a result
|
---|
205 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
206 | (host initiated), or bus errors (collisions).
|
---|
207 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
208 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
209 |
|
---|
210 | @return The byte read from the SMBUS.
|
---|
211 |
|
---|
212 | **/
|
---|
213 | UINT8
|
---|
214 | EFIAPI
|
---|
215 | SmBusReadDataByte (
|
---|
216 | IN UINTN SmBusAddress,
|
---|
217 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
218 | )
|
---|
219 | {
|
---|
220 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
221 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
222 | if (Status != NULL) {
|
---|
223 | *Status = RETURN_UNSUPPORTED;
|
---|
224 | }
|
---|
225 | return 0;
|
---|
226 | }
|
---|
227 |
|
---|
228 | /**
|
---|
229 | Executes an SMBUS write data byte command.
|
---|
230 |
|
---|
231 | Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.
|
---|
232 | The 8-bit value specified by Value is written.
|
---|
233 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
|
---|
234 | Value is returned.
|
---|
235 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
236 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
237 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
238 |
|
---|
239 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
240 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
241 | @param Value The 8-bit value to write.
|
---|
242 | @param Status Return status for the executed command.
|
---|
243 | This is an optional parameter and may be NULL.
|
---|
244 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
245 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
246 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
247 | reflected in the Host Status Register bit. Device errors are a result
|
---|
248 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
249 | (host initiated), or bus errors (collisions).
|
---|
250 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
251 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
252 |
|
---|
253 | @return The parameter of Value.
|
---|
254 |
|
---|
255 | **/
|
---|
256 | UINT8
|
---|
257 | EFIAPI
|
---|
258 | SmBusWriteDataByte (
|
---|
259 | IN UINTN SmBusAddress,
|
---|
260 | IN UINT8 Value,
|
---|
261 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
262 | )
|
---|
263 | {
|
---|
264 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
265 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
266 | if (Status != NULL) {
|
---|
267 | *Status = RETURN_UNSUPPORTED;
|
---|
268 | }
|
---|
269 | return 0;
|
---|
270 | }
|
---|
271 |
|
---|
272 | /**
|
---|
273 | Executes an SMBUS read data word command.
|
---|
274 |
|
---|
275 | Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.
|
---|
276 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
|
---|
277 | The 16-bit value read from the SMBUS is returned.
|
---|
278 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
279 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
280 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
281 |
|
---|
282 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
283 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
284 | @param Status Return status for the executed command.
|
---|
285 | This is an optional parameter and may be NULL.
|
---|
286 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
287 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
288 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
289 | reflected in the Host Status Register bit. Device errors are a result
|
---|
290 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
291 | (host initiated), or bus errors (collisions).
|
---|
292 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
293 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
294 |
|
---|
295 | @return The byte read from the SMBUS.
|
---|
296 |
|
---|
297 | **/
|
---|
298 | UINT16
|
---|
299 | EFIAPI
|
---|
300 | SmBusReadDataWord (
|
---|
301 | IN UINTN SmBusAddress,
|
---|
302 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
303 | )
|
---|
304 | {
|
---|
305 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
306 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
307 | if (Status != NULL) {
|
---|
308 | *Status = RETURN_UNSUPPORTED;
|
---|
309 | }
|
---|
310 | return 0;
|
---|
311 | }
|
---|
312 |
|
---|
313 | /**
|
---|
314 | Executes an SMBUS write data word command.
|
---|
315 |
|
---|
316 | Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.
|
---|
317 | The 16-bit value specified by Value is written.
|
---|
318 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
|
---|
319 | Value is returned.
|
---|
320 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
321 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
322 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
323 |
|
---|
324 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
325 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
326 | @param Value The 16-bit value to write.
|
---|
327 | @param Status Return status for the executed command.
|
---|
328 | This is an optional parameter and may be NULL.
|
---|
329 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
330 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
331 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
332 | reflected in the Host Status Register bit. Device errors are a result
|
---|
333 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
334 | (host initiated), or bus errors (collisions).
|
---|
335 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
336 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
337 |
|
---|
338 | @return The parameter of Value.
|
---|
339 |
|
---|
340 | **/
|
---|
341 | UINT16
|
---|
342 | EFIAPI
|
---|
343 | SmBusWriteDataWord (
|
---|
344 | IN UINTN SmBusAddress,
|
---|
345 | IN UINT16 Value,
|
---|
346 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
347 | )
|
---|
348 | {
|
---|
349 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
350 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
351 | if (Status != NULL) {
|
---|
352 | *Status = RETURN_UNSUPPORTED;
|
---|
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 | return 0;
|
---|
399 | }
|
---|
400 |
|
---|
401 | /**
|
---|
402 | Executes an SMBUS read block command.
|
---|
403 |
|
---|
404 | Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.
|
---|
405 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
|
---|
406 | Bytes are read from the SMBUS and stored in Buffer.
|
---|
407 | The number of bytes read is returned, and will never return a value larger than 32-bytes.
|
---|
408 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
409 | It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
|
---|
410 | SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
|
---|
411 | If Length in SmBusAddress is not zero, then ASSERT().
|
---|
412 | If Buffer is NULL, then ASSERT().
|
---|
413 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
414 |
|
---|
415 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
416 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
417 | @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
|
---|
418 | @param Status Return status for the executed command.
|
---|
419 | This is an optional parameter and may be NULL.
|
---|
420 | RETURN_SUCCESS The SMBUS command was executed.
|
---|
421 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
422 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
423 | reflected in the Host Status Register bit. Device errors are a result
|
---|
424 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
425 | (host initiated), or bus errors (collisions).
|
---|
426 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
427 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
428 |
|
---|
429 | @return The number of bytes read.
|
---|
430 |
|
---|
431 | **/
|
---|
432 | UINTN
|
---|
433 | EFIAPI
|
---|
434 | SmBusReadBlock (
|
---|
435 | IN UINTN SmBusAddress,
|
---|
436 | OUT VOID *Buffer,
|
---|
437 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
438 | )
|
---|
439 | {
|
---|
440 | ASSERT (Buffer != NULL);
|
---|
441 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
|
---|
442 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
443 | if (Status != NULL) {
|
---|
444 | *Status = RETURN_UNSUPPORTED;
|
---|
445 | }
|
---|
446 | return 0;
|
---|
447 | }
|
---|
448 |
|
---|
449 | /**
|
---|
450 | Executes an SMBUS write block command.
|
---|
451 |
|
---|
452 | Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.
|
---|
453 | The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
|
---|
454 | Bytes are written to the SMBUS from Buffer.
|
---|
455 | The number of bytes written is returned, and will never return a value larger than 32-bytes.
|
---|
456 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
457 | If Length in SmBusAddress is zero or greater than 32, then ASSERT().
|
---|
458 | If Buffer is NULL, then ASSERT().
|
---|
459 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
460 |
|
---|
461 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
462 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
463 | @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
|
---|
464 | @param Status Return status for the executed command.
|
---|
465 | This is an optional parameter and may be NULL.
|
---|
466 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
467 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
468 | reflected in the Host Status Register bit. Device errors are a result
|
---|
469 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
470 | (host initiated), or bus errors (collisions).
|
---|
471 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
472 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
473 |
|
---|
474 | @return The number of bytes written.
|
---|
475 |
|
---|
476 | **/
|
---|
477 | UINTN
|
---|
478 | EFIAPI
|
---|
479 | SmBusWriteBlock (
|
---|
480 | IN UINTN SmBusAddress,
|
---|
481 | OUT VOID *Buffer,
|
---|
482 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
483 | )
|
---|
484 | {
|
---|
485 | ASSERT (Buffer != NULL);
|
---|
486 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
|
---|
487 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
|
---|
488 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
489 | if (Status != NULL) {
|
---|
490 | *Status = RETURN_UNSUPPORTED;
|
---|
491 | }
|
---|
492 | return 0;
|
---|
493 | }
|
---|
494 |
|
---|
495 | /**
|
---|
496 | Executes an SMBUS block process call command.
|
---|
497 |
|
---|
498 | Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.
|
---|
499 | The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
|
---|
500 | Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer.
|
---|
501 | If Status is not NULL, then the status of the executed command is returned in Status.
|
---|
502 | It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.
|
---|
503 | SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
|
---|
504 | If Length in SmBusAddress is zero or greater than 32, then ASSERT().
|
---|
505 | If WriteBuffer is NULL, then ASSERT().
|
---|
506 | If ReadBuffer is NULL, then ASSERT().
|
---|
507 | If any reserved bits of SmBusAddress are set, then ASSERT().
|
---|
508 |
|
---|
509 | @param SmBusAddress Address that encodes the SMBUS Slave Address,
|
---|
510 | SMBUS Command, SMBUS Data Length, and PEC.
|
---|
511 | @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS.
|
---|
512 | @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS.
|
---|
513 | @param Status Return status for the executed command.
|
---|
514 | This is an optional parameter and may be NULL.
|
---|
515 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
|
---|
516 | RETURN_DEVICE_ERROR The request was not completed because a failure
|
---|
517 | reflected in the Host Status Register bit. Device errors are a result
|
---|
518 | of a transaction collision, illegal command field, unclaimed cycle
|
---|
519 | (host initiated), or bus errors (collisions).
|
---|
520 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
|
---|
521 | RETURN_UNSUPPORTED The SMBus operation is not supported.
|
---|
522 |
|
---|
523 | @return The number of bytes written.
|
---|
524 |
|
---|
525 | **/
|
---|
526 | UINTN
|
---|
527 | EFIAPI
|
---|
528 | SmBusBlockProcessCall (
|
---|
529 | IN UINTN SmBusAddress,
|
---|
530 | IN VOID *WriteBuffer,
|
---|
531 | OUT VOID *ReadBuffer,
|
---|
532 | OUT RETURN_STATUS *Status OPTIONAL
|
---|
533 | )
|
---|
534 | {
|
---|
535 | ASSERT (WriteBuffer != NULL);
|
---|
536 | ASSERT (ReadBuffer != NULL);
|
---|
537 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
|
---|
538 | ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
|
---|
539 | ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
|
---|
540 | if (Status != NULL) {
|
---|
541 | *Status = RETURN_UNSUPPORTED;
|
---|
542 | }
|
---|
543 | return 0;
|
---|
544 | }
|
---|