TianoCore EDK2 master
Loading...
Searching...
No Matches
I2cHost.c
Go to the documentation of this file.
1
11#include "I2cDxe.h"
12
13EFI_DRIVER_BINDING_PROTOCOL gI2cHostDriverBinding = {
17 0x10,
18 NULL,
19 NULL
20};
21
22//
23// Driver name table
24//
26 { "eng;en", L"I2c Host Driver" },
27 { NULL, NULL }
28};
29
30//
31// EFI Component Name Protocol
32//
36 "eng"
37};
38
39//
40// EFI Component Name 2 Protocol
41//
45 "en"
46};
47
88EFIAPI
91 IN CHAR8 *Language,
92 OUT CHAR16 **DriverName
93 )
94{
96 Language,
97 This->SupportedLanguages,
98 mI2cHostDriverNameTable,
99 DriverName,
100 (BOOLEAN)(This != &gI2cHostComponentName2)
101 );
102}
103
173EFIAPI
176 IN EFI_HANDLE ControllerHandle,
177 IN EFI_HANDLE ChildHandle OPTIONAL,
178 IN CHAR8 *Language,
179 OUT CHAR16 **ControllerName
180 )
181{
182 return EFI_UNSUPPORTED;
183}
184
228EFIAPI
231 IN EFI_HANDLE Controller,
232 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
233 )
234{
235 EFI_I2C_MASTER_PROTOCOL *I2cMaster;
236 EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *I2cBusConfigurationManagement;
237 EFI_STATUS Status;
238
239 //
240 // Locate I2C Bus Configuration Management Protocol
241 //
242 Status = gBS->OpenProtocol (
243 Controller,
245 (VOID **)&I2cBusConfigurationManagement,
246 This->DriverBindingHandle,
247 Controller,
248 EFI_OPEN_PROTOCOL_BY_DRIVER
249 );
250 if (EFI_ERROR (Status)) {
251 return Status;
252 }
253
254 //
255 // Close the protocol because we don't use it here
256 //
257 gBS->CloseProtocol (
258 Controller,
260 This->DriverBindingHandle,
261 Controller
262 );
263
264 //
265 // Locate I2C Master Protocol
266 //
267 Status = gBS->OpenProtocol (
268 Controller,
269 &gEfiI2cMasterProtocolGuid,
270 (VOID **)&I2cMaster,
271 This->DriverBindingHandle,
272 Controller,
273 EFI_OPEN_PROTOCOL_GET_PROTOCOL
274 );
275 if (EFI_ERROR (Status)) {
276 return Status;
277 }
278
279 return EFI_SUCCESS;
280}
281
318EFIAPI
321 IN EFI_HANDLE Controller,
322 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
323 )
324{
325 EFI_STATUS Status;
326 EFI_I2C_MASTER_PROTOCOL *I2cMaster;
327 EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *I2cBusConfigurationManagement;
328 I2C_HOST_CONTEXT *I2cHostContext;
329
330 I2cMaster = NULL;
331 I2cHostContext = NULL;
332 I2cBusConfigurationManagement = NULL;
333
334 //
335 // Locate I2C Bus Configuration Management Protocol
336 //
337 Status = gBS->OpenProtocol (
338 Controller,
340 (VOID **)&I2cBusConfigurationManagement,
341 This->DriverBindingHandle,
342 Controller,
343 EFI_OPEN_PROTOCOL_BY_DRIVER
344 );
345 if (EFI_ERROR (Status)) {
346 DEBUG ((DEBUG_ERROR, "I2cHost: Open I2C bus configuration error, Status = %r\n", Status));
347 return Status;
348 }
349
350 //
351 // Locate I2C Master Protocol
352 //
353 Status = gBS->OpenProtocol (
354 Controller,
355 &gEfiI2cMasterProtocolGuid,
356 (VOID **)&I2cMaster,
357 This->DriverBindingHandle,
358 Controller,
359 EFI_OPEN_PROTOCOL_GET_PROTOCOL
360 );
361 if (EFI_ERROR (Status)) {
362 DEBUG ((DEBUG_ERROR, "I2cHost: Open I2C master error, Status = %r\n", Status));
363 goto Exit;
364 }
365
366 //
367 // Allocate the I2C Host Context structure
368 //
369 I2cHostContext = AllocateZeroPool (sizeof (I2C_HOST_CONTEXT));
370 if (I2cHostContext == NULL) {
371 DEBUG ((DEBUG_ERROR, "I2cHost: there is no enough memory to allocate.\n"));
372 Status = EFI_OUT_OF_RESOURCES;
373 goto Exit;
374 }
375
376 //
377 // Initialize the context structure for the current I2C Controller
378 //
379 I2cHostContext->Signature = I2C_HOST_SIGNATURE;
380 I2cHostContext->I2cMaster = I2cMaster;
381 I2cHostContext->I2cBusConfigurationManagement = I2cBusConfigurationManagement;
382 I2cHostContext->I2cBusConfiguration = (UINTN)-1;
383 InitializeListHead (&I2cHostContext->RequestList);
384
385 //
386 // Reset the controller
387 //
388 Status = I2cMaster->Reset (I2cMaster);
389 if (EFI_ERROR (Status)) {
390 DEBUG ((DEBUG_ERROR, "I2cHost: I2C controller reset failed!\n"));
391 goto Exit;
392 }
393
394 //
395 // Create the I2C transaction complete event
396 //
397 Status = gBS->CreateEvent (
398 EVT_NOTIFY_SIGNAL,
399 TPL_I2C_SYNC,
401 I2cHostContext,
402 &I2cHostContext->I2cEvent
403 );
404 if (EFI_ERROR (Status)) {
405 DEBUG ((DEBUG_ERROR, "I2cHost: create complete event error, Status = %r\n", Status));
406 goto Exit;
407 }
408
409 //
410 // Get the bus management event
411 //
412 Status = gBS->CreateEvent (
413 EVT_NOTIFY_SIGNAL,
414 TPL_I2C_SYNC,
416 I2cHostContext,
417 &I2cHostContext->I2cBusConfigurationEvent
418 );
419 if (EFI_ERROR (Status)) {
420 DEBUG ((DEBUG_ERROR, "I2cHost: create bus available event error, Status = %r\n", Status));
421 goto Exit;
422 }
423
424 //
425 // Build the I2C host protocol for the current I2C controller
426 //
427 I2cHostContext->I2cHost.QueueRequest = I2cHostQueueRequest;
428 I2cHostContext->I2cHost.I2cControllerCapabilities = I2cMaster->I2cControllerCapabilities;
429
430 //
431 // Install the driver protocol
432 //
433 Status = gBS->InstallMultipleProtocolInterfaces (
434 &Controller,
436 &I2cHostContext->I2cHost,
437 NULL
438 );
439Exit:
440 if (EFI_ERROR (Status)) {
441 DEBUG ((DEBUG_ERROR, "I2cHost: Start() function failed, Status = %r\n", Status));
442 if (I2cBusConfigurationManagement != NULL) {
443 gBS->CloseProtocol (
444 Controller,
446 This->DriverBindingHandle,
447 Controller
448 );
449 }
450
451 if ((I2cHostContext != NULL) && (I2cHostContext->I2cEvent != NULL)) {
452 gBS->CloseEvent (I2cHostContext->I2cEvent);
453 I2cHostContext->I2cEvent = NULL;
454 }
455
456 if ((I2cHostContext != NULL) && (I2cHostContext->I2cBusConfigurationEvent != NULL)) {
457 gBS->CloseEvent (I2cHostContext->I2cBusConfigurationEvent);
458 I2cHostContext->I2cBusConfigurationEvent = NULL;
459 }
460
461 //
462 // Release the context structure upon failure
463 //
464 if (I2cHostContext != NULL) {
465 FreePool (I2cHostContext);
466 }
467 }
468
469 //
470 // Return the operation status.
471 //
472 return Status;
473}
474
502EFIAPI
505 IN EFI_HANDLE Controller,
506 IN UINTN NumberOfChildren,
507 IN EFI_HANDLE *ChildHandleBuffer
508 )
509{
510 EFI_STATUS Status;
511 I2C_HOST_CONTEXT *I2cHostContext;
512 EFI_I2C_HOST_PROTOCOL *I2cHost;
513 EFI_TPL TplPrevious;
514
515 TplPrevious = EfiGetCurrentTpl ();
516 if (TplPrevious > TPL_I2C_SYNC) {
517 DEBUG ((DEBUG_ERROR, "I2cHost: TPL %d is too high in Stop.\n", TplPrevious));
518 return EFI_DEVICE_ERROR;
519 }
520
521 Status = gBS->OpenProtocol (
522 Controller,
524 (VOID **)&I2cHost,
525 This->DriverBindingHandle,
526 Controller,
527 EFI_OPEN_PROTOCOL_GET_PROTOCOL
528 );
529
530 if (EFI_ERROR (Status)) {
531 return EFI_DEVICE_ERROR;
532 }
533
534 I2cHostContext = I2C_HOST_CONTEXT_FROM_PROTOCOL (I2cHost);
535
536 //
537 // Raise TPL for critical section
538 //
539 TplPrevious = gBS->RaiseTPL (TPL_I2C_SYNC);
540
541 //
542 // If there is pending request or pending bus configuration, do not stop
543 //
544 Status = EFI_DEVICE_ERROR;
545 if ( (!I2cHostContext->I2cBusConfigurationManagementPending)
546 && IsListEmpty (&I2cHostContext->RequestList))
547 {
548 //
549 // Remove the I2C host protocol
550 //
551 Status = gBS->UninstallMultipleProtocolInterfaces (
552 Controller,
554 I2cHost,
555 NULL
556 );
557 }
558
559 //
560 // Leave critical section
561 //
562 gBS->RestoreTPL (TplPrevious);
563 if (!EFI_ERROR (Status)) {
564 gBS->CloseProtocol (
565 Controller,
567 This->DriverBindingHandle,
568 Controller
569 );
570
571 //
572 // Release I2c Host resources
573 //
574 if (I2cHostContext->I2cBusConfigurationEvent != NULL) {
575 gBS->CloseEvent (I2cHostContext->I2cBusConfigurationEvent);
576 I2cHostContext->I2cBusConfigurationEvent = NULL;
577 }
578
579 if (I2cHostContext->I2cEvent != NULL) {
580 gBS->CloseEvent (I2cHostContext->I2cEvent);
581 I2cHostContext->I2cEvent = NULL;
582 }
583
584 FreePool (I2cHostContext);
585 }
586
587 //
588 // Return the stop status
589 //
590 return Status;
591}
592
602VOID
603EFIAPI
605 IN EFI_EVENT Event,
606 IN VOID *Context
607 )
608{
609 I2C_HOST_CONTEXT *I2cHostContext;
610 EFI_I2C_MASTER_PROTOCOL *I2cMaster;
611 I2C_REQUEST *I2cRequest;
612 LIST_ENTRY *EntryHeader;
613 LIST_ENTRY *Entry;
614 EFI_STATUS Status;
615
616 //
617 // Mark this I2C bus configuration management operation as complete
618 //
619 I2cHostContext = (I2C_HOST_CONTEXT *)Context;
620 I2cMaster = I2cHostContext->I2cMaster;
621 ASSERT (I2cMaster != NULL);
622 //
623 // Clear flag to indicate I2C bus configuration is finished
624 //
625 I2cHostContext->I2cBusConfigurationManagementPending = FALSE;
626
627 //
628 // Validate the completion status
629 //
630 if (EFI_ERROR (I2cHostContext->Status)) {
631 //
632 // Setting I2C bus configuration failed before
633 //
634 I2cHostRequestComplete (I2cHostContext, I2cHostContext->Status);
635
636 //
637 // Unknown I2C bus configuration
638 // Force next operation to enable the I2C bus configuration
639 //
640 I2cHostContext->I2cBusConfiguration = (UINTN)-1;
641
642 //
643 // Do not continue current I2C request
644 //
645 return;
646 }
647
648 //
649 // Get the first request in the link with FIFO order
650 //
651 EntryHeader = &I2cHostContext->RequestList;
652 Entry = GetFirstNode (EntryHeader);
653 I2cRequest = I2C_REQUEST_FROM_ENTRY (Entry);
654
655 //
656 // Update the I2C bus configuration of the current I2C request
657 //
658 I2cHostContext->I2cBusConfiguration = I2cRequest->I2cBusConfiguration;
659
660 //
661 // Start an I2C operation on the host, the status is returned by I2cHostContext->Status
662 //
663 Status = I2cMaster->StartRequest (
664 I2cMaster,
665 I2cRequest->SlaveAddress,
666 I2cRequest->RequestPacket,
667 I2cHostContext->I2cEvent,
668 &I2cHostContext->Status
669 );
670
671 if (EFI_ERROR (Status)) {
672 DEBUG ((DEBUG_ERROR, "I2cHostI2cBusConfigurationAvailable: Error starting I2C operation, %r\n", Status));
673 }
674}
675
689 I2C_HOST_CONTEXT *I2cHostContext,
690 EFI_STATUS Status
691 )
692{
693 I2C_REQUEST *I2cRequest;
694 LIST_ENTRY *EntryHeader;
695 LIST_ENTRY *Entry;
696
697 //
698 // Remove the current I2C request from the list
699 //
700 EntryHeader = &I2cHostContext->RequestList;
701 Entry = GetFirstNode (EntryHeader);
702 I2cRequest = I2C_REQUEST_FROM_ENTRY (Entry);
703
704 //
705 // Save the status for QueueRequest
706 //
707 if ( NULL != I2cRequest->Status ) {
708 *I2cRequest->Status = Status;
709 }
710
711 //
712 // Notify the user of the I2C request completion
713 //
714 if ( NULL != I2cRequest->Event ) {
715 gBS->SignalEvent (I2cRequest->Event);
716 }
717
718 //
719 // Done with this request, remove the current request from list
720 //
721 RemoveEntryList (&I2cRequest->Link);
722 FreePool (I2cRequest->RequestPacket);
723 FreePool (I2cRequest);
724
725 //
726 // If there is more I2C request, start next one
727 //
728 if (!IsListEmpty (EntryHeader)) {
729 I2cHostRequestEnable (I2cHostContext);
730 }
731
732 return Status;
733}
734
744VOID
745EFIAPI
747 IN EFI_EVENT Event,
748 IN VOID *Context
749 )
750{
751 I2C_HOST_CONTEXT *I2cHostContext;
752
753 //
754 // Handle the completion event
755 //
756 I2cHostContext = (I2C_HOST_CONTEXT *)Context;
757 I2cHostRequestComplete (I2cHostContext, I2cHostContext->Status);
758}
759
787 I2C_HOST_CONTEXT *I2cHostContext
788 )
789{
790 UINTN I2cBusConfiguration;
791 CONST EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *I2cBusConfigurationManagement;
792 I2C_REQUEST *I2cRequest;
793 EFI_STATUS Status;
794 EFI_TPL TplPrevious;
795 LIST_ENTRY *EntryHeader;
796 LIST_ENTRY *Entry;
797
798 //
799 // Assume pending request
800 //
801 Status = EFI_NOT_READY;
802
803 I2cBusConfigurationManagement = I2cHostContext->I2cBusConfigurationManagement;
804
805 //
806 // Validate the I2c bus configuration
807 //
808 EntryHeader = &I2cHostContext->RequestList;
809 Entry = GetFirstNode (EntryHeader);
810 I2cRequest = I2C_REQUEST_FROM_ENTRY (Entry);
811
812 I2cBusConfiguration = I2cRequest->I2cBusConfiguration;
813
814 if (I2cHostContext->I2cBusConfiguration != I2cBusConfiguration ) {
815 //
816 // Set flag to indicate I2C bus configuration is in progress
817 //
818 I2cHostContext->I2cBusConfigurationManagementPending = TRUE;
819 //
820 // Update bus configuration for this device's requesting bus configuration
821 //
822 Status = I2cBusConfigurationManagement->EnableI2cBusConfiguration (
823 I2cBusConfigurationManagement,
824 I2cBusConfiguration,
825 I2cHostContext->I2cBusConfigurationEvent,
826 &I2cHostContext->Status
827 );
828 } else {
829 //
830 // I2C bus configuration is same, no need change configuration and start I2c transaction directly
831 //
832 TplPrevious = gBS->RaiseTPL (TPL_I2C_SYNC);
833
834 //
835 // Same I2C bus configuration
836 //
837 I2cHostContext->Status = EFI_SUCCESS;
838 I2cHostI2cBusConfigurationAvailable (I2cHostContext->I2cBusConfigurationEvent, I2cHostContext);
839
840 //
841 // Release the thread synchronization
842 //
843 gBS->RestoreTPL (TplPrevious);
844 }
845
846 return Status;
847}
848
914EFIAPI
917 IN UINTN I2cBusConfiguration,
918 IN UINTN SlaveAddress,
919 IN EFI_EVENT Event OPTIONAL,
920 IN EFI_I2C_REQUEST_PACKET *RequestPacket,
921 OUT EFI_STATUS *I2cStatus OPTIONAL
922 )
923{
924 EFI_STATUS Status;
925 EFI_EVENT SyncEvent;
926 EFI_TPL TplPrevious;
927 I2C_REQUEST *I2cRequest;
928 I2C_HOST_CONTEXT *I2cHostContext;
929 BOOLEAN FirstRequest;
930 UINTN RequestPacketSize;
931 UINTN StartBit;
932
933 SyncEvent = NULL;
934 FirstRequest = FALSE;
935 Status = EFI_SUCCESS;
936
937 if (RequestPacket == NULL) {
938 return EFI_INVALID_PARAMETER;
939 }
940
941 if ((SlaveAddress & I2C_ADDRESSING_10_BIT) != 0) {
942 //
943 // 10-bit address, bits 0-9 are used for 10-bit I2C slave addresses,
944 // bits 10-30 are reserved bits and must be zero
945 //
946 StartBit = 10;
947 } else {
948 //
949 // 7-bit address, Bits 0-6 are used for 7-bit I2C slave addresses,
950 // bits 7-30 are reserved bits and must be zero
951 //
952 StartBit = 7;
953 }
954
955 if (BitFieldRead32 ((UINT32)SlaveAddress, StartBit, 30) != 0) {
956 //
957 // Reserved bit set in the SlaveAddress parameter
958 //
959 return EFI_NOT_FOUND;
960 }
961
962 I2cHostContext = I2C_HOST_CONTEXT_FROM_PROTOCOL (This);
963
964 if (Event == NULL) {
965 //
966 // For synchronous transaction, register an event used to wait for finishing synchronous transaction
967 //
968 Status = gBS->CreateEvent (
969 0,
970 TPL_I2C_SYNC,
971 NULL,
972 NULL,
973 &SyncEvent
974 );
975 if (EFI_ERROR (Status)) {
976 return Status;
977 }
978 }
979
980 //
981 // TPL should be at or below TPL_NOTIFY.
982 // For synchronous requests this routine must be called at or below TPL_CALLBACK.
983 //
984 TplPrevious = EfiGetCurrentTpl ();
985 if ((TplPrevious > TPL_I2C_SYNC) || ((Event == NULL) && (TplPrevious > TPL_CALLBACK))) {
986 DEBUG ((DEBUG_ERROR, "ERROR - TPL %d is too high!\n", TplPrevious));
987 return EFI_INVALID_PARAMETER;
988 }
989
990 //
991 // Allocate the request structure
992 //
993 I2cRequest = AllocateZeroPool (sizeof (I2C_REQUEST));
994 if (I2cRequest == NULL) {
995 DEBUG ((DEBUG_ERROR, "WARNING - Failed to allocate I2C_REQUEST!\n"));
996 return EFI_OUT_OF_RESOURCES;
997 }
998
999 //
1000 // Initialize the request
1001 //
1002 I2cRequest->Signature = I2C_REQUEST_SIGNATURE;
1003 I2cRequest->I2cBusConfiguration = I2cBusConfiguration;
1004 I2cRequest->SlaveAddress = SlaveAddress;
1005 I2cRequest->Event = (Event == NULL) ? SyncEvent : Event;
1006 I2cRequest->Status = I2cStatus;
1007
1008 //
1009 // Copy request packet into private buffer, as RequestPacket may be freed during asynchronous transaction
1010 //
1011 RequestPacketSize = sizeof (UINTN) + RequestPacket->OperationCount * sizeof (EFI_I2C_OPERATION);
1012 I2cRequest->RequestPacket = AllocateZeroPool (RequestPacketSize);
1013 ASSERT (I2cRequest->RequestPacket != NULL);
1014 CopyMem (I2cRequest->RequestPacket, RequestPacket, RequestPacketSize);
1015
1016 //
1017 // Synchronize with the other threads
1018 //
1019 gBS->RaiseTPL (TPL_I2C_SYNC);
1020
1021 FirstRequest = IsListEmpty (&I2cHostContext->RequestList);
1022
1023 //
1024 // Insert new I2C request in the list
1025 //
1026 InsertTailList (&I2cHostContext->RequestList, &I2cRequest->Link);
1027
1028 //
1029 // Release the thread synchronization
1030 //
1031 gBS->RestoreTPL (TplPrevious);
1032
1033 if (FirstRequest) {
1034 //
1035 // Start the first I2C request, then the subsequent of I2C request will continue
1036 //
1037 Status = I2cHostRequestEnable (I2cHostContext);
1038 }
1039
1040 if (Event != NULL) {
1041 //
1042 // For asynchronous, return EFI_SUCCESS indicating that the asynchronously I2C transaction was queued.
1043 // No real I2C operation status in I2cStatus
1044 //
1045 return EFI_SUCCESS;
1046 }
1047
1048 //
1049 // For synchronous transaction, wait for the operation completion
1050 //
1051 do {
1052 Status = gBS->CheckEvent (SyncEvent);
1053 } while (Status == EFI_NOT_READY);
1054
1055 //
1056 // Get the I2C operation status
1057 //
1058 Status = I2cHostContext->Status;
1059
1060 //
1061 // Return the I2C operation status
1062 //
1063 if (I2cStatus != NULL) {
1064 *I2cStatus = Status;
1065 }
1066
1067 //
1068 // Close the event if necessary
1069 //
1070 if (SyncEvent != NULL) {
1071 gBS->CloseEvent (SyncEvent);
1072 }
1073
1074 return Status;
1075}
1076
1088EFIAPI
1090 IN EFI_HANDLE ImageHandle,
1091 IN EFI_SYSTEM_TABLE *SystemTable
1092 )
1093{
1094 EFI_STATUS Status;
1095
1096 //
1097 // Install driver model protocol(s).
1098 //
1100 ImageHandle,
1101 SystemTable,
1102 &gI2cHostDriverBinding,
1103 ImageHandle,
1104 &gI2cHostComponentName,
1105 &gI2cHostComponentName2
1106 );
1107 ASSERT_EFI_ERROR (Status);
1108 return Status;
1109}
1110
1124EFIAPI
1126 IN EFI_HANDLE ImageHandle
1127 )
1128{
1129 EFI_STATUS Status;
1130 EFI_HANDLE *DeviceHandleBuffer;
1131 UINTN DeviceHandleCount;
1132 UINTN Index;
1133 EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
1134 EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
1135
1136 //
1137 // Get the list of all I2C Controller handles in the handle database.
1138 // If there is an error getting the list, then the unload
1139 // operation fails.
1140 //
1141 Status = gBS->LocateHandleBuffer (
1142 ByProtocol,
1144 NULL,
1145 &DeviceHandleCount,
1146 &DeviceHandleBuffer
1147 );
1148
1149 if (!EFI_ERROR (Status)) {
1150 //
1151 // Disconnect the driver specified by ImageHandle from all
1152 // the devices in the handle database.
1153 //
1154 for (Index = 0; Index < DeviceHandleCount; Index++) {
1155 Status = gBS->DisconnectController (
1156 DeviceHandleBuffer[Index],
1157 ImageHandle,
1158 NULL
1159 );
1160 if (EFI_ERROR (Status)) {
1161 goto Done;
1162 }
1163 }
1164 }
1165
1166 //
1167 // Uninstall all the protocols installed in the driver entry point
1168 //
1169 Status = gBS->UninstallMultipleProtocolInterfaces (
1170 gI2cHostDriverBinding.DriverBindingHandle,
1171 &gEfiDriverBindingProtocolGuid,
1172 &gI2cHostDriverBinding,
1173 NULL
1174 );
1175 ASSERT_EFI_ERROR (Status);
1176
1177 //
1178 // Note we have to one by one uninstall the following protocols.
1179 // It's because some of them are optionally installed based on
1180 // the following PCD settings.
1181 // gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable
1182 // gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable
1183 // gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable
1184 // gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable
1185 //
1186 Status = gBS->HandleProtocol (
1187 gI2cHostDriverBinding.DriverBindingHandle,
1188 &gEfiComponentNameProtocolGuid,
1189 (VOID **)&ComponentName
1190 );
1191 if (!EFI_ERROR (Status)) {
1192 gBS->UninstallProtocolInterface (
1193 gI2cHostDriverBinding.DriverBindingHandle,
1194 &gEfiComponentNameProtocolGuid,
1195 ComponentName
1196 );
1197 }
1198
1199 Status = gBS->HandleProtocol (
1200 gI2cHostDriverBinding.DriverBindingHandle,
1201 &gEfiComponentName2ProtocolGuid,
1202 (VOID **)&ComponentName2
1203 );
1204 if (!EFI_ERROR (Status)) {
1205 gBS->UninstallProtocolInterface (
1206 gI2cHostDriverBinding.DriverBindingHandle,
1207 &gEfiComponentName2ProtocolGuid,
1208 ComponentName2
1209 );
1210 }
1211
1212 Status = EFI_SUCCESS;
1213
1214Done:
1215 //
1216 // Free the buffer containing the list of handles from the handle database
1217 //
1218 if (DeviceHandleBuffer != NULL) {
1219 gBS->FreePool (DeviceHandleBuffer);
1220 }
1221
1222 return Status;
1223}
UINT64 UINTN
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
Definition: LinkedList.c:403
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
Definition: LinkedList.c:298
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
UINT32 EFIAPI BitFieldRead32(IN UINT32 Operand, IN UINTN StartBit, IN UINTN EndBit)
Definition: BitField.c:527
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_GUID gEfiI2cBusConfigurationManagementProtocolGuid
EFI_STATUS EFIAPI I2cHostDriverStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: I2cHost.c:319
EFI_STATUS I2cHostRequestComplete(I2C_HOST_CONTEXT *I2cHostContext, EFI_STATUS Status)
Definition: I2cHost.c:688
EFI_STATUS EFIAPI I2cHostUnload(IN EFI_HANDLE ImageHandle)
Definition: I2cHost.c:1125
EFI_STATUS EFIAPI I2cHostComponentNameGetDriverName(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
Definition: I2cHost.c:89
VOID EFIAPI I2cHostI2cBusConfigurationAvailable(IN EFI_EVENT Event, IN VOID *Context)
Definition: I2cHost.c:604
EFI_STATUS I2cHostRequestEnable(I2C_HOST_CONTEXT *I2cHostContext)
Definition: I2cHost.c:786
EFI_STATUS EFIAPI InitializeI2cHost(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: I2cHost.c:1089
EFI_STATUS EFIAPI I2cHostComponentNameGetControllerName(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
Definition: I2cHost.c:174
EFI_STATUS EFIAPI I2cHostDriverSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: I2cHost.c:229
EFI_STATUS EFIAPI I2cHostQueueRequest(IN CONST EFI_I2C_HOST_PROTOCOL *This, IN UINTN I2cBusConfiguration, IN UINTN SlaveAddress, IN EFI_EVENT Event OPTIONAL, IN EFI_I2C_REQUEST_PACKET *RequestPacket, OUT EFI_STATUS *I2cStatus OPTIONAL)
Definition: I2cHost.c:915
EFI_STATUS EFIAPI I2cHostDriverStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: I2cHost.c:503
VOID EFIAPI I2cHostRequestCompleteEvent(IN EFI_EVENT Event, IN VOID *Context)
Definition: I2cHost.c:746
EFI_GUID gEfiI2cHostProtocolGuid
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define GLOBAL_REMOVE_IF_UNREFERENCED
Definition: Base.h:48
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_STATUS(EFIAPI * EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
Definition: ComponentName.h:96
EFI_STATUS(EFIAPI * EFI_COMPONENT_NAME_GET_DRIVER_NAME)(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
Definition: ComponentName.h:48
#define I2C_ADDRESSING_10_BIT
Definition: PiI2c.h:20
VOID EFIAPI Exit(IN EFI_STATUS Status)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
UINTN EFI_TPL
Definition: UefiBaseType.h:41
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_TPL EFIAPI EfiGetCurrentTpl(VOID)
Definition: UefiLib.c:375
EFI_STATUS EFIAPI LookupUnicodeString2(IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable, OUT CHAR16 **UnicodeString, IN BOOLEAN Iso639Language)
Definition: UefiLib.c:801
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
@ ByProtocol
Definition: UefiSpec.h:1518
CONST EFI_I2C_CONTROLLER_CAPABILITIES * I2cControllerCapabilities
Definition: I2cHost.h:137
EFI_I2C_HOST_PROTOCOL_QUEUE_REQUEST QueueRequest
Definition: I2cHost.h:131
EFI_I2C_MASTER_PROTOCOL_RESET Reset
Definition: I2cMaster.h:170
EFI_I2C_MASTER_PROTOCOL_START_REQUEST StartRequest
Definition: I2cMaster.h:175
CONST EFI_I2C_CONTROLLER_CAPABILITIES * I2cControllerCapabilities
Definition: I2cMaster.h:181