3. SMBus Host Controller Code Definitions

3.1. Introduction

This section contains the basic definitions of the SMBus Host Controller Protocol. The following protocol is defined in this section:

  • EFI_SMBUS_HC_PROTOCOL

This section also contains the definitions for additional data types and structures that are subordinate to the structures in which they are called. The following types or structures can be found in “Related Definitions” of the parent function definition:

  • EFI_SMBUS_NOTIFY_FUNCTION

3.2. SMBus Host Controller Protocol

EFI_SMBUS_HC_PROTOCOL

Summary

Provides basic SMBus host controller management and basic data transactions over the SMBus.

GUID

#define EFI_SMBUS_HC_PROTOCOL_GUID \\
{0xe49d33ed, 0x513d, 0x4634, 0xb6, 0x98, 0x6f, 0x55, \\
0xaa, 0x75, 0x1c, 0x1b}

Protocol Interface Structure

typedef struct \_EFI_SMBUS_HC_PROTOCOL {
EFI_SMBUS_HC_EXECUTE_OPERATION Execute;
EFI_SMBUS_HC_PROTOCOL_ARP_DEVICE ArpDevice;
EFI_SMBUS_HC_PROTOCOL_GET_ARP_MAP GetArpMap;
EFI_SMBUS_HC_PROTOCOL_NOTIFY Notify;
} EFI_SMBUS_HC_PROTOCOL;

Parameters

Execute

Executes the SMBus operation to an SMBus slave device. See the Execute() function description.

ArpDevice

Allows an SMBus 2.0 device(s) to be Address Resolution Protocol (ARP). See the ArpDevice() function description.

GetArpMap

Allows a driver to retrieve the address that was allocated by the SMBus host controller during enumeration/ARP. See the GetArpMap() function description.

Notify

Allows a driver to register for a callback to the SMBus host controller driver when the bus issues a notification to the bus controller driver. See the Notify() function description.

Description

The EFI_SMBUS_HC_PROTOCOL provides SMBus host controller management and basic data transactions over SMBus. There is one EFI_SMBUS_HC_PROTOCOL instance for each SMBus host controller.

Early chipset drivers can communicate with specific SMBus slave devices by calling this protocol directly. Also, for drivers that are called during the Boot Device Selection (BDS) phase, the device driver that wishes to manage an SMBus bus in a system retrieves the EFI_SMBUS_HC_PROTOCOL instance that is associated with the SMBus bus to be managed. A device handle for an SMBus host controller will minimally contain an EFI_DEVICE_PATH_PROTOCOL instance and an EFI_SMBUS_HC_PROTOCOL instance.

3.2.1. EFI_SMBUS_HC_PROTOCOL.Execute()

Summary

Executes an SMBus operation to an SMBus controller. Returns when either the command has been executed or an error is encountered in doing the operation.

Prototype

typedef

EFI_STATUS

(EFIAPI \*EFI_SMBUS_HC_EXECUTE_OPERATION) (

IN CONST EFI_SMBUS_HC_PROTOCOL \*This,

IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,

IN EFI_SMBUS_DEVICE_COMMAND Command,

IN EFI_SMBUS_OPERATION Operation,

IN BOOLEAN PecCheck,

IN OUT UINTN \*Length,

IN OUT VOID \*Buffer

);

Parameters

This

A pointer to the EFI_SMBUS_HC_PROTOCOL instance.

SlaveAddress

The SMBus slave address of the device with which to communicate. Type EFI_SMBUS_DEVICE_ADDRESS is defined in EFI_PEI_SMBUS_PPI.Execute() in the Platform Initialization SMBus PPI Specification.

Command

This command is transmitted by the SMBus host controller to the SMBus slave device and the interpretation is SMBus slave device specific. It can mean the offset to a list of functions inside an SMBus slave device. Not all operations or slave devices support this command’s registers. Type EFI_SMBUS_DEVICE_COMMAND is defined in EFI_PEI_SMBUS_PPI.Execute() in the Platform Initialization SMBus PPI Specification .

