]>
git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h
3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 Public header file for Smbus Lib
23 #ifndef __EDKII_GLUE_SMBUS_LIB_H__
24 #define __EDKII_GLUE_SMBUS_LIB_H__
27 // PEC BIT is bit 22 in SMBUS address
29 #define SMBUS_LIB_PEC_BIT (1 << 22)
32 Macro that converts SMBUS slave address, SMBUS command, SMBUS data length,
33 and PEC to a value that can be passed to the SMBUS Library functions.
35 Computes an address that is compatible with the SMBUS Library functions.
36 The unused upper bits of SlaveAddress, Command, and Length are stripped
37 prior to the generation of the address.
39 @param SlaveAddress SMBUS Slave Address. Range 0..127.
40 @param Command SMBUS Command. Range 0..255.
41 @param Length SMBUS Data Length. Range 0..32.
42 @param Pec TRUE if Packet Error Checking is enabled. Otherwise FALSE.
45 #define SMBUS_LIB_ADDRESS(SlaveAddress,Command,Length,Pec) \
46 ( ((Pec) ? SMBUS_LIB_PEC_BIT: 0) | \
47 (((SlaveAddress) & 0x7f) << 1) | \
48 (((Command) & 0xff) << 8) | \
49 (((Length) & 0x3f) << 16) \
53 Executes an SMBUS quick read command.
55 Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.
56 Only the SMBUS slave address field of SmBusAddress is required.
57 If Status is not NULL, then the status of the executed command is returned in Status.
58 If PEC is set in SmBusAddress, then ASSERT().
59 If Command in SmBusAddress is not zero, then ASSERT().
60 If Length in SmBusAddress is not zero, then ASSERT().
61 If any reserved bits of SmBusAddress are set, then ASSERT().
63 @param SmBusAddress Address that encodes the SMBUS Slave Address,
64 SMBUS Command, SMBUS Data Length, and PEC.
65 @param Status Return status for the executed command.
66 This is an optional parameter and may be NULL.
72 IN UINTN SmBusAddress
,
73 OUT RETURN_STATUS
*Status OPTIONAL
78 Executes an SMBUS quick write command.
80 Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.
81 Only the SMBUS slave address field of SmBusAddress is required.
82 If Status is not NULL, then the status of the executed command is returned in Status.
83 If PEC is set in SmBusAddress, then ASSERT().
84 If Command in SmBusAddress is not zero, then ASSERT().
85 If Length in SmBusAddress is not zero, then ASSERT().
86 If any reserved bits of SmBusAddress are set, then ASSERT().
88 @param SmBusAddress Address that encodes the SMBUS Slave Address,
89 SMBUS Command, SMBUS Data Length, and PEC.
90 @param Status Return status for the executed command.
91 This is an optional parameter and may be NULL.
97 IN UINTN SmBusAddress
,
98 OUT RETURN_STATUS
*Status OPTIONAL
103 Executes an SMBUS receive byte command.
105 Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.
106 Only the SMBUS slave address field of SmBusAddress is required.
107 The byte received from the SMBUS is returned.
108 If Status is not NULL, then the status of the executed command is returned in Status.
109 If Command in SmBusAddress is not zero, then ASSERT().
110 If Length in SmBusAddress is not zero, then ASSERT().
111 If any reserved bits of SmBusAddress are set, then ASSERT().
113 @param SmBusAddress Address that encodes the SMBUS Slave Address,
114 SMBUS Command, SMBUS Data Length, and PEC.
115 @param Status Return status for the executed command.
116 This is an optional parameter and may be NULL.
118 @return The byte received from the SMBUS.
124 IN UINTN SmBusAddress
,
125 OUT RETURN_STATUS
*Status OPTIONAL
130 Executes an SMBUS send byte command.
132 Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.
133 The byte specified by Value is sent.
134 Only the SMBUS slave address field of SmBusAddress is required. Value is returned.
135 If Status is not NULL, then the status of the executed command is returned in Status.
136 If Command in SmBusAddress is not zero, then ASSERT().
137 If Length in SmBusAddress is not zero, then ASSERT().
138 If any reserved bits of SmBusAddress are set, then ASSERT().
140 @param SmBusAddress Address that encodes the SMBUS Slave Address,
141 SMBUS Command, SMBUS Data Length, and PEC.
142 @param Value The 8-bit value to send.
143 @param Status Return status for the executed command.
144 This is an optional parameter and may be NULL.
146 @return The parameter of Value.
152 IN UINTN SmBusAddress
,
154 OUT RETURN_STATUS
*Status OPTIONAL
159 Executes an SMBUS read data byte command.
161 Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.
162 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
163 The 8-bit value read from the SMBUS is returned.
164 If Status is not NULL, then the status of the executed command is returned in Status.
165 If Length in SmBusAddress is not zero, then ASSERT().
166 If any reserved bits of SmBusAddress are set, then ASSERT().
168 @param SmBusAddress Address that encodes the SMBUS Slave Address,
169 SMBUS Command, SMBUS Data Length, and PEC.
170 @param Status Return status for the executed command.
171 This is an optional parameter and may be NULL.
173 @return The byte read from the SMBUS.
179 IN UINTN SmBusAddress
,
180 OUT RETURN_STATUS
*Status OPTIONAL
185 Executes an SMBUS write data byte command.
187 Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.
188 The 8-bit value specified by Value is written.
189 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
191 If Status is not NULL, then the status of the executed command is returned in Status.
192 If Length in SmBusAddress is not zero, then ASSERT().
193 If any reserved bits of SmBusAddress are set, then ASSERT().
195 @param SmBusAddress Address that encodes the SMBUS Slave Address,
196 SMBUS Command, SMBUS Data Length, and PEC.
197 @param Value The 8-bit value to write.
198 @param Status Return status for the executed command.
199 This is an optional parameter and may be NULL.
201 @return The parameter of Value.
207 IN UINTN SmBusAddress
,
209 OUT RETURN_STATUS
*Status OPTIONAL
214 Executes an SMBUS read data word command.
216 Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.
217 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
218 The 16-bit value read from the SMBUS is returned.
219 If Status is not NULL, then the status of the executed command is returned in Status.
220 If Length in SmBusAddress is not zero, then ASSERT().
221 If any reserved bits of SmBusAddress are set, then ASSERT().
223 @param SmBusAddress Address that encodes the SMBUS Slave Address,
224 SMBUS Command, SMBUS Data Length, and PEC.
225 @param Status Return status for the executed command.
226 This is an optional parameter and may be NULL.
228 @return The byte read from the SMBUS.
234 IN UINTN SmBusAddress
,
235 OUT RETURN_STATUS
*Status OPTIONAL
240 Executes an SMBUS write data word command.
242 Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.
243 The 16-bit value specified by Value is written.
244 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
246 If Status is not NULL, then the status of the executed command is returned in Status.
247 If Length in SmBusAddress is not zero, then ASSERT().
248 If any reserved bits of SmBusAddress are set, then ASSERT().
250 @param SmBusAddress Address that encodes the SMBUS Slave Address,
251 SMBUS Command, SMBUS Data Length, and PEC.
252 @param Value The 16-bit value to write.
253 @param Status Return status for the executed command.
254 This is an optional parameter and may be NULL.
256 @return The parameter of Value.
262 IN UINTN SmBusAddress
,
264 OUT RETURN_STATUS
*Status OPTIONAL
269 Executes an SMBUS process call command.
271 Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.
272 The 16-bit value specified by Value is written.
273 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
274 The 16-bit value returned by the process call command is returned.
275 If Status is not NULL, then the status of the executed command is returned in Status.
276 If Length in SmBusAddress is not zero, then ASSERT().
277 If any reserved bits of SmBusAddress are set, then ASSERT().
279 @param SmBusAddress Address that encodes the SMBUS Slave Address,
280 SMBUS Command, SMBUS Data Length, and PEC.
281 @param Value The 16-bit value to write.
282 @param Status Return status for the executed command.
283 This is an optional parameter and may be NULL.
285 @return The 16-bit value returned by the process call command.
291 IN UINTN SmBusAddress
,
293 OUT RETURN_STATUS
*Status OPTIONAL
298 Executes an SMBUS read block command.
300 Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.
301 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
302 Bytes are read from the SMBUS and stored in Buffer.
303 The number of bytes read is returned, and will never return a value larger than 32-bytes.
304 If Status is not NULL, then the status of the executed command is returned in Status.
305 It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
306 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
307 If Length in SmBusAddress is not zero, then ASSERT().
308 If Buffer is NULL, then ASSERT().
309 If any reserved bits of SmBusAddress are set, then ASSERT().
311 @param SmBusAddress Address that encodes the SMBUS Slave Address,
312 SMBUS Command, SMBUS Data Length, and PEC.
313 @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
314 @param Status Return status for the executed command.
315 This is an optional parameter and may be NULL.
317 @return The number of bytes read.
323 IN UINTN SmBusAddress
,
325 OUT RETURN_STATUS
*Status OPTIONAL
330 Executes an SMBUS write block command.
332 Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.
333 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
334 Bytes are written to the SMBUS from Buffer.
335 The number of bytes written is returned, and will never return a value larger than 32-bytes.
336 If Status is not NULL, then the status of the executed command is returned in Status.
337 If Length in SmBusAddress is zero or greater than 32, then ASSERT().
338 If Buffer is NULL, then ASSERT().
339 If any reserved bits of SmBusAddress are set, then ASSERT().
341 @param SmBusAddress Address that encodes the SMBUS Slave Address,
342 SMBUS Command, SMBUS Data Length, and PEC.
343 @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
344 @param Status Return status for the executed command.
345 This is an optional parameter and may be NULL.
347 @return The number of bytes written.
353 IN UINTN SmBusAddress
,
355 OUT RETURN_STATUS
*Status OPTIONAL
360 Executes an SMBUS block process call command.
362 Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.
363 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
364 Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer.
365 If Status is not NULL, then the status of the executed command is returned in Status.
366 It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.
367 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
368 If Length in SmBusAddress is zero or greater than 32, then ASSERT().
369 If WriteBuffer is NULL, then ASSERT().
370 If ReadBuffer is NULL, then ASSERT().
371 If any reserved bits of SmBusAddress are set, then ASSERT().
373 @param SmBusAddress Address that encodes the SMBUS Slave Address,
374 SMBUS Command, SMBUS Data Length, and PEC.
375 @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS.
376 @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS.
377 @param Status Return status for the executed command.
378 This is an optional parameter and may be NULL.
380 @return The number of bytes written.
385 SmBusBlockProcessCall (
386 IN UINTN SmBusAddress
,
387 IN VOID
*WriteBuffer
,
388 OUT VOID
*ReadBuffer
,
389 OUT RETURN_STATUS
*Status OPTIONAL