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