]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2DeviceRefCodePkg/AcpiTablesPCAT/Lpit/Lpit.aslc
Vlv2DeviceRefCodePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Vlv2DeviceRefCodePkg / AcpiTablesPCAT / Lpit / Lpit.aslc
1 /*++
2
3 Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7
8
9 --*/
10
11 //
12 // Include files
13 //
14
15 #include <PiDxe.h>
16 #include <IndustryStandard/Acpi50.h>
17
18
19
20 //
21 // LPIT Definitions
22 //
23
24 #define EFI_ACPI_LOW_POWER_IDLE_TABLE_REVISION 0x1
25
26 //
27 // Ensure proper structure formats
28 //
29 #pragma pack(1)
30
31 typedef union _EFI_ACPI_LPI_STATE_FLAGS {
32 struct {
33 UINT32 Disabled :1;
34 UINT32 CounterUnavailable :1;
35 UINT32 Reserved :30;
36 };
37 UINT32 AsUlong;
38 } EFI_ACPI_LPI_STATE_FLAGS, *PEFI_ACPI_LPI_STATE_FLAGS;
39
40 // Only Mwait LPI here:
41
42 typedef struct _EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR {
43 UINT32 Type; // offset: 0
44 UINT32 Length; // offset: 4
45 UINT16 UniqueId; // offset: 8
46 UINT8 Reserved[2]; // offset: 9
47 EFI_ACPI_LPI_STATE_FLAGS Flags; // offset: 12
48 EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE EntryTrigger; // offset: 16
49 UINT32 Residency; // offset: 28
50 UINT32 Latency; // offset: 32
51 EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE ResidencyCounter; // offset: 36
52 UINT64 ResidencyCounterFrequency; //offset: 48
53 } EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR;
54
55
56 //
57 // Defines for LPIT table, some are VLV specific
58 //
59
60
61 // signature "LPIT"
62 #define EFI_ACPI_LOW_POWER_IDLE_TABLE_SIGNATURE 0x5449504c
63
64 #define EFI_ACPI_OEM_LPIT_REVISION 0x00000000
65
66 #define EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE 0x0
67 #define EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG 0x0
68 #define EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K 0x8000 // 32768
69
70 //
71 // LPI state count (4 on VLV: S0ir, S0i1, S0i2, S0i3)
72 //
73
74 #define EFI_ACPI_VLV_LPI_STATE_COUNT 0x4
75
76 //
77 // LPI TRIGGER (HW C7 on VLV),
78 // TOFIX!!!
79 //
80 #define EFI_ACPI_VLV_LPI_TRIGGER {0x7F,0x1,0x2,0x0,0x64}
81
82 //
83 // LPI residency counter (MMIO)
84 //
85 #define EFI_ACPI_VLV_LPI_RES_COUNTER0 {0x0,32,0x0,0x03,0xFED03080}
86 #define EFI_ACPI_VLV_LPI_RES_COUNTER1 {0x0,32,0x0,0x03,0xFED03084}
87 #define EFI_ACPI_VLV_LPI_RES_COUNTER2 {0x0,32,0x0,0x03,0xFED03088}
88 #define EFI_ACPI_VLV_LPI_RES_COUNTER3 {0x0,32,0x0,0x03,0xFED0308C}
89
90 //
91 // LPI break-even residency in us - all match S0i3 residency
92 // Residency estimate: Latency x 3
93 //
94 #define EFI_ACPI_VLV_LPI_MIN_RES0 15000
95 #define EFI_ACPI_VLV_LPI_MIN_RES1 15000
96 #define EFI_ACPI_VLV_LPI_MIN_RES2 15000
97 #define EFI_ACPI_VLV_LPI_MIN_RES3 15000
98
99 //
100 // LPI latency in us - all match S0i3 latency
101 //
102 #define EFI_ACPI_VLV_LPI_LATENCY0 5000
103 #define EFI_ACPI_VLV_LPI_LATENCY1 5000
104 #define EFI_ACPI_VLV_LPI_LATENCY2 5000
105 #define EFI_ACPI_VLV_LPI_LATENCY3 5000
106
107
108 //
109 // LPI ID
110 //
111 #define EFI_ACPI_VLV_LPI_UNIQUE_ID0 0
112 #define EFI_ACPI_VLV_LPI_UNIQUE_ID1 1
113 #define EFI_ACPI_VLV_LPI_UNIQUE_ID2 2
114 #define EFI_ACPI_VLV_LPI_UNIQUE_ID3 3
115
116 //
117 // LPI ACPI table header
118 //
119
120
121 typedef struct _EFI_ACPI_LOW_POWER_IDLE_TABLE {
122 EFI_ACPI_DESCRIPTION_HEADER Header;
123 EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR LpiStates[EFI_ACPI_VLV_LPI_STATE_COUNT];
124 } EFI_ACPI_LOW_POWER_IDLE_TABLE;
125
126 #pragma pack()
127
128 EFI_ACPI_LOW_POWER_IDLE_TABLE Lpit = {
129
130 //
131 // Header
132 //
133
134
135 EFI_ACPI_LOW_POWER_IDLE_TABLE_SIGNATURE,
136 sizeof (EFI_ACPI_LOW_POWER_IDLE_TABLE),
137 EFI_ACPI_LOW_POWER_IDLE_TABLE_REVISION ,
138
139 //
140 // Checksum will be updated at runtime
141 //
142 0x00,
143
144 //
145 // It is expected that these values will be updated at runtime
146 //
147 ' ', ' ', ' ', ' ', ' ', ' ',
148
149 0,
150 EFI_ACPI_OEM_LPIT_REVISION,
151 0,
152 0,
153
154
155
156 //
157 // Descriptor
158 //
159 {
160 {
161 EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,
162 sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),
163 EFI_ACPI_VLV_LPI_UNIQUE_ID0,
164 {0,0},
165 {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags
166 EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger
167 EFI_ACPI_VLV_LPI_MIN_RES0, //Residency
168 EFI_ACPI_VLV_LPI_LATENCY0, //Latency
169 EFI_ACPI_VLV_LPI_RES_COUNTER0, //ResidencyCounter
170 EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency
171 },
172 {
173 EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,
174 sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),
175 EFI_ACPI_VLV_LPI_UNIQUE_ID1,
176 {0,0},
177 {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags
178 EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger
179 EFI_ACPI_VLV_LPI_MIN_RES1, //Residency
180 EFI_ACPI_VLV_LPI_LATENCY1, //Latency
181 EFI_ACPI_VLV_LPI_RES_COUNTER1, //ResidencyCounter
182 EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency
183 },
184 {
185 EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,
186 sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),
187 EFI_ACPI_VLV_LPI_UNIQUE_ID2,
188 {0,0},
189 {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags
190 EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger
191 EFI_ACPI_VLV_LPI_MIN_RES2, //Residency
192 EFI_ACPI_VLV_LPI_LATENCY2, //Latency
193 EFI_ACPI_VLV_LPI_RES_COUNTER2, //ResidencyCounter
194 EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency
195 },
196 {
197 EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,
198 sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),
199 EFI_ACPI_VLV_LPI_UNIQUE_ID3,
200 {0,0},
201 {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags
202 EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger
203 EFI_ACPI_VLV_LPI_MIN_RES3, //Residency
204 EFI_ACPI_VLV_LPI_LATENCY3, //Latency
205 EFI_ACPI_VLV_LPI_RES_COUNTER3, //ResidencyCounter
206 EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency
207 }
208 }
209
210 };
211
212
213 VOID*
214 ReferenceAcpiTable (
215 VOID
216 )
217 {
218 //
219 // Reference the table being generated to prevent the optimizer from
220 // removing the data structure from the executable
221 //
222 return (VOID*)&Lpit;
223 }