summaryrefslogtreecommitdiff
path: root/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPostMemPei/PlatformInit.h
blob: c931b07ff3a9cb3b6f2fb0790b2e3261f911e1af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/** @file
  Platform Early Stage header file.

  Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.<BR>

  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php.

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#ifndef _EFI_PLATFORM_INIT_H_
#define _EFI_PLATFORM_INIT_H_

#define EFI_FORWARD_DECLARATION(x) typedef struct _##x x

#include <CpuRegs.h>
#include <CpuType.h>
#include <FrameworkPei.h>
#include <PeiSaPolicyUpdate.h>
#include <Core/Pei/PeiMain.h>

#include <Pi/PiFirmwareFile.h>
#include <Pi/PiPeiCis.h>

#include <Guid/Capsule.h>
#include <Guid/EfiVpdData.h>
#include <Guid/FirmwareFileSystem.h>
#include <Guid/GlobalVariable.h>
#include <Guid/MemoryTypeInformation.h>
#include <Guid/PlatformInfo.h>

#include <Guid/RecoveryDevice.h>
#include <Guid/SetupVariable.h>
#include <Guid/PlatformCpuInfo.h>

#include <Ppi/AtaController.h>
#include <Ppi/BlockIo.h>
#include <Ppi/BootInRecoveryMode.h>
#include <Ppi/Capsule.h>
#include <Ppi/DeviceRecoveryModule.h>
#include <Ppi/EndOfPeiPhase.h>
#include <Ppi/MasterBootMode.h>
#include <Ppi/MemoryDiscovered.h>
#include <Ppi/ReadOnlyVariable2.h>
#include <Ppi/RecoveryModule.h>
#include <Ppi/Reset.h>
#include <Ppi/Smbus.h>
#include <Ppi/Stall.h>
#include <Ppi/CpuPolicy.h>
#include <Ppi/FirmwareVolume.h>
#include <Ppi/BoardInitSignalling.h>
#include <Library/PeiPolicyInitLib.h>
#include <Library/PeiCpuPolicyUpdateLib.h>
#include <Library/SideBandLib.h>
#include <Library/DebugLib.h>
#include <Library/TimerLib.h>
#include <Library/GpioLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/HobLib.h>
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <IndustryStandard/Pci22.h>
#include <Library/PmicLib.h>

#include "CMOSMap.h"
#include "Platform.h"
#include <PlatformBaseAddresses.h>
#include <PlatformBootMode.h>
#include <SaAccess.h>
#include <ScAccess.h>
#include <SetupMode.h>
#include <CpuAccess.h>

#define SMC_LAN_ON      0x46
#define SMC_LAN_OFF     0x47
#define SMC_DEEP_S3_STS 0xB2

//
// Wake Event Types
//
#define SMBIOS_WAKEUP_TYPE_RESERVED           0x00
#define SMBIOS_WAKEUP_TYPE_OTHERS             0x01
#define SMBIOS_WAKEUP_TYPE_UNKNOWN            0x02
#define SMBIOS_WAKEUP_TYPE_APM_TIMER          0x03
#define SMBIOS_WAKEUP_TYPE_MODEM_RING         0x04
#define SMBIOS_WAKEUP_TYPE_LAN_REMOTE         0x05
#define SMBIOS_WAKEUP_TYPE_POWER_SWITCH       0x06
#define SMBIOS_WAKEUP_TYPE_PCI_PME            0x07
#define SMBIOS_WAKEUP_TYPE_AC_POWER_RESTORED  0x08

//
// Defines for stall PPI
//
#define PEI_STALL_RESOLUTION  1

//
// Define for Vibra
//
#define  PWM_DUTY_CYCLE            0x55  // zero duty cycle is 0x32/0xff
#define  PWM_BASE_UNIT             0x3   // DRV2603 work on 10k-250k while PWM base is 19.2M, 0x3/0xFF*19.2MHz ~ 200KHz
#define  PWM_TIMEOUT_MAX           100
#define  PWM_DELAY                 1000000

extern EFI_GUID gVbtInfoGuid;

typedef struct {
  EFI_PHYSICAL_ADDRESS    VbtAddress;
  UINT32                  VbtSize;
} VBT_INFO;

#pragma pack(push, 1)
typedef union {
  UINT32 Raw;
  struct {
    UINT32 Pwm_On_Time_Divisor    :8;  ///< [7:0]
    UINT32 Pwm_Base_Unit          :16; ///< [23:8]
    UINT32 Pwm_Rsvd               :6;  ///< [29:24]
    UINT32 Pwm_Sw_Update          :1;  ///< [30]
    UINT32 Pwm_Enable             :1;  ///< [31]
  } BITS; // Bits
} PWMCTRL;
#pragma pack(pop)

//
// Function Prototypes
//
EFI_STATUS
PlatformScInit (
  IN SYSTEM_CONFIGURATION        *SystemConfiguration,
  IN CONST EFI_PEI_SERVICES      **PeiServices,
  IN UINT16                      PlatformType
  );

EFI_STATUS
EFIAPI
IchReset (
  IN CONST EFI_PEI_SERVICES     **PeiServices
  );

BOOLEAN
GetSleepTypeAfterWakeup (
  IN  CONST EFI_PEI_SERVICES    **PeiServices,
  OUT UINT16                    *SleepType
  );

EFI_STATUS
EndOfPeiPpiNotifyCallback (
  IN EFI_PEI_SERVICES           **PeiServices,
  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,
  IN VOID                       *Ppi
  );

EFI_STATUS
EFIAPI
PeimInitializeRecovery (
  IN CONST EFI_PEI_SERVICES     **PeiServices
  );

VOID
CheckPowerOffNow (
  VOID
  );

VOID
SetPlatformBootMode (
  IN CONST EFI_PEI_SERVICES    **PeiServices,
  IN OUT EFI_PLATFORM_INFO_HOB *PlatformInfoHob
  );

EFI_STATUS
EFIAPI
CpuOnlyReset (
  IN CONST EFI_PEI_SERVICES   **PeiServices
  );

EFI_STATUS
EFIAPI
Stall (
  IN CONST EFI_PEI_SERVICES     **PeiServices,
  IN CONST EFI_PEI_STALL_PPI    *This,
  IN UINTN                      Microseconds
  );

EFI_STATUS
MultiPlatformInfoInit (
  IN CONST EFI_PEI_SERVICES    **PeiServices,
  IN OUT EFI_PLATFORM_INFO_HOB *PlatformInfoHob
  );

BOOLEAN
IsRecoveryJumper (
  IN CONST EFI_PEI_SERVICES    **PeiServices,
  IN OUT EFI_PLATFORM_INFO_HOB *PlatformInfoHob
  );

EFI_STATUS
PlatformInfoUpdate (
  IN CONST EFI_PEI_SERVICES    **PeiServices,
  IN OUT EFI_PLATFORM_INFO_HOB *PlatformInfoHob,
  IN SYSTEM_CONFIGURATION      *SystemConfiguration
  );

EFI_STATUS
InitializePlatform (
  IN CONST EFI_PEI_SERVICES       **PeiServices,
  IN EFI_PLATFORM_INFO_HOB        *PlatformInfoHob,
  IN SYSTEM_CONFIGURATION         *SystemConfiguration
  );

EFI_STATUS
GeneralPowerFailureHandler (
  IN CONST EFI_PEI_SERVICES       **PeiServices
  );

BOOLEAN
IsRtcUipAlwaysSet (
  IN CONST EFI_PEI_SERVICES       **PeiServices
  );

EFI_STATUS
RtcPowerFailureHandler (
  IN CONST EFI_PEI_SERVICES       **PeiServices
  );

EFI_STATUS
EFIAPI
PublishMemoryTypeInfo (
  VOID
  );

EFI_STATUS
EFIAPI
PeiGetSectionFromFv (
  IN CONST  EFI_GUID        NameGuid,
  OUT VOID                  **Address,
  OUT UINT32               *Size
  );

EFI_STATUS
EFIAPI
ConfigClockTrunk (
  IN CONST EFI_PEI_SERVICES  **PeiServices
  );

EFI_STATUS
EFIAPI
PlatformInitFinalConfig (
  IN CONST EFI_PEI_SERVICES           **PeiServices
  );

EFI_STATUS
ValidateFvHeader (
  IN EFI_FIRMWARE_VOLUME_HEADER            *FwVolHeader
  );

EFI_STATUS
UpdateBootMode (
  IN CONST EFI_PEI_SERVICES                       **PeiServices,
  IN OUT EFI_PLATFORM_INFO_HOB                    *PlatformInfoHob
  );

UINT8
ConfigurePlatformPmic (
  VOID
  );

VOID
ScUsb2PhyOverride (
  VOID
  );
#endif // _EFI_PLATFORM_INIT_H_