]> git.proxmox.com Git - mirror_edk2.git/blob - QuarkPlatformPkg/Include/Library/PlatformHelperLib.h
65429626c8a4c5f5253b7fdcbd343df026c61c47
[mirror_edk2.git] / QuarkPlatformPkg / Include / Library / PlatformHelperLib.h
1 /** @file
2 PlatformHelperLib function prototype definitions.
3
4 Copyright (c) 2013 - 2016 Intel Corporation.
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef __PLATFORM_HELPER_LIB_H__
11 #define __PLATFORM_HELPER_LIB_H__
12
13 #include "Platform.h"
14
15 //
16 // Function prototypes for routines exported by this library.
17 //
18
19 /**
20 Find pointer to RAW data in Firmware volume file.
21
22 @param FvNameGuid Firmware volume to search. If == NULL search all.
23 @param FileNameGuid Firmware volume file to search for.
24 @param SectionData Pointer to RAW data section of found file.
25 @param SectionDataSize Pointer to UNITN to get size of RAW data.
26
27 @retval EFI_SUCCESS Raw Data found.
28 @retval EFI_INVALID_PARAMETER FileNameGuid == NULL.
29 @retval EFI_NOT_FOUND Firmware volume file not found.
30 @retval EFI_UNSUPPORTED Unsupported in current enviroment (PEI or DXE).
31
32 **/
33 EFI_STATUS
34 EFIAPI
35 PlatformFindFvFileRawDataSection (
36 IN CONST EFI_GUID *FvNameGuid OPTIONAL,
37 IN CONST EFI_GUID *FileNameGuid,
38 OUT VOID **SectionData,
39 OUT UINTN *SectionDataSize
40 );
41
42 /**
43 Find free spi protect register and write to it to protect a flash region.
44
45 @param DirectValue Value to directly write to register.
46 if DirectValue == 0 the use Base & Length below.
47 @param BaseAddress Base address of region in Flash Memory Map.
48 @param Length Length of region to protect.
49
50 @retval EFI_SUCCESS Free spi protect register found & written.
51 @retval EFI_NOT_FOUND Free Spi protect register not found.
52 @retval EFI_DEVICE_ERROR Unable to write to spi protect register.
53
54 **/
55 EFI_STATUS
56 EFIAPI
57 PlatformWriteFirstFreeSpiProtect (
58 IN CONST UINT32 DirectValue,
59 IN CONST UINT32 BaseAddress,
60 IN CONST UINT32 Length
61 );
62
63 /**
64 Lock legacy SPI static configuration information.
65
66 Function will assert if unable to lock config.
67
68 **/
69 VOID
70 EFIAPI
71 PlatformFlashLockConfig (
72 VOID
73 );
74
75 /**
76 Lock regions and config of SPI flash given the policy for this platform.
77
78 Function will assert if unable to lock regions or config.
79
80 @param PreBootPolicy If TRUE do Pre Boot Flash Lock Policy.
81
82 **/
83 VOID
84 EFIAPI
85 PlatformFlashLockPolicy (
86 IN CONST BOOLEAN PreBootPolicy
87 );
88
89 /** Check if System booted with recovery Boot Stage1 image.
90
91 @retval TRUE If system booted with recovery Boot Stage1 image.
92 @retval FALSE If system booted with normal stage1 image.
93
94 **/
95 BOOLEAN
96 EFIAPI
97 PlatformIsBootWithRecoveryStage1 (
98 VOID
99 );
100
101 /**
102 Clear SPI Protect registers.
103
104 @retval EFI_SUCESS SPI protect registers cleared.
105 @retval EFI_ACCESS_DENIED Unable to clear SPI protect registers.
106 **/
107
108 EFI_STATUS
109 EFIAPI
110 PlatformClearSpiProtect (
111 VOID
112 );
113
114 /**
115 Determine if an SPI address range is protected.
116
117 @param SpiBaseAddress Base of SPI range.
118 @param Length Length of SPI range.
119
120 @retval TRUE Range is protected.
121 @retval FALSE Range is not protected.
122 **/
123 BOOLEAN
124 EFIAPI
125 PlatformIsSpiRangeProtected (
126 IN CONST UINT32 SpiBaseAddress,
127 IN CONST UINT32 Length
128 );
129
130 /**
131 Set Legacy GPIO Level
132
133 @param LevelRegOffset GPIO level register Offset from GPIO Base Address.
134 @param GpioNum GPIO bit to change.
135 @param HighLevel If TRUE set GPIO High else Set GPIO low.
136
137 **/
138 VOID
139 EFIAPI
140 PlatformLegacyGpioSetLevel (
141 IN CONST UINT32 LevelRegOffset,
142 IN CONST UINT32 GpioNum,
143 IN CONST BOOLEAN HighLevel
144 );
145
146 /**
147 Get Legacy GPIO Level
148
149 @param LevelRegOffset GPIO level register Offset from GPIO Base Address.
150 @param GpioNum GPIO bit to check.
151
152 @retval TRUE If bit is SET.
153 @retval FALSE If bit is CLEAR.
154
155 **/
156 BOOLEAN
157 EFIAPI
158 PlatformLegacyGpioGetLevel (
159 IN CONST UINT32 LevelRegOffset,
160 IN CONST UINT32 GpioNum
161 );
162
163 /**
164 Set the direction of Pcal9555 IO Expander GPIO pin.
165
166 @param Pcal9555SlaveAddr I2c Slave address of Pcal9555 Io Expander.
167 @param GpioNum Gpio direction to configure - values 0-7 for Port0
168 and 8-15 for Port1.
169 @param CfgAsInput If TRUE set pin direction as input else set as output.
170
171 **/
172 VOID
173 EFIAPI
174 PlatformPcal9555GpioSetDir (
175 IN CONST UINT32 Pcal9555SlaveAddr,
176 IN CONST UINT32 GpioNum,
177 IN CONST BOOLEAN CfgAsInput
178 );
179
180 /**
181 Set the level of Pcal9555 IO Expander GPIO high or low.
182
183 @param Pcal9555SlaveAddr I2c Slave address of Pcal9555 Io Expander.
184 @param GpioNum Gpio to change values 0-7 for Port0 and 8-15
185 for Port1.
186 @param HighLevel If TRUE set pin high else set pin low.
187
188 **/
189 VOID
190 EFIAPI
191 PlatformPcal9555GpioSetLevel (
192 IN CONST UINT32 Pcal9555SlaveAddr,
193 IN CONST UINT32 GpioNum,
194 IN CONST BOOLEAN HighLevel
195 );
196
197 /**
198
199 Enable pull-up/pull-down resistors of Pcal9555 GPIOs.
200
201 @param Pcal9555SlaveAddr I2c Slave address of Pcal9555 Io Expander.
202 @param GpioNum Gpio to change values 0-7 for Port0 and 8-15
203 for Port1.
204
205 **/
206 VOID
207 EFIAPI
208 PlatformPcal9555GpioEnablePull (
209 IN CONST UINT32 Pcal9555SlaveAddr,
210 IN CONST UINT32 GpioNum
211 );
212
213 /**
214
215 Disable pull-up/pull-down resistors of Pcal9555 GPIOs.
216
217 @param Pcal9555SlaveAddr I2c Slave address of Pcal9555 Io Expander.
218 @param GpioNum Gpio to change values 0-7 for Port0 and 8-15
219 for Port1.
220
221 **/
222 VOID
223 EFIAPI
224 PlatformPcal9555GpioDisablePull (
225 IN CONST UINT32 Pcal9555SlaveAddr,
226 IN CONST UINT32 GpioNum
227 );
228
229 BOOLEAN
230 EFIAPI
231 PlatformPcal9555GpioGetState (
232 IN CONST UINT32 Pcal9555SlaveAddr,
233 IN CONST UINT32 GpioNum
234 );
235
236 /**
237 Init platform LEDs into known state.
238
239 @param PlatformType Executing platform type.
240
241 @retval EFI_SUCCESS Operation success.
242
243 **/
244 EFI_STATUS
245 EFIAPI
246 PlatformLedInit (
247 IN CONST EFI_PLATFORM_TYPE Type
248 );
249
250 /**
251 Turn on or off platform flash update LED.
252
253 @param PlatformType Executing platform type.
254 @param TurnOn If TRUE turn on else turn off.
255
256 @retval EFI_SUCCESS Operation success.
257
258 **/
259 EFI_STATUS
260 EFIAPI
261 PlatformFlashUpdateLed (
262 IN CONST EFI_PLATFORM_TYPE Type,
263 IN CONST BOOLEAN TurnOn
264 );
265
266 #endif // #ifndef __PLATFORM_HELPER_LIB_H__