blob: ba2a44ff5881b4c1d9d47747337a9970c25bec4d [file] [log] [blame]
Angel Pons3bd1e3d2020-04-05 15:47:17 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Lee Leahyb0005132015-05-12 18:19:47 -07003
4#include <soc/iomap.h>
5
Subrata Banik36eb5002020-01-22 16:01:14 +05306Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */) // _HID: Hardware ID
7Name (_CID, EisaId ("PNP0A03") /* PCI Bus */) // _CID: Compatible ID
8Name (_SEG, Zero) // _SEG: PCI Segment
9Name (_UID, Zero) // _UID: Unique ID
Lee Leahyb0005132015-05-12 18:19:47 -070010
Lee Leahyb0005132015-05-12 18:19:47 -070011Device (MCHC)
12{
Duncan Laurief966d3b2015-08-27 17:19:24 -070013 Name (_ADR, 0x00000000)
Lee Leahyb0005132015-05-12 18:19:47 -070014
15 OperationRegion (MCHP, PCI_Config, 0x00, 0x100)
16 Field (MCHP, DWordAcc, NoLock, Preserve)
17 {
Duncan Laurief966d3b2015-08-27 17:19:24 -070018 Offset(0x40), /* EPBAR (0:0:0:40) */
19 EPEN, 1, /* Enable */
20 , 11,
Subrata Banik4f65b872020-01-22 16:05:16 +053021 EPBR, 27, /* EPBAR [38:12] */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070022
Duncan Laurief966d3b2015-08-27 17:19:24 -070023 Offset(0x48), /* MCHBAR (0:0:0:48) */
24 MHEN, 1, /* Enable */
25 , 14,
Subrata Banik4f65b872020-01-22 16:05:16 +053026 MHBR, 24, /* MCHBAR [38:15] */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070027
Duncan Laurief966d3b2015-08-27 17:19:24 -070028 Offset(0x60), /* PCIEXBAR (0:0:0:60) */
29 PXEN, 1, /* Enable */
30 PXSZ, 2, /* PCI Express Size */
31 , 23,
Subrata Banik4f65b872020-01-22 16:05:16 +053032 PXBR, 13, /* PCI Express BAR [38:26] */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070033
Duncan Laurief966d3b2015-08-27 17:19:24 -070034 Offset(0x68), /* DMIBAR (0:0:0:68) */
35 DIEN, 1, /* Enable */
36 , 11,
Subrata Banik4f65b872020-01-22 16:05:16 +053037 DIBR, 27, /* DMIBAR [38:12] */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070038
Duncan Laurief966d3b2015-08-27 17:19:24 -070039 Offset (0x70), /* ME Base Address */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070040 MEBA, 64,
Subrata Banik4f65b872020-01-22 16:05:16 +053041
Subrata Banike938fb72020-01-03 14:02:50 +053042 Offset (0xa0),
43 TOM, 64, /* Top of Used Memory */
44 TUUD, 64, /* Top of Upper Used Memory */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070045
Duncan Laurief966d3b2015-08-27 17:19:24 -070046 Offset (0xbc), /* Top of Low Used Memory */
Lee Leahy1d14b3e2015-05-12 18:23:27 -070047 TLUD, 32,
Lee Leahyb0005132015-05-12 18:19:47 -070048 }
49}
50
Lee Leahyb0005132015-05-12 18:19:47 -070051Method (_CRS, 0, Serialized)
52{
Subrata Banike938fb72020-01-03 14:02:50 +053053 Name (MCRS, ResourceTemplate ()
54 {
55 /* Bus Numbers */
56 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
57 0x0000, 0x0000, 0x00ff, 0x0000, 0x0100)
58
59 /* IO Region 0 */
60 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode,
61 EntireRange,
62 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8)
63
64 /* PCI Config Space */
65 Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008)
66
67 /* IO Region 1 */
68 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode,
69 EntireRange,
70 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300)
71
72 /* VGA memory (0xa0000-0xbffff) */
73 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
74 Cacheable, ReadWrite,
75 0x00000000, 0x000a0000, 0x000bffff, 0x00000000,
76 0x00020000)
77
78 /* OPROM reserved (0xc0000-0xc3fff) */
79 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
80 Cacheable, ReadWrite,
81 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000,
82 0x00004000)
83
84 /* OPROM reserved (0xc4000-0xc7fff) */
85 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
86 Cacheable, ReadWrite,
87 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000,
88 0x00004000)
89
90 /* OPROM reserved (0xc8000-0xcbfff) */
91 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
92 Cacheable, ReadWrite,
93 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000,
94 0x00004000)
95
96 /* OPROM reserved (0xcc000-0xcffff) */
97 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
98 Cacheable, ReadWrite,
99 0x00000000, 0x000cc000, 0x000cffff, 0x00000000,
100 0x00004000)
101
102 /* OPROM reserved (0xd0000-0xd3fff) */
103 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
104 Cacheable, ReadWrite,
105 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000,
106 0x00004000)
107
108 /* OPROM reserved (0xd4000-0xd7fff) */
109 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
110 Cacheable, ReadWrite,
111 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000,
112 0x00004000)
113
114 /* OPROM reserved (0xd8000-0xdbfff) */
115 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
116 Cacheable, ReadWrite,
117 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000,
118 0x00004000)
119
120 /* OPROM reserved (0xdc000-0xdffff) */
121 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
122 Cacheable, ReadWrite,
123 0x00000000, 0x000dc000, 0x000dffff, 0x00000000,
124 0x00004000)
125
126 /* BIOS Extension (0xe0000-0xe3fff) */
127 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
128 Cacheable, ReadWrite,
129 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000,
130 0x00004000)
131
132 /* BIOS Extension (0xe4000-0xe7fff) */
133 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
134 Cacheable, ReadWrite,
135 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000,
136 0x00004000)
137
138 /* BIOS Extension (0xe8000-0xebfff) */
139 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
140 Cacheable, ReadWrite,
141 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000,
142 0x00004000)
143
144 /* BIOS Extension (0xec000-0xeffff) */
145 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
146 Cacheable, ReadWrite,
147 0x00000000, 0x000ec000, 0x000effff, 0x00000000,
148 0x00004000)
149
150 /* System BIOS (0xf0000-0xfffff) */
151 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
152 Cacheable, ReadWrite,
153 0x00000000, 0x000f0000, 0x000fffff, 0x00000000,
154 0x00010000)
155
156 /* PCI Memory Region (TLUD - 0xdfffffff) */
157 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
158 NonCacheable, ReadWrite,
159 0x00000000, 0x00000000, 0xdfffffff, 0x00000000,
160 0xE0000000,,, PM01)
161
162 /* PCI Memory Region (TUUD - (TUUD + ABOVE_4G_MMIO_SIZE)) */
163 QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
164 NonCacheable, ReadWrite,
165 0x00000000, 0x10000, 0x1ffff, 0x00000000,
166 0x10000,,, PM02)
167
168 /* PCH reserved resource (0xfc800000-0xfe7fffff) */
169 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
170 Cacheable, ReadWrite,
171 0x00000000, PCH_PRESERVED_BASE_ADDRESS, 0xfe7fffff,
172 0x00000000, PCH_PRESERVED_BASE_SIZE)
173
Subrata Banikfa8f9ec2020-01-22 15:58:39 +0530174#if !CONFIG(TPM_CR50)
Subrata Banike938fb72020-01-03 14:02:50 +0530175 /* TPM Area (0xfed40000-0xfed44fff) */
176 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
177 Cacheable, ReadWrite,
178 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000,
179 0x00005000)
Subrata Banikfa8f9ec2020-01-22 15:58:39 +0530180#endif
Subrata Banike938fb72020-01-03 14:02:50 +0530181})
182
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700183 /* Find PCI resource area in MCRS */
Subrata Banike938fb72020-01-03 14:02:50 +0530184 CreateDwordField (MCRS, PM01._MIN, PMIN)
185 CreateDwordField (MCRS, PM01._MAX, PMAX)
186 CreateDwordField (MCRS, PM01._LEN, PLEN)
Lee Leahyb0005132015-05-12 18:19:47 -0700187
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700188 /*
189 * Fix up PCI memory region
190 * Start with Top of Lower Usable DRAM
191 */
Subrata Banike938fb72020-01-03 14:02:50 +0530192 Store (\_SB.PCI0.MCHC.TLUD, Local0)
193 Store (\_SB.PCI0.MCHC.MEBA, Local1)
Lee Leahyb0005132015-05-12 18:19:47 -0700194
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700195 /* Check if ME base is equal */
Lee Leahyb0005132015-05-12 18:19:47 -0700196 If (LEqual (Local0, Local1)) {
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700197 /* Use Top Of Memory instead */
Subrata Banike938fb72020-01-03 14:02:50 +0530198 Store (\_SB.PCI0.MCHC.TOM, Local0)
Lee Leahyb0005132015-05-12 18:19:47 -0700199 }
200
201 Store (Local0, PMIN)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700202 Add (Subtract (PMAX, PMIN), 1, PLEN)
203
204 /* Patch PM02 range based on Memory Size */
Subrata Banikb6df6b02020-01-03 15:29:02 +0530205 If (LEqual (A4GS, 0)) {
206 CreateQwordField (MCRS, PM02._LEN, MSEN)
207 Store (0, MSEN)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700208 } Else {
Subrata Banikb6df6b02020-01-03 15:29:02 +0530209 CreateQwordField (MCRS, PM02._MIN, MMIN)
210 CreateQwordField (MCRS, PM02._MAX, MMAX)
211 CreateQwordField (MCRS, PM02._LEN, MLEN)
212 /* Set 64bit MMIO resource base and length */
213 Store (A4GS, MLEN)
214 Store (A4GB, MMIN)
215 Subtract (Add (MMIN, MLEN), 1, MMAX)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700216 }
Lee Leahyb0005132015-05-12 18:19:47 -0700217
Subrata Banike938fb72020-01-03 14:02:50 +0530218 Return (MCRS)
Lee Leahyb0005132015-05-12 18:19:47 -0700219}
220
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700221/* Get MCH BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700222Method (GMHB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700223{
Subrata Banike938fb72020-01-03 14:02:50 +0530224 ShiftLeft (\_SB.PCI0.MCHC.MHBR, 15, Local0)
225 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700226}
227
228/* Get EP BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700229Method (GEPB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700230{
Subrata Banike938fb72020-01-03 14:02:50 +0530231 ShiftLeft (\_SB.PCI0.MCHC.EPBR, 12, Local0)
232 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700233}
234
235/* Get PCIe BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700236Method (GPCB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700237{
Subrata Banike938fb72020-01-03 14:02:50 +0530238 ShiftLeft (\_SB.PCI0.MCHC.PXBR, 26, Local0)
239 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700240}
241
242/* Get PCIe Length */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700243Method (GPCL, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700244{
Subrata Banike938fb72020-01-03 14:02:50 +0530245 ShiftRight (0x10000000, \_SB.PCI0.MCHC.PXSZ, Local0)
246 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700247}
248
249/* Get DMI BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700250Method (GDMB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700251{
Subrata Banike938fb72020-01-03 14:02:50 +0530252 ShiftLeft (\_SB.PCI0.MCHC.DIBR, 12, Local0)
253 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700254}
255
Lee Leahyb0005132015-05-12 18:19:47 -0700256/* PCI Device Resource Consumption */
257Device (PDRC)
258{
Duncan Laurief966d3b2015-08-27 17:19:24 -0700259 Name (_HID, EISAID ("PNP0C02"))
Lee Leahyb0005132015-05-12 18:19:47 -0700260 Name (_UID, 1)
261
Lee Leahyb0005132015-05-12 18:19:47 -0700262 Method (_CRS, 0, Serialized)
263 {
Subrata Banike938fb72020-01-03 14:02:50 +0530264 Name (BUF0, ResourceTemplate ()
265 {
266 /* MCH BAR _BAS will be updated in _CRS below according to
267 * B0:D0:F0:Reg.48h
268 */
269 Memory32Fixed (ReadWrite, 0, 0x08000, MCHB)
270
271 /* DMI BAR _BAS will be updated in _CRS below according to
272 * B0:D0:F0:Reg.68h
273 */
274 Memory32Fixed (ReadWrite, 0, 0x01000, DMIB)
275
276 /* EP BAR _BAS will be updated in _CRS below according to
277 * B0:D0:F0:Reg.40h
278 */
279 Memory32Fixed (ReadWrite, 0, 0x01000, EGPB)
280
281 /* PCI Express BAR _BAS and _LEN will be updated in
282 * _CRS below according to B0:D0:F0:Reg.60h
283 */
284 Memory32Fixed (ReadWrite, 0, 0, PCIX)
285
Subrata Banike938fb72020-01-03 14:02:50 +0530286 /* VTD engine memory range. */
287 Memory32Fixed (ReadOnly, VTD_BASE_ADDRESS, VTD_BASE_SIZE)
288
Subrata Banike938fb72020-01-03 14:02:50 +0530289 /* FLASH range */
290 Memory32Fixed (ReadOnly, 0, CONFIG_ROM_SIZE, FIOH)
291
292 /* Local APIC range(0xFEE0_0000 to 0xFEEF_FFFF) */
293 Memory32Fixed (ReadOnly, 0xFEE00000, 0x100000)
294
295 /* HPET address decode range */
296 Memory32Fixed (ReadWrite, HPET_BASE_ADDRESS, 0x400)
297 })
298
299 CreateDwordField (BUF0, MCHB._BAS, MBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700300 Store (\_SB.PCI0.GMHB (), MBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700301
Subrata Banike938fb72020-01-03 14:02:50 +0530302 CreateDwordField (BUF0, DMIB._BAS, DBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700303 Store (\_SB.PCI0.GDMB (), DBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700304
Subrata Banike938fb72020-01-03 14:02:50 +0530305 CreateDwordField (BUF0, EGPB._BAS, EBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700306 Store (\_SB.PCI0.GEPB (), EBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700307
Subrata Banike938fb72020-01-03 14:02:50 +0530308 CreateDwordField (BUF0, PCIX._BAS, XBR0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700309 Store (\_SB.PCI0.GPCB (), XBR0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700310
Subrata Banike938fb72020-01-03 14:02:50 +0530311 CreateDwordField (BUF0, PCIX._LEN, XSZ0)
Duncan Laurief966d3b2015-08-27 17:19:24 -0700312 Store (\_SB.PCI0.GPCL (), XSZ0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700313
Subrata Banike938fb72020-01-03 14:02:50 +0530314 CreateDwordField (BUF0, FIOH._BAS, FBR0)
315 Subtract(0x100000000, CONFIG_ROM_SIZE, FBR0)
316
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700317 Return (BUF0)
Lee Leahyb0005132015-05-12 18:19:47 -0700318 }
319}