blob: c4d8a706bcb4c67ea8e19d3c2a9881249cabf98d [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
Duncan Laurief966d3b2015-08-27 17:19:24 -070020Name (_HID, EISAID ("PNP0A08")) /* PCIe */
21Name (_CID, EISAID ("PNP0A03")) /* PCI */
Lee Leahyb0005132015-05-12 18:19:47 -070022
Lee Leahyb0005132015-05-12 18:19:47 -070023Device (MCHC)
24{
Duncan Laurief966d3b2015-08-27 17:19:24 -070025 Name (_ADR, 0x00000000)
Lee Leahyb0005132015-05-12 18:19:47 -070026
27 OperationRegion (MCHP, PCI_Config, 0x00, 0x100)
28 Field (MCHP, DWordAcc, NoLock, Preserve)
29 {
Duncan Laurief966d3b2015-08-27 17:19:24 -070030 Offset(0x40), /* EPBAR (0:0:0:40) */
31 EPEN, 1, /* Enable */
32 , 11,
33 EPBR, 20, /* EPBAR [31:12] */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070034
Duncan Laurief966d3b2015-08-27 17:19:24 -070035 Offset(0x48), /* MCHBAR (0:0:0:48) */
36 MHEN, 1, /* Enable */
37 , 14,
38 MHBR, 17, /* MCHBAR [31:15] */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070039
Duncan Laurief966d3b2015-08-27 17:19:24 -070040 Offset(0x60), /* PCIEXBAR (0:0:0:60) */
41 PXEN, 1, /* Enable */
42 PXSZ, 2, /* PCI Express Size */
43 , 23,
44 PXBR, 6, /* PCI Express BAR [31:26] */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070045
Duncan Laurief966d3b2015-08-27 17:19:24 -070046 Offset(0x68), /* DMIBAR (0:0:0:68) */
47 DIEN, 1, /* Enable */
48 , 11,
49 DIBR, 20, /* DMIBAR [31:12] */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070050
Duncan Laurief966d3b2015-08-27 17:19:24 -070051 Offset (0x70), /* ME Base Address */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070052 MEBA, 64,
Subrata Banike938fb72020-01-03 14:02:50 +053053 Offset (0xa0),
54 TOM, 64, /* Top of Used Memory */
55 TUUD, 64, /* Top of Upper Used Memory */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070056
Duncan Laurief966d3b2015-08-27 17:19:24 -070057 Offset (0xbc), /* Top of Low Used Memory */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070058 TLUD, 32,
Lee Leahyb0005132015-05-12 18:19:47 -070059 }
60}
61
Lee Leahyb0005132015-05-12 18:19:47 -070062Method (_CRS, 0, Serialized)
63{
Subrata Banike938fb72020-01-03 14:02:50 +053064 Name (MCRS, ResourceTemplate ()
65 {
66 /* Bus Numbers */
67 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
68 0x0000, 0x0000, 0x00ff, 0x0000, 0x0100)
69
70 /* IO Region 0 */
71 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode,
72 EntireRange,
73 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8)
74
75 /* PCI Config Space */
76 Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008)
77
78 /* IO Region 1 */
79 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode,
80 EntireRange,
81 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300)
82
83 /* VGA memory (0xa0000-0xbffff) */
84 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
85 Cacheable, ReadWrite,
86 0x00000000, 0x000a0000, 0x000bffff, 0x00000000,
87 0x00020000)
88
89 /* OPROM reserved (0xc0000-0xc3fff) */
90 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
91 Cacheable, ReadWrite,
92 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000,
93 0x00004000)
94
95 /* OPROM reserved (0xc4000-0xc7fff) */
96 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
97 Cacheable, ReadWrite,
98 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000,
99 0x00004000)
100
101 /* OPROM reserved (0xc8000-0xcbfff) */
102 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
103 Cacheable, ReadWrite,
104 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000,
105 0x00004000)
106
107 /* OPROM reserved (0xcc000-0xcffff) */
108 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
109 Cacheable, ReadWrite,
110 0x00000000, 0x000cc000, 0x000cffff, 0x00000000,
111 0x00004000)
112
113 /* OPROM reserved (0xd0000-0xd3fff) */
114 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
115 Cacheable, ReadWrite,
116 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000,
117 0x00004000)
118
119 /* OPROM reserved (0xd4000-0xd7fff) */
120 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
121 Cacheable, ReadWrite,
122 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000,
123 0x00004000)
124
125 /* OPROM reserved (0xd8000-0xdbfff) */
126 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
127 Cacheable, ReadWrite,
128 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000,
129 0x00004000)
130
131 /* OPROM reserved (0xdc000-0xdffff) */
132 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
133 Cacheable, ReadWrite,
134 0x00000000, 0x000dc000, 0x000dffff, 0x00000000,
135 0x00004000)
136
137 /* BIOS Extension (0xe0000-0xe3fff) */
138 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
139 Cacheable, ReadWrite,
140 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000,
141 0x00004000)
142
143 /* BIOS Extension (0xe4000-0xe7fff) */
144 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
145 Cacheable, ReadWrite,
146 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000,
147 0x00004000)
148
149 /* BIOS Extension (0xe8000-0xebfff) */
150 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
151 Cacheable, ReadWrite,
152 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000,
153 0x00004000)
154
155 /* BIOS Extension (0xec000-0xeffff) */
156 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
157 Cacheable, ReadWrite,
158 0x00000000, 0x000ec000, 0x000effff, 0x00000000,
159 0x00004000)
160
161 /* System BIOS (0xf0000-0xfffff) */
162 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
163 Cacheable, ReadWrite,
164 0x00000000, 0x000f0000, 0x000fffff, 0x00000000,
165 0x00010000)
166
167 /* PCI Memory Region (TLUD - 0xdfffffff) */
168 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
169 NonCacheable, ReadWrite,
170 0x00000000, 0x00000000, 0xdfffffff, 0x00000000,
171 0xE0000000,,, PM01)
172
173 /* PCI Memory Region (TUUD - (TUUD + ABOVE_4G_MMIO_SIZE)) */
174 QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
175 NonCacheable, ReadWrite,
176 0x00000000, 0x10000, 0x1ffff, 0x00000000,
177 0x10000,,, PM02)
178
179 /* PCH reserved resource (0xfc800000-0xfe7fffff) */
180 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
181 Cacheable, ReadWrite,
182 0x00000000, PCH_PRESERVED_BASE_ADDRESS, 0xfe7fffff,
183 0x00000000, PCH_PRESERVED_BASE_SIZE)
184
Subrata Banikfa8f9ec2020-01-22 15:58:39 +0530185#if !CONFIG(TPM_CR50)
Subrata Banike938fb72020-01-03 14:02:50 +0530186 /* TPM Area (0xfed40000-0xfed44fff) */
187 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
188 Cacheable, ReadWrite,
189 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000,
190 0x00005000)
Subrata Banikfa8f9ec2020-01-22 15:58:39 +0530191#endif
Subrata Banike938fb72020-01-03 14:02:50 +0530192})
193
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700194 /* Find PCI resource area in MCRS */
Subrata Banike938fb72020-01-03 14:02:50 +0530195 CreateDwordField (MCRS, PM01._MIN, PMIN)
196 CreateDwordField (MCRS, PM01._MAX, PMAX)
197 CreateDwordField (MCRS, PM01._LEN, PLEN)
Lee Leahyb0005132015-05-12 18:19:47 -0700198
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700199 /*
200 * Fix up PCI memory region
201 * Start with Top of Lower Usable DRAM
202 */
Subrata Banike938fb72020-01-03 14:02:50 +0530203 Store (\_SB.PCI0.MCHC.TLUD, Local0)
204 Store (\_SB.PCI0.MCHC.MEBA, Local1)
Lee Leahyb0005132015-05-12 18:19:47 -0700205
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700206 /* Check if ME base is equal */
Lee Leahyb0005132015-05-12 18:19:47 -0700207 If (LEqual (Local0, Local1)) {
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700208 /* Use Top Of Memory instead */
Subrata Banike938fb72020-01-03 14:02:50 +0530209 Store (\_SB.PCI0.MCHC.TOM, Local0)
Lee Leahyb0005132015-05-12 18:19:47 -0700210 }
211
212 Store (Local0, PMIN)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700213 Add (Subtract (PMAX, PMIN), 1, PLEN)
214
215 /* Patch PM02 range based on Memory Size */
Subrata Banikb6df6b02020-01-03 15:29:02 +0530216 If (LEqual (A4GS, 0)) {
217 CreateQwordField (MCRS, PM02._LEN, MSEN)
218 Store (0, MSEN)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700219 } Else {
Subrata Banikb6df6b02020-01-03 15:29:02 +0530220 CreateQwordField (MCRS, PM02._MIN, MMIN)
221 CreateQwordField (MCRS, PM02._MAX, MMAX)
222 CreateQwordField (MCRS, PM02._LEN, MLEN)
223 /* Set 64bit MMIO resource base and length */
224 Store (A4GS, MLEN)
225 Store (A4GB, MMIN)
226 Subtract (Add (MMIN, MLEN), 1, MMAX)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700227 }
Lee Leahyb0005132015-05-12 18:19:47 -0700228
Subrata Banike938fb72020-01-03 14:02:50 +0530229 Return (MCRS)
Lee Leahyb0005132015-05-12 18:19:47 -0700230}
231
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700232/* Get MCH BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700233Method (GMHB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700234{
Subrata Banike938fb72020-01-03 14:02:50 +0530235 ShiftLeft (\_SB.PCI0.MCHC.MHBR, 15, Local0)
236 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700237}
238
239/* Get EP BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700240Method (GEPB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700241{
Subrata Banike938fb72020-01-03 14:02:50 +0530242 ShiftLeft (\_SB.PCI0.MCHC.EPBR, 12, Local0)
243 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700244}
245
246/* Get PCIe BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700247Method (GPCB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700248{
Subrata Banike938fb72020-01-03 14:02:50 +0530249 ShiftLeft (\_SB.PCI0.MCHC.PXBR, 26, Local0)
250 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700251}
252
253/* Get PCIe Length */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700254Method (GPCL, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700255{
Subrata Banike938fb72020-01-03 14:02:50 +0530256 ShiftRight (0x10000000, \_SB.PCI0.MCHC.PXSZ, Local0)
257 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700258}
259
260/* Get DMI BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700261Method (GDMB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700262{
Subrata Banike938fb72020-01-03 14:02:50 +0530263 ShiftLeft (\_SB.PCI0.MCHC.DIBR, 12, Local0)
264 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700265}
266
Lee Leahyb0005132015-05-12 18:19:47 -0700267/* PCI Device Resource Consumption */
268Device (PDRC)
269{
Duncan Laurief966d3b2015-08-27 17:19:24 -0700270 Name (_HID, EISAID ("PNP0C02"))
Lee Leahyb0005132015-05-12 18:19:47 -0700271 Name (_UID, 1)
272
Lee Leahyb0005132015-05-12 18:19:47 -0700273 Method (_CRS, 0, Serialized)
274 {
Subrata Banike938fb72020-01-03 14:02:50 +0530275 Name (BUF0, ResourceTemplate ()
276 {
277 /* MCH BAR _BAS will be updated in _CRS below according to
278 * B0:D0:F0:Reg.48h
279 */
280 Memory32Fixed (ReadWrite, 0, 0x08000, MCHB)
281
282 /* DMI BAR _BAS will be updated in _CRS below according to
283 * B0:D0:F0:Reg.68h
284 */
285 Memory32Fixed (ReadWrite, 0, 0x01000, DMIB)
286
287 /* EP BAR _BAS will be updated in _CRS below according to
288 * B0:D0:F0:Reg.40h
289 */
290 Memory32Fixed (ReadWrite, 0, 0x01000, EGPB)
291
292 /* PCI Express BAR _BAS and _LEN will be updated in
293 * _CRS below according to B0:D0:F0:Reg.60h
294 */
295 Memory32Fixed (ReadWrite, 0, 0, PCIX)
296
Subrata Banike938fb72020-01-03 14:02:50 +0530297 /* VTD engine memory range. */
298 Memory32Fixed (ReadOnly, VTD_BASE_ADDRESS, VTD_BASE_SIZE)
299
Subrata Banike938fb72020-01-03 14:02:50 +0530300 /* FLASH range */
301 Memory32Fixed (ReadOnly, 0, CONFIG_ROM_SIZE, FIOH)
302
303 /* Local APIC range(0xFEE0_0000 to 0xFEEF_FFFF) */
304 Memory32Fixed (ReadOnly, 0xFEE00000, 0x100000)
305
306 /* HPET address decode range */
307 Memory32Fixed (ReadWrite, HPET_BASE_ADDRESS, 0x400)
308 })
309
310 CreateDwordField (BUF0, MCHB._BAS, MBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700311 Store (\_SB.PCI0.GMHB (), MBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700312
Subrata Banike938fb72020-01-03 14:02:50 +0530313 CreateDwordField (BUF0, DMIB._BAS, DBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700314 Store (\_SB.PCI0.GDMB (), DBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700315
Subrata Banike938fb72020-01-03 14:02:50 +0530316 CreateDwordField (BUF0, EGPB._BAS, EBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700317 Store (\_SB.PCI0.GEPB (), EBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700318
Subrata Banike938fb72020-01-03 14:02:50 +0530319 CreateDwordField (BUF0, PCIX._BAS, XBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700320 Store (\_SB.PCI0.GPCB (), XBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700321
Subrata Banike938fb72020-01-03 14:02:50 +0530322 CreateDwordField (BUF0, PCIX._LEN, XSZ0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700323 Store (\_SB.PCI0.GPCL (), XSZ0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700324
Subrata Banike938fb72020-01-03 14:02:50 +0530325 CreateDwordField (BUF0, FIOH._BAS, FBR0)
326 Subtract(0x100000000, CONFIG_ROM_SIZE, FBR0)
327
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700328 Return (BUF0)
Lee Leahyb0005132015-05-12 18:19:47 -0700329 }
330}