]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/SpiConfiguration.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Include / Protocol / SpiConfiguration.h
CommitLineData
db04b706
MH
1/** @file\r
2 This file defines the SPI Configuration Protocol.\r
3\r
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
9344f092 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
db04b706
MH
6\r
7 @par Revision Reference:\r
8 This Protocol was introduced in UEFI PI Specification 1.6.\r
9\r
10**/\r
11\r
12#ifndef __SPI_CONFIGURATION_PROTOCOL_H__\r
13#define __SPI_CONFIGURATION_PROTOCOL_H__\r
14\r
15///\r
16/// Global ID for the SPI Configuration Protocol\r
17///\r
18#define EFI_SPI_CONFIGURATION_GUID \\r
19 { 0x85a6d3e6, 0xb65b, 0x4afc, \\r
20 { 0xb3, 0x8f, 0xc6, 0xd5, 0x4a, 0xf6, 0xdd, 0xc8 }}\r
21\r
22///\r
23/// Macros to easily specify frequencies in hertz, kilohertz and megahertz.\r
24///\r
25#define Hz(Frequency) (Frequency)\r
26#define KHz(Frequency) (1000 * Hz (Frequency))\r
27#define MHz(Frequency) (1000 * KHz (Frequency))\r
28\r
29typedef struct _EFI_SPI_PERIPHERAL EFI_SPI_PERIPHERAL;\r
30\r
31/**\r
32 Manipulate the chip select for a SPI device.\r
33\r
34 This routine must be called at or below TPL_NOTIFY.\r
35 Update the value of the chip select line for a SPI peripheral.\r
36 The SPI bus layer calls this routine either in the board layer or in the SPI\r
37 controller to manipulate the chip select pin at the start and end of a SPI\r
38 transaction.\r
39\r
40 @param[in] SpiPeripheral The address of an EFI_SPI_PERIPHERAL data structure\r
41 describing the SPI peripheral whose chip select pin\r
42 is to be manipulated. The routine may access the\r
43 ChipSelectParameter field to gain sufficient\r
44 context to complete the operation.\r
45 @param[in] PinValue The value to be applied to the chip select line of\r
46 the SPI peripheral.\r
47\r
48 @retval EFI_SUCCESS The chip select was set successfully\r
49 @retval EFI_NOT_READY Support for the chip select is not properly\r
50 initialized\r
51 @retval EFI_INVALID_PARAMETER The SpiPeripheral->ChipSelectParameter value\r
52 is invalid\r
53\r
54**/\r
55typedef\r
56EFI_STATUS\r
2f88bd3a 57(EFIAPI *EFI_SPI_CHIP_SELECT)(\r
db04b706
MH
58 IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral,\r
59 IN BOOLEAN PinValue\r
60 );\r
61\r
62/**\r
63 Set up the clock generator to produce the correct clock frequency, phase and\r
64 polarity for a SPI chip.\r
65\r
66 This routine must be called at or below TPL_NOTIFY.\r
67 This routine updates the clock generator to generate the correct frequency\r
68 and polarity for the SPI clock.\r
69\r
70 @param[in] SpiPeripheral Pointer to a EFI_SPI_PERIPHERAL data structure from\r
71 which the routine can access the ClockParameter,\r
72 ClockPhase and ClockPolarity fields. The routine\r
73 also has access to the names for the SPI bus and\r
74 chip which can be used during debugging.\r
75 @param[in] ClockHz Pointer to the requested clock frequency. The clock\r
76 generator will choose a supported clock frequency\r
77 which is less then or equal to this value.\r
78 Specify zero to turn the clock generator off.\r
79 The actual clock frequency supported by the clock\r
80 generator will be returned.\r
81\r
82 @retval EFI_SUCCESS The clock was set up successfully\r
83 @retval EFI_UNSUPPORTED The SPI controller was not able to support the\r
84 frequency requested by CLockHz\r
85\r
86**/\r
87typedef EFI_STATUS\r
2f88bd3a 88(EFIAPI *EFI_SPI_CLOCK)(\r
db04b706
MH
89 IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral,\r
90 IN UINT32 *ClockHz\r
91 );\r
92\r
93///\r
94/// The EFI_SPI_PART data structure provides a description of a SPI part which\r
95/// is independent of the use on the board. This data is available directly\r
96/// from the part's datasheet and may be provided by the vendor.\r
97///\r
98typedef struct _EFI_SPI_PART {\r
99 ///\r
100 /// A Unicode string specifying the SPI chip vendor.\r
101 ///\r
2f88bd3a 102 CONST CHAR16 *Vendor;\r
db04b706
MH
103\r
104 ///\r
105 /// A Unicode string specifying the SPI chip part number.\r
106 ///\r
2f88bd3a 107 CONST CHAR16 *PartNumber;\r
db04b706
MH
108\r
109 ///\r
110 /// The minimum SPI bus clock frequency used to access this chip. This value\r
111 /// may be specified in the chip's datasheet. If not, use the value of zero.\r
112 ///\r
2f88bd3a 113 UINT32 MinClockHz;\r
db04b706
MH
114\r
115 ///\r
116 /// The maximum SPI bus clock frequency used to access this chip. This value\r
117 /// is found in the chip's datasheet.\r
118 ///\r
2f88bd3a 119 UINT32 MaxClockHz;\r
db04b706
MH
120\r
121 ///\r
122 /// Specify the polarity of the chip select pin. This value can be found in\r
123 /// the SPI chip's datasheet. Specify TRUE when a one asserts the chip select\r
2f88bd3a 124 /// and FALSE when a zero asserts the chip select.\r
db04b706 125 ///\r
2f88bd3a 126 BOOLEAN ChipSelectPolarity;\r
db04b706
MH
127} EFI_SPI_PART;\r
128\r
129///\r
130/// The EFI_SPI_BUS data structure provides the connection details between the\r
131/// physical SPI bus and the EFI_SPI_HC_PROTOCOL instance which controls that\r
132/// SPI bus. This data structure also describes the details of how the clock is\r
133/// generated for that SPI bus. Finally this data structure provides the list\r
134/// of physical SPI devices which are attached to the SPI bus.\r
135///\r
136typedef struct _EFI_SPI_BUS {\r
137 ///\r
138 /// A Unicode string describing the SPI bus\r
139 ///\r
2f88bd3a 140 CONST CHAR16 *FriendlyName;\r
db04b706
MH
141\r
142 ///\r
143 /// Address of the first EFI_SPI_PERIPHERAL data structure connected to this\r
144 /// bus. Specify NULL if there are no SPI peripherals connected to this bus.\r
145 ///\r
2f88bd3a 146 CONST EFI_SPI_PERIPHERAL *Peripherallist;\r
db04b706
MH
147\r
148 ///\r
149 /// Address of an EFI_DEVICE_PATH_PROTOCOL data structure which uniquely\r
150 /// describes the SPI controller.\r
151 ///\r
2f88bd3a 152 CONST EFI_DEVICE_PATH_PROTOCOL *ControllerPath;\r
db04b706
MH
153\r
154 ///\r
155 /// Address of the routine which controls the clock used by the SPI bus for\r
156 /// this SPI peripheral. The SPI host co ntroller's clock routine is called\r
157 /// when this value is set to NULL.\r
158 ///\r
2f88bd3a 159 EFI_SPI_CLOCK Clock;\r
db04b706
MH
160\r
161 ///\r
162 /// Address of a data structure containing the additional values which\r
163 /// describe the necessary control for the clock. When Clock is NULL,\r
164 /// the declaration for this data structure is provided by the vendor of the\r
165 /// host's SPI controller driver. When Clock is not NULL, the declaration for\r
166 /// this data structure is provided by the board layer.\r
167 ///\r
2f88bd3a 168 VOID *ClockParameter;\r
db04b706
MH
169} EFI_SPI_BUS;\r
170\r
171///\r
172/// The EFI_SPI_PERIPHERAL data structure describes how a specific block of\r
173/// logic which is connected to the SPI bus. This data structure also selects\r
174/// which upper level driver is used to manipulate this SPI device.\r
175/// The SpiPeripheraLDriverGuid is available from the vendor of the SPI\r
176/// peripheral driver.\r
177///\r
178struct _EFI_SPI_PERIPHERAL {\r
179 ///\r
180 /// Address of the next EFI_SPI_PERIPHERAL data structure. Specify NULL if\r
181 /// the current data structure is the last one on the SPI bus.\r
182 ///\r
2f88bd3a 183 CONST EFI_SPI_PERIPHERAL *NextSpiPeripheral;\r
db04b706
MH
184\r
185 ///\r
186 /// A unicode string describing the function of the SPI part.\r
187 ///\r
2f88bd3a 188 CONST CHAR16 *FriendlyName;\r
db04b706
MH
189\r
190 ///\r
191 /// Address of a GUID provided by the vendor of the SPI peripheral driver.\r
192 /// Instead of using a " EFI_SPI_IO_PROTOCOL" GUID, the SPI bus driver uses\r
193 /// this GUID to identify an EFI_SPI_IO_PROTOCOL data structure and to\r
194 /// provide the connection points for the SPI peripheral drivers.\r
195 /// This reduces the comparison logic in the SPI peripheral driver's\r
196 /// Supported routine.\r
197 ///\r
2f88bd3a 198 CONST GUID *SpiPeripheralDriverGuid;\r
db04b706
MH
199\r
200 ///\r
201 /// The address of an EFI_SPI_PART data structure which describes this chip.\r
202 ///\r
2f88bd3a 203 CONST EFI_SPI_PART *SpiPart;\r
db04b706
MH
204\r
205 ///\r
206 /// The maximum clock frequency is specified in the EFI_SPI_P ART. When this\r
207 /// this value is non-zero and less than the value in the EFI_SPI_PART then\r
208 /// this value is used for the maximum clock frequency for the SPI part.\r
209 ///\r
2f88bd3a 210 UINT32 MaxClockHz;\r
db04b706
MH
211\r
212 ///\r
213 /// Specify the idle value of the clock as found in the datasheet.\r
214 /// Use zero (0) if the clock'S idle value is low or one (1) if the the\r
215 /// clock's idle value is high.\r
216 ///\r
2f88bd3a 217 BOOLEAN ClockPolarity;\r
db04b706
MH
218\r
219 ///\r
220 /// Specify the clock delay after chip select. Specify zero (0) to delay an\r
221 /// entire clock cycle or one (1) to delay only half a clock cycle.\r
222 ///\r
2f88bd3a 223 BOOLEAN ClockPhase;\r
db04b706
MH
224\r
225 ///\r
226 /// SPI peripheral attributes, select zero or more of:\r
227 /// * SPI_PART_SUPPORTS_2_B1T_DATA_BUS_W1DTH - The SPI peripheral is wired to\r
228 /// support a 2-bit data bus\r
229 /// * SPI_PART_SUPPORTS_4_B1T_DATA_BUS_W1DTH - The SPI peripheral is wired to\r
230 /// support a 4-bit data bus\r
231 ///\r
2f88bd3a 232 UINT32 Attributes;\r
db04b706
MH
233\r
234 ///\r
235 /// Address of a vendor specific data structure containing additional board\r
236 /// configuration details related to the SPI chip. The SPI peripheral layer\r
237 /// uses this data structure when configuring the chip.\r
238 ///\r
2f88bd3a 239 CONST VOID *ConfigurationData;\r
db04b706
MH
240\r
241 ///\r
242 /// The address of an EFI_SPI_BUS data structure which describes the SPI bus\r
243 /// to which this chip is connected.\r
244 ///\r
2f88bd3a 245 CONST EFI_SPI_BUS *SpiBus;\r
db04b706
MH
246\r
247 ///\r
248 /// Address of the routine which controls the chip select pin for this SPI\r
249 /// peripheral. Call the SPI host controller's chip select routine when this\r
250 /// value is set to NULL.\r
251 ///\r
2f88bd3a 252 EFI_SPI_CHIP_SELECT ChipSelect;\r
db04b706
MH
253\r
254 ///\r
255 /// Address of a data structure containing the additional values which\r
256 /// describe the necessary control for the chip select. When ChipSelect is\r
257 /// NULL, the declaration for this data structure is provided by the vendor\r
258 /// of the host's SPI controller driver. The vendor's documentation specifies\r
259 /// the necessary values to use for the chip select pin selection and\r
260 /// control. When Chipselect is not NULL, the declaration for this data\r
261 /// structure is provided by the board layer.\r
262 ///\r
2f88bd3a 263 VOID *ChipSelectParameter;\r
db04b706
MH
264};\r
265\r
266///\r
267/// Describe the details of the board's SPI busses to the SPI driver stack.\r
268/// The board layer uses the EFI_SPI_CONFIGURATION_PROTOCOL to expose the data\r
269/// tables which describe the board's SPI busses, The SPI bus layer uses these\r
270/// tables to configure the clock, chip select and manage the SPI transactions\r
271/// on the SPI controllers.\r
272///\r
273typedef struct _EFI_SPI_CONFIGURATION_PROTOCOL {\r
274 ///\r
275 /// The number of SPI busses on the board.\r
276 ///\r
2f88bd3a 277 UINT32 BusCount;\r
db04b706
MH
278\r
279 ///\r
280 /// The address of an array of EFI_SPI_BUS data structure addresses.\r
281 ///\r
2f88bd3a 282 CONST EFI_SPI_BUS *CONST *CONST Buslist;\r
db04b706
MH
283} EFI_SPI_CONFIGURATION_PROTOCOL;\r
284\r
2f88bd3a 285extern EFI_GUID gEfiSpiConfigurationProtocolGuid;\r
db04b706
MH
286\r
287#endif // __SPI_CONFIGURATION_PROTOCOL_H__\r