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