]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/PlatformInitPei/PlatformInfoInit.c
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2TbltDevicePkg / PlatformInitPei / PlatformInfoInit.c
1 /** @file
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 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
14 Module Name:
15
16 PlatformInfoInit.c
17
18 Abstract:
19 Platform Info Driver.
20
21 --*/
22
23 #include "PlatformEarlyInit.h"
24
25 #define LEN_64M 0x4000000
26
27 //
28 // Default PCI32 resource size
29 //
30 #define RES_MEM32_MIN_LEN 0x38000000
31
32 #define RES_IO_BASE 0x0D00
33 #define RES_IO_LIMIT 0xFFFF
34
35 #define MemoryCeilingVariable L"MemCeil."
36
37 EFI_STATUS
38 CheckOsSelection (
39 IN CONST EFI_PEI_SERVICES **PeiServices,
40 IN SYSTEM_CONFIGURATION *SystemConfiguration
41 )
42 {
43 EFI_STATUS Status;
44 EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable;
45 UINTN VariableSize;
46 EFI_OS_SELECTION_HOB *OsSelectionHob;
47 UINT8 OsSelection;
48 UINT8 *LpssDataHobPtr;
49 UINT8 *LpssDataVarPtr;
50 UINTN i;
51
52 Status = (*PeiServices)->LocatePpi (
53 PeiServices,
54 &gEfiPeiReadOnlyVariable2PpiGuid,
55 0,
56 NULL,
57 (void **)&Variable
58 );
59 if (!EFI_ERROR(Status)) {
60 VariableSize = sizeof (OsSelection);
61 Status = Variable->GetVariable (
62 Variable,
63 L"OsSelection",
64 &gOsSelectionVariableGuid,
65 NULL,
66 &VariableSize,
67 &OsSelection
68 );
69
70 if (!EFI_ERROR(Status) && (SystemConfiguration->ReservedO != OsSelection)) {
71 //
72 // Build HOB for OsSelection
73 //
74 OsSelectionHob = BuildGuidHob (&gOsSelectionVariableGuid, sizeof (EFI_OS_SELECTION_HOB));
75 ASSERT (OsSelectionHob != NULL);
76
77 OsSelectionHob->OsSelectionChanged = TRUE;
78 OsSelectionHob->OsSelection = OsSelection;
79 SystemConfiguration->ReservedO = OsSelectionHob->OsSelection;
80
81 //
82 // Load LPSS and SCC defalut configurations
83 //
84 OsSelectionHob->LpssData.LpsseMMCEnabled = FALSE;
85 OsSelectionHob->LpssData.LpssSdioEnabled = TRUE;
86 OsSelectionHob->LpssData.LpssSdcardEnabled = TRUE;
87 OsSelectionHob->LpssData.LpssSdCardSDR25Enabled = FALSE;
88 OsSelectionHob->LpssData.LpssSdCardDDR50Enabled = TRUE;
89 OsSelectionHob->LpssData.LpssMipiHsi = FALSE;
90 OsSelectionHob->LpssData.LpsseMMC45Enabled = TRUE;
91 OsSelectionHob->LpssData.LpsseMMC45DDR50Enabled = TRUE;
92 OsSelectionHob->LpssData.LpsseMMC45HS200Enabled = FALSE;
93 OsSelectionHob->LpssData.LpsseMMC45RetuneTimerValue = 8;
94 OsSelectionHob->LpssData.eMMCBootMode = 1; // Auto Detect
95
96
97 SystemConfiguration->Lpe = OsSelectionHob->Lpe;
98 SystemConfiguration->PchAzalia = SystemConfiguration->PchAzalia;
99 LpssDataHobPtr = &OsSelectionHob->LpssData.LpssPciModeEnabled;
100 LpssDataVarPtr = &SystemConfiguration->LpssPciModeEnabled;
101
102 for (i = 0; i < sizeof(EFI_PLATFORM_LPSS_DATA); i++) {
103 *LpssDataVarPtr = *LpssDataHobPtr;
104 LpssDataVarPtr++;
105 LpssDataHobPtr++;
106 }
107 }
108 }
109
110 return EFI_SUCCESS;
111 }
112
113
114 EFI_STATUS
115 PlatformInfoUpdate (
116 IN CONST EFI_PEI_SERVICES **PeiServices,
117 IN OUT EFI_PLATFORM_INFO_HOB *PlatformInfoHob,
118 IN SYSTEM_CONFIGURATION *SystemConfiguration
119 )
120 {
121 EFI_STATUS Status;
122 EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable;
123 UINTN VariableSize;
124 UINT32 MemoryCeiling;
125
126 //
127 // Checking PCI32 resource from previous boot to determine the memory ceiling
128 //
129 Status = (*PeiServices)->LocatePpi (
130 PeiServices,
131 &gEfiPeiReadOnlyVariable2PpiGuid,
132 0,
133 NULL,
134 (void **)&Variable
135 );
136 if (!EFI_ERROR(Status)) {
137 //
138 // Get the memory ceiling
139 //
140 VariableSize = sizeof(MemoryCeiling);
141 Status = Variable->GetVariable (
142 Variable,
143 MemoryCeilingVariable,
144 &gEfiGlobalVariableGuid,
145 NULL,
146 &VariableSize,
147 &MemoryCeiling
148 );
149 if(!EFI_ERROR(Status)) {
150 //
151 // Set the new PCI32 resource Base if the variable available
152 //
153 PlatformInfoHob->PciData.PciResourceMem32Base = MemoryCeiling;
154 PlatformInfoHob->MemData.MemMaxTolm = MemoryCeiling;
155 PlatformInfoHob->MemData.MemTolm = MemoryCeiling;
156
157 //
158 // Platform PCI MMIO Size in unit of 1MB
159 //
160 PlatformInfoHob->MemData.MmioSize = 0x1000 - (UINT16)(PlatformInfoHob->MemData.MemMaxTolm >> 20);
161 }
162 }
163
164 return EFI_SUCCESS;
165 }
166
167 /**
168 Initialize the platform related info hob according to the
169 pre-determine value or setup option
170
171 @retval EFI_SUCCESS Memory initialization completed successfully.
172 @retval Others All other error conditions encountered result in an ASSERT.
173 **/
174 EFI_STATUS
175 InitializePlatform (
176 IN CONST EFI_PEI_SERVICES **PeiServices,
177 IN EFI_PLATFORM_INFO_HOB *PlatformInfoHob,
178 IN SYSTEM_CONFIGURATION *SystemConfiguration
179 )
180 {
181 //
182 // -- cchew10 need to update here.
183 //
184 return EFI_SUCCESS;
185 }
186