TianoCore EDK2 master
Loading...
Searching...
No Matches
I2cDxe.h File Reference

Go to the source code of this file.

Data Structures

struct  I2C_BUS_CONTEXT
 
struct  I2C_DEVICE_CONTEXT
 
struct  I2C_REQUEST
 
struct  I2C_HOST_CONTEXT
 

Macros

#define I2C_DEVICE_SIGNATURE   SIGNATURE_32 ('I', '2', 'C', 'D')
 
#define I2C_HOST_SIGNATURE   SIGNATURE_32 ('I', '2', 'C', 'H')
 
#define I2C_REQUEST_SIGNATURE   SIGNATURE_32 ('I', '2', 'C', 'R')
 
#define TPL_I2C_SYNC   TPL_NOTIFY
 
#define I2C_DEVICE_CONTEXT_FROM_PROTOCOL(a)   CR (a, I2C_DEVICE_CONTEXT, I2cIo, I2C_DEVICE_SIGNATURE)
 
#define I2C_REQUEST_FROM_ENTRY(a)   CR (a, I2C_REQUEST, Link, I2C_REQUEST_SIGNATURE);
 
#define I2C_HOST_CONTEXT_FROM_PROTOCOL(a)   CR (a, I2C_HOST_CONTEXT, I2cHost, I2C_HOST_SIGNATURE)
 

Functions

