]> git.proxmox.com Git - mirror_edk2.git/blame - QuarkSocPkg/QuarkNorthCluster/QNCInit/Dxe/DxeQNCSmbus.h
QuarkSocPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / QuarkSocPkg / QuarkNorthCluster / QNCInit / Dxe / DxeQNCSmbus.h
CommitLineData
9b6bbcdb
MK
1/** @file\r
2Header file for the defintions used in SMBus DXE driver.\r
3\r
4Copyright (c) 2013-2015 Intel Corporation.\r
5\r
c9f231d0 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
9b6bbcdb
MK
7\r
8**/\r
9\r
10\r
11#ifndef _DXE_QNC_SMBUS_H_\r
12#define _DXE_QNC_SMBUS_H_\r
13#include "CommonHeader.h"\r
14\r
15#include "QNCSmbus.h"\r
16\r
17#define MAX_SMBUS_DEVICES 107 // Max number of SMBus devices (7 bit\r
18 // address yields 128 combinations but 21\r
19 // of those are reserved)\r
20\r
21#define MICROSECOND 10\r
22#define MILLISECOND (1000 * MICROSECOND)\r
23#define ONESECOND (1000 * MILLISECOND)\r
24\r
25#define STALL_TIME 1000000 // 1,000,000 microseconds = 1 second\r
26#define BUS_TRIES 3 // How many times to retry on Bus Errors\r
27#define SMBUS_NUM_RESERVED 21 // Number of device addresses that are\r
28 // reserved by the SMBus spec.\r
29#define SMBUS_ADDRESS_ARP 0xC2 >> 1\r
30#define SMBUS_DATA_PREPARE_TO_ARP 0x01\r
31#define SMBUS_DATA_RESET_DEVICE 0x02\r
32#define SMBUS_DATA_GET_UDID_GENERAL 0x03\r
33#define SMBUS_DATA_ASSIGN_ADDRESS 0x04\r
34#define SMBUS_GET_UDID_LENGTH 17 // 16 byte UDID + 1 byte address\r
35\r
36/**\r
37 Executes an SMBus operation to an SMBus controller. Returns when either the command has been\r
38 executed or an error is encountered in doing the operation.\r
39\r
40 The Execute() function provides a standard way to execute an operation as defined in the System\r
41 Management Bus (SMBus) Specification. The resulting transaction will be either that the SMBus\r
42 slave devices accept this transaction or that this function returns with error.\r
43\r
44 @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance.\r
45 @param SlaveAddress The SMBus slave address of the device with which to communicate.\r
46 @param Command This command is transmitted by the SMBus host controller to the\r
47 SMBus slave device and the interpretation is SMBus slave device\r
48 specific. It can mean the offset to a list of functions inside an\r
49 SMBus slave device. Not all operations or slave devices support\r
50 this command's registers.\r
51 @param Operation Signifies which particular SMBus hardware protocol instance that\r
52 it will use to execute the SMBus transactions. This SMBus\r
53 hardware protocol is defined by the SMBus Specification and is\r
54 not related to EFI.\r
55 @param PecCheck Defines if Packet Error Code (PEC) checking is required for this\r
56 operation.\r
57 @param Length Signifies the number of bytes that this operation will do. The\r
58 maximum number of bytes can be revision specific and operation\r
59 specific. This field will contain the actual number of bytes that\r
60 are executed for this operation. Not all operations require this\r
61 argument.\r
62 @param Buffer Contains the value of data to execute to the SMBus slave device.\r
63 Not all operations require this argument. The length of this\r
64 buffer is identified by Length.\r
65\r
66 @retval EFI_SUCCESS The last data that was returned from the access matched the poll\r
67 exit criteria.\r
68 @retval EFI_CRC_ERROR Checksum is not correct (PEC is incorrect).\r
69 @retval EFI_TIMEOUT Timeout expired before the operation was completed. Timeout is\r
70 determined by the SMBus host controller device.\r
71 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
72 @retval EFI_DEVICE_ERROR The request was not completed because a failure that was\r
73 reflected in the Host Status Register bit. Device errors are a\r
74 result of a transaction collision, illegal command field,\r
75 unclaimed cycle (host initiated), or bus errors (collisions).\r
76 @retval EFI_INVALID_PARAMETER Operation is not defined in EFI_SMBUS_OPERATION.\r
77 @retval EFI_INVALID_PARAMETER Length/Buffer is NULL for operations except for EfiSmbusQuickRead\r
78 and EfiSmbusQuickWrite. Length is outside the range of valid\r
79 values.\r
80 @retval EFI_UNSUPPORTED The SMBus operation or PEC is not supported.\r
81 @retval EFI_BUFFER_TOO_SMALL Buffer is not sufficient for this operation.\r
82\r
83**/\r
84EFI_STATUS\r
85EFIAPI\r
86SmbusExecute (\r
87 IN CONST EFI_SMBUS_HC_PROTOCOL *This,\r
88 IN CONST EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,\r
89 IN CONST EFI_SMBUS_DEVICE_COMMAND Command,\r
90 IN CONST EFI_SMBUS_OPERATION Operation,\r
91 IN CONST BOOLEAN PecCheck,\r
92 IN OUT UINTN *Length,\r
93 IN OUT VOID *Buffer\r
94 );\r
95\r
96/**\r
97 Sets the SMBus slave device addresses for the device with a given unique ID or enumerates the\r
98 entire bus.\r
99\r
100 The ArpDevice() function provides a standard way for a device driver to enumerate the entire\r
101 SMBus or specific devices on the bus.\r
102\r
103 @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance.\r
104 @param ArpAll A Boolean expression that indicates if the host drivers need to\r
105 enumerate all the devices or enumerate only the device that is\r
106 identified by SmbusUdid. If ArpAll is TRUE, SmbusUdid and\r
107 SlaveAddress are optional. If ArpAll is FALSE, ArpDevice will\r
108 enumerate SmbusUdid and the address will be at SlaveAddress.\r
109 @param SmbusUdid The Unique Device Identifier (UDID) that is associated with this\r
110 device.\r
111 @param SlaveAddress The SMBus slave address that is associated with an SMBus UDID.\r
112\r
113 @retval EFI_SUCCESS The last data that was returned from the access matched the poll\r
114 exit criteria.\r
115 @retval EFI_CRC_ERROR Checksum is not correct (PEC is incorrect).\r
116 @retval EFI_TIMEOUT Timeout expired before the operation was completed. Timeout is\r
117 determined by the SMBus host controller device.\r
118 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
119 @retval EFI_DEVICE_ERROR The request was not completed because a failure that was\r
120 reflected in the Host Status Register bit. Device errors are a\r
121 result of a transaction collision, illegal command field,\r
122 unclaimed cycle (host initiated), or bus errors (collisions).\r
123 @retval EFI_UNSUPPORTED The corresponding operation is not supported.\r
124\r
125**/\r
126EFI_STATUS\r
127EFIAPI\r
128SmbusArpDevice (\r
129 IN CONST EFI_SMBUS_HC_PROTOCOL *This,\r
130 IN BOOLEAN ArpAll,\r
131 IN EFI_SMBUS_UDID *SmbusUdid, OPTIONAL\r
132 IN OUT EFI_SMBUS_DEVICE_ADDRESS *SlaveAddress OPTIONAL\r
133 );\r
134\r
135/**\r
136 Returns a pointer to the Address Resolution Protocol (ARP) map that contains the ID/address pair\r
137 of the slave devices that were enumerated by the SMBus host controller driver.\r
138\r
139 The GetArpMap() function returns the mapping of all the SMBus devices that were enumerated by the\r
140 SMBus host driver.\r
141\r
142 @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance.\r
143 @param Length Size of the buffer that contains the SMBus device map.\r
144 @param SmbusDeviceMap The pointer to the device map as enumerated by the SMBus\r
145 controller driver.\r
146\r
147 @retval EFI_SUCCESS The SMBus returned the current device map.\r
148 @retval EFI_UNSUPPORTED The corresponding operation is not supported.\r
149\r
150**/\r
151EFI_STATUS\r
152EFIAPI\r
153SmbusGetArpMap (\r
154 IN CONST EFI_SMBUS_HC_PROTOCOL *This,\r
155 IN OUT UINTN *Length,\r
156 IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap\r
157 );\r
158\r
159/**\r
160 Allows a device driver to register for a callback when the bus driver detects a state that it\r
161 needs to propagate to other drivers that are registered for a callback.\r
162\r
163 The Notify() function registers all the callback functions to allow the bus driver to call these\r
164 functions when the SlaveAddress/Data pair happens.\r
165 If NotifyFunction is NULL, then ASSERT ().\r
166\r
167 @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance.\r
168 @param SlaveAddress The SMBUS hardware address to which the SMBUS device is\r
169 preassigned or allocated.\r
170 @param Data Data of the SMBus host notify command that the caller wants to be\r
171 called.\r
172 @param NotifyFunction The function to call when the bus driver detects the SlaveAddress\r
173 and Data pair.\r
174\r
175 @retval EFI_SUCCESS NotifyFunction was registered.\r
176 @retval EFI_UNSUPPORTED The corresponding operation is not supported.\r
177\r
178**/\r
179EFI_STATUS\r
180EFIAPI\r
181SmbusNotify (\r
182 IN CONST EFI_SMBUS_HC_PROTOCOL *This,\r
183 IN CONST EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,\r
184 IN CONST UINTN Data,\r
185 IN CONST EFI_SMBUS_NOTIFY_FUNCTION NotifyFunction\r
186 );\r
187\r
188/**\r
189 Entry point to the DXE Driver that produces the SMBus Host Controller Protocol.\r
190\r
191 @param ImageHandle ImageHandle of the loaded driver.\r
192 @param SystemTable Pointer to the EFI System Table.\r
193\r
194 @retval EFI_SUCCESS The entry point of SMBus DXE driver is executed successfully.\r
195 @retval !EFI_SUCESS Some error occurs in the entry point of SMBus DXE driver.\r
196\r
197**/\r
198EFI_STATUS\r
199EFIAPI\r
200InitializeQNCSmbus (\r
201 IN EFI_HANDLE ImageHandle,\r
202 IN EFI_SYSTEM_TABLE *SystemTable\r
203 );\r
204\r
205#endif\r