blob: e430b43ca9ff702145b569adc5b2cfbd3c3e2267 [file] [log] [blame]
Lee Leahyb0005132015-05-12 18:19:47 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
Duncan Laurief966d3b2015-08-27 17:19:24 -07005 * Copyright (C) 2015 Google Inc.
Subrata Banikb6df6b02020-01-03 15:29:02 +05306 * Copyright (C) 2015-2020 Intel Corporation.
Lee Leahyb0005132015-05-12 18:19:47 -07007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Lee Leahyb0005132015-05-12 18:19:47 -070016 */
17
18#include <soc/iomap.h>
19
Subrata Banik36eb5002020-01-22 16:01:14 +053020Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */) // _HID: Hardware ID
21Name (_CID, EisaId ("PNP0A03") /* PCI Bus */) // _CID: Compatible ID
22Name (_SEG, Zero) // _SEG: PCI Segment
23Name (_UID, Zero) // _UID: Unique ID
Lee Leahyb0005132015-05-12 18:19:47 -070024
Lee Leahyb0005132015-05-12 18:19:47 -070025Device (MCHC)
26{
Duncan Laurief966d3b2015-08-27 17:19:24 -070027 Name (_ADR, 0x00000000)
Lee Leahyb0005132015-05-12 18:19:47 -070028
29 OperationRegion (MCHP, PCI_Config, 0x00, 0x100)
30 Field (MCHP, DWordAcc, NoLock, Preserve)
31 {
Duncan Laurief966d3b2015-08-27 17:19:24 -070032 Offset(0x40), /* EPBAR (0:0:0:40) */
33 EPEN, 1, /* Enable */
34 , 11,
Subrata Banik4f65b872020-01-22 16:05:16 +053035 EPBR, 27, /* EPBAR [38:12] */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070036
Duncan Laurief966d3b2015-08-27 17:19:24 -070037 Offset(0x48), /* MCHBAR (0:0:0:48) */
38 MHEN, 1, /* Enable */
39 , 14,
Subrata Banik4f65b872020-01-22 16:05:16 +053040 MHBR, 24, /* MCHBAR [38:15] */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070041
Duncan Laurief966d3b2015-08-27 17:19:24 -070042 Offset(0x60), /* PCIEXBAR (0:0:0:60) */
43 PXEN, 1, /* Enable */
44 PXSZ, 2, /* PCI Express Size */
45 , 23,
Subrata Banik4f65b872020-01-22 16:05:16 +053046 PXBR, 13, /* PCI Express BAR [38:26] */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070047
Duncan Laurief966d3b2015-08-27 17:19:24 -070048 Offset(0x68), /* DMIBAR (0:0:0:68) */
49 DIEN, 1, /* Enable */
50 , 11,
Subrata Banik4f65b872020-01-22 16:05:16 +053051 DIBR, 27, /* DMIBAR [38:12] */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070052
Duncan Laurief966d3b2015-08-27 17:19:24 -070053 Offset (0x70), /* ME Base Address */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070054 MEBA, 64,
Subrata Banik4f65b872020-01-22 16:05:16 +053055
Subrata Banike938fb72020-01-03 14:02:50 +053056 Offset (0xa0),
57 TOM, 64, /* Top of Used Memory */
58 TUUD, 64, /* Top of Upper Used Memory */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070059
Duncan Laurief966d3b2015-08-27 17:19:24 -070060 Offset (0xbc), /* Top of Low Used Memory */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070061 TLUD, 32,
Lee Leahyb0005132015-05-12 18:19:47 -070062 }
63}
64
Lee Leahyb0005132015-05-12 18:19:47 -070065Method (_CRS, 0, Serialized)
66{
Subrata Banike938fb72020-01-03 14:02:50 +053067 Name (MCRS, ResourceTemplate ()
68 {
69 /* Bus Numbers */
70 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
71 0x0000, 0x0000, 0x00ff, 0x0000, 0x0100)
72
73 /* IO Region 0 */
74 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode,
75 EntireRange,
76 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8)
77
78 /* PCI Config Space */
79 Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008)
80
81 /* IO Region 1 */
82 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode,
83 EntireRange,
84 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300)
85
86 /* VGA memory (0xa0000-0xbffff) */
87 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
88 Cacheable, ReadWrite,
89 0x00000000, 0x000a0000, 0x000bffff, 0x00000000,
90 0x00020000)
91
92 /* OPROM reserved (0xc0000-0xc3fff) */
93 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
94 Cacheable, ReadWrite,
95 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000,
96 0x00004000)
97
98 /* OPROM reserved (0xc4000-0xc7fff) */
99 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
100 Cacheable, ReadWrite,
101 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000,
102 0x00004000)
103
104 /* OPROM reserved (0xc8000-0xcbfff) */
105 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
106 Cacheable, ReadWrite,
107 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000,
108 0x00004000)
109
110 /* OPROM reserved (0xcc000-0xcffff) */
111 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
112 Cacheable, ReadWrite,
113 0x00000000, 0x000cc000, 0x000cffff, 0x00000000,
114 0x00004000)
115
116 /* OPROM reserved (0xd0000-0xd3fff) */
117 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
118 Cacheable, ReadWrite,
119 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000,
120 0x00004000)
121
122 /* OPROM reserved (0xd4000-0xd7fff) */
123 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
124 Cacheable, ReadWrite,
125 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000,
126 0x00004000)
127
128 /* OPROM reserved (0xd8000-0xdbfff) */
129 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
130 Cacheable, ReadWrite,
131 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000,
132 0x00004000)
133
134 /* OPROM reserved (0xdc000-0xdffff) */
135 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
136 Cacheable, ReadWrite,
137 0x00000000, 0x000dc000, 0x000dffff, 0x00000000,
138 0x00004000)
139
140 /* BIOS Extension (0xe0000-0xe3fff) */
141 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
142 Cacheable, ReadWrite,
143 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000,
144 0x00004000)
145
146 /* BIOS Extension (0xe4000-0xe7fff) */
147 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
148 Cacheable, ReadWrite,
149 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000,
150 0x00004000)
151
152 /* BIOS Extension (0xe8000-0xebfff) */
153 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
154 Cacheable, ReadWrite,
155 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000,
156 0x00004000)
157
158 /* BIOS Extension (0xec000-0xeffff) */
159 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
160 Cacheable, ReadWrite,
161 0x00000000, 0x000ec000, 0x000effff, 0x00000000,
162 0x00004000)
163
164 /* System BIOS (0xf0000-0xfffff) */
165 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
166 Cacheable, ReadWrite,
167 0x00000000, 0x000f0000, 0x000fffff, 0x00000000,
168 0x00010000)
169
170 /* PCI Memory Region (TLUD - 0xdfffffff) */
171 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
172 NonCacheable, ReadWrite,
173 0x00000000, 0x00000000, 0xdfffffff, 0x00000000,
174 0xE0000000,,, PM01)
175
176 /* PCI Memory Region (TUUD - (TUUD + ABOVE_4G_MMIO_SIZE)) */
177 QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
178 NonCacheable, ReadWrite,
179 0x00000000, 0x10000, 0x1ffff, 0x00000000,
180 0x10000,,, PM02)
181
182 /* PCH reserved resource (0xfc800000-0xfe7fffff) */
183 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
184 Cacheable, ReadWrite,
185 0x00000000, PCH_PRESERVED_BASE_ADDRESS, 0xfe7fffff,
186 0x00000000, PCH_PRESERVED_BASE_SIZE)
187
Subrata Banikfa8f9ec2020-01-22 15:58:39 +0530188#if !CONFIG(TPM_CR50)
Subrata Banike938fb72020-01-03 14:02:50 +0530189 /* TPM Area (0xfed40000-0xfed44fff) */
190 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
191 Cacheable, ReadWrite,
192 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000,
193 0x00005000)
Subrata Banikfa8f9ec2020-01-22 15:58:39 +0530194#endif
Subrata Banike938fb72020-01-03 14:02:50 +0530195})
196
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700197 /* Find PCI resource area in MCRS */
Subrata Banike938fb72020-01-03 14:02:50 +0530198 CreateDwordField (MCRS, PM01._MIN, PMIN)
199 CreateDwordField (MCRS, PM01._MAX, PMAX)
200 CreateDwordField (MCRS, PM01._LEN, PLEN)
Lee Leahyb0005132015-05-12 18:19:47 -0700201
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700202 /*
203 * Fix up PCI memory region
204 * Start with Top of Lower Usable DRAM
205 */
Subrata Banike938fb72020-01-03 14:02:50 +0530206 Store (\_SB.PCI0.MCHC.TLUD, Local0)
207 Store (\_SB.PCI0.MCHC.MEBA, Local1)
Lee Leahyb0005132015-05-12 18:19:47 -0700208
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700209 /* Check if ME base is equal */
Lee Leahyb0005132015-05-12 18:19:47 -0700210 If (LEqual (Local0, Local1)) {
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700211 /* Use Top Of Memory instead */
Subrata Banike938fb72020-01-03 14:02:50 +0530212 Store (\_SB.PCI0.MCHC.TOM, Local0)
Lee Leahyb0005132015-05-12 18:19:47 -0700213 }
214
215 Store (Local0, PMIN)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700216 Add (Subtract (PMAX, PMIN), 1, PLEN)
217
218 /* Patch PM02 range based on Memory Size */
Subrata Banikb6df6b02020-01-03 15:29:02 +0530219 If (LEqual (A4GS, 0)) {
220 CreateQwordField (MCRS, PM02._LEN, MSEN)
221 Store (0, MSEN)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700222 } Else {
Subrata Banikb6df6b02020-01-03 15:29:02 +0530223 CreateQwordField (MCRS, PM02._MIN, MMIN)
224 CreateQwordField (MCRS, PM02._MAX, MMAX)
225 CreateQwordField (MCRS, PM02._LEN, MLEN)
226 /* Set 64bit MMIO resource base and length */
227 Store (A4GS, MLEN)
228 Store (A4GB, MMIN)
229 Subtract (Add (MMIN, MLEN), 1, MMAX)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700230 }
Lee Leahyb0005132015-05-12 18:19:47 -0700231
Subrata Banike938fb72020-01-03 14:02:50 +0530232 Return (MCRS)
Lee Leahyb0005132015-05-12 18:19:47 -0700233}
234
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700235/* Get MCH BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700236Method (GMHB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700237{
Subrata Banike938fb72020-01-03 14:02:50 +0530238 ShiftLeft (\_SB.PCI0.MCHC.MHBR, 15, Local0)
239 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700240}
241
242/* Get EP BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700243Method (GEPB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700244{
Subrata Banike938fb72020-01-03 14:02:50 +0530245 ShiftLeft (\_SB.PCI0.MCHC.EPBR, 12, Local0)
246 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700247}
248
249/* Get PCIe BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700250Method (GPCB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700251{
Subrata Banike938fb72020-01-03 14:02:50 +0530252 ShiftLeft (\_SB.PCI0.MCHC.PXBR, 26, Local0)
253 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700254}
255
256/* Get PCIe Length */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700257Method (GPCL, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700258{
Subrata Banike938fb72020-01-03 14:02:50 +0530259 ShiftRight (0x10000000, \_SB.PCI0.MCHC.PXSZ, Local0)
260 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700261}
262
263/* Get DMI BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700264Method (GDMB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700265{
Subrata Banike938fb72020-01-03 14:02:50 +0530266 ShiftLeft (\_SB.PCI0.MCHC.DIBR, 12, Local0)
267 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700268}
269
Lee Leahyb0005132015-05-12 18:19:47 -0700270/* PCI Device Resource Consumption */
271Device (PDRC)
272{
Duncan Laurief966d3b2015-08-27 17:19:24 -0700273 Name (_HID, EISAID ("PNP0C02"))
Lee Leahyb0005132015-05-12 18:19:47 -0700274 Name (_UID, 1)
275
Lee Leahyb0005132015-05-12 18:19:47 -0700276 Method (_CRS, 0, Serialized)
277 {
Subrata Banike938fb72020-01-03 14:02:50 +0530278 Name (BUF0, ResourceTemplate ()
279 {
280 /* MCH BAR _BAS will be updated in _CRS below according to
281 * B0:D0:F0:Reg.48h
282 */
283 Memory32Fixed (ReadWrite, 0, 0x08000, MCHB)
284
285 /* DMI BAR _BAS will be updated in _CRS below according to
286 * B0:D0:F0:Reg.68h
287 */
288 Memory32Fixed (ReadWrite, 0, 0x01000, DMIB)
289
290 /* EP BAR _BAS will be updated in _CRS below according to
291 * B0:D0:F0:Reg.40h
292 */
293 Memory32Fixed (ReadWrite, 0, 0x01000, EGPB)
294
295 /* PCI Express BAR _BAS and _LEN will be updated in
296 * _CRS below according to B0:D0:F0:Reg.60h
297 */
298 Memory32Fixed (ReadWrite, 0, 0, PCIX)
299
Subrata Banike938fb72020-01-03 14:02:50 +0530300 /* VTD engine memory range. */
301 Memory32Fixed (ReadOnly, VTD_BASE_ADDRESS, VTD_BASE_SIZE)
302
Subrata Banike938fb72020-01-03 14:02:50 +0530303 /* FLASH range */
304 Memory32Fixed (ReadOnly, 0, CONFIG_ROM_SIZE, FIOH)
305
306 /* Local APIC range(0xFEE0_0000 to 0xFEEF_FFFF) */
307 Memory32Fixed (ReadOnly, 0xFEE00000, 0x100000)
308
309 /* HPET address decode range */
310 Memory32Fixed (ReadWrite, HPET_BASE_ADDRESS, 0x400)
311 })
312
313 CreateDwordField (BUF0, MCHB._BAS, MBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700314 Store (\_SB.PCI0.GMHB (), MBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700315
Subrata Banike938fb72020-01-03 14:02:50 +0530316 CreateDwordField (BUF0, DMIB._BAS, DBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700317 Store (\_SB.PCI0.GDMB (), DBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700318
Subrata Banike938fb72020-01-03 14:02:50 +0530319 CreateDwordField (BUF0, EGPB._BAS, EBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700320 Store (\_SB.PCI0.GEPB (), EBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700321
Subrata Banike938fb72020-01-03 14:02:50 +0530322 CreateDwordField (BUF0, PCIX._BAS, XBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700323 Store (\_SB.PCI0.GPCB (), XBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700324
Subrata Banike938fb72020-01-03 14:02:50 +0530325 CreateDwordField (BUF0, PCIX._LEN, XSZ0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700326 Store (\_SB.PCI0.GPCL (), XSZ0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700327
Subrata Banike938fb72020-01-03 14:02:50 +0530328 CreateDwordField (BUF0, FIOH._BAS, FBR0)
329 Subtract(0x100000000, CONFIG_ROM_SIZE, FBR0)
330
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700331 Return (BUF0)
Lee Leahyb0005132015-05-12 18:19:47 -0700332 }
333}