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