]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/SmbusLib.h
Coding style fix.
[mirror_edk2.git] / MdePkg / Include / Library / SmbusLib.h
CommitLineData
fb3df220 1/** @file\r
2 SMBUS Functions\r
3\r
4 Copyright (c) 2006, Intel Corporation\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
fb3df220 13**/\r
14\r
15#ifndef __SMBUS_LIB__\r
16#define __SMBUS_LIB__\r
17\r
fb3df220 18/**\r
19 Macro that converts SMBUS slave address, SMBUS command, SMBUS data length,\r
20 and PEC to a value that can be passed to the SMBUS Library functions.\r
21\r
22 Computes an address that is compatible with the SMBUS Library functions.\r
23 The unused upper bits of SlaveAddress, Command, and Length are stripped\r
24 prior to the generation of the address.\r
25 \r
26 @param SlaveAddress SMBUS Slave Address. Range 0..127.\r
27 @param Command SMBUS Command. Range 0..255.\r
28 @param Length SMBUS Data Length. Range 0..32.\r
29 @param Pec TRUE if Packet Error Checking is enabled. Otherwise FALSE.\r
30\r
31**/\r
32#define SMBUS_LIB_ADDRESS(SlaveAddress,Command,Length,Pec) \\r
e60d361d 33 ( ((Pec) ? BIT22: 0) | \\r
fb3df220 34 (((SlaveAddress) & 0x7f) << 1) | \\r
35 (((Command) & 0xff) << 8) | \\r
36 (((Length) & 0x3f) << 16) \\r
37 )\r
38\r
2d8debe7 39/**\r
40 Macro that returns the SMBUS Slave Address value from an SmBusAddress Parameter value.\r
41 \r
42 @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC \r
43**/\r
44#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f)\r
45\r
46/**\r
47 Macro that returns the SMBUS Command value from an SmBusAddress Parameter value.\r
48 \r
49 @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC\r
50**/\r
51#define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff)\r
52\r
53/**\r
54 Macro that returns the SMBUS Data Length value from an SmBusAddress Parameter value.\r
55 \r
56 @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC \r
57**/\r
58#define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x3f)\r
59\r
60/**\r
61 Macro that returns the SMBUS PEC value from an SmBusAddress Parameter value.\r
62 \r
63 @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC \r
64**/\r
65#define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & BIT22) != 0))\r
66\r
67/**\r
68 Macro that returns the set of reserved bits from an SmBusAddress Parameter value.\r
69 \r
70 @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC \r
71**/\r
72#define SMBUS_LIB_RESERVED(SmBusAddress) ((SmBusAddress) & ~(((1 << 22) - 2) | BIT22))\r
73\r
fb3df220 74/**\r
75 Executes an SMBUS quick read command.\r
76\r
77 Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.\r
78 Only the SMBUS slave address field of SmBusAddress is required.\r
79 If Status is not NULL, then the status of the executed command is returned in Status.\r
80 If PEC is set in SmBusAddress, then ASSERT().\r
81 If Command in SmBusAddress is not zero, then ASSERT().\r
82 If Length in SmBusAddress is not zero, then ASSERT().\r
83 If any reserved bits of SmBusAddress are set, then ASSERT().\r
84\r
85 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
86 SMBUS Command, SMBUS Data Length, and PEC.\r
87 @param Status Return status for the executed command.\r
88 This is an optional parameter and may be NULL.\r
89\r
90**/\r
91VOID\r
92EFIAPI\r
93SmBusQuickRead (\r
94 IN UINTN SmBusAddress,\r
95 OUT RETURN_STATUS *Status OPTIONAL\r
dca1cc59 96 );\r
fb3df220 97\r
98/**\r
99 Executes an SMBUS quick write command.\r
100\r
101 Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.\r
102 Only the SMBUS slave address field of SmBusAddress is required.\r
103 If Status is not NULL, then the status of the executed command is returned in Status.\r
104 If PEC is set in SmBusAddress, then ASSERT().\r
105 If Command in SmBusAddress is not zero, then ASSERT().\r
106 If Length in SmBusAddress is not zero, then ASSERT().\r
107 If any reserved bits of SmBusAddress are set, then ASSERT().\r
108\r
109 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
110 SMBUS Command, SMBUS Data Length, and PEC.\r
111 @param Status Return status for the executed command.\r
112 This is an optional parameter and may be NULL.\r
113\r
114**/\r
115VOID\r
116EFIAPI\r
117SmBusQuickWrite (\r
118 IN UINTN SmBusAddress,\r
119 OUT RETURN_STATUS *Status OPTIONAL\r
dca1cc59 120 );\r
fb3df220 121\r
122/**\r
123 Executes an SMBUS receive byte command.\r
124\r
125 Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.\r
126 Only the SMBUS slave address field of SmBusAddress is required.\r
127 The byte received from the SMBUS is returned.\r
128 If Status is not NULL, then the status of the executed command is returned in Status.\r
129 If Command in SmBusAddress is not zero, then ASSERT().\r
130 If Length in SmBusAddress is not zero, then ASSERT().\r
131 If any reserved bits of SmBusAddress are set, then ASSERT().\r
132\r
133 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
134 SMBUS Command, SMBUS Data Length, and PEC.\r
135 @param Status Return status for the executed command.\r
136 This is an optional parameter and may be NULL.\r
137\r
138 @return The byte received from the SMBUS.\r
139\r
140**/\r
141UINT8\r
142EFIAPI\r
143SmBusReceiveByte (\r
144 IN UINTN SmBusAddress,\r
145 OUT RETURN_STATUS *Status OPTIONAL\r
dca1cc59 146 );\r
fb3df220 147\r
148/**\r
149 Executes an SMBUS send byte command.\r
150\r
151 Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.\r
152 The byte specified by Value is sent.\r
153 Only the SMBUS slave address field of SmBusAddress is required. Value is returned.\r
154 If Status is not NULL, then the status of the executed command is returned in Status.\r
155 If Command in SmBusAddress is not zero, then ASSERT().\r
156 If Length in SmBusAddress is not zero, then ASSERT().\r
157 If any reserved bits of SmBusAddress are set, then ASSERT().\r
158\r
159 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
160 SMBUS Command, SMBUS Data Length, and PEC.\r
161 @param Value The 8-bit value to send.\r
162 @param Status Return status for the executed command.\r
163 This is an optional parameter and may be NULL.\r
164\r
165 @return The parameter of Value.\r
166\r
167**/\r
168UINT8\r
169EFIAPI\r
170SmBusSendByte (\r
171 IN UINTN SmBusAddress,\r
172 IN UINT8 Value,\r
173 OUT RETURN_STATUS *Status OPTIONAL\r
dca1cc59 174 );\r
fb3df220 175\r
176/**\r
177 Executes an SMBUS read data byte command.\r
178\r
179 Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.\r
180 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
181 The 8-bit value read from the SMBUS is returned.\r
182 If Status is not NULL, then the status of the executed command is returned in Status.\r
183 If Length in SmBusAddress is not zero, then ASSERT().\r
184 If any reserved bits of SmBusAddress are set, then ASSERT().\r
185\r
186 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
187 SMBUS Command, SMBUS Data Length, and PEC.\r
188 @param Status Return status for the executed command.\r
189 This is an optional parameter and may be NULL.\r
190\r
191 @return The byte read from the SMBUS.\r
192\r
193**/\r
194UINT8\r
195EFIAPI\r
196SmBusReadDataByte (\r
197 IN UINTN SmBusAddress,\r
198 OUT RETURN_STATUS *Status OPTIONAL\r
dca1cc59 199 );\r
fb3df220 200\r
201/**\r
202 Executes an SMBUS write data byte command.\r
203\r
204 Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.\r
205 The 8-bit value specified by Value is written.\r
206 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
207 Value is returned.\r
208 If Status is not NULL, then the status of the executed command is returned in Status.\r
209 If Length in SmBusAddress is not zero, then ASSERT().\r
210 If any reserved bits of SmBusAddress are set, then ASSERT().\r
211\r
212 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
213 SMBUS Command, SMBUS Data Length, and PEC.\r
214 @param Value The 8-bit value to write.\r
215 @param Status Return status for the executed command.\r
216 This is an optional parameter and may be NULL.\r
217\r
218 @return The parameter of Value.\r
219\r
220**/\r
221UINT8\r
222EFIAPI\r
223SmBusWriteDataByte (\r
224 IN UINTN SmBusAddress,\r
225 IN UINT8 Value,\r
226 OUT RETURN_STATUS *Status OPTIONAL\r
dca1cc59 227 );\r
fb3df220 228\r
229/**\r
230 Executes an SMBUS read data word command.\r
231\r
232 Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.\r
233 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
234 The 16-bit value read from the SMBUS is returned.\r
235 If Status is not NULL, then the status of the executed command is returned in Status.\r
236 If Length in SmBusAddress is not zero, then ASSERT().\r
237 If any reserved bits of SmBusAddress are set, then ASSERT().\r
238 \r
239 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
240 SMBUS Command, SMBUS Data Length, and PEC.\r
241 @param Status Return status for the executed command.\r
242 This is an optional parameter and may be NULL.\r
243\r
244 @return The byte read from the SMBUS.\r
245\r
246**/\r
247UINT16\r
248EFIAPI\r
249SmBusReadDataWord (\r
250 IN UINTN SmBusAddress,\r
251 OUT RETURN_STATUS *Status OPTIONAL\r
dca1cc59 252 );\r
fb3df220 253\r
254/**\r
255 Executes an SMBUS write data word command.\r
256\r
257 Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.\r
258 The 16-bit value specified by Value is written.\r
259 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
260 Value is returned.\r
261 If Status is not NULL, then the status of the executed command is returned in Status.\r
262 If Length in SmBusAddress is not zero, then ASSERT().\r
263 If any reserved bits of SmBusAddress are set, then ASSERT().\r
264\r
265 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
266 SMBUS Command, SMBUS Data Length, and PEC.\r
267 @param Value The 16-bit value to write.\r
268 @param Status Return status for the executed command.\r
269 This is an optional parameter and may be NULL.\r
270\r
271 @return The parameter of Value.\r
272\r
273**/\r
274UINT16\r
275EFIAPI\r
276SmBusWriteDataWord (\r
277 IN UINTN SmBusAddress,\r
278 IN UINT16 Value,\r
279 OUT RETURN_STATUS *Status OPTIONAL\r
dca1cc59 280 );\r
fb3df220 281\r
282/**\r
283 Executes an SMBUS process call command.\r
284\r
285 Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.\r
286 The 16-bit value specified by Value is written.\r
287 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
288 The 16-bit value returned by the process call command is returned.\r
289 If Status is not NULL, then the status of the executed command is returned in Status.\r
290 If Length in SmBusAddress is not zero, then ASSERT().\r
291 If any reserved bits of SmBusAddress are set, then ASSERT().\r
292\r
293 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
294 SMBUS Command, SMBUS Data Length, and PEC.\r
295 @param Value The 16-bit value to write.\r
296 @param Status Return status for the executed command.\r
297 This is an optional parameter and may be NULL.\r
298\r
299 @return The 16-bit value returned by the process call command.\r
300\r
301**/\r
302UINT16\r
303EFIAPI\r
304SmBusProcessCall (\r
305 IN UINTN SmBusAddress,\r
306 IN UINT16 Value,\r
307 OUT RETURN_STATUS *Status OPTIONAL\r
dca1cc59 308 );\r
fb3df220 309\r
310/**\r
311 Executes an SMBUS read block command.\r
312\r
313 Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.\r
314 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
315 Bytes are read from the SMBUS and stored in Buffer.\r
316 The number of bytes read is returned, and will never return a value larger than 32-bytes.\r
317 If Status is not NULL, then the status of the executed command is returned in Status.\r
318 It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.\r
319 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
320 If Length in SmBusAddress is not zero, then ASSERT().\r
321 If Buffer is NULL, then ASSERT().\r
322 If any reserved bits of SmBusAddress are set, then ASSERT().\r
323\r
324 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
325 SMBUS Command, SMBUS Data Length, and PEC.\r
326 @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.\r
327 @param Status Return status for the executed command.\r
328 This is an optional parameter and may be NULL.\r
329\r
330 @return The number of bytes read.\r
331\r
332**/\r
333UINTN\r
334EFIAPI\r
335SmBusReadBlock (\r
336 IN UINTN SmBusAddress,\r
337 OUT VOID *Buffer,\r
338 OUT RETURN_STATUS *Status OPTIONAL\r
dca1cc59 339 );\r
fb3df220 340\r
341/**\r
342 Executes an SMBUS write block command.\r
343\r
344 Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.\r
345 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
346 Bytes are written to the SMBUS from Buffer.\r
347 The number of bytes written is returned, and will never return a value larger than 32-bytes.\r
348 If Status is not NULL, then the status of the executed command is returned in Status. \r
349 If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
350 If Buffer is NULL, then ASSERT().\r
351 If any reserved bits of SmBusAddress are set, then ASSERT().\r
352\r
353 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
354 SMBUS Command, SMBUS Data Length, and PEC.\r
355 @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.\r
356 @param Status Return status for the executed command.\r
357 This is an optional parameter and may be NULL.\r
358\r
359 @return The number of bytes written.\r
360\r
361**/\r
362UINTN\r
363EFIAPI\r
364SmBusWriteBlock (\r
365 IN UINTN SmBusAddress,\r
366 OUT VOID *Buffer,\r
367 OUT RETURN_STATUS *Status OPTIONAL\r
dca1cc59 368 );\r
fb3df220 369\r
370/**\r
371 Executes an SMBUS block process call command.\r
372\r
373 Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.\r
374 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
375 Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer.\r
376 If Status is not NULL, then the status of the executed command is returned in Status.\r
377 It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.\r
378 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
379 If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
380 If WriteBuffer is NULL, then ASSERT().\r
381 If ReadBuffer is NULL, then ASSERT().\r
382 If any reserved bits of SmBusAddress are set, then ASSERT().\r
383\r
384 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
385 SMBUS Command, SMBUS Data Length, and PEC.\r
386 @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS.\r
387 @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS.\r
388 @param Status Return status for the executed command.\r
389 This is an optional parameter and may be NULL.\r
390\r
391 @return The number of bytes written.\r
392\r
393**/\r
394UINTN\r
395EFIAPI\r
396SmBusBlockProcessCall (\r
397 IN UINTN SmBusAddress,\r
398 IN VOID *WriteBuffer,\r
399 OUT VOID *ReadBuffer,\r
400 OUT RETURN_STATUS *Status OPTIONAL\r
dca1cc59 401 );\r
fb3df220 402\r
403\r
404#endif\r