]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/SmbusLib.h
add function header
[mirror_edk2.git] / MdePkg / Include / Library / SmbusLib.h
CommitLineData
878ddf1f 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
13 Module Name: SmbusLib.h\r
14\r
15**/\r
16\r
17#ifndef __SMBUS_LIB__\r
18#define __SMBUS_LIB__\r
19\r
abea19db 20//\r
21// PEC BIT is bit 21 in SMBUS address\r
22//\r
23#define SMBUS_LIB_PEC_BIT (1 << 21)\r
24\r
878ddf1f 25/**\r
26 Macro that converts SMBUS slave address, SMBUS command, SMBUS data length,\r
27 and PEC to a value that can be passed to the SMBUS Library functions.\r
28\r
29 Computes an address that is compatible with the SMBUS Library functions.\r
30 The unused upper bits of SlaveAddress, Command, and Length are stripped\r
31 prior to the generation of the address.\r
32 \r
33 @param SlaveAddress SMBUS Slave Address. Range 0..127.\r
34 @param Command SMBUS Command. Range 0..255.\r
abea19db 35 @param Length SMBUS Data Length. Range 0..31.\r
878ddf1f 36 @param Pec TRUE if Packet Error Checking is enabled. Otherwise FALSE.\r
37\r
38**/\r
39#define SMBUS_LIB_ADDRESS(SlaveAddress,Command,Length,Pec) \\r
abea19db 40 ( ((Pec) ? SMBUS_LIB_PEC_BIT: 0) | \\r
41 (((SlaveAddress) & 0x7f) << 1) | \\r
42 (((Command) & 0xff) << 8) | \\r
43 (((Length) & 0x1f) << 16) \\r
878ddf1f 44 )\r
45\r
46/**\r
47 Executes an SMBUS quick read command.\r
48\r
49 Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.\r
50 Only the SMBUS slave address field of SmBusAddress is required.\r
51 If Status is not NULL, then the status of the executed command is returned in Status.\r
52 If PEC is set in SmBusAddress, then ASSERT().\r
53 If Command in SmBusAddress is not zero, then ASSERT().\r
54 If Length in SmBusAddress is not zero, then ASSERT().\r
55 If any reserved bits of SmBusAddress are set, then ASSERT().\r
56\r
57 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
58 SMBUS Command, SMBUS Data Length, and PEC.\r
59 @param Status Return status for the executed command.\r
60 This is an optional parameter and may be NULL.\r
61\r
62**/\r
63VOID\r
64EFIAPI\r
65SmBusQuickRead (\r
66 IN UINTN SmBusAddress,\r
67 OUT RETURN_STATUS *Status OPTIONAL\r
68 )\r
69;\r
70\r
71/**\r
72 Executes an SMBUS quick write command.\r
73\r
74 Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.\r
75 Only the SMBUS slave address field of SmBusAddress is required.\r
76 If Status is not NULL, then the status of the executed command is returned in Status.\r
77 If PEC is set in SmBusAddress, then ASSERT().\r
78 If Command in SmBusAddress is not zero, then ASSERT().\r
79 If Length in SmBusAddress is not zero, then ASSERT().\r
80 If any reserved bits of SmBusAddress are set, then ASSERT().\r
81\r
82 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
83 SMBUS Command, SMBUS Data Length, and PEC.\r
84 @param Status Return status for the executed command.\r
85 This is an optional parameter and may be NULL.\r
86\r
87**/\r
abea19db 88VOID\r
878ddf1f 89EFIAPI\r
90SmBusQuickWrite (\r
91 IN UINTN SmBusAddress,\r
92 OUT RETURN_STATUS *Status OPTIONAL\r
93 )\r
94;\r
95\r
96/**\r
97 Executes an SMBUS receive byte command.\r
98\r
99 Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.\r
100 Only the SMBUS slave address field of SmBusAddress is required.\r
101 The byte received from the SMBUS is returned.\r
102 If Status is not NULL, then the status of the executed command is returned in Status.\r
103 If Command in SmBusAddress is not zero, then ASSERT().\r
104 If Length in SmBusAddress is not zero, then ASSERT().\r
105 If any reserved bits of SmBusAddress are set, then ASSERT().\r
106\r
107 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
108 SMBUS Command, SMBUS Data Length, and PEC.\r
109 @param Status Return status for the executed command.\r
110 This is an optional parameter and may be NULL.\r
111\r
112 @return The byte received from the SMBUS.\r
113\r
114**/\r
115UINT8\r
116EFIAPI\r
117SmBusReceiveByte (\r
118 IN UINTN SmBusAddress,\r
119 OUT RETURN_STATUS *Status OPTIONAL\r
120 )\r
121;\r
122\r
123/**\r
124 Executes an SMBUS send byte command.\r
125\r
126 Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.\r
127 The byte specified by Value is sent.\r
128 Only the SMBUS slave address field of SmBusAddress is required. Value is returned.\r
129 If Status is not NULL, then the status of the executed command is returned in Status.\r
130 If Command in SmBusAddress is not zero, then ASSERT().\r
131 If Length in SmBusAddress is not zero, then ASSERT().\r
132 If any reserved bits of SmBusAddress are set, then ASSERT().\r
133\r
134 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
135 SMBUS Command, SMBUS Data Length, and PEC.\r
136 @param Value The 8-bit value to send.\r
137 @param Status Return status for the executed command.\r
138 This is an optional parameter and may be NULL.\r
139\r
140 @return The parameter of Value.\r
141\r
142**/\r
143UINT8\r
144EFIAPI\r
145SmBusSendByte (\r
146 IN UINTN SmBusAddress,\r
147 IN UINT8 Value,\r
148 OUT RETURN_STATUS *Status OPTIONAL\r
149 )\r
150;\r
151\r
152/**\r
153 Executes an SMBUS read data byte command.\r
154\r
155 Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.\r
156 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
157 The 8-bit value read from the SMBUS is returned.\r
158 If Status is not NULL, then the status of the executed command is returned in Status.\r
159 If Length in SmBusAddress is not zero, then ASSERT().\r
160 If any reserved bits of SmBusAddress are set, then ASSERT().\r
161\r
162 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
163 SMBUS Command, SMBUS Data Length, and PEC.\r
164 @param Status Return status for the executed command.\r
165 This is an optional parameter and may be NULL.\r
166\r
167 @return The byte read from the SMBUS.\r
168\r
169**/\r
170UINT8\r
171EFIAPI\r
172SmBusReadDataByte (\r
173 IN UINTN SmBusAddress,\r
174 OUT RETURN_STATUS *Status OPTIONAL\r
175 )\r
176;\r
177\r
178/**\r
179 Executes an SMBUS write data byte command.\r
180\r
181 Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.\r
182 The 8-bit value specified by Value is written.\r
183 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
184 Value is returned.\r
185 If Status is not NULL, then the status of the executed command is returned in Status.\r
186 If Length in SmBusAddress is not zero, then ASSERT().\r
187 If any reserved bits of SmBusAddress are set, then ASSERT().\r
188\r
189 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
190 SMBUS Command, SMBUS Data Length, and PEC.\r
191 @param Value The 8-bit value to write.\r
192 @param Status Return status for the executed command.\r
193 This is an optional parameter and may be NULL.\r
194\r
195 @return The parameter of Value.\r
196\r
197**/\r
198UINT8\r
199EFIAPI\r
200SmBusWriteDataByte (\r
201 IN UINTN SmBusAddress,\r
202 IN UINT8 Value,\r
203 OUT RETURN_STATUS *Status OPTIONAL\r
204 )\r
205;\r
206\r
207/**\r
208 Executes an SMBUS read data word command.\r
209\r
210 Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.\r
211 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
212 The 16-bit value read from the SMBUS is returned.\r
213 If Status is not NULL, then the status of the executed command is returned in Status.\r
214 If Length in SmBusAddress is not zero, then ASSERT().\r
215 If any reserved bits of SmBusAddress are set, then ASSERT().\r
216 \r
217 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
218 SMBUS Command, SMBUS Data Length, and PEC.\r
219 @param Status Return status for the executed command.\r
220 This is an optional parameter and may be NULL.\r
221\r
222 @return The byte read from the SMBUS.\r
223\r
224**/\r
225UINT16\r
226EFIAPI\r
227SmBusReadDataWord (\r
228 IN UINTN SmBusAddress,\r
229 OUT RETURN_STATUS *Status OPTIONAL\r
230 )\r
231;\r
232\r
233/**\r
234 Executes an SMBUS write data word command.\r
235\r
236 Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.\r
237 The 16-bit value specified by Value is written.\r
238 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
239 Value is returned.\r
240 If Status is not NULL, then the status of the executed command is returned in Status.\r
241 If Length in SmBusAddress is not zero, then ASSERT().\r
242 If any reserved bits of SmBusAddress are set, then ASSERT().\r
243\r
244 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
245 SMBUS Command, SMBUS Data Length, and PEC.\r
246 @param Value The 16-bit value to write.\r
247 @param Status Return status for the executed command.\r
248 This is an optional parameter and may be NULL.\r
249\r
250 @return The parameter of Value.\r
251\r
252**/\r
253UINT16\r
254EFIAPI\r
255SmBusWriteDataWord (\r
256 IN UINTN SmBusAddress,\r
257 IN UINT16 Value,\r
258 OUT RETURN_STATUS *Status OPTIONAL\r
259 )\r
260;\r
261\r
262/**\r
263 Executes an SMBUS process call command.\r
264\r
265 Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.\r
266 The 16-bit value specified by Value is written.\r
267 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
268 The 16-bit value returned by the process call command is returned.\r
269 If Status is not NULL, then the status of the executed command is returned in Status.\r
270 If Length in SmBusAddress is not zero, then ASSERT().\r
271 If any reserved bits of SmBusAddress are set, then ASSERT().\r
272\r
273 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
274 SMBUS Command, SMBUS Data Length, and PEC.\r
275 @param Value The 16-bit value to write.\r
276 @param Status Return status for the executed command.\r
277 This is an optional parameter and may be NULL.\r
278\r
279 @return The 16-bit value returned by the process call command.\r
280\r
281**/\r
282UINT16\r
283EFIAPI\r
284SmBusProcessCall (\r
285 IN UINTN SmBusAddress,\r
286 IN UINT16 Value,\r
287 OUT RETURN_STATUS *Status OPTIONAL\r
288 )\r
289;\r
290\r
291/**\r
292 Executes an SMBUS read block command.\r
293\r
294 Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.\r
295 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
296 Bytes are read from the SMBUS and stored in Buffer.\r
297 The number of bytes read is returned, and will never return a value larger than 32-bytes.\r
298 If Status is not NULL, then the status of the executed command is returned in Status.\r
299