blob: 920062c021315c26aef2e67611ad76f0dfb10f63 [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,
35 EPBR, 20, /* EPBAR [31: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,
40 MHBR, 17, /* MCHBAR [31: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,
46 PXBR, 6, /* PCI Express BAR [31: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,
51 DIBR, 20, /* DMIBAR [31: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 Banike938fb72020-01-03 14:02:50 +053055 Offset (0xa0),
56 TOM, 64, /* Top of Used Memory */
57 TUUD, 64, /* Top of Upper Used Memory */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070058
Duncan Laurief966d3b2015-08-27 17:19:24 -070059 Offset (0xbc), /* Top of Low Used Memory */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070060 TLUD, 32,
Lee Leahyb0005132015-05-12 18:19:47 -070061 }
62}
63
Lee Leahyb0005132015-05-12 18:19:47 -070064Method (_CRS, 0, Serialized)
65{
Subrata Banike938fb72020-01-03 14:02:50 +053066 Name (MCRS, ResourceTemplate ()
67 {
68 /* Bus Numbers */
69 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
70 0x0000, 0x0000, 0x00ff, 0x0000, 0x0100)
71
72 /* IO Region 0 */
73 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode,
74 EntireRange,
75 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8)
76
77 /* PCI Config Space */
78 Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008)
79
80 /* IO Region 1 */
81 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode,
82 EntireRange,
83 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300)
84
85 /* VGA memory (0xa0000-0xbffff) */
86 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
87 Cacheable, ReadWrite,
88 0x00000000, 0x000a0000, 0x000bffff, 0x00000000,
89 0x00020000)
90
91 /* OPROM reserved (0xc0000-0xc3fff) */
92 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
93 Cacheable, ReadWrite,
94 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000,
95 0x00004000)
96
97 /* OPROM reserved (0xc4000-0xc7fff) */
98 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
99 Cacheable, ReadWrite,
100 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000,
101 0x00004000)
102
103 /* OPROM reserved (0xc8000-0xcbfff) */
104 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
105 Cacheable, ReadWrite,
106 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000,
107 0x00004000)
108
109 /* OPROM reserved (0xcc000-0xcffff) */
110 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
111 Cacheable, ReadWrite,
112 0x00000000, 0x000cc000, 0x000cffff, 0x00000000,
113 0x00004000)
114
115 /* OPROM reserved (0xd0000-0xd3fff) */
116 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
117 Cacheable, ReadWrite,
118 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000,
119 0x00004000)
120
121 /* OPROM reserved (0xd4000-0xd7fff) */
122 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
123 Cacheable, ReadWrite,
124 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000,
125 0x00004000)
126
127 /* OPROM reserved (0xd8000-0xdbfff) */
128 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
129 Cacheable, ReadWrite,
130 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000,
131 0x00004000)
132
133 /* OPROM reserved (0xdc000-0xdffff) */
134 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
135 Cacheable, ReadWrite,
136 0x00000000, 0x000dc000, 0x000dffff, 0x00000000,
137 0x00004000)
138
139 /* BIOS Extension (0xe0000-0xe3fff) */
140 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
141 Cacheable, ReadWrite,
142 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000,
143 0x00004000)
144
145 /* BIOS Extension (0xe4000-0xe7fff) */
146 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
147 Cacheable, ReadWrite,
148 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000,
149 0x00004000)
150
151 /* BIOS Extension (0xe8000-0xebfff) */
152 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
153 Cacheable, ReadWrite,
154 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000,
155 0x00004000)
156
157 /* BIOS Extension (0xec000-0xeffff) */
158 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
159 Cacheable, ReadWrite,
160 0x00000000, 0x000ec000, 0x000effff, 0x00000000,
161 0x00004000)
162
163 /* System BIOS (0xf0000-0xfffff) */
164 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
165 Cacheable, ReadWrite,
166 0x00000000, 0x000f0000, 0x000fffff, 0x00000000,
167 0x00010000)
168
169 /* PCI Memory Region (TLUD - 0xdfffffff) */
170 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
171 NonCacheable, ReadWrite,
172 0x00000000, 0x00000000, 0xdfffffff, 0x00000000,
173 0xE0000000,,, PM01)
174
175 /* PCI Memory Region (TUUD - (TUUD + ABOVE_4G_MMIO_SIZE)) */
176 QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
177 NonCacheable, ReadWrite,
178 0x00000000, 0x10000, 0x1ffff, 0x00000000,
179 0x10000,,, PM02)
180
181 /* PCH reserved resource (0xfc800000-0xfe7fffff) */
182 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
183 Cacheable, ReadWrite,
184 0x00000000, PCH_PRESERVED_BASE_ADDRESS, 0xfe7fffff,
185 0x00000000, PCH_PRESERVED_BASE_SIZE)
186
Subrata Banikfa8f9ec2020-01-22 15:58:39 +0530187#if !CONFIG(TPM_CR50)
Subrata Banike938fb72020-01-03 14:02:50 +0530188 /* TPM Area (0xfed40000-0xfed44fff) */
189 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
190 Cacheable, ReadWrite,
191 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000,
192 0x00005000)
Subrata Banikfa8f9ec2020-01-22 15:58:39 +0530193#endif
Subrata Banike938fb72020-01-03 14:02:50 +0530194})
195
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700196 /* Find PCI resource area in MCRS */
Subrata Banike938fb72020-01-03 14:02:50 +0530197 CreateDwordField (MCRS, PM01._MIN, PMIN)
198 CreateDwordField (MCRS, PM01._MAX, PMAX)
199 CreateDwordField (MCRS, PM01._LEN, PLEN)
Lee Leahyb0005132015-05-12 18:19:47 -0700200
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700201 /*
202 * Fix up PCI memory region
203 * Start with Top of Lower Usable DRAM
204 */
Subrata Banike938fb72020-01-03 14:02:50 +0530205 Store (\_SB.PCI0.MCHC.TLUD, Local0)
206 Store (\_SB.PCI0.MCHC.MEBA, Local1)
Lee Leahyb0005132015-05-12 18:19:47 -0700207
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700208 /* Check if ME base is equal */
Lee Leahyb0005132015-05-12 18:19:47 -0700209 If (LEqual (Local0, Local1)) {
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700210 /* Use Top Of Memory instead */
Subrata Banike938fb72020-01-03 14:02:50 +0530211 Store (\_SB.PCI0.MCHC.TOM, Local0)
Lee Leahyb0005132015-05-12 18:19:47 -0700212 }
213
214 Store (Local0, PMIN)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700215 Add (Subtract (PMAX, PMIN), 1, PLEN)
216
217 /* Patch PM02 range based on Memory Size */
Subrata Banikb6df6b02020-01-03 15:29:02 +0530218 If (LEqual (A4GS, 0)) {
219 CreateQwordField (MCRS, PM02._LEN, MSEN)
220 Store (0, MSEN)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700221 } Else {
Subrata Banikb6df6b02020-01-03 15:29:02 +0530222 CreateQwordField (MCRS, PM02._MIN, MMIN)
223 CreateQwordField (MCRS, PM02._MAX, MMAX)
224 CreateQwordField (MCRS, PM02._LEN, MLEN)
225 /* Set 64bit MMIO resource base and length */
226 Store (A4GS, MLEN)
227 Store (A4GB, MMIN)
228 Subtract (Add (MMIN, MLEN), 1, MMAX)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700229 }
Lee Leahyb0005132015-05-12 18:19:47 -0700230
Subrata Banike938fb72020-01-03 14:02:50 +0530231 Return (MCRS)
Lee Leahyb0005132015-05-12 18:19:47 -0700232}
233
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700234/* Get MCH BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700235Method (GMHB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700236{
Subrata Banike938fb72020-01-03 14:02:50 +0530237 ShiftLeft (\_SB.PCI0.MCHC.MHBR, 15, Local0)
238 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700239}
240
241/* Get EP BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700242Method (GEPB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700243{
Subrata Banike938fb72020-01-03 14:02:50 +0530244 ShiftLeft (\_SB.PCI0.MCHC.EPBR, 12, Local0)
245 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700246}
247
248/* Get PCIe BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700249Method (GPCB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700250{
Subrata Banike938fb72020-01-03 14:02:50 +0530251 ShiftLeft (\_SB.PCI0.MCHC.PXBR, 26, Local0)
252 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700253}
254
255/* Get PCIe Length */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700256Method (GPCL, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700257{
Subrata Banike938fb72020-01-03 14:02:50 +0530258 ShiftRight (0x10000000, \_SB.PCI0.MCHC.PXSZ, Local0)
259 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700260}
261
262/* Get DMI BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700263Method (GDMB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700264{
Subrata Banike938fb72020-01-03 14:02:50 +0530265 ShiftLeft (\_SB.PCI0.MCHC.DIBR, 12, Local0)
266 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700267}
268
Lee Leahyb0005132015-05-12 18:19:47 -0700269/* PCI Device Resource Consumption */
270Device (PDRC)
271{
Duncan Laurief966d3b2015-08-27 17:19:24 -0700272 Name (_HID, EISAID ("PNP0C02"))
Lee Leahyb0005132015-05-12 18:19:47 -0700273 Name (_UID, 1)
274
Lee Leahyb0005132015-05-12 18:19:47 -0700275 Method (_CRS, 0, Serialized)
276 {
Subrata Banike938fb72020-01-03 14:02:50 +0530277 Name (BUF0, ResourceTemplate ()
278 {
279 /* MCH BAR _BAS will be updated in _CRS below according to
280 * B0:D0:F0:Reg.48h
281 */
282 Memory32Fixed (ReadWrite, 0, 0x08000, MCHB)
283
284 /* DMI BAR _BAS will be updated in _CRS below according to
285 * B0:D0:F0:Reg.68h
286 */
287 Memory32Fixed (ReadWrite, 0, 0x01000, DMIB)
288
289 /* EP BAR _BAS will be updated in _CRS below according to
290 * B0:D0:F0:Reg.40h
291 */
292 Memory32Fixed (ReadWrite, 0, 0x01000, EGPB)
293
294 /* PCI Express BAR _BAS and _LEN will be updated in
295 * _CRS below according to B0:D0:F0:Reg.60h
296 */
297 Memory32Fixed (ReadWrite, 0, 0, PCIX)
298
Subrata Banike938fb72020-01-03 14:02:50 +0530299 /* VTD engine memory range. */
300 Memory32Fixed (ReadOnly, VTD_BASE_ADDRESS, VTD_BASE_SIZE)
301
Subrata Banike938fb72020-01-03 14:02:50 +0530302 /* FLASH range */
303 Memory32Fixed (ReadOnly, 0, CONFIG_ROM_SIZE, FIOH)
304
305 /* Local APIC range(0xFEE0_0000 to 0xFEEF_FFFF) */
306 Memory32Fixed (ReadOnly, 0xFEE00000, 0x100000)
307
308 /* HPET address decode range */
309 Memory32Fixed (ReadWrite, HPET_BASE_ADDRESS, 0x400)
310 })
311
312 CreateDwordField (BUF0, MCHB._BAS, MBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700313 Store (\_SB.PCI0.GMHB (), MBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700314
Subrata Banike938fb72020-01-03 14:02:50 +0530315 CreateDwordField (BUF0, DMIB._BAS, DBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700316 Store (\_SB.PCI0.GDMB (), DBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700317
Subrata Banike938fb72020-01-03 14:02:50 +0530318 CreateDwordField (BUF0, EGPB._BAS, EBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700319 Store (\_SB.PCI0.GEPB (), EBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700320
Subrata Banike938fb72020-01-03 14:02:50 +0530321 CreateDwordField (BUF0, PCIX._BAS, XBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700322 Store (\_SB.PCI0.GPCB (), XBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700323
Subrata Banike938fb72020-01-03 14:02:50 +0530324 CreateDwordField (BUF0, PCIX._LEN, XSZ0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700325 Store (\_SB.PCI0.GPCL (), XSZ0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700326
Subrata Banike938fb72020-01-03 14:02:50 +0530327 CreateDwordField (BUF0, FIOH._BAS, FBR0)
328 Subtract(0x100000000, CONFIG_ROM_SIZE, FBR0)
329
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700330 Return (BUF0)
Lee Leahyb0005132015-05-12 18:19:47 -0700331 }
332}