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