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