public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* How to operate I2C in UEFI app?
@ 2022-08-01 10:18 gordontcp
  0 siblings, 0 replies; only message in thread
From: gordontcp @ 2022-08-01 10:18 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 1728 bytes --]

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!

[-- Attachment #2: Type: text/html, Size: 7202 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-01 10:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-01 10:18 How to operate I2C in UEFI app? gordontcp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox