blob: 5a15ac556258fe3942ce4774f22e695c48455449 [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
Felix Singer9df60d32022-12-26 09:43:07 +01008Name (_SEG, 0) // _SEG: PCI Segment
9Name (_UID, 0) // _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
Arthur Heymans08769c62022-05-09 14:33:15 +020051External (A4GS, IntObj)
52External (A4GB, IntObj)
53
Lee Leahyb0005132015-05-12 18:19:47 -070054Method (_CRS, 0, Serialized)
55{
Subrata Banike938fb72020-01-03 14:02:50 +053056 Name (MCRS, ResourceTemplate ()
57 {
58 /* Bus Numbers */
59 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
60 0x0000, 0x0000, 0x00ff, 0x0000, 0x0100)
61
62 /* IO Region 0 */
63 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode,
64 EntireRange,
65 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8)
66
67 /* PCI Config Space */
68 Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008)
69
70 /* IO Region 1 */
71 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode,
72 EntireRange,
73 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300)
74
75 /* VGA memory (0xa0000-0xbffff) */
76 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
77 Cacheable, ReadWrite,
78 0x00000000, 0x000a0000, 0x000bffff, 0x00000000,
79 0x00020000)
80
81 /* OPROM reserved (0xc0000-0xc3fff) */
82 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
83 Cacheable, ReadWrite,
84 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000,
85 0x00004000)
86
87 /* OPROM reserved (0xc4000-0xc7fff) */
88 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
89 Cacheable, ReadWrite,
90 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000,
91 0x00004000)
92
93 /* OPROM reserved (0xc8000-0xcbfff) */
94 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
95 Cacheable, ReadWrite,
96 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000,
97 0x00004000)
98
99 /* OPROM reserved (0xcc000-0xcffff) */
100 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
101 Cacheable, ReadWrite,
102 0x00000000, 0x000cc000, 0x000cffff, 0x00000000,
103 0x00004000)
104
105 /* OPROM reserved (0xd0000-0xd3fff) */
106 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
107 Cacheable, ReadWrite,
108 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000,
109 0x00004000)
110
111 /* OPROM reserved (0xd4000-0xd7fff) */
112 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
113 Cacheable, ReadWrite,
114 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000,
115 0x00004000)
116
117 /* OPROM reserved (0xd8000-0xdbfff) */
118 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
119 Cacheable, ReadWrite,
120 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000,
121 0x00004000)
122
123 /* OPROM reserved (0xdc000-0xdffff) */
124 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
125 Cacheable, ReadWrite,
126 0x00000000, 0x000dc000, 0x000dffff, 0x00000000,
127 0x00004000)
128
129 /* BIOS Extension (0xe0000-0xe3fff) */
130 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
131 Cacheable, ReadWrite,
132 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000,
133 0x00004000)
134
135 /* BIOS Extension (0xe4000-0xe7fff) */
136 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
137 Cacheable, ReadWrite,
138 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000,
139 0x00004000)
140
141 /* BIOS Extension (0xe8000-0xebfff) */
142 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
143 Cacheable, ReadWrite,
144 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000,
145 0x00004000)
146
147 /* BIOS Extension (0xec000-0xeffff) */
148 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
149 Cacheable, ReadWrite,
150 0x00000000, 0x000ec000, 0x000effff, 0x00000000,
151 0x00004000)
152
153 /* System BIOS (0xf0000-0xfffff) */
154 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
155 Cacheable, ReadWrite,
156 0x00000000, 0x000f0000, 0x000fffff, 0x00000000,
157 0x00010000)
158
159 /* PCI Memory Region (TLUD - 0xdfffffff) */
160 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
161 NonCacheable, ReadWrite,
162 0x00000000, 0x00000000, 0xdfffffff, 0x00000000,
163 0xE0000000,,, PM01)
164
165 /* PCI Memory Region (TUUD - (TUUD + ABOVE_4G_MMIO_SIZE)) */
166 QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
167 NonCacheable, ReadWrite,
168 0x00000000, 0x10000, 0x1ffff, 0x00000000,
169 0x10000,,, PM02)
170
171 /* PCH reserved resource (0xfc800000-0xfe7fffff) */
172 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
173 Cacheable, ReadWrite,
174 0x00000000, PCH_PRESERVED_BASE_ADDRESS, 0xfe7fffff,
175 0x00000000, PCH_PRESERVED_BASE_SIZE)
176
Jes B. Klinkec6b041a12022-04-19 14:00:33 -0700177#if !CONFIG(TPM_GOOGLE)
Subrata Banike938fb72020-01-03 14:02:50 +0530178 /* TPM Area (0xfed40000-0xfed44fff) */
179 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
180 Cacheable, ReadWrite,
181 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000,
182 0x00005000)
Subrata Banikfa8f9ec2020-01-22 15:58:39 +0530183#endif
Subrata Banike938fb72020-01-03 14:02:50 +0530184})
185
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700186 /* Find PCI resource area in MCRS */
Subrata Banike938fb72020-01-03 14:02:50 +0530187 CreateDwordField (MCRS, PM01._MIN, PMIN)
188 CreateDwordField (MCRS, PM01._MAX, PMAX)
189 CreateDwordField (MCRS, PM01._LEN, PLEN)
Lee Leahyb0005132015-05-12 18:19:47 -0700190
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700191 /*
192 * Fix up PCI memory region
193 * Start with Top of Lower Usable DRAM
Furquan Shaikh01750ef2020-05-16 21:41:35 -0700194 * Lower 20 bits of TOLUD register need to be masked since they contain lock and
195 * reserved bits.
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700196 */
Furquan Shaikh01750ef2020-05-16 21:41:35 -0700197 Local0 = \_SB.PCI0.MCHC.TLUD & (0xfff << 20)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700198 Local1 = \_SB.PCI0.MCHC.MEBA
Lee Leahyb0005132015-05-12 18:19:47 -0700199
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700200 /* Check if ME base is equal */
Furquan Shaikhc3361302020-05-16 21:38:33 -0700201 If (Local0 == Local1) {
Furquan Shaikh01750ef2020-05-16 21:41:35 -0700202 /*
203 * Use Top Of Memory instead
204 * Lower 20 bits of TOM register need to be masked since they contain lock and
205 * reserved bits.
206 */
207 Local0 = \_SB.PCI0.MCHC.TOM & (0x7ffff << 20)
Lee Leahyb0005132015-05-12 18:19:47 -0700208 }
209
Elyes HAOUASfc29afb2020-10-09 15:05:28 +0200210 PMIN = Local0
Furquan Shaikhc3361302020-05-16 21:38:33 -0700211 PLEN = (PMAX - PMIN) + 1
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700212
213 /* Patch PM02 range based on Memory Size */
Furquan Shaikhc3361302020-05-16 21:38:33 -0700214 If (A4GS == 0) {
Subrata Banikb6df6b02020-01-03 15:29:02 +0530215 CreateQwordField (MCRS, PM02._LEN, MSEN)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700216 MSEN = 0
Duncan Laurief966d3b2015-08-27 17:19:24 -0700217 } Else {
Subrata Banikb6df6b02020-01-03 15:29:02 +0530218 CreateQwordField (MCRS, PM02._MIN, MMIN)
219 CreateQwordField (MCRS, PM02._MAX, MMAX)
220 CreateQwordField (MCRS, PM02._LEN, MLEN)
221 /* Set 64bit MMIO resource base and length */
Furquan Shaikhc3361302020-05-16 21:38:33 -0700222 MLEN = A4GS
223 MMIN = A4GB
224 MMAX = (MMIN + MLEN) - 1
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700225 }
Lee Leahyb0005132015-05-12 18:19:47 -0700226
Subrata Banike938fb72020-01-03 14:02:50 +0530227 Return (MCRS)
Lee Leahyb0005132015-05-12 18:19:47 -0700228}
229
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700230/* Get MCH BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700231Method (GMHB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700232{
Furquan Shaikhc3361302020-05-16 21:38:33 -0700233 Local0 = \_SB.PCI0.MCHC.MHBR << 15
Subrata Banike938fb72020-01-03 14:02:50 +0530234 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700235}
236
237/* Get EP BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700238Method (GEPB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700239{
Furquan Shaikhc3361302020-05-16 21:38:33 -0700240 Local0 = \_SB.PCI0.MCHC.EPBR << 12
Subrata Banike938fb72020-01-03 14:02:50 +0530241 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700242}
243
244/* Get PCIe BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700245Method (GPCB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700246{
Furquan Shaikhc3361302020-05-16 21:38:33 -0700247 Local0 = \_SB.PCI0.MCHC.PXBR << 26
Subrata Banike938fb72020-01-03 14:02:50 +0530248 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700249}
250
251/* Get PCIe Length */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700252Method (GPCL, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700253{
Furquan Shaikhc3361302020-05-16 21:38:33 -0700254 Local0 = 0x10000000 >> \_SB.PCI0.MCHC.PXSZ
Subrata Banike938fb72020-01-03 14:02:50 +0530255 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700256}
257
258/* Get DMI BAR */
Duncan Laurief966d3b2015-08-27 17:19:24 -0700259Method (GDMB, 0, Serialized)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700260{
Furquan Shaikhc3361302020-05-16 21:38:33 -0700261 Local0 = \_SB.PCI0.MCHC.DIBR << 12
Subrata Banike938fb72020-01-03 14:02:50 +0530262 Return (Local0)
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700263}
264
Lee Leahyb0005132015-05-12 18:19:47 -0700265/* PCI Device Resource Consumption */
266Device (PDRC)
267{
Duncan Laurief966d3b2015-08-27 17:19:24 -0700268 Name (_HID, EISAID ("PNP0C02"))
Lee Leahyb0005132015-05-12 18:19:47 -0700269 Name (_UID, 1)
270
Lee Leahyb0005132015-05-12 18:19:47 -0700271 Method (_CRS, 0, Serialized)
272 {
Subrata Banike938fb72020-01-03 14:02:50 +0530273 Name (BUF0, ResourceTemplate ()
274 {
275 /* MCH BAR _BAS will be updated in _CRS below according to
276 * B0:D0:F0:Reg.48h
277 */
278 Memory32Fixed (ReadWrite, 0, 0x08000, MCHB)
279
280 /* DMI BAR _BAS will be updated in _CRS below according to
281 * B0:D0:F0:Reg.68h
282 */
283 Memory32Fixed (ReadWrite, 0, 0x01000, DMIB)
284
285 /* EP BAR _BAS will be updated in _CRS below according to
286 * B0:D0:F0:Reg.40h
287 */
288 Memory32Fixed (ReadWrite, 0, 0x01000, EGPB)
289
290 /* PCI Express BAR _BAS and _LEN will be updated in
291 * _CRS below according to B0:D0:F0:Reg.60h
292 */
293 Memory32Fixed (ReadWrite, 0, 0, PCIX)
294
Subrata Banike938fb72020-01-03 14:02:50 +0530295 /* VTD engine memory range. */
296 Memory32Fixed (ReadOnly, VTD_BASE_ADDRESS, VTD_BASE_SIZE)
297
Subrata Banike938fb72020-01-03 14:02:50 +0530298 /* FLASH range */
299 Memory32Fixed (ReadOnly, 0, CONFIG_ROM_SIZE, FIOH)
300
301 /* Local APIC range(0xFEE0_0000 to 0xFEEF_FFFF) */
302 Memory32Fixed (ReadOnly, 0xFEE00000, 0x100000)
303
304 /* HPET address decode range */
305 Memory32Fixed (ReadWrite, HPET_BASE_ADDRESS, 0x400)
306 })
307
308 CreateDwordField (BUF0, MCHB._BAS, MBR0)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700309 MBR0 = \_SB.PCI0.GMHB ()
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700310
Subrata Banike938fb72020-01-03 14:02:50 +0530311 CreateDwordField (BUF0, DMIB._BAS, DBR0)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700312 DBR0 = \_SB.PCI0.GDMB ()
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700313
Subrata Banike938fb72020-01-03 14:02:50 +0530314 CreateDwordField (BUF0, EGPB._BAS, EBR0)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700315 EBR0 = \_SB.PCI0.GEPB ()
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700316
Subrata Banike938fb72020-01-03 14:02:50 +0530317 CreateDwordField (BUF0, PCIX._BAS, XBR0)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700318 XBR0 = \_SB.PCI0.GPCB ()
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700319
Subrata Banike938fb72020-01-03 14:02:50 +0530320 CreateDwordField (BUF0, PCIX._LEN, XSZ0)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700321 XSZ0 = \_SB.PCI0.GPCL ()
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700322
Subrata Banike938fb72020-01-03 14:02:50 +0530323 CreateDwordField (BUF0, FIOH._BAS, FBR0)
Furquan Shaikhc3361302020-05-16 21:38:33 -0700324 FBR0 = 0x100000000 - CONFIG_ROM_SIZE
Subrata Banike938fb72020-01-03 14:02:50 +0530325
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700326 Return (BUF0)
Lee Leahyb0005132015-05-12 18:19:47 -0700327 }
328}
Angel Pons09f06052021-01-05 20:30:16 +0100329
330/* Integrated graphics 0:2.0 */
331#include <drivers/intel/gma/acpi/gfx.asl>