How to Enable I2c configuration in edk2

Viewed 32

I use the \MdeModulePkg\Bus\I2c\I2cDxe driver and load the driver with the following command:

load I2cDxe.efi

As a result, both I2cHostDriverSupported and I2cBusDriverSupported get the returned value Unsupported. The code is as follows:

I2cHostDriverSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
...
Status = gBS->OpenProtocol (
Controller,
&gEfiI2cBusConfigurationManagementProtocolGuid,
(VOID **)&I2cBusConfigurationManagement,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);

I2cBusDriverSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
..
Status = gBS->OpenProtocol (
Controller,
&gEfiI2cEnumerateProtocolGuid,
(VOID**)&I2cEnumerate,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);

My system is as follows:

Platform: Minnowboard Max
pkg : edk2-platform\ Vlv2TbltDevicePkgX64

My questions are as follows:

1.Before I2cHostDriverSupported, should I need to enable the host configuratoin, such as setting slave address or frequency? Is there a more complete example? 2.For the Minnowboard platform, how to set I2cHostDriverSupported and I2cBusDriverSupported to get the return value of EFI_SUCCESS?

Any suggestion is highly appreciated! Thanks!

1 Answers

try to check, if the underline hardware API requires special privileges. there are some privileges that are only granted in certain stage of the UEFI boot stage, and these privileges are no longer available when UEFI shell is loaded up. Even if you load DXE driver from UEFI shell, it does not really get any privileges that are special to DXE drivers.

article about UEFI boot sequence: https://edk2-docs.gitbook.io/edk-ii-build-specification/2_design_discussion/23_boot_sequence

Related