瀏覽代碼

Platform/96Boards/96BoardsI2cDxe: connect I2C controllers at EndOfDxe

The 96boards I2C driver currently relies on the platform to connect
all controllers, or I2C peripherals will not be exposed if they are
not the active boot target. Since I2C peripherals are not boot targets
in the first place, but are used to expose things like random number
generators, let's connect the I2C controllers specifically at EndOfDxe
so that the devices living on it will be available regardless of the
boot policy.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Ard Biesheuvel 4 年之前
父節點
當前提交
032ac8f8e3

+ 18 - 0
Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.c

@@ -179,6 +179,19 @@ RegisterI2cBus (
   ASSERT_EFI_ERROR (Status);
 }
 
+STATIC
+VOID
+EFIAPI
+OnEndOfDxe (
+  IN EFI_EVENT  Event,
+  IN VOID       *Context
+  )
+{
+  gBS->CloseEvent (Event);
+  gBS->ConnectController (mI2cBus0.I2cMasterHandle, NULL, NULL, TRUE);
+  gBS->ConnectController (mI2cBus1.I2cMasterHandle, NULL, NULL, TRUE);
+}
+
 EFI_STATUS
 EFIAPI
 EntryPoint (
@@ -187,6 +200,7 @@ EntryPoint (
   )
 {
   EFI_STATUS    Status;
+  EFI_EVENT     EndOfDxeEvent;
 
   Status = gBS->LocateProtocol (&g96BoardsMezzanineProtocolGuid, NULL,
                   (VOID **)&mMezzanine);
@@ -197,5 +211,9 @@ EntryPoint (
   RegisterI2cBus (&g96BoardsI2c1MasterGuid, &mI2cBus1,
     mMezzanine->I2c1NumDevices, mMezzanine->I2c1DeviceArray);
 
+  Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, OnEndOfDxe,
+                  NULL, &gEfiEndOfDxeEventGroupGuid, &EndOfDxeEvent);
+  ASSERT_EFI_ERROR (Status);
+
   return EFI_SUCCESS;
 }

+ 1 - 0
Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf

@@ -36,6 +36,7 @@
 [Guids]
   g96BoardsI2c0MasterGuid
   g96BoardsI2c1MasterGuid
+  gEfiEndOfDxeEventGroupGuid
 
 [FixedPcd]
   g96BoardsTokenSpaceGuid.PcdI2c0BusFrequencyHz