blob: 36d49327c6cf69b664b1c39cf43db6dbcb595e45 [file] [log] [blame]
Angel Pons3bd1e3d2020-04-05 15:47:17 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lee Leahyb0005132015-05-12 18:19:47 -07002
Felix Held4b2464f2022-02-23 17:54:20 +01003#include <arch/hpet.h>
Lee Leahyb0005132015-05-12 18:19:47 -07004#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
Furquan Shaikh01750ef2020-05-16 21:41:35 -0700191 * Lower 20 bits of TOLUD register need to be masked since they contain lock and
192 * reserved bits.
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700193 */
Furquan Shaikh01750ef2020-05-16 21:41:35 -0700194 Local0 = \_SB.PCI0.MCHC.TLUD & (0xfff << 20)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700195 Local1 = \_SB.PCI0.MCHC.MEBA
Lee Leahyb0005132015-05-12 18:19:47 -0700196
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700197 /* Check if ME base is equal */
Furquan Shaikhc3361302020-05-16 21:38:33 -0700198 If (Local0 == Local1) {
Furquan Shaikh01750ef2020-05-16 21:41:35 -0700199 /*
200 * Use Top Of Memory instead
201 * Lower 20 bits of TOM register need to be masked since they contain lock and
202 * reserved bits.
203 */
204 Local0 = \_SB.PCI0.MCHC.TOM & (0x7ffff << 20)
Lee Leahyb0005132015-05-12 18:19:47 -0700205 }
206
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200207 PMIN = Local0
Furquan Shaikhc3361302020-05-16 21:38:33 -0700208 PLEN = (PMAX - PMIN) + 1
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700209
210 /* Patch PM02 range based on Memory Size */
Furquan Shaikhc3361302020-05-16 21:38:33 -0700211 If (A4GS == 0) {
Subrata Banikb6df6b02020-01-03 15:29:02 +0530212 CreateQwordField (MCRS, PM02._LEN, MSEN)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700213 MSEN = 0
Duncan Laurief966d3b2015-08-27 17:19:24 -0700214 } Else {
Subrata Banikb6df6b02020-01-03 15:29:02 +0530215 CreateQwordField (MCRS, PM02._MIN, MMIN)
216 CreateQwordField (MCRS, PM02._MAX, MMAX)
217 CreateQwordField (MCRS, PM02._LEN, MLEN)
218 /* Set 64bit MMIO resource base and length */
Furquan Shaikhc3361302020-05-16 21:38:33 -0700219 MLEN = A4GS
220 MMIN = A4GB
221 MMAX = (MMIN + MLEN) - 1
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700222 }
Lee Leahyb0005132015-05-12 18:19:47 -0700223
Subrata Banike938fb72020-01-03 14:02:50 +0530224 Return (MCRS)
Lee Leahyb0005132015-05-12 18:19:47 -0700225}
226
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700227/* Get MCH BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700228Method (GMHB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700229{
Furquan Shaikhc3361302020-05-16 21:38:33 -0700230 Local0 = \_SB.PCI0.MCHC.MHBR << 15
Subrata Banike938fb72020-01-03 14:02:50 +0530231 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700232}
233
234/* Get EP BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700235Method (GEPB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700236{
Furquan Shaikhc3361302020-05-16 21:38:33 -0700237 Local0 = \_SB.PCI0.MCHC.EPBR << 12
Subrata Banike938fb72020-01-03 14:02:50 +0530238 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700239}
240
241/* Get PCIe BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700242Method (GPCB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700243{
Furquan Shaikhc3361302020-05-16 21:38:33 -0700244 Local0 = \_SB.PCI0.MCHC.PXBR << 26
Subrata Banike938fb72020-01-03 14:02:50 +0530245 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700246}
247
248/* Get PCIe Length */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700249Method (GPCL, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700250{
Furquan Shaikhc3361302020-05-16 21:38:33 -0700251 Local0 = 0x10000000 >> \_SB.PCI0.MCHC.PXSZ
Subrata Banike938fb72020-01-03 14:02:50 +0530252 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700253}
254
255/* Get DMI BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700256Method (GDMB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700257{
Furquan Shaikhc3361302020-05-16 21:38:33 -0700258 Local0 = \_SB.PCI0.MCHC.DIBR << 12
Subrata Banike938fb72020-01-03 14:02:50 +0530259 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700260}
261
Lee Leahyb0005132015-05-12 18:19:47 -0700262/* PCI Device Resource Consumption */
263Device (PDRC)
264{
Duncan Laurief966d3b2015-08-27 17:19:24 -0700265 Name (_HID, EISAID ("PNP0C02"))
Lee Leahyb0005132015-05-12 18:19:47 -0700266 Name (_UID, 1)
267
Lee Leahyb0005132015-05-12 18:19:47 -0700268 Method (_CRS, 0, Serialized)
269 {
Subrata Banike938fb72020-01-03 14:02:50 +0530270 Name (BUF0, ResourceTemplate ()
271 {
272 /* MCH BAR _BAS will be updated in _CRS below according to
273 * B0:D0:F0:Reg.48h
274 */
275 Memory32Fixed (ReadWrite, 0, 0x08000, MCHB)
276
277 /* DMI BAR _BAS will be updated in _CRS below according to
278 * B0:D0:F0:Reg.68h
279 */
280 Memory32Fixed (ReadWrite, 0, 0x01000, DMIB)
281
282 /* EP BAR _BAS will be updated in _CRS below according to
283 * B0:D0:F0:Reg.40h
284 */
285 Memory32Fixed (ReadWrite, 0, 0x01000, EGPB)
286
287 /* PCI Express BAR _BAS and _LEN will be updated in
288 * _CRS below according to B0:D0:F0:Reg.60h
289 */
290 Memory32Fixed (ReadWrite, 0, 0, PCIX)
291
Subrata Banike938fb72020-01-03 14:02:50 +0530292 /* VTD engine memory range. */
293 Memory32Fixed (ReadOnly, VTD_BASE_ADDRESS, VTD_BASE_SIZE)
294
Subrata Banike938fb72020-01-03 14:02:50 +0530295 /* FLASH range */
296 Memory32Fixed (ReadOnly, 0, CONFIG_ROM_SIZE, FIOH)
297
298 /* Local APIC range(0xFEE0_0000 to 0xFEEF_FFFF) */
299 Memory32Fixed (ReadOnly, 0xFEE00000, 0x100000)
300
301 /* HPET address decode range */
302 Memory32Fixed (ReadWrite, HPET_BASE_ADDRESS, 0x400)
303 })
304
305 CreateDwordField (BUF0, MCHB._BAS, MBR0)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700306 MBR0 = \_SB.PCI0.GMHB ()
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700307
Subrata Banike938fb72020-01-03 14:02:50 +0530308 CreateDwordField (BUF0, DMIB._BAS, DBR0)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700309 DBR0 = \_SB.PCI0.GDMB ()
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700310
Subrata Banike938fb72020-01-03 14:02:50 +0530311 CreateDwordField (BUF0, EGPB._BAS, EBR0)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700312 EBR0 = \_SB.PCI0.GEPB ()
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700313
Subrata Banike938fb72020-01-03 14:02:50 +0530314 CreateDwordField (BUF0, PCIX._BAS, XBR0)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700315 XBR0 = \_SB.PCI0.GPCB ()
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700316
Subrata Banike938fb72020-01-03 14:02:50 +0530317 CreateDwordField (BUF0, PCIX._LEN, XSZ0)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700318 XSZ0 = \_SB.PCI0.GPCL ()
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700319
Subrata Banike938fb72020-01-03 14:02:50 +0530320 CreateDwordField (BUF0, FIOH._BAS, FBR0)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700321 FBR0 = 0x100000000 - CONFIG_ROM_SIZE
Subrata Banike938fb72020-01-03 14:02:50 +0530322
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700323 Return (BUF0)
Lee Leahyb0005132015-05-12 18:19:47 -0700324 }
325}
Angel Pons09f06052021-01-05 20:30:16 +0100326
327/* Integrated graphics 0:2.0 */
328#include <drivers/intel/gma/acpi/gfx.asl>