EFI_STATUS RegisterI2cDevice (IN I2C_BUS_CONTEXT *I2cBus, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS UnRegisterI2cDevice (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_HANDLE Handle)
 
EFI_STATUS I2cBusDevicePathAppend (IN I2C_DEVICE_CONTEXT *I2cDeviceContext, IN BOOLEAN BuildControllerNode)
 
EFI_STATUS EFIAPI I2cBusQueueRequest (IN CONST EFI_I2C_IO_PROTOCOL *This, IN UINTN SlaveAddressIndex, IN EFI_EVENT Event OPTIONAL, IN EFI_I2C_REQUEST_PACKET *RequestPacket, OUT EFI_STATUS *I2cStatus OPTIONAL)
 
EFI_STATUS EFIAPI I2cBusDriverSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI I2cBusDriverStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI I2cBusDriverStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
EFI_STATUS EFIAPI I2cBusComponentNameGetDriverName (IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
 
EFI_STATUS EFIAPI I2cBusComponentNameGetControllerName (IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
 
EFI_STATUS EFIAPI InitializeI2cBus (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI I2cBusUnload (IN EFI_HANDLE ImageHandle)
 
VOID ReleaseI2cDeviceContext (IN I2C_DEVICE_CONTEXT *I2cDeviceContext)
 
EFI_STATUS I2cHostRequestComplete (I2C_HOST_CONTEXT *I2cHost, EFI_STATUS Status)
 
EFI_STATUS I2cHostRequestEnable (I2C_HOST_CONTEXT *I2cHost)
 
EFI_STATUS EFIAPI I2cHostDriverSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI I2cHostDriverStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI I2cHostDriverStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
EFI_STATUS EFIAPI I2cHostComponentNameGetDriverName (IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
 
EFI_STATUS EFIAPI I2cHostComponentNameGetControllerName (IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
 
VOID EFIAPI I2cHostRequestCompleteEvent (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI I2cHostI2cBusConfigurationAvailable (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI I2cHostQueueRequest (IN CONST EFI_I2C_HOST_PROTOCOL *This, IN UINTN I2cBusConfiguration, IN UINTN SlaveAddress, IN EFI_EVENT Event OPTIONAL, IN EFI_I2C_REQUEST_PACKET *RequestPacket, OUT EFI_STATUS *I2cStatus OPTIONAL)
 
EFI_STATUS EFIAPI InitializeI2cHost (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI I2cHostUnload (IN EFI_HANDLE ImageHandle)
 

Variables

EFI_COMPONENT_NAME_PROTOCOL gI2cBusComponentName
 
EFI_COMPONENT_NAME2_PROTOCOL gI2cBusComponentName2
 
EFI_DRIVER_BINDING_PROTOCOL gI2cBusDriverBinding
 
EFI_COMPONENT_NAME_PROTOCOL gI2cHostComponentName
 
EFI_COMPONENT_NAME2_PROTOCOL gI2cHostComponentName2
 
EFI_DRIVER_BINDING_PROTOCOL gI2cHostDriverBinding
 

Detailed Description

Private data structures for the I2C DXE driver.

This file defines common data structures, macro definitions and some module internal function header files.

Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file I2cDxe.h.

Macro Definition Documentation

◆ I2C_DEVICE_CONTEXT_FROM_PROTOCOL

#define I2C_DEVICE_CONTEXT_FROM_PROTOCOL (   a)    CR (a, I2C_DEVICE_CONTEXT, I2cIo, I2C_DEVICE_SIGNATURE)

Definition at line 89 of file I2cDxe.h.

◆ I2C_DEVICE_SIGNATURE

#define I2C_DEVICE_SIGNATURE   SIGNATURE_32 ('I', '2', 'C', 'D')

Definition at line 33 of file I2cDxe.h.

◆ I2C_HOST_CONTEXT_FROM_PROTOCOL

#define I2C_HOST_CONTEXT_FROM_PROTOCOL (   a)    CR (a, I2C_HOST_CONTEXT, I2cHost, I2C_HOST_SIGNATURE)

Definition at line 189 of file I2cDxe.h.

◆ I2C_HOST_SIGNATURE

#define I2C_HOST_SIGNATURE   SIGNATURE_32 ('I', '2', 'C', 'H')

Definition at line 34 of file I2cDxe.h.

◆ I2C_REQUEST_FROM_ENTRY

#define I2C_REQUEST_FROM_ENTRY (   a)    CR (a, I2C_REQUEST, Link, I2C_REQUEST_SIGNATURE);

Definition at line 132 of file I2cDxe.h.

◆ I2C_REQUEST_SIGNATURE

#define I2C_REQUEST_SIGNATURE   SIGNATURE_32 ('I', '2', 'C', 'R')

Definition at line 35 of file I2cDxe.h.

◆ TPL_I2C_SYNC

#define TPL_I2C_SYNC   TPL_NOTIFY

Definition at line 40 of file I2cDxe.h.

Function Documentation

◆ I2cBusComponentNameGetControllerName()

EFI_STATUS EFIAPI I2cBusComponentNameGetControllerName ( IN EFI_COMPONENT_NAME2_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_HANDLE ChildHandle  OPTIONAL,
IN CHAR8 *  Language,
OUT CHAR16 **  ControllerName 
)

Retrieves a Unicode string that is the user readable name of the controller that is being managed by a driver.

This function retrieves the user readable name of the controller specified by ControllerHandle and ChildHandle in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the controller name is returned in ControllerName, and EFI_SUCCESS is returned. If the driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle, then EFI_UNSUPPORTED is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned.

Parameters
This[in]A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance.
ControllerHandle[in]The handle of a controller that the driver specified by This is managing. This handle specifies the controller whose name is to be returned.
ChildHandle[in]The handle of the child controller to retrieve the name of. This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers that wish to retrieve the name of the bus controller. It will not be NULL for a bus driver that wishes to retrieve the name of a child controller.
Language[in]A pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the languages specified in SupportedLanguages. The number of languages supported by a driver is up to the driver writer. Language is specified in RFC 4646 or ISO 639-2 language code format.
ControllerName[out]A pointer to the Unicode string to return. This Unicode string is the name of the controller specified by ControllerHandle and ChildHandle in the language specified by Language from the point of view of the driver specified by This.
Return values
EFI_SUCCESSThe Unicode string for the user readable name in the language specified by Language for the driver specified by This was returned in DriverName.
EFI_INVALID_PARAMETERControllerHandle is NULL.
EFI_INVALID_PARAMETERChildHandle is not NULL and it is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERControllerName is NULL.
EFI_UNSUPPORTEDThe driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle.
EFI_UNSUPPORTEDThe driver specified by This does not support the language specified by Language.

Definition at line 225 of file I2cBus.c.

◆ I2cBusComponentNameGetDriverName()

EFI_STATUS EFIAPI I2cBusComponentNameGetDriverName ( IN EFI_COMPONENT_NAME2_PROTOCOL This,
IN CHAR8 *  Language,
OUT CHAR16 **  DriverName 
)

Retrieves a Unicode string that is the user readable name of the driver.

This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned.

Parameters
This[in]A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance.
Language[in]A pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the languages specified in SupportedLanguages. The number of languages supported by a driver is up to the driver writer. Language is specified in RFC 4646 or ISO 639-2 language code format.
DriverName[out]A pointer to the Unicode string to return. This Unicode string is the name of the driver specified by This in the language specified by Language.
Return values
EFI_SUCCESSThe Unicode string for the Driver specified by This and the language specified by Language was returned in DriverName.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERDriverName is NULL.
EFI_UNSUPPORTEDThe driver specified by This does not support the language specified by Language.

Definition at line 140 of file I2cBus.c.

◆ I2cBusDevicePathAppend()

EFI_STATUS I2cBusDevicePathAppend ( IN I2C_DEVICE_CONTEXT I2cDeviceContext,
IN BOOLEAN  BuildControllerNode 
)

Create a path for the I2C device

Append the I2C slave path to the I2C master controller path.

Parameters
[in]I2cDeviceContextAddress of an I2C_DEVICE_CONTEXT structure.
[in]BuildControllerNodeFlag to build controller node in device path.
Return values
EFI_SUCCESSThe I2C device path is built successfully.
Returns
Others It is failed to built device path.

Definition at line 1317 of file I2cBus.c.

◆ I2cBusDriverStart()

EFI_STATUS EFIAPI I2cBusDriverStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Starts a device controller or a bus controller.

The Start() function is designed to be invoked from the EFI boot service ConnectController(). As a result, much of the error checking on the parameters to Start() has been moved into this common boot service. It is legal to call Start() from other locations, but the following calling restrictions must be followed or the system behavior will not be deterministic.

  1. ControllerHandle must be a valid EFI_HANDLE.
  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned EFI_DEVICE_PATH_PROTOCOL.
  3. Prior to calling Start(), the Supported() function for the driver specified by This must have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
Parameters
[in]ThisA pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
[in]ControllerHandleThe handle of the controller to start. This handle must support a protocol interface that supplies an I/O abstraction to the driver.
[in]RemainingDevicePathA pointer to the remaining portion of a device path. This parameter is ignored by device drivers, and is optional for bus drivers. For a bus driver, if this parameter is NULL, then handles for all the children of Controller are created by this driver. If this parameter is not NULL and the first Device Path Node is not the End of Device Path Node, then only the handle for the child device specified by the first Device Path Node of RemainingDevicePath is created by this driver. If the first Device Path Node of RemainingDevicePath is the End of Device Path Node, no child handle is created by this driver.
Return values
EFI_SUCCESSThe device was started.
EFI_DEVICE_ERRORThe device could not be started due to a device error.Currently not implemented.
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources.
OthersThe driver failed to start the device.

Definition at line 557 of file I2cBus.c.

◆ I2cBusDriverStop()

EFI_STATUS EFIAPI I2cBusDriverStop ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN UINTN  NumberOfChildren,
IN EFI_HANDLE ChildHandleBuffer 
)

Stops a device controller or a bus controller.

The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). As a result, much of the error checking on the parameters to Stop() has been moved into this common boot service. It is legal to call Stop() from other locations, but the following calling restrictions must be followed or the system behavior will not be deterministic.

  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this same driver's Start() function.
  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid EFI_HANDLE. In addition, all of these handles must have been created in this driver's Start() function, and the Start() function must have called OpenProtocol() on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
Parameters
[in]ThisA pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
[in]ControllerHandleA handle to the device being stopped. The handle must support a bus specific I/O protocol for the driver to use to stop the device.
[in]NumberOfChildrenThe number of child device handles in ChildHandleBuffer.
[in]ChildHandleBufferAn array of child handles to be freed. May be NULL if NumberOfChildren is 0.
Return values
EFI_SUCCESSThe device was stopped.
EFI_DEVICE_ERRORThe device could not be stopped due to a device error.

Definition at line 777 of file I2cBus.c.

◆ I2cBusDriverSupported()

EFI_STATUS EFIAPI I2cBusDriverSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device.

This function checks to see if the driver specified by This supports the device specified by ControllerHandle. Drivers will typically use the device path attached to ControllerHandle and/or the services from the bus I/O abstraction attached to ControllerHandle to determine if the driver supports ControllerHandle. This function may be called many times during platform initialization. In order to reduce boot times, the tests performed by this function must be very small, and take as little time as possible to execute. This function must not change the state of any hardware devices, and this function must be aware that the device specified by ControllerHandle may already be managed by the same driver or a different driver. This function must match its calls to AllocatePages() with FreePages(), AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). Since ControllerHandle may have been previously started by the same driver, if a protocol is already in the opened state, then it must not be closed with CloseProtocol(). This is required to guarantee the state of ControllerHandle is not modified by this function.

Parameters
[in]ThisA pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
[in]ControllerHandleThe handle of the controller to test. This handle must support a protocol interface that supplies an I/O abstraction to the driver.
[in]RemainingDevicePathA pointer to the remaining portion of a device path. This parameter is ignored by device drivers, and is optional for bus drivers. For bus drivers, if this parameter is not NULL, then the bus driver must determine if the bus controller specified by ControllerHandle and the child controller specified by RemainingDevicePath are both supported by this bus driver.
Return values
EFI_SUCCESSThe device specified by ControllerHandle and RemainingDevicePath is supported by the driver specified by This.
EFI_ALREADY_STARTEDThe device specified by ControllerHandle and RemainingDevicePath is already being managed by the driver specified by This.
EFI_ACCESS_DENIEDThe device specified by ControllerHandle and RemainingDevicePath is already being managed by a different driver or an application that requires exclusive access. Currently not implemented.
EFI_UNSUPPORTEDThe device specified by ControllerHandle and RemainingDevicePath is not supported by the driver specified by This.

Definition at line 385 of file I2cBus.c.

◆ I2cBusQueueRequest()

EFI_STATUS EFIAPI I2cBusQueueRequest ( IN CONST EFI_I2C_IO_PROTOCOL This,
IN UINTN  SlaveAddressIndex,
IN EFI_EVENT Event  OPTIONAL,
IN EFI_I2C_REQUEST_PACKET RequestPacket,
OUT EFI_STATUS *I2cStatus  OPTIONAL 
)

Queue an I2C transaction for execution on the I2C device.

This routine must be called at or below TPL_NOTIFY. For synchronous requests this routine must be called at or below TPL_CALLBACK.

This routine queues an I2C transaction to the I2C controller for execution on the I2C bus.

When Event is NULL, QueueRequest() operates synchronously and returns the I2C completion status as its return value.

When Event is not NULL, QueueRequest() synchronously returns EFI_SUCCESS indicating that the asynchronous I2C transaction was queued. The values above are returned in the buffer pointed to by I2cStatus upon the completion of the I2C transaction when I2cStatus is not NULL.

The upper layer driver writer provides the following to the platform vendor:

  1. Vendor specific GUID for the I2C part
  2. Guidance on proper construction of the slave address array when the I2C device uses more than one slave address. The I2C bus protocol uses the SlaveAddressIndex to perform relative to physical address translation to access the blocks of hardware within the I2C device.
Parameters
[in]ThisPointer to an EFI_I2C_IO_PROTOCOL structure.
[in]SlaveAddressIndexIndex value into an array of slave addresses for the I2C device. The values in the array are specified by the board designer, with the third party I2C device driver writer providing the slave address order.

For devices that have a single slave address, this value must be zero. If the I2C device uses more than one slave address then the third party (upper level) I2C driver writer needs to specify the order of entries in the slave address array.

Third Party I2C Drivers" section in I2cMaster.h. @param [in] Event Event to signal for asynchronous transactions, NULL for synchronous transactions @param [in] RequestPacket Pointer to an EFI_I2C_REQUEST_PACKET structure describing the I2C transaction @param [out] I2cStatus Optional buffer to receive the I2C transaction completion status @retval EFI_SUCCESS The asynchronous transaction was successfully queued when Event is not NULL. @retval EFI_SUCCESS The transaction completed successfully when Event is NULL. @retval EFI_ABORTED The request did not complete because the driver binding Stop() routine was called. @retval EFI_BAD_BUFFER_SIZE The RequestPacket->LengthInBytes value is too large. @retval EFI_DEVICE_ERROR There was an I2C error (NACK) during the transaction. @retval EFI_INVALID_PARAMETER RequestPacket is NULL @retval EFI_NOT_FOUND Reserved bit set in the SlaveAddress parameter @retval EFI_NO_MAPPING The EFI_I2C_HOST_PROTOCOL could not set the bus configuration required to access this I2C device. @retval EFI_NO_RESPONSE The I2C device is not responding to the slave address selected by SlaveAddressIndex. EFI_DEVICE_ERROR will be returned if the controller cannot distinguish when the NACK occurred. @retval EFI_OUT_OF_RESOURCES Insufficient memory for I2C transaction @retval EFI_UNSUPPORTED The controller does not support the requested transaction. Queue an I2C transaction for execution on the I2C device. This routine must be called at or below TPL_NOTIFY. For synchronous requests this routine must be called at or below TPL_CALLBACK. This routine queues an I2C transaction to the I2C controller for execution on the I2C bus. When Event is NULL, QueueRequest() operates synchronously and returns the I2C completion status as its return value. When Event is not NULL, QueueRequest() synchronously returns EFI_SUCCESS indicating that the asynchronous I2C transaction was queued. The values above are returned in the buffer pointed to by I2cStatus upon the completion of the I2C transaction when I2cStatus is not NULL. The upper layer driver writer provides the following to the platform vendor: 1. Vendor specific GUID for the I2C part 2. Guidance on proper construction of the slave address array when the I2C device uses more than one slave address. The I2C bus protocol uses the SlaveAddressIndex to perform relative to physical address translation to access the blocks of hardware within the I2C device. @param [in] This Pointer to an EFI_I2C_IO_PROTOCOL structure. @param [in] SlaveAddressIndex Index value into an array of slave addresses for the I2C device. The values in the array are specified by the board designer, with the third party I2C device driver writer providing the slave address order. For devices that have a single slave address, this value must be zero. If the I2C device uses more than one slave address then the third party (upper level) I2C driver writer needs to specify the order of entries in the slave address array. \ref ThirdPartyI2cDrivers "Third Party I2C Drivers" section in I2cMaster.h.

Parameters
[in]EventEvent to signal for asynchronous transactions, NULL for synchronous transactions
[in]RequestPacketPointer to an EFI_I2C_REQUEST_PACKET structure describing the I2C transaction
[out]I2cStatusOptional buffer to receive the I2C transaction completion status
Return values
EFI_SUCCESSThe asynchronous transaction was successfully queued when Event is not NULL.
EFI_SUCCESSThe transaction completed successfully when Event is NULL.
EFI_BAD_BUFFER_SIZEThe RequestPacket->LengthInBytes value is too large.
EFI_DEVICE_ERRORThere was an I2C error (NACK) during the transaction.
EFI_INVALID_PARAMETERRequestPacket is NULL
EFI_NO_MAPPINGThe EFI_I2C_HOST_PROTOCOL could not set the bus configuration required to access this I2C device.
EFI_NO_RESPONSEThe I2C device is not responding to the slave address selected by SlaveAddressIndex. EFI_DEVICE_ERROR will be returned if the controller cannot distinguish when the NACK occurred.
EFI_OUT_OF_RESOURCESInsufficient memory for I2C transaction
EFI_UNSUPPORTEDThe controller does not support the requested transaction.

Definition at line 1141 of file I2cBus.c.

◆ I2cBusUnload()

EFI_STATUS EFIAPI I2cBusUnload ( IN EFI_HANDLE  ImageHandle)

This is the unload handle for I2C bus module.

Disconnect the driver specified by ImageHandle from all the devices in the handle database. Uninstall all the protocols installed in the driver entry point.

Parameters
[in]ImageHandleThe drivers' driver image.
Return values
EFI_SUCCESSThe image is unloaded.
OthersFailed to unload the image.

Definition at line 1409 of file I2cBus.c.

◆ I2cHostComponentNameGetControllerName()

EFI_STATUS EFIAPI I2cHostComponentNameGetControllerName ( IN EFI_COMPONENT_NAME2_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_HANDLE ChildHandle  OPTIONAL,
IN CHAR8 *  Language,
OUT CHAR16 **  ControllerName 
)

Retrieves a Unicode string that is the user readable name of the controller that is being managed by a driver.

This function retrieves the user readable name of the controller specified by ControllerHandle and ChildHandle in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the controller name is returned in ControllerName, and EFI_SUCCESS is returned. If the driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle, then EFI_UNSUPPORTED is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned.

Parameters
This[in]A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance.
ControllerHandle[in]The handle of a controller that the driver specified by This is managing. This handle specifies the controller whose name is to be returned.
ChildHandle[in]The handle of the child controller to retrieve the name of. This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers that wish to retrieve the name of the bus controller. It will not be NULL for a bus driver that wishes to retrieve the name of a child controller.
Language[in]A pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the languages specified in SupportedLanguages. The number of languages supported by a driver is up to the driver writer. Language is specified in RFC 4646 or ISO 639-2 language code format.
ControllerName[out]A pointer to the Unicode string to return. This Unicode string is the name of the controller specified by ControllerHandle and ChildHandle in the language specified by Language from the point of view of the driver specified by This.
Return values
EFI_SUCCESSThe Unicode string for the user readable name in the language specified by Language for the driver specified by This was returned in DriverName.
EFI_INVALID_PARAMETERControllerHandle is NULL.
EFI_INVALID_PARAMETERChildHandle is not NULL and it is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERControllerName is NULL.
EFI_UNSUPPORTEDThe driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle.
EFI_UNSUPPORTEDThe driver specified by This does not support the language specified by Language.

Definition at line 174 of file I2cHost.c.

◆ I2cHostComponentNameGetDriverName()

EFI_STATUS EFIAPI I2cHostComponentNameGetDriverName ( IN EFI_COMPONENT_NAME2_PROTOCOL This,
IN CHAR8 *  Language,
OUT CHAR16 **  DriverName 
)

Retrieves a Unicode string that is the user readable name of the driver.

This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned.

Parameters
This[in]A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance.
Language[in]A pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the languages specified in SupportedLanguages. The number of languages supported by a driver is up to the driver writer. Language is specified in RFC 4646 or ISO 639-2 language code format.
DriverName[out]A pointer to the Unicode string to return. This Unicode string is the name of the driver specified by This in the language specified by Language.
Return values
EFI_SUCCESSThe Unicode string for the Driver specified by This and the language specified by Language was returned in DriverName.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERDriverName is NULL.
EFI_UNSUPPORTEDThe driver specified by This does not support the language specified by Language.

Definition at line 89 of file I2cHost.c.

◆ I2cHostDriverStart()

EFI_STATUS EFIAPI I2cHostDriverStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Starts a device controller or a bus controller.

The Start() function is designed to be invoked from the EFI boot service ConnectController(). As a result, much of the error checking on the parameters to Start() has been moved into this common boot service. It is legal to call Start() from other locations, but the following calling restrictions must be followed, or the system behavior will not be deterministic.

  1. ControllerHandle must be a valid EFI_HANDLE.
  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned EFI_DEVICE_PATH_PROTOCOL.
  3. Prior to calling Start(), the Supported() function for the driver specified by This must have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
Parameters
[in]ThisA pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
[in]ControllerHandleThe handle of the controller to start. This handle must support a protocol interface that supplies an I/O abstraction to the driver.
[in]RemainingDevicePathA pointer to the remaining portion of a device path. This parameter is ignored by device drivers, and is optional for bus drivers. For a bus driver, if this parameter is NULL, then handles for all the children of Controller are created by this driver. If this parameter is not NULL and the first Device Path Node is not the End of Device Path Node, then only the handle for the child device specified by the first Device Path Node of RemainingDevicePath is created by this driver. If the first Device Path Node of RemainingDevicePath is the End of Device Path Node, no child handle is created by this driver.
Return values
EFI_SUCCESSThe device was started.
EFI_DEVICE_ERRORThe device could not be started due to a device error.Currently not implemented.
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources.
OthersThe driver failed to start the device.

Definition at line 319 of file I2cHost.c.

◆ I2cHostDriverStop()

EFI_STATUS EFIAPI I2cHostDriverStop ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN UINTN  NumberOfChildren,
IN EFI_HANDLE ChildHandleBuffer 
)

Stops a device controller or a bus controller.

The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). As a result, much of the error checking on the parameters to Stop() has been moved into this common boot service. It is legal to call Stop() from other locations, but the following calling restrictions must be followed, or the system behavior will not be deterministic.

  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this same driver's Start() function.
  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid EFI_HANDLE. In addition, all of these handles must have been created in this driver's Start() function, and the Start() function must have called OpenProtocol() on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
Parameters
[in]ThisA pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
[in]ControllerHandleA handle to the device being stopped. The handle must support a bus specific I/O protocol for the driver to use to stop the device.
[in]NumberOfChildrenThe number of child device handles in ChildHandleBuffer.
[in]ChildHandleBufferAn array of child handles to be freed. May be NULL if NumberOfChildren is 0.
Return values
EFI_SUCCESSThe device was stopped.
EFI_DEVICE_ERRORThe device could not be stopped due to a device error.

Definition at line 503 of file I2cHost.c.

◆ I2cHostDriverSupported()

EFI_STATUS EFIAPI I2cHostDriverSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device.

This function checks to see if the driver specified by This supports the device specified by ControllerHandle. Drivers will typically use the device path attached to ControllerHandle and/or the services from the bus I/O abstraction attached to ControllerHandle to determine if the driver supports ControllerHandle. This function may be called many times during platform initialization. In order to reduce boot times, the tests performed by this function must be very small, and take as little time as possible to execute. This function must not change the state of any hardware devices, and this function must be aware that the device specified by ControllerHandle may already be managed by the same driver or a different driver. This function must match its calls to AllocatePages() with FreePages(), AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). Since ControllerHandle may have been previously started by the same driver, if a protocol is already in the opened state, then it must not be closed with CloseProtocol(). This is required to guarantee the state of ControllerHandle is not modified by this function.

Parameters
[in]ThisA pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
[in]ControllerHandleThe handle of the controller to test. This handle must support a protocol interface that supplies an I/O abstraction to the driver.
[in]RemainingDevicePathA pointer to the remaining portion of a device path. This parameter is ignored by device drivers, and is optional for bus drivers. For bus drivers, if this parameter is not NULL, then the bus driver must determine if the bus controller specified by ControllerHandle and the child controller specified by RemainingDevicePath are both supported by this bus driver.
Return values
EFI_SUCCESSThe device specified by ControllerHandle and RemainingDevicePath is supported by the driver specified by This.
EFI_ALREADY_STARTEDThe device specified by ControllerHandle and RemainingDevicePath is already being managed by the driver specified by This.
EFI_ACCESS_DENIEDThe device specified by ControllerHandle and RemainingDevicePath is already being managed by a different driver or an application that requires exclusive access. Currently not implemented.
EFI_UNSUPPORTEDThe device specified by ControllerHandle and RemainingDevicePath is not supported by the driver specified by This.

Definition at line 229 of file I2cHost.c.

◆ I2cHostI2cBusConfigurationAvailable()

VOID EFIAPI I2cHostI2cBusConfigurationAvailable ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Handle the I2C bus configuration available event

This routine is called at TPL_I2C_SYNC.

Parameters
[in]EventAddress of an EFI_EVENT handle
[in]ContextAddress of an I2C_HOST_CONTEXT structure

Definition at line 604 of file I2cHost.c.

◆ I2cHostQueueRequest()

EFI_STATUS EFIAPI I2cHostQueueRequest ( IN CONST EFI_I2C_HOST_PROTOCOL This,
IN UINTN  I2cBusConfiguration,
IN UINTN  SlaveAddress,
IN EFI_EVENT Event  OPTIONAL,
IN EFI_I2C_REQUEST_PACKET RequestPacket,
OUT EFI_STATUS *I2cStatus  OPTIONAL 
)

Queue an I2C operation for execution on the I2C controller.

This routine must be called at or below TPL_NOTIFY. For synchronous requests this routine must be called at or below TPL_CALLBACK.

N.B. The typical consumers of this API are the I2C bus driver and on rare occasions the I2C test application. Extreme care must be taken by other consumers of this API to prevent confusing the third party I2C drivers due to a state change at the I2C device which the third party I2C drivers did not initiate. I2C platform drivers may use this API within these guidelines.

This layer uses the concept of I2C bus configurations to describe the I2C bus. An I2C bus configuration is defined as a unique setting of the multiplexers and switches in the I2C bus which enable access to one or more I2C devices. When using a switch to divide a bus, due to speed differences, the I2C platform layer would define an I2C bus configuration for the I2C devices on each side of the switch. When using a multiplexer, the I2C platform layer defines an I2C bus configuration for each of the selector values required to control the multiplexer. See Figure 1 in the I2C Specification for a complex I2C bus configuration.

The I2C host driver processes all operations in FIFO order. Prior to performing the operation, the I2C host driver calls the I2C platform driver to reconfigure the switches and multiplexers in the I2C bus enabling access to the specified I2C device. The I2C platform driver also selects the maximum bus speed for the device. After the I2C bus is configured, the I2C host driver calls the I2C port driver to initialize the I2C controller and start the I2C operation.

Parameters
[in]ThisAddress of an EFI_I2C_HOST_PROTOCOL instance.
[in]I2cBusConfigurationI2C bus configuration to access the I2C device.
[in]SlaveAddressAddress of the device on the I2C bus.
[in]EventEvent to set for asynchronous operations, NULL for synchronous operations
[in]RequestPacketAddress of an EFI_I2C_REQUEST_PACKET structure describing the I2C operation
[out]I2cStatusOptional buffer to receive the I2C operation completion status
Return values
EFI_SUCCESSThe operation completed successfully.
EFI_ABORTEDThe request did not complete because the driver was shutdown.
EFI_BAD_BUFFER_SIZEThe WriteBytes or ReadBytes buffer size is too large.
EFI_DEVICE_ERRORThere was an I2C error (NACK) during the operation. This could indicate the slave device is not present.
EFI_INVALID_PARAMETERRequestPacket is NULL
EFI_INVALID_PARAMETERTPL is too high
EFI_NO_MAPPINGInvalid I2cBusConfiguration value
EFI_NO_RESPONSEThe I2C device is not responding to the slave address. EFI_DEVICE_ERROR may also be returned if the controller can not distinguish when the NACK occurred.
EFI_NOT_FOUNDI2C slave address exceeds maximum address
EFI_NOT_READYI2C bus is busy or operation pending, wait for the event and then read status pointed to by the request packet.
EFI_OUT_OF_RESOURCESInsufficient memory for I2C operation
EFI_TIMEOUTThe transaction did not complete within an internally specified timeout period.

Queue an I2C operation for execution on the I2C controller.

This routine must be called at or below TPL_NOTIFY. For synchronous requests this routine must be called at or below TPL_CALLBACK.

N.B. The typical consumers of this API are the I2C bus driver and on rare occasions the I2C test application. Extreme care must be taken by other consumers of this API to prevent confusing the third party I2C drivers due to a state change at the I2C device which the third party I2C drivers did not initiate. I2C platform drivers may use this API within these guidelines.

This layer uses the concept of I2C bus configurations to describe the I2C bus. An I2C bus configuration is defined as a unique setting of the multiplexers and switches in the I2C bus which enable access to one or more I2C devices. When using a switch to divide a bus, due to speed differences, the I2C platform layer would define an I2C bus configuration for the I2C devices on each side of the switch. When using a multiplexer, the I2C platform layer defines an I2C bus configuration for each of the selector values required to control the multiplexer. See Figure 1 in the I2C Specification for a complex I2C bus configuration.

The I2C host driver processes all operations in FIFO order. Prior to performing the operation, the I2C host driver calls the I2C platform driver to reconfigure the switches and multiplexers in the I2C bus enabling access to the specified I2C device. The I2C platform driver also selects the maximum bus speed for the device. After the I2C bus is configured, the I2C host driver calls the I2C port driver to initialize the I2C controller and start the I2C operation.

Parameters
[in]ThisAddress of an EFI_I2C_HOST_PROTOCOL instance.
[in]I2cBusConfigurationI2C bus configuration to access the I2C device.
[in]SlaveAddressAddress of the device on the I2C bus.
[in]EventEvent to set for asynchronous operations, NULL for synchronous operations
[in]RequestPacketAddress of an EFI_I2C_REQUEST_PACKET structure describing the I2C operation
[out]I2cStatusOptional buffer to receive the I2C operation completion status
Return values
EFI_SUCCESSThe operation completed successfully.
EFI_BAD_BUFFER_SIZEThe WriteBytes or ReadBytes buffer size is too large.
EFI_DEVICE_ERRORThere was an I2C error (NACK) during the operation. This could indicate the slave device is not present.
EFI_INVALID_PARAMETERRequestPacket is NULL
EFI_INVALID_PARAMETERTPL is too high
EFI_NO_MAPPINGInvalid I2cBusConfiguration value
EFI_NO_RESPONSEThe I2C device is not responding to the slave address. EFI_DEVICE_ERROR may also be returned if the controller can not distinguish when the NACK occurred.
EFI_NOT_FOUNDI2C slave address exceeds maximum address
EFI_NOT_READYI2C bus is busy or operation pending, wait for the event and then read status pointed to by the request packet.
EFI_OUT_OF_RESOURCESInsufficient memory for I2C operation
EFI_TIMEOUTThe transaction did not complete within an internally specified timeout period.

Definition at line 915 of file I2cHost.c.

◆ I2cHostRequestComplete()

EFI_STATUS I2cHostRequestComplete ( I2C_HOST_CONTEXT I2cHostContext,
EFI_STATUS  Status 
)

Complete the current request

Parameters
[in]I2cHostAddress of an I2C_HOST_CONTEXT structure.
[in]StatusStatus of the I2C operation.
Returns
This routine returns the input status value.

Complete the current request

This routine is called at TPL_I2C_SYNC.

Parameters
[in]I2cHostContextAddress of an I2C_HOST_CONTEXT structure.
[in]StatusStatus of the I2C operation.
Returns
This routine returns the input status value.

Definition at line 688 of file I2cHost.c.

◆ I2cHostRequestCompleteEvent()

VOID EFIAPI I2cHostRequestCompleteEvent ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Handle the bus available event

This routine is called at TPL_I2C_SYNC.

Parameters
[in]EventAddress of an EFI_EVENT handle
[in]ContextAddress of an I2C_HOST_CONTEXT structure

Definition at line 746 of file I2cHost.c.

◆ I2cHostRequestEnable()

EFI_STATUS I2cHostRequestEnable ( I2C_HOST_CONTEXT I2cHostContext)

Enable access to the I2C bus configuration

Parameters
[in]I2cHostContextAddress of an I2C_HOST_CONTEXT structure
Return values
EFI_SUCCESSThe operation completed successfully.
EFI_ABORTEDThe request did not complete because the driver was shutdown.
EFI_BAD_BUFFER_SIZEThe WriteBytes or ReadBytes buffer size is too large.
EFI_DEVICE_ERRORThere was an I2C error (NACK) during the operation. This could indicate the slave device is not present.
EFI_INVALID_PARAMETERRequestPacket is NULL
EFI_NO_MAPPINGInvalid I2cBusConfiguration value
EFI_NO_RESPONSEThe I2C device is not responding to the slave address. EFI_DEVICE_ERROR may also be returned if the controller can not distinguish when the NACK occurred.
EFI_NOT_FOUNDI2C slave address exceeds maximum address
EFI_NOT_READYI2C bus is busy or operation pending, wait for the event and then read status.
EFI_OUT_OF_RESOURCESInsufficient memory for I2C operation
EFI_TIMEOUTThe transaction did not complete within an internally specified timeout period.

Definition at line 786 of file I2cHost.c.

◆ I2cHostUnload()

EFI_STATUS EFIAPI I2cHostUnload ( IN EFI_HANDLE  ImageHandle)

This is the unload handle for I2C host module.

Disconnect the driver specified by ImageHandle from all the devices in the handle database. Uninstall all the protocols installed in the driver entry point.

Parameters
[in]ImageHandleThe drivers' driver image.
Return values
EFI_SUCCESSThe image is unloaded.
OthersFailed to unload the image.

Definition at line 1125 of file I2cHost.c.

◆ InitializeI2cBus()

EFI_STATUS EFIAPI InitializeI2cBus ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The user entry point for the I2C bus module. The user code starts with this function.

Parameters
[in]ImageHandleThe firmware allocated handle for the EFI image.
[in]SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.
otherSome error occurs when executing this entry point.

Definition at line 1372 of file I2cBus.c.

◆ InitializeI2cHost()

EFI_STATUS EFIAPI InitializeI2cHost ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The user Entry Point for I2C host module. The user code starts with this function.

Parameters
[in]ImageHandleThe firmware allocated handle for the EFI image.
[in]SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.
otherSome error occurs when executing this entry point.

Definition at line 1089 of file I2cHost.c.

◆ RegisterI2cDevice()

EFI_STATUS RegisterI2cDevice ( IN I2C_BUS_CONTEXT I2cBusContext,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Start the I2C driver

This routine allocates the necessary resources for the driver.

This routine is called by I2cBusDriverStart to complete the driver initialization.

Parameters
[in]I2cBusAddress of an I2C_BUS_CONTEXT structure
[in]ControllerHandle to the controller
[in]RemainingDevicePathA pointer to the remaining portion of a device path.
Return values
EFI_SUCCESSDriver API properly initialized

Enumerate the I2C bus

This routine walks the platform specific data describing the I2C bus to create the I2C devices where driver GUIDs were specified.

Parameters
[in]I2cBusContextAddress of an I2C_BUS_CONTEXT structure
[in]ControllerHandle to the controller
[in]RemainingDevicePathA pointer to the remaining portion of a device path.
Return values
EFI_SUCCESSThe bus is successfully configured

Definition at line 866 of file I2cBus.c.

◆ ReleaseI2cDeviceContext()

VOID ReleaseI2cDeviceContext ( IN I2C_DEVICE_CONTEXT I2cDeviceContext)

Release all the resources allocated for the I2C device.

This function releases all the resources allocated for the I2C device.

Parameters
I2cDeviceContextThe I2C child device involved for the operation.

Definition at line 1198 of file I2cBus.c.

◆ UnRegisterI2cDevice()

EFI_STATUS UnRegisterI2cDevice ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_HANDLE  Handle 
)

Unregister an I2C device.

This function removes the protocols installed on the controller handle and frees the resources allocated for the I2C device.

Parameters
ThisThe pointer to EFI_DRIVER_BINDING_PROTOCOL instance.
ControllerThe controller handle of the I2C device.
HandleThe child handle.
Return values
EFI_SUCCESSThe I2C device is successfully unregistered.
Returns
Others Some error occurs when unregistering the I2C device.

Definition at line 1228 of file I2cBus.c.

Variable Documentation

◆ gI2cBusComponentName

EFI_COMPONENT_NAME_PROTOCOL gI2cBusComponentName
extern

Definition at line 84 of file I2cBus.c.

◆ gI2cBusComponentName2

EFI_COMPONENT_NAME2_PROTOCOL gI2cBusComponentName2
extern

Definition at line 93 of file I2cBus.c.

◆ gI2cBusDriverBinding

EFI_DRIVER_BINDING_PROTOCOL gI2cBusDriverBinding
extern

Definition at line 15 of file I2cBus.c.

◆ gI2cHostComponentName

EFI_COMPONENT_NAME_PROTOCOL gI2cHostComponentName
extern

Definition at line 33 of file I2cHost.c.

◆ gI2cHostComponentName2

EFI_COMPONENT_NAME2_PROTOCOL gI2cHostComponentName2
extern

Definition at line 42 of file I2cHost.c.

◆ gI2cHostDriverBinding

EFI_DRIVER_BINDING_PROTOCOL gI2cHostDriverBinding
extern

Definition at line 13 of file I2cHost.c.