e179d0ceb36f050491f2aa459eab047ce9626143
[mirror_edk2.git] / IntelFrameworkPkg / Include / Ppi / Smbus.h
1 /** @file
2 This file declares Smbus PPI.
3
4 Copyright (c) 2007, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 Module Name: Smbus.h
14
15 @par Revision Reference:
16 This PPI is defined in Framework of EFI SmBus PPI spec.
17 Version 0.9
18
19 **/
20
21 #ifndef _PEI_SMBUS_PPI_H
22 #define _PEI_SMBUS_PPI_H
23
24 #include <PiPei.h>
25 #include <Ppi/Smbus2.h>
26
27 #define EFI_PEI_SMBUS_PPI_GUID \
28 { \
29 0xabd42895, 0x78cf, 0x4872, {0x84, 0x44, 0x1b, 0x5c, 0x18, 0xb, 0xfb, 0xda } \
30 }
31
32 typedef struct _EFI_PEI_SMBUS_PPI EFI_PEI_SMBUS_PPI;
33
34 /**
35 Executes an SMBus operation to an SMBus controller.
36
37 @param PeiServices A pointer to the system PEI Services Table.
38 @param This A pointer to the EFI_PEI_SMBUS_PPI instance.
39 @param SlaveAddress The SMBUS hardware address to which the SMBUS
40 device is preassigned or allocated.
41 @param Command This command is transmitted by the SMBus host
42 controller to the SMBus slave device and the interpretation is
43 SMBus slave device specific.
44 @param Operation Signifies which particular SMBus hardware protocol
45 instance that it will use to execute the SMBus transactions.
46 @param PecCheck Defines if Packet Error Code (PEC) checking is required
47 for this operation.
48 @param Length Signifies the number of bytes that this operation will do.
49 @param Buffer Contains the value of data to execute to the SMBus slave device.
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. 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_SMBUS_PPI_EXECUTE_OPERATION) (
70 IN EFI_PEI_SERVICES **PeiServices,
71 IN EFI_PEI_SMBUS_PPI *This,
72 IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
73 IN EFI_SMBUS_DEVICE_COMMAND Command,
74 IN EFI_SMBUS_OPERATION Operation,
75 IN BOOLEAN PecCheck,
76 IN OUT UINTN *Length,
77 IN OUT VOID *Buffer
78 );
79
80 /**
81 CallBack function can be registered in EFI_PEI_SMBUS_PPI_NOTIFY.
82
83 @param PeiServices A pointer to the system PEI Services Table.
84 @param This A pointer to the EFI_PEI_SMBUS_PPI instance.
85 @param SlaveAddress The SMBUS hardware address to which the SMBUS
86 device is preassigned or allocated.
87 @param Data Data of the SMBus host notify command that
88 the caller wants to be called.
89
90 @return Status Code
91
92 **/
93 typedef
94 EFI_STATUS
95 (EFIAPI *EFI_PEI_SMBUS_NOTIFY_FUNCTION) (
96 IN EFI_PEI_SERVICES **PeiServices,
97 IN EFI_PEI_SMBUS_PPI *SmbusPpi,
98 IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
99 IN UINTN Data
100 );
101
102 /**
103 The ArpDevice() function enumerates the entire bus or enumerates a specific
104 device that is identified by SmbusUdid.
105
106 @param PeiServices A pointer to the system PEI Services Table.
107 @param This A pointer to the EFI_PEI_SMBUS_PPI instance.
108 @param ArpAll A Boolean expression that indicates if the host drivers need
109 to enumerate all the devices or enumerate only the device that is identified
110 by SmbusUdid. If ArpAll is TRUE, SmbusUdid and SlaveAddress are optional.
111 If ArpAll is FALSE, ArpDevice will enumerate SmbusUdid and the address
112 will be at SlaveAddress.
113 @param SmbusUdid The targeted SMBus Unique Device Identifier (UDID).
114 The UDID may not exist for SMBus devices with fixed addresses.
115 @param SlaveAddress The new SMBus address for the slave device for
116 which the operation is targeted.
117
118 @retval EFI_SUCCESS The SMBus slave device address was set.
119 @retval EFI_INVALID_PARAMETER SlaveAddress is NULL.
120 @retval EFI_OUT_OF_RESOURCES The request could not be completed
121 due to a lack of resources.
122 @retval EFI_TIMEOUT The SMBus slave device did not respond.
123 @retval EFI_DEVICE_ERROR The request was not completed because the transaction failed.
124
125 **/
126 typedef
127 EFI_STATUS
128 (EFIAPI *EFI_PEI_SMBUS_PPI_ARP_DEVICE) (
129 IN EFI_PEI_SERVICES **PeiServices,
130 IN EFI_PEI_SMBUS_PPI *This,
131 IN BOOLEAN ArpAll,
132 IN EFI_SMBUS_UDID *SmbusUdid, OPTIONAL
133 IN OUT EFI_SMBUS_DEVICE_ADDRESS *SlaveAddress OPTIONAL
134 );
135
136 /**
137 The GetArpMap() function returns the mapping of all the SMBus devices
138 that are enumerated by the SMBus host driver.
139
140 @param PeiServices A pointer to the system PEI Services Table.
141 @param This A pointer to the EFI_PEI_SMBUS_PPI instance.
142 @param Length Size of the buffer that contains the SMBus device map.
143 @param SmbusDeviceMap The pointer to the device map as enumerated
144 by the SMBus controller driver.
145
146 @retval EFI_SUCCESS The device map was returned correctly in the buffer.
147
148 **/
149 typedef
150 EFI_STATUS
151 (EFIAPI *EFI_PEI_SMBUS_PPI_GET_ARP_MAP) (
152 IN EFI_PEI_SERVICES **PeiServices,
153 IN EFI_PEI_SMBUS_PPI *This,
154 IN OUT UINTN *Length,
155 IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap
156 );
157
158 /**
159 The Notify() function registers all the callback functions to allow the
160 bus driver to call these functions when the SlaveAddress/Data pair happens.
161
162 @param PeiServices A pointer to the system PEI Services Table.
163 @param This A pointer to the EFI_PEI_SMBUS_PPI instance.
164 @param SlaveAddress Address that the host controller detects as
165 sending a message and calls all the registered functions.
166 @param Data Data that the host controller detects as sending a message
167 and calls all the registered functions.
168 @param NotifyFunction The function to call when the bus driver
169 detects the SlaveAddress and Data pair.
170
171 @retval EFI_SUCCESS NotifyFunction has been registered.
172
173 **/
174 typedef
175 EFI_STATUS
176 (EFIAPI *EFI_PEI_SMBUS_PPI_NOTIFY) (
177 IN EFI_PEI_SERVICES **PeiServices,
178 IN EFI_PEI_SMBUS_PPI *This,
179 IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
180 IN UINTN Data,
181 IN EFI_PEI_SMBUS_NOTIFY_FUNCTION NotifyFunction
182 );
183
184 /**
185 @par Ppi Description:
186 Provides the basic I/O interfaces that a PEIM uses to access
187 its SMBus controller and the slave devices attached to it.
188
189 @param Execute
190 Executes the SMBus operation to an SMBus slave device.
191
192 @param ArpDevice
193 Allows an SMBus 2.0 device(s) to be Address Resolution Protocol (ARP)
194
195 @param GetArpMap
196 Allows a PEIM to retrieve the address that was allocated by the SMBus
197 host controller during enumeration/ARP.
198
199 @param Notify
200 Allows a driver to register for a callback to the SMBus host
201 controller driver when the bus issues a notification to the bus controller PEIM.
202
203 **/
204 struct _EFI_PEI_SMBUS_PPI {
205 EFI_PEI_SMBUS_PPI_EXECUTE_OPERATION Execute;
206 EFI_PEI_SMBUS_PPI_ARP_DEVICE ArpDevice;
207 EFI_PEI_SMBUS_PPI_GET_ARP_MAP GetArpMap;
208 EFI_PEI_SMBUS_PPI_NOTIFY Notify;
209 };
210
211 extern EFI_GUID gEfiPeiSmbusPpiGuid;
212
213 #endif