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