]> git.proxmox.com Git - mirror_edk2.git/blame - QuarkSocPkg/QuarkNorthCluster/QNCInit/Dxe/DxeQNCSmbus.c
QuarkSocPkg: Add new package for Quark SoC X1000
[mirror_edk2.git] / QuarkSocPkg / QuarkNorthCluster / QNCInit / Dxe / DxeQNCSmbus.c
CommitLineData
9b6bbcdb
MK
1/** @file\r
2Implementation for SMBus DXE driver entry point and SMBus Host\r
3Controller protocol.\r
4\r
5Copyright (c) 2013-2015 Intel Corporation.\r
6\r
7This program and the accompanying materials\r
8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16#include "CommonHeader.h"\r
17\r
18#include "DxeQNCSmbus.h"\r
19\r
20//\r
21// Interface defintion of SMBUS Host Controller Protocol.\r
22//\r
23EFI_SMBUS_HC_PROTOCOL mSmbusHc = {\r
24 SmbusExecute,\r
25 SmbusArpDevice,\r
26 SmbusGetArpMap,\r
27 SmbusNotify\r
28};\r
29\r
30//\r
31// Handle to install SMBus Host Controller protocol.\r
32//\r
33EFI_HANDLE mSmbusHcHandle = NULL;\r
34UINT8 mDeviceMapEntries = 0;\r
35EFI_SMBUS_DEVICE_MAP mDeviceMap[MAX_SMBUS_DEVICES];\r
36UINT8 mPlatformNumRsvd = 0;\r
37UINT8 *mPlatformAddrRsvd = NULL;\r
38\r
39//\r
40// These addresses are reserved by the SMBus 2.0 specification\r
41//\r
42UINT8 mReservedAddress[SMBUS_NUM_RESERVED] = {\r
43 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, 0x18, 0x50, 0x6E, 0xC2,\r
44 0xF0, 0xF2, 0xF4, 0xF6, 0xF8, 0xFA, 0xFC, 0xFE\r
45};\r
46\r
47\r
48/**\r
49 Gets Io port base address of Smbus Host Controller.\r
50\r
51 This internal function depends on a feature flag named PcdIchSmbusFixedIoPortBaseAddress\r
52 to retrieve Smbus Io port base. If that feature flag is true, it will get Smbus Io port base\r
53 address from a preset Pcd entry named PcdIchSmbusIoPortBaseAddress; otherwise, it will always\r
54 read Pci configuration space to get that value in each Smbus bus transaction.\r
55\r
56 @return The Io port base address of Smbus host controller.\r
57\r
58**/\r
59UINTN\r
60GetSmbusIoPortBaseAddress (\r
61 VOID\r
62 )\r
63{\r
64 UINTN IoPortBaseAddress;\r
65\r
66 if (FeaturePcdGet (PcdSmbaIoBaseAddressFixed)) {\r
67 IoPortBaseAddress = (UINTN) PcdGet16 (PcdSmbaIoBaseAddress);\r
68 } else {\r
69 IoPortBaseAddress = (UINTN) LpcPciCfg32 (R_QNC_LPC_SMBUS_BASE) & B_QNC_LPC_SMBUS_BASE_MASK;\r
70 }\r
71\r
72 //\r
73 // Make sure that the IO port base address has been properly set.\r
74 //\r
75 ASSERT (IoPortBaseAddress != 0);\r
76\r
77 return IoPortBaseAddress;\r
78}\r
79\r
80\r
81VOID\r
82InitializeInternal (\r
83 )\r
84{\r
85 UINTN IoPortBaseAddress;\r
86\r
87 IoPortBaseAddress = GetSmbusIoPortBaseAddress ();\r
88\r
89 //\r
90 // Step1: Enable QNC SMBUS I/O space.\r
91 //\r
92 LpcPciCfg32Or(R_QNC_LPC_SMBUS_BASE, B_QNC_LPC_SMBUS_BASE_EN);\r
93\r
94 //\r
95 // Step2: Clear Status Register before anyone uses the interfaces.\r
96 //\r
97 IoWrite8 (IoPortBaseAddress + R_QNC_SMBUS_HSTS, B_QNC_SMBUS_HSTS_ALL);\r
98\r
99 //\r
100 // Step3: Program the correct smbus clock\r
101 //\r
102 IoWrite8 (IoPortBaseAddress + R_QNC_SMBUS_HCLK, V_QNC_SMBUS_HCLK_100KHZ);\r
103}\r
104\r
105\r
106\r
107\r
108BOOLEAN\r
109IsAddressAvailable (\r
110 IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress\r
111 )\r
112{\r
113 UINT8 Index;\r
114\r
115 //\r
116 // See if we have already assigned this address to a device\r
117 //\r
118 for (Index = 0; Index < mDeviceMapEntries; Index++) {\r
119 if (SlaveAddress.SmbusDeviceAddress ==\r
120 mDeviceMap[Index].SmbusDeviceAddress.SmbusDeviceAddress) {\r
121 return FALSE;\r
122 }\r
123 }\r
124\r
125 //\r
126 // See if this address is claimed by a platform non-ARP-capable device\r
127 //\r
128 for (Index = 0; Index < mPlatformNumRsvd; Index++) {\r
129 if ((SlaveAddress.SmbusDeviceAddress << 1) == mPlatformAddrRsvd[Index]) {\r
130 return FALSE;\r
131 }\r
132 }\r
133\r
134 //\r
135 // See if this is a reserved address\r
136 //\r
137 for (Index = 0; Index < SMBUS_NUM_RESERVED; Index++) {\r
138 if (SlaveAddress.SmbusDeviceAddress == (UINTN) mReservedAddress[Index]) {\r
139 return FALSE;\r
140 }\r
141 }\r
142\r
143 return TRUE;\r
144}\r
145\r
146\r
147EFI_STATUS\r
148GetNextAvailableAddress (\r
149 IN EFI_SMBUS_DEVICE_ADDRESS *SlaveAddress\r
150 )\r
151{\r
152 for (SlaveAddress->SmbusDeviceAddress = 0x03;\r
153 SlaveAddress->SmbusDeviceAddress < 0x7F;\r
154 SlaveAddress->SmbusDeviceAddress++\r
155 ) {\r
156 if (IsAddressAvailable (*SlaveAddress)) {\r
157 return EFI_SUCCESS;\r
158 }\r
159 }\r
160\r
161 return EFI_OUT_OF_RESOURCES;\r
162}\r
163\r
164EFI_STATUS\r
165SmbusPrepareToArp (\r
166 )\r
167{\r
168 EFI_SMBUS_DEVICE_ADDRESS SlaveAddress;\r
169 EFI_STATUS Status;\r
170 UINTN Length;\r
171 UINT8 Buffer;\r
172\r
173 SlaveAddress.SmbusDeviceAddress = SMBUS_ADDRESS_ARP;\r
174 Length = 1;\r
175 Buffer = SMBUS_DATA_PREPARE_TO_ARP;\r
176\r
177 Status = Execute (\r
178 SlaveAddress,\r
179 0,\r
180 EfiSmbusSendByte,\r
181 TRUE,\r
182 &Length,\r
183 &Buffer\r
184 );\r
185 return Status;\r
186}\r
187\r
188EFI_STATUS\r
189SmbusGetUdidGeneral (\r
190 IN OUT EFI_SMBUS_DEVICE_MAP *DeviceMap\r
191 )\r
192{\r
193 EFI_SMBUS_DEVICE_ADDRESS SlaveAddress;\r
194 EFI_STATUS Status;\r
195 UINTN Length;\r
196 UINT8 Buffer[SMBUS_GET_UDID_LENGTH];\r
197\r
198 SlaveAddress.SmbusDeviceAddress = SMBUS_ADDRESS_ARP;\r
199 Length = SMBUS_GET_UDID_LENGTH;\r
200\r
201 Status = Execute (\r
202 SlaveAddress,\r
203 SMBUS_DATA_GET_UDID_GENERAL,\r
204 EfiSmbusReadBlock,\r
205 TRUE,\r
206 &Length,\r
207 Buffer\r
208 );\r
209\r
210 if (!EFI_ERROR(Status)) {\r
211 if (Length == SMBUS_GET_UDID_LENGTH) {\r
212 DeviceMap->SmbusDeviceUdid.DeviceCapabilities = Buffer[0];\r
213 DeviceMap->SmbusDeviceUdid.VendorRevision = Buffer[1];\r
214 DeviceMap->SmbusDeviceUdid.VendorId = (UINT16)((Buffer[2] << 8) + Buffer[3]);\r
215 DeviceMap->SmbusDeviceUdid.DeviceId = (UINT16)((Buffer[4] << 8) + Buffer[5]);\r
216 DeviceMap->SmbusDeviceUdid.Interface = (UINT16)((Buffer[6] << 8) + Buffer[7]);\r
217 DeviceMap->SmbusDeviceUdid.SubsystemVendorId = (UINT16)((Buffer[8] << 8) + Buffer[9]);\r
218 DeviceMap->SmbusDeviceUdid.SubsystemDeviceId = (UINT16)((Buffer[10] << 8) + Buffer[11]);\r
219 DeviceMap->SmbusDeviceUdid.VendorSpecificId = (UINT32)((Buffer[12] << 24) + (Buffer[13] << 16) + (Buffer[14] << 8) + Buffer[15]);\r
220 DeviceMap->SmbusDeviceAddress.SmbusDeviceAddress = (UINT8)(Buffer[16] >> 1);\r
221 } else {\r
222 Status = EFI_DEVICE_ERROR;\r
223 }\r
224 }\r
225\r
226 return Status;\r
227}\r
228\r
229EFI_STATUS\r
230SmbusAssignAddress (\r
231 IN OUT EFI_SMBUS_DEVICE_MAP *DeviceMap\r
232 )\r
233{\r
234 EFI_SMBUS_DEVICE_ADDRESS SlaveAddress;\r
235 EFI_STATUS Status;\r
236 UINTN Length;\r
237 UINT8 Buffer[SMBUS_GET_UDID_LENGTH];\r
238\r
239 Buffer[0] = DeviceMap->SmbusDeviceUdid.DeviceCapabilities;\r
240 Buffer[1] = DeviceMap->SmbusDeviceUdid.VendorRevision;\r
241 Buffer[2] = (UINT8)(DeviceMap->SmbusDeviceUdid.VendorId >> 8);\r
242 Buffer[3] = (UINT8)(DeviceMap->SmbusDeviceUdid.VendorId);\r
243 Buffer[4] = (UINT8)(DeviceMap->SmbusDeviceUdid.DeviceId >> 8);\r
244 Buffer[5] = (UINT8)(DeviceMap->SmbusDeviceUdid.DeviceId);\r
245 Buffer[6] = (UINT8)(DeviceMap->SmbusDeviceUdid.Interface >> 8);\r
246 Buffer[7] = (UINT8)(DeviceMap->SmbusDeviceUdid.Interface);\r
247 Buffer[8] = (UINT8)(DeviceMap->SmbusDeviceUdid.SubsystemVendorId >> 8);\r
248 Buffer[9] = (UINT8)(DeviceMap->SmbusDeviceUdid.SubsystemVendorId);\r
249 Buffer[10] = (UINT8)(DeviceMap->SmbusDeviceUdid.SubsystemDeviceId >> 8);\r
250 Buffer[11] = (UINT8)(DeviceMap->SmbusDeviceUdid.SubsystemDeviceId);\r
251 Buffer[12] = (UINT8)(DeviceMap->SmbusDeviceUdid.VendorSpecificId >> 24);\r
252 Buffer[13] = (UINT8)(DeviceMap->SmbusDeviceUdid.VendorSpecificId >> 16);\r
253 Buffer[14] = (UINT8)(DeviceMap->SmbusDeviceUdid.VendorSpecificId >> 8);\r
254 Buffer[15] = (UINT8)(DeviceMap->SmbusDeviceUdid.VendorSpecificId);\r
255 Buffer[16] = (UINT8)(DeviceMap->SmbusDeviceAddress.SmbusDeviceAddress << 1);\r
256\r
257 SlaveAddress.SmbusDeviceAddress = SMBUS_ADDRESS_ARP;\r
258 Length = SMBUS_GET_UDID_LENGTH;\r
259\r
260 Status = Execute (\r
261 SlaveAddress,\r
262 SMBUS_DATA_ASSIGN_ADDRESS,\r
263 EfiSmbusWriteBlock,\r
264 TRUE,\r
265 &Length,\r
266 Buffer\r
267 );\r
268 return Status;\r
269}\r
270\r
271\r
272EFI_STATUS\r
273SmbusFullArp (\r
274 )\r
275{\r
276 EFI_STATUS Status;\r
277 EFI_SMBUS_DEVICE_MAP *CurrentDeviceMap;\r
278\r
279 Status = SmbusPrepareToArp ();\r
280 if (EFI_ERROR(Status)) {\r
281 if (Status == EFI_DEVICE_ERROR) {\r
282 //\r
283 // ARP is complete\r
284 //\r
285 return EFI_SUCCESS;\r
286 } else {\r
287 return Status;\r
288 }\r
289 }\r
290\r
291 //\r
292 // Main loop to ARP all ARP-capable devices\r
293 //\r
294 do {\r
295 CurrentDeviceMap = &mDeviceMap[mDeviceMapEntries];\r
296 Status = SmbusGetUdidGeneral (CurrentDeviceMap);\r
297 if (EFI_ERROR(Status)) {\r
298 break;\r
299 }\r
300\r
301 if (CurrentDeviceMap->SmbusDeviceAddress.SmbusDeviceAddress == (0xFF >> 1)) {\r
302 //\r
303 // If address is unassigned, assign it\r
304 //\r
305 Status = GetNextAvailableAddress (\r
306 &CurrentDeviceMap->SmbusDeviceAddress\r
307 );\r
308 if (EFI_ERROR(Status)) {\r
309 return EFI_OUT_OF_RESOURCES;\r
310 }\r
311 } else if (((CurrentDeviceMap->SmbusDeviceUdid.DeviceCapabilities) & 0xC0) != 0) {\r
312 //\r
313 // if address is not fixed, check if the current address is available\r
314 //\r
315 if (!IsAddressAvailable (\r
316 CurrentDeviceMap->SmbusDeviceAddress\r
317 )) {\r
318 //\r
319 // if currently assigned address is already used, get a new one\r
320 //\r
321 Status = GetNextAvailableAddress (\r
322 &CurrentDeviceMap->SmbusDeviceAddress\r
323 );\r
324 if (EFI_ERROR(Status)) {\r
325 return EFI_OUT_OF_RESOURCES;\r
326 }\r
327 }\r
328 }\r
329\r
330 Status = SmbusAssignAddress (CurrentDeviceMap);\r
331 if (EFI_ERROR(Status)) {\r
332 //\r
333 // If there was a device error, just continue on and try again.\r
334 // Other errors should be reported.\r
335 //\r
336 if (Status != EFI_DEVICE_ERROR) {\r
337 return Status;\r
338 }\r
339 } else {\r
340 //\r
341 // If there was no error, the address was assigned and we must update our\r
342 // records.\r
343 //\r
344 mDeviceMapEntries++;\r
345 }\r
346\r
347 } while (mDeviceMapEntries < MAX_SMBUS_DEVICES);\r
348\r
349 return EFI_SUCCESS;\r
350}\r
351\r
352\r
353EFI_STATUS\r
354SmbusDirectedArp (\r
355 IN EFI_SMBUS_UDID *SmbusUdid,\r
356 IN OUT EFI_SMBUS_DEVICE_ADDRESS *SlaveAddress\r
357 )\r
358{\r
359 EFI_STATUS Status;\r
360 EFI_SMBUS_DEVICE_MAP *CurrentDeviceMap;\r
361\r
362 if (mDeviceMapEntries >= MAX_SMBUS_DEVICES) {\r
363 return EFI_OUT_OF_RESOURCES;\r
364 }\r
365\r
366 CurrentDeviceMap = &mDeviceMap[mDeviceMapEntries];\r
367\r
368 //\r
369 // Find an available address to assign\r
370 //\r
371 Status = GetNextAvailableAddress (\r
372 &CurrentDeviceMap->SmbusDeviceAddress\r
373 );\r
374 if (EFI_ERROR(Status)) {\r
375 return EFI_OUT_OF_RESOURCES;\r
376 }\r
377\r
378 CurrentDeviceMap->SmbusDeviceUdid.DeviceCapabilities = SmbusUdid->DeviceCapabilities;\r
379 CurrentDeviceMap->SmbusDeviceUdid.DeviceId = SmbusUdid->DeviceId;\r
380 CurrentDeviceMap->SmbusDeviceUdid.Interface = SmbusUdid->Interface;\r
381 CurrentDeviceMap->SmbusDeviceUdid.SubsystemDeviceId = SmbusUdid->SubsystemDeviceId;\r
382 CurrentDeviceMap->SmbusDeviceUdid.SubsystemVendorId = SmbusUdid->SubsystemVendorId;\r
383 CurrentDeviceMap->SmbusDeviceUdid.VendorId = SmbusUdid->VendorId;\r
384 CurrentDeviceMap->SmbusDeviceUdid.VendorRevision = SmbusUdid->VendorRevision;\r
385 CurrentDeviceMap->SmbusDeviceUdid.VendorSpecificId = SmbusUdid->VendorSpecificId;\r
386\r
387 Status = SmbusAssignAddress (CurrentDeviceMap);\r
388 if (EFI_ERROR(Status)) {\r
389 return Status;\r
390 }\r
391\r
392 mDeviceMapEntries++;\r
393 SlaveAddress->SmbusDeviceAddress = CurrentDeviceMap->SmbusDeviceAddress.SmbusDeviceAddress;\r
394\r
395 return EFI_SUCCESS;\r
396}\r
397\r
398\r
399\r
400/**\r
401 Executes an SMBus operation to an SMBus controller. Returns when either the command has been\r
402 executed or an error is encountered in doing the operation.\r
403\r
404 The Execute() function provides a standard way to execute an operation as defined in the System\r
405 Management Bus (SMBus) Specification. The resulting transaction will be either that the SMBus\r
406 slave devices accept this transaction or that this function returns with error.\r
407\r
408 @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance.\r
409 @param SlaveAddress The SMBus slave address of the device with which to communicate.\r
410 @param Command This command is transmitted by the SMBus host controller to the\r
411 SMBus slave device and the interpretation is SMBus slave device\r
412 specific. It can mean the offset to a list of functions inside an\r
413 SMBus slave device. Not all operations or slave devices support\r
414 this command's registers.\r
415 @param Operation Signifies which particular SMBus hardware protocol instance that\r
416 it will use to execute the SMBus transactions. This SMBus\r
417 hardware protocol is defined by the SMBus Specification and is\r
418 not related to EFI.\r
419 @param PecCheck Defines if Packet Error Code (PEC) checking is required for this\r
420 operation.\r
421 @param Length Signifies the number of bytes that this operation will do. The\r
422 maximum number of bytes can be revision specific and operation\r
423 specific. This field will contain the actual number of bytes that\r
424 are executed for this operation. Not all operations require this\r
425 argument.\r
426 @param Buffer Contains the value of data to execute to the SMBus slave device.\r
427 Not all operations require this argument. The length of this\r
428 buffer is identified by Length.\r
429\r
430 @retval EFI_SUCCESS The last data that was returned from the access matched the poll\r
431 exit criteria.\r
432 @retval EFI_CRC_ERROR Checksum is not correct (PEC is incorrect).\r
433 @retval EFI_TIMEOUT Timeout expired before the operation was completed. Timeout is\r
434 determined by the SMBus host controller device.\r
435 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
436 @retval EFI_DEVICE_ERROR The request was not completed because a failure that was\r
437 reflected in the Host Status Register bit. Device errors are a\r
438 result of a transaction collision, illegal command field,\r
439 unclaimed cycle (host initiated), or bus errors (collisions).\r
440 @retval EFI_INVALID_PARAMETER Operation is not defined in EFI_SMBUS_OPERATION.\r
441 @retval EFI_INVALID_PARAMETER Length/Buffer is NULL for operations except for EfiSmbusQuickRead\r
442 and EfiSmbusQuickWrite. Length is outside the range of valid\r
443 values.\r
444 @retval EFI_UNSUPPORTED The SMBus operation or PEC is not supported.\r
445 @retval EFI_BUFFER_TOO_SMALL Buffer is not sufficient for this operation.\r
446\r
447**/\r
448EFI_STATUS\r
449EFIAPI\r
450SmbusExecute (\r
451 IN CONST EFI_SMBUS_HC_PROTOCOL *This,\r
452 IN CONST EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,\r
453 IN CONST EFI_SMBUS_DEVICE_COMMAND Command,\r
454 IN CONST EFI_SMBUS_OPERATION Operation,\r
455 IN CONST BOOLEAN PecCheck,\r
456 IN OUT UINTN *Length,\r
457 IN OUT VOID *Buffer\r
458 )\r
459{\r
460 InitializeInternal ();\r
461 return Execute (\r
462 SlaveAddress,\r
463 Command,\r
464 Operation,\r
465 PecCheck,\r
466 Length,\r
467 Buffer\r
468 );\r
469}\r
470\r
471/**\r
472 Sets the SMBus slave device addresses for the device with a given unique ID or enumerates the\r
473 entire bus.\r
474\r
475 The ArpDevice() function provides a standard way for a device driver to enumerate the entire\r
476 SMBus or specific devices on the bus.\r
477\r
478 @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance.\r
479 @param ArpAll A Boolean expression that indicates if the host drivers need to\r
480 enumerate all the devices or enumerate only the device that is\r
481 identified by SmbusUdid. If ArpAll is TRUE, SmbusUdid and\r
482 SlaveAddress are optional. If ArpAll is FALSE, ArpDevice will\r
483 enumerate SmbusUdid and the address will be at SlaveAddress.\r
484 @param SmbusUdid The Unique Device Identifier (UDID) that is associated with this\r
485 device.\r
486 @param SlaveAddress The SMBus slave address that is associated with an SMBus UDID.\r
487\r
488 @retval EFI_SUCCESS The last data that was returned from the access matched the poll\r
489 exit criteria.\r
490 @retval EFI_CRC_ERROR Checksum is not correct (PEC is incorrect).\r
491 @retval EFI_TIMEOUT Timeout expired before the operation was completed. Timeout is\r
492 determined by the SMBus host controller device.\r
493 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
494 @retval EFI_DEVICE_ERROR The request was not completed because a failure that was\r
495 reflected in the Host Status Register bit. Device errors are a\r
496 result of a transaction collision, illegal command field,\r
497 unclaimed cycle (host initiated), or bus errors (collisions).\r
498 @retval EFI_UNSUPPORTED The corresponding SMBus operation is not supported.\r
499\r
500**/\r
501EFI_STATUS\r
502EFIAPI\r
503SmbusArpDevice (\r
504 IN CONST EFI_SMBUS_HC_PROTOCOL *This,\r
505 IN BOOLEAN ArpAll,\r
506 IN EFI_SMBUS_UDID *SmbusUdid, OPTIONAL\r
507 IN OUT EFI_SMBUS_DEVICE_ADDRESS *SlaveAddress OPTIONAL\r
508 )\r
509{\r
510 InitializeInternal ();\r
511\r
512 if (ArpAll) {\r
513 return SmbusFullArp ();\r
514 } else {\r
515 if ((SmbusUdid == NULL) || (SlaveAddress == NULL)) {\r
516 return EFI_INVALID_PARAMETER;\r
517 }\r
518 return SmbusDirectedArp ((EFI_SMBUS_UDID *)SmbusUdid, SlaveAddress);\r
519 }\r
520}\r
521\r
522/**\r
523 Returns a pointer to the Address Resolution Protocol (ARP) map that contains the ID/address pair\r
524 of the slave devices that were enumerated by the SMBus host controller driver.\r
525\r
526 The GetArpMap() function returns the mapping of all the SMBus devices that were enumerated by the\r
527 SMBus host driver.\r
528\r
529 @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance.\r
530 @param Length Size of the buffer that contains the SMBus device map.\r
531 @param SmbusDeviceMap The pointer to the device map as enumerated by the SMBus\r
532 controller driver.\r
533\r
534 @retval EFI_SUCCESS The SMBus returned the current device map.\r
535 @retval EFI_UNSUPPORTED The corresponding operation is not supported.\r
536\r
537**/\r
538EFI_STATUS\r
539EFIAPI\r
540SmbusGetArpMap (\r
541 IN CONST EFI_SMBUS_HC_PROTOCOL *This,\r
542 IN OUT UINTN *Length,\r
543 IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap\r
544 )\r
545{\r
546 *Length = mDeviceMapEntries;\r
547 *SmbusDeviceMap = mDeviceMap;\r
548 return EFI_SUCCESS;\r
549}\r
550\r
551\r
552/**\r
553 Allows a device driver to register for a callback when the bus driver detects a state that it\r
554 needs to propagate to other drivers that are registered for a callback.\r
555\r
556 The Notify() function registers all the callback functions to allow the bus driver to call these\r
557 functions when the SlaveAddress/Data pair happens.\r
558 If NotifyFunction is NULL, then ASSERT ().\r
559\r
560 @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance.\r
561 @param SlaveAddress The SMBUS hardware address to which the SMBUS device is\r
562 preassigned or allocated.\r
563 @param Data Data of the SMBus host notify command that the caller wants to be\r
564 called.\r
565 @param NotifyFunction The function to call when the bus driver detects the SlaveAddress\r
566 and Data pair.\r
567\r
568 @retval EFI_SUCCESS NotifyFunction was registered.\r
569 @retval EFI_UNSUPPORTED The corresponding operation is not supported.\r
570\r
571**/\r
572EFI_STATUS\r
573EFIAPI\r
574SmbusNotify (\r
575 IN CONST EFI_SMBUS_HC_PROTOCOL *This,\r
576 IN CONST EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,\r
577 IN CONST UINTN Data,\r
578 IN CONST EFI_SMBUS_NOTIFY_FUNCTION NotifyFunction\r
579 )\r
580{\r
581 return EFI_UNSUPPORTED;\r
582}\r
583\r
584/**\r
585 Entry point to the DXE Driver that produces the SMBus Host Controller Protocol.\r
586\r
587 @param ImageHandle ImageHandle of the loaded driver.\r
588 @param SystemTable Pointer to the EFI System Table.\r
589\r
590 @retval EFI_SUCCESS The entry point of SMBus DXE driver is executed successfully.\r
591 @retval !EFI_SUCESS Some error occurs in the entry point of SMBus DXE driver.\r
592\r
593**/\r
594EFI_STATUS\r
595EFIAPI\r
596InitializeQNCSmbus (\r
597 IN EFI_HANDLE ImageHandle,\r
598 IN EFI_SYSTEM_TABLE *SystemTable\r
599 )\r
600{\r
601 EFI_STATUS Status;\r
602\r
603 mPlatformNumRsvd = (UINT8)PcdGet32 (PcdPlatformSmbusAddrNum);\r
604 mPlatformAddrRsvd = (UINT8 *)(UINTN) PcdGet64 (PcdPlatformSmbusAddrTable);\r
605\r
606 //\r
607 // Install SMBus Host Controller protocol interface.\r
608 //\r
609 Status = gBS->InstallMultipleProtocolInterfaces (\r
610 &mSmbusHcHandle,\r
611 &gEfiSmbusHcProtocolGuid,\r
612 &mSmbusHc,\r
613 NULL\r
614 );\r
615 ASSERT_EFI_ERROR (Status);\r
616\r
617 return Status;\r
618}\r