Date
1 - 3 of 3
How to operate I2C in UEFI app?
gordontcp@...
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!
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!
Bruno Oliveira
Hi Gordon
2 - Yes, it is necessary the I2CDxe has to be loaded before to use it
You can check the drivers available in your system using the command 'drivers' in the EFI Shell. There is a column that said how many devices are connected in this driver.
Are you trying to access a specific I2C pin? What are you trying to do?
Bruno Oliveira.
2 - Yes, it is necessary the I2CDxe has to be loaded before to use it
You can check the drivers available in your system using the command 'drivers' in the EFI Shell. There is a column that said how many devices are connected in this driver.
Are you trying to access a specific I2C pin? What are you trying to do?
Bruno Oliveira.
gordontcp@...
Hi Bruno,
Thanks for your response!
I set following command to load i2cdxe.efi:
load I2cDxe.efi.
Then, I set ‘drivers’ command in UEFI shell, and the number of devices connected to this driver is 0.
After I loaded I2cDXe.efi, it showed the messages that I2cBusDriverSupported and I2cHostDriverSupported returned the values EFI_UNSUPPORTED.
I2cBusDriverSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{..
// Determine if the I2c Enumerate Protocol is available
//
Status = gBS->OpenProtocol (
Controller,
&gEfiI2cEnumerateProtocolGuid,
(VOID **)&I2cEnumerate,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
My questions are
1.Before loading I2cDXE.efi, should I need to set acpi table or other table?
2.If I want to add an interrupt pin for the I2c device, how to set it?
3.Is there any full sample code for I2c device driver?
4.How to modify I2CDXE to load driver successfully?
Any suggestion is highly appreciated!
Thanks!
Thanks for your response!
I set following command to load i2cdxe.efi:
load I2cDxe.efi.
Then, I set ‘drivers’ command in UEFI shell, and the number of devices connected to this driver is 0.
After I loaded I2cDXe.efi, it showed the messages that I2cBusDriverSupported and I2cHostDriverSupported returned the values EFI_UNSUPPORTED.
I2cBusDriverSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{..
// Determine if the I2c Enumerate Protocol is available
//
Status = gBS->OpenProtocol (
Controller,
&gEfiI2cEnumerateProtocolGuid,
(VOID **)&I2cEnumerate,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
My questions are
1.Before loading I2cDXE.efi, should I need to set acpi table or other table?
2.If I want to add an interrupt pin for the I2c device, how to set it?
3.Is there any full sample code for I2c device driver?
4.How to modify I2CDXE to load driver successfully?
Any suggestion is highly appreciated!
Thanks!