1 /** @file 2 This file declares Smbus2 PPI. 3 This PPI provides the basic I/O interfaces that a PEIM uses to access its 4 SMBus controller and the slave devices attached to it. 5 6 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR> 7 This program and the accompanying materials 8 are licensed and made available under the terms and conditions of the BSD License 9 which accompanies this distribution. The full text of the license may be found at 10 http://opensource.org/licenses/bsd-license.php 11 12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 15 @par Revision Reference: 16 This PPI is introduced in PI Version 1.0. 17 18 **/ 19 20 #ifndef __PEI_SMBUS2_PPI_H__ 21 #define __PEI_SMBUS2_PPI_H__ 22 23 #include <IndustryStandard/SmBus.h> 24 25 #define EFI_PEI_SMBUS2_PPI_GUID \ 26 { 0x9ca93627, 0xb65b, 0x4324, { 0xa2, 0x2, 0xc0, 0xb4, 0x61, 0x76, 0x45, 0x43 } } 27 28 29 typedef struct _EFI_PEI_SMBUS2_PPI EFI_PEI_SMBUS2_PPI; 30 31 /** 32 Executes an SMBus operation to an SMBus controller. Returns when either 33 the command has been executed or an error is encountered in doing the operation. 34 35 @param This A pointer to the EFI_PEI_SMBUS2_PPI instance. 36 @param SlaveAddress The SMBUS hardware address to which the SMBUS device is preassigned or 37 allocated. 38 @param Command This command is transmitted by the SMBus host controller to the SMBus slave 39 device and the interpretation is SMBus slave device specific. 40 It can mean the offset to a list of functions inside 41 an SMBus slave device. Not all operations or slave devices support 42 this command's registers. 43 @param Operation Signifies which particular SMBus hardware protocol instance that it 44 will use to execute the SMBus transactions. 45 This SMBus hardware protocol is defined by the System Management Bus (SMBus) 46 Specification and is not related to UEFI. 47 @param PecCheck Defines if Packet Error Code (PEC) checking is required for this operation. 48 @param Length Signifies the number of bytes that this operation will do. 49 The maximum number of bytes can be revision specific and operation specific. 50 This parameter will contain the actual number of bytes that are executed 51 for this operation. Not all operations require this argument. 52 @param Buffer Contains the value of data to execute to the SMBus slave device. 53 Not all operations require this argument. 54 The length of this buffer is identified by Length. 55 56 57 @retval EFI_SUCCESS The last data that was returned from the access 58 matched the poll exit criteria. 59 @retval EFI_CRC_ERROR The checksum is not correct (PEC is incorrect) 60 @retval EFI_TIMEOUT Timeout expired before the operation was completed. 61 Timeout is determined by the SMBus host controller device. 62 @retval EFI_OUT_OF_RESOURCES The request could not be completed 63 due to a lack of resources. 64 @retval EFI_DEVICE_ERROR The request was not completed because 65 a failure reflected in the Host Status Register bit. 66 @retval EFI_INVALID_PARAMETER Operation is not defined in EFI_SMBUS_OPERATION. 67 Or Length/Buffer is NULL for operations except for EfiSmbusQuickRead and 68 EfiSmbusQuickWrite. Or Length is outside the range of valid values. 69 @retval EFI_UNSUPPORTED The SMBus operation or PEC is not supported. 70 @retval EFI_BUFFER_TOO_SMALL Buffer is not sufficient for this operation. 71 72 **/ 73 typedef 74 EFI_STATUS 75 (EFIAPI *EFI_PEI_SMBUS2_PPI_EXECUTE_OPERATION)( 76 IN CONST EFI_PEI_SMBUS2_PPI *This, 77 IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, 78 IN EFI_SMBUS_DEVICE_COMMAND Command, 79 IN EFI_SMBUS_OPERATION Operation, 80 IN BOOLEAN PecCheck, 81 IN OUT UINTN *Length, 82 IN OUT VOID *Buffer 83 ); 84 85 /** 86 The ArpDevice() function enumerates the entire bus or enumerates a specific 87 device that is identified by SmbusUdid. 88 89 @param This A pointer to the EFI_PEI_SMBUS2_PPI instance. 90 @param ArpAll A Boolean expression that indicates if the host drivers need 91 to enumerate all the devices or enumerate only the device that is identified 92 by SmbusUdid. If ArpAll is TRUE, SmbusUdid and SlaveAddress are optional. 93 If ArpAll is FALSE, ArpDevice will enumerate SmbusUdid and the address 94 will be at SlaveAddress. 95 @param SmbusUdid The targeted SMBus Unique Device Identifier (UDID). 96 The UDID may not exist for SMBus devices with fixed addresses. 97 @param SlaveAddress The new SMBus address for the slave device for 98 which the operation is targeted. 99 100 @retval EFI_SUCCESS The SMBus slave device address was set. 101 @retval EFI_INVALID_PARAMETER SlaveAddress is NULL. 102 @retval EFI_OUT_OF_RESOURCES The request could not be completed 103 due to a lack of resources. 104 @retval EFI_TIMEOUT The SMBus slave device did not respond. 105 @retval EFI_DEVICE_ERROR The request was not completed because the transaction failed. 106 @retval EFI_UNSUPPORTED ArpDevice, GetArpMap, and Notify are not implemented by this PEIM. 107 108 **/ 109 typedef 110 EFI_STATUS 111 (EFIAPI *EFI_PEI_SMBUS2_PPI_ARP_DEVICE)( 112 IN CONST EFI_PEI_SMBUS2_PPI *This, 113 IN BOOLEAN ArpAll, 114 IN EFI_SMBUS_UDID *SmbusUdid, OPTIONAL 115 IN OUT EFI_SMBUS_DEVICE_ADDRESS *SlaveAddress OPTIONAL 116 ); 117 118 /** 119 The GetArpMap() function returns the mapping of all the SMBus devices 120 that are enumerated by the SMBus host driver. 121 122 @param This A pointer to the EFI_PEI_SMBUS2_PPI instance. 123 @param Length Size of the buffer that contains the SMBus device map. 124 @param SmbusDeviceMap The pointer to the device map as enumerated 125 by the SMBus controller driver. 126 127 @retval EFI_SUCCESS The device map was returned correctly in the buffer. 128 @retval EFI_UNSUPPORTED ArpDevice, GetArpMap, and Notify are not implemented by this PEIM. 129 130 **/ 131 typedef 132 EFI_STATUS 133 (EFIAPI *EFI_PEI_SMBUS2_PPI_GET_ARP_MAP)( 134 IN CONST EFI_PEI_SMBUS2_PPI *This, 135 IN OUT UINTN *Length, 136 IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap 137 ); 138 139 /** 140 CallBack function can be registered in EFI_PEI_SMBUS2_PPI_NOTIFY. 141 142 @param This A pointer to the EFI_PEI_SMBUS2_PPI instance. 143 @param SlaveAddress The SMBUS hardware address to which the SMBUS 144 device is preassigned or allocated. 145 @param Data Data of the SMBus host notify command that 146 the caller wants to be called. 147 148 @retval EFI_SUCCESS NotifyFunction has been registered. 149 @retval EFI_UNSUPPORTED ArpDevice, GetArpMap, and Notify are not 150 implemented by this PEIM. 151 152 **/ 153 typedef 154 EFI_STATUS 155 (EFIAPI *EFI_PEI_SMBUS_NOTIFY2_FUNCTION)( 156 IN CONST EFI_PEI_SMBUS2_PPI *SmbusPpi, 157 IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, 158 IN UINTN Data 159 ); 160 161 /** 162 The Notify() function registers all the callback functions to allow the 163 bus driver to call these functions when the SlaveAddress/Data pair happens. 164 165 @param This A pointer to the EFI_PEI_SMBUS2_PPI instance. 166 @param SlaveAddress Address that the host controller detects as 167 sending a message and calls all the registered functions. 168 @param Data Data that the host controller detects as sending a message 169 and calls all the registered functions. 170 @param NotifyFunction The function to call when the bus driver 171 detects the SlaveAddress and Data pair. 172 173 @retval EFI_SUCCESS NotifyFunction has been registered. 174 @retval EFI_UNSUPPORTED ArpDevice, GetArpMap, and Notify are not 175 implemented by this PEIM. 176 **/ 177 typedef 178 EFI_STATUS 179 (EFIAPI *EFI_PEI_SMBUS2_PPI_NOTIFY)( 180 IN CONST EFI_PEI_SMBUS2_PPI *This, 181 IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, 182 IN UINTN Data, 183 IN EFI_PEI_SMBUS_NOTIFY2_FUNCTION NotifyFunction 184 ); 185 186 /// 187 /// Provides the basic I/O interfaces that a PEIM uses to access 188 /// its SMBus controller and the slave devices attached to it. 189 /// 190 struct _EFI_PEI_SMBUS2_PPI { 191 EFI_PEI_SMBUS2_PPI_EXECUTE_OPERATION Execute; 192 EFI_PEI_SMBUS2_PPI_ARP_DEVICE ArpDevice; 193 EFI_PEI_SMBUS2_PPI_GET_ARP_MAP GetArpMap; 194 EFI_PEI_SMBUS2_PPI_NOTIFY Notify; 195 /// 196 /// Identifier which uniquely identifies this SMBus controller in a system. 197 /// 198 EFI_GUID Identifier; 199 }; 200 201 extern EFI_GUID gEfiPeiSmbus2PpiGuid; 202 203 #endif 204