Operation

Signifies which particular SMBus hardware protocol instance that it will use to execute the SMBus transactions. This SMBus hardware protocol is defined by the SMBus Specification and is not related to PI Architecture. Type EFI_SMBUS_OPERATION is defined in EFI_PEI_SMBUS_PPI.Execute*() in the *Platform Initialization SMBus PPI Specification .

PecCheck

Defines if Packet Error Code (PEC) checking is required for this operation.

Length

Signifies the number of bytes that this operation will do. The maximum number of bytes can be revision specific and operation specific. This field will contain the actual number of bytes that are executed for this operation. Not all operations require this argument.

Buffer

Contains the value of data to execute to the SMBus slave device. Not all operations require this argument. The length of this buffer is identified by Length .

Description

The Execute() function provides a standard way to execute an operation as defined in the System Management Bus (SMBus) Specification . The resulting transaction will be either that the SMBus slave devices accept this transaction or that this function returns with error.

Status Codes Returned

EFI_SUCCESS

The last data that was returned from the access matched the poll exit criteria

EFI_CRC_ERROR

Checksum is not correct PEC is incorrect

EFI_TIMEOUT

Timeout expired before the operation was completed Timeout is determined by the SMBus host controller device

EFI_OUT_OF_RESOURCES

The request could not be completed due to a lack of resources

EFI_DEVICE_ERROR

The request was not completed because a failure that was reflected in the Host Status Register bit Device errors are a result of a transaction collision illegal command field unclaimed cycle host initiated or bus errors collisions

EFI_INVALID_PARAMETER

Operation is not defined in EFI_SMBUS_OPERATION

EFI_INVALID_PARAMETER

Length Buffer is NULL for operations except for EfiSmbusQuickRead and EfiSmbusQuickWrite Length is outside the range of valid values

EFI_UNSUPPORTED

The SMBus operation or PEC is not supported

EFI_BUFFER_TOO_SMALL

Buffer is not sufficient for this operation

3.2.2. EFI_SMBUS_HC_PROTOCOL.ArpDevice()

Summary

Sets the SMBus slave device addresses for the device with a given unique ID or enumerates the entire bus.

Prototype

typedef
EFI_STATUS
(EFIAPI \*EFI_SMBUS_HC_PROTOCOL_ARP_DEVICE) (
IN CONST EFI_SMBUS_HC_PROTOCOL \*This,
IN BOOLEAN ArpAll,
IN EFI_SMBUS_UDID \*SmbusUdid, OPTIONAL
IN OUT EFI_SMBUS_DEVICE_ADDRESS \*SlaveAddress OPTIONAL
);

Parameters

This

A pointer to the EFI_SMBUS_HC_PROTOCOL instance.

ArpAll

A Boolean expression that indicates if the host drivers need to enumerate all the devices or enumerate only the device that is identified by SmbusUdid . If ArpAll is TRUE , SmbusUdid and SlaveAddress are optional. If ArpAll is FALSE , ArpDevice will enumerate SmbusUdid and the address will be at SlaveAddress .

SmbusUdid

The Unique Device Identifier (UDID) that is associated with this device. Type EFI_SMBUS_UDID is defined in EFI_PEI_SMBUS_PPI.ArpDevice*() in the *Platform Initialization SMBus PPI Specification .

SlaveAddress

The SMBus slave address that is associated with an SMBus UDID. Type EFI_SMBUS_DEVICE_ADDRESS is defined in EFI_PEI_SMBUS_PPI.Execute() in the Platform Initialization SMBus PPI Specification.

Description

The ArpDevice() function provides a standard way for a device driver to enumerate the entire SMBus or specific devices on the bus.

Status Codes Returned

EFI_SUCCESS

The last data that was returned from the access matched the poll exit criteria

EFI_CRC_ERROR

