MdePkg[all]  1.08
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
I2cMaster.h File Reference

Data Structures

struct  _EFI_I2C_MASTER_PROTOCOL
 

Macros

#define EFI_I2C_MASTER_PROTOCOL_GUID   { 0xcd72881f, 0x45b5, 0x4feb, { 0x98, 0xc8, 0x31, 0x3d, 0xa8, 0x11, 0x74, 0x62 }}
 

Typedefs

typedef struct
_EFI_I2C_MASTER_PROTOCOL 
EFI_I2C_MASTER_PROTOCOL
 
typedef IN OUT UINTNBusClockHertz
 
typedef IN UINTN SlaveAddress
 
typedef IN UINTN IN
EFI_I2C_REQUEST_PACKET
RequestPacket
 
typedef IN UINTN IN
EFI_I2C_REQUEST_PACKET IN
EFI_EVENT 
Event
 
typedef IN UINTN IN
EFI_I2C_REQUEST_PACKET IN
EFI_EVENT OUT EFI_STATUS
I2cStatus
 

Functions

typedef EFI_STATUS (EFIAPI *EFI_I2C_MASTER_PROTOCOL_SET_BUS_FREQUENCY)(IN CONST EFI_I2C_MASTER_PROTOCOL *This
 

Variables

EFI_GUID gEfiI2cMasterProtocolGuid
 

Detailed Description

I2C Master Protocol as defined in the PI 1.3 specification.

This protocol manipulates the I2C host controller to perform transactions as a master on the I2C bus using the current state of any switches or multiplexers in the I2C bus.

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

Revision Reference:
This protocol is from PI Version 1.3.

Macro Definition Documentation

#define EFI_I2C_MASTER_PROTOCOL_GUID   { 0xcd72881f, 0x45b5, 0x4feb, { 0x98, 0xc8, 0x31, 0x3d, 0xa8, 0x11, 0x74, 0x62 }}

Typedef Documentation

Function Documentation

typedef EFI_STATUS ( EFIAPI EFI_I2C_MASTER_PROTOCOL_START_REQUEST)

Set the frequency for the I2C clock line.

This routine must be called at or below TPL_NOTIFY.

The software and controller do a best case effort of using the specified frequency for the I2C bus. If the frequency does not match exactly then the I2C master protocol selects the next lower frequency to avoid exceeding the operating conditions for any of the I2C devices on the bus. For example if 400 KHz was specified and the controller's divide network only supports 402 KHz or 398 KHz then the I2C master protocol selects 398 KHz. If there are not lower frequencies available, then return EFI_UNSUPPORTED.

Parameters
[in]ThisPointer to an EFI_I2C_MASTER_PROTOCOL structure
[in]BusClockHertzPointer to the requested I2C bus clock frequency in Hertz. Upon return this value contains the actual frequency in use by the I2C controller.
Return values
EFI_SUCCESSThe bus frequency was set successfully.
EFI_ALREADY_STARTEDThe controller is busy with another transaction.
EFI_INVALID_PARAMETERBusClockHertz is NULL
EFI_UNSUPPORTEDThe controller does not support this frequency.

Reset the I2C controller and configure it for use

This routine must be called at or below TPL_NOTIFY.

The I2C controller is reset. The caller must call SetBusFrequench() after calling Reset().

Parameters
[in]ThisPointer to an EFI_I2C_MASTER_PROTOCOL structure.
Return values
EFI_SUCCESSThe reset completed successfully.
EFI_ALREADY_STARTEDThe controller is busy with another transaction.
EFI_DEVICE_ERRORThe reset operation failed.

Start an I2C transaction on the host controller.

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

This function initiates an I2C transaction on the controller. To enable proper error handling by the I2C protocol stack, the I2C master protocol does not support queuing but instead only manages one I2C transaction at a time. This API requires that the I2C bus is in the correct configuration for the I2C transaction.

The transaction is performed by sending a start-bit and selecting the I2C device with the specified I2C slave address and then performing the specified I2C operations. When multiple operations are requested they are separated with a repeated start bit and the slave address. The transaction is terminated with a stop bit.

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

When Event is not NULL, StartRequest synchronously returns EFI_SUCCESS indicating that the I2C transaction was started asynchronously. The transaction status value is returned in the buffer pointed to by I2cStatus upon the completion of the I2C transaction when I2cStatus is not NULL. After the transaction status is returned the Event is signaled.

Note: The typical consumer of this API is the I2C host protocol. 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 specific code may use this API within these guidelines.

Parameters
[in]ThisPointer to an EFI_I2C_MASTER_PROTOCOL structure.
[in]SlaveAddressAddress of the device on the I2C bus. Set the I2C_ADDRESSING_10_BIT when using 10-bit addresses, clear this bit for 7-bit addressing. Bits 0-6 are used for 7-bit I2C slave addresses and bits 0-9 are used for 10-bit I2C slave addresses.
[in]RequestPacketPointer to an EFI_I2C_REQUEST_PACKET structure describing the I2C transaction.
[in]EventEvent to signal for asynchronous transactions, NULL for asynchronous transactions
[out]I2cStatusOptional buffer to receive the I2C transaction completion status
Return values
EFI_SUCCESSThe asynchronous transaction was successfully started when Event is not NULL.
EFI_SUCCESSThe transaction completed successfully when Event is NULL.
EFI_ALREADY_STARTEDThe controller is busy with another transaction.
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_NOT_FOUNDReserved bit set in the SlaveAddress parameter
EFI_NO_RESPONSEThe I2C device is not responding to the slave address. 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.

Variable Documentation

EFI_GUID gEfiI2cMasterProtocolGuid