There is has an example of I2cDxe driver in edk2, the path is \MdeModulePkg\Bus\I2c\I2cDxe.
However, I can't find an I2C example related to the app.
I use the following function, try to get the I2C handle:
EFI_STATUS LocateI2CIO(void)
{
EFI_STATUS Status;
EFI_HANDLE* I2CIOHandleBuffer = NULL;
UINTNHandleIndex = 0;
UINTNHandleCount = 0;
//get the handles which supports
Status = gBS->LocateHandleBuffer(
ByProtocol,
&gEfiI2cIoProtocolGuid,
NULL,
&HandleCount,
&I2CIOHandleBuffer
);
But the return value is EFI_NOT_FOUND.
My system : Minnowboard Max.
By the way, I also loaded I2CDxe.efi,
Command : load I2CDxe.efi
The result is as follows:
EFI_STATUS
EFIAPI
I2cBusDriverSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
EFI_STATUS Status;
EFI_I2C_ENUMERATE_PROTOCOL *I2cEnumerate;
EFI_I2C_HOST_PROTOCOL *I2cHost;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
BOOLEAN RemainingHasControllerNode;
UINT32 RemainingControllerNumber;
RemainingHasControllerNode = FALSE;
RemainingControllerNumber = 0;
//
// Determine if the I2c Enumerate Protocol is available
//
Status = gBS->OpenProtocol (
Controller,
&gEfiI2cEnumerateProtocolGuid,
(VOID**)&I2cEnumerate,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
The above function return value: Status : EFI_UNSUPPORTED
My questions are as follows:
1. Is there any full example in edk2 with I2C operation?
2. Do I need to load I2CDxe.efi before I2c operation?
3. Does I2cDxe.efi need to be modified to be loaded?
Any suggestion is greatly appreciated.
Thanks!