Checksum is not correct PEC is incorrect

EFI_TIMEOUT

Timeout expired before the operation was completed Timeout is determined by the SMBus host controller device

EFI_OUT_OF_RESOURCES

The request could not be completed due to a lack of resources

EFI_DEVICE_ERROR

The request was not completed because a failure was reflected in the Host Status Register bit Device Errors are a result of a transaction collision illegal command field unclaimed cycle host initiated or bus errors collisions

EFI_UNSUPPORTED

ArpDevice GetArpMap and Notify are not implemented by this driver

3.2.3. EFI_SMBUS_HC_PROTOCOL.GetArpMap()

Summary

Returns a pointer to the Address Resolution Protocol (ARP) map that contains the ID/address pair of the slave devices that were enumerated by the SMBus host controller driver.

Prototype

typedef
EFI_STATUS
(EFIAPI \*EFI_SMBUS_HC_PROTOCOL_GET_ARP_MAP) (
IN CONST EFI_SMBUS_HC_PROTOCOL \*This,
IN OUT UINTN \*Length,
IN OUT EFI_SMBUS_DEVICE_MAP \**SmbusDeviceMap
);

Parameters

This

A pointer to the EFI_SMBUS_HC_PROTOCOL instance.

Length

Size of the buffer that contains the SMBus device map.

SmbusDeviceMap

The pointer to the device map as enumerated by the SMBus controller driver. Type EFI_SMBUS_DEVICE_MAP is defined in EFI_PEI_SMBUS_PPI.GetArpMap*() in the *Platform Initialization SMBus PPI Specification .

Description

The GetArpMap() function returns the mapping of all the SMBus devices that were enumerated by the SMBus host driver.

Status Codes Returned

EFI_SUCCESS

The SMBus returned the current device map

EFI_UNSUPPORTED

ArpDevice GetArpMap and Notify are not implemented by this driver

3.2.4. EFI_SMBUS_HC_PROTOCOL.Notify()

Summary

Allows a device driver to register for a callback when the bus driver detects a state that it needs to propagate to other drivers that are registered for a callback.

Prototype

typedef
EFI_STATUS
(EFIAPI \*EFI_SMBUS_HC_PROTOCOL_NOTIFY) (
IN CONST EFI_SMBUS_HC_PROTOCOL \*This,
IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
IN UINTN Data,
IN EFI_SMBUS_NOTIFY_FUNCTION NotifyFunction
);

Parameters

This

A pointer to the EFI_SMBUS_HC_PROTOCOL instance.

SlaveAddress

Address that the host controller detects as sending a message and calls all the registered function. Type EFI_SMBUS_DEVICE_ADDRESS is defined in EFI_PEI_SMBUS_PPI.Execute*() in the *Platform Initialization SMBus PPI Specification .

Data

Data that the host controller detects as sending a message and calls all the registered function.

NotifyFunction

The function to call when the bus driver detects the SlaveAddress and Data pair. Type EFI_SMBUS_NOTIFY_FUNCTION is defined in “Related Definitions” below.

Description

The Notify() function registers all the callback functions to allow the bus driver to call these functions when the SlaveAddress / Data pair happens.

//******************************************************\*
// EFI_SMBUS_NOTIFY_FUNCTION
//******************************************************\*
typedef
EFI_STATUS
(EFIAPI \*EFI_SMBUS_NOTIFY_FUNCTION) (
IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
IN UINTN Data
);
SlaveAddress

The SMBUS hardware address to which the SMBUS device is preassigned or allocated. Type EFI_SMBUS_DEVICE_ADDRESS is defined in EFI_PEI_SMBUS_PPI.Execute*() in the *Platform Initialization SMBus PPI Specification .

Data

Data of the SMBus host notify command that the caller wants to be called.

Status Codes Returned

EFI_SUCCESS

NotifyFunction was registered

EFI_UNSUPPORTED

ArpDevice GetArpMap and Notify are not implemented by this driver