blob: 7c8600341a888609528b507551715409304b1a43 [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgi2efc8802012-11-06 11:03:53 +01002
3#include <arch/ioapic.h>
4
5Name(_HID,EISAID("PNP0A08")) // PCIe
6Name(_CID,EISAID("PNP0A03")) // PCI
7
Patrick Georgi2efc8802012-11-06 11:03:53 +01008Name(_BBN, 0)
9
10Device (MCHC)
11{
Angel Ponsd85d7e22020-07-07 12:51:57 +020012 Name(_ADR, 0x00000000) /* 0:0.0 */
Patrick Georgi2efc8802012-11-06 11:03:53 +010013
14 OperationRegion(MCHP, PCI_Config, 0x00, 0x100)
15 Field (MCHP, DWordAcc, NoLock, Preserve)
16 {
Angel Ponsd85d7e22020-07-07 12:51:57 +020017 Offset (0x40), /* EPBAR */
18 EPEN, 1, /* Enable */
19 , 11,
20 EPBR, 24, /* EPBAR */
Patrick Georgi2efc8802012-11-06 11:03:53 +010021
Angel Ponsd85d7e22020-07-07 12:51:57 +020022 Offset (0x48), /* MCHBAR */
23 MHEN, 1, /* Enable */
24 , 13,
25 MHBR, 22, /* MCHBAR */
Patrick Georgi2efc8802012-11-06 11:03:53 +010026
Angel Ponsd85d7e22020-07-07 12:51:57 +020027 Offset (0x60), /* PCIec BAR */
28 PXEN, 1, /* Enable */
29 PXSZ, 2, /* BAR size */
30 , 23,
31 PXBR, 10, /* PCIe BAR */
Patrick Georgi2efc8802012-11-06 11:03:53 +010032
Angel Ponsd85d7e22020-07-07 12:51:57 +020033 Offset (0x68), /* DMIBAR */
34 DMEN, 1, /* Enable */
35 , 11,
36 DMBR, 24, /* DMIBAR */
Patrick Georgi2efc8802012-11-06 11:03:53 +010037
Angel Ponsd85d7e22020-07-07 12:51:57 +020038 /* ... */
Patrick Georgi2efc8802012-11-06 11:03:53 +010039
Angel Ponsd85d7e22020-07-07 12:51:57 +020040 Offset (0x90), /* PAM0 */
Patrick Georgi2efc8802012-11-06 11:03:53 +010041 , 4,
42 PM0H, 2,
43 , 2,
Angel Ponsd85d7e22020-07-07 12:51:57 +020044 Offset (0x91), /* PAM1 */
Patrick Georgi2efc8802012-11-06 11:03:53 +010045 PM1L, 2,
46 , 2,
47 PM1H, 2,
48 , 2,
Angel Ponsd85d7e22020-07-07 12:51:57 +020049 Offset (0x92), /* PAM2 */
Patrick Georgi2efc8802012-11-06 11:03:53 +010050 PM2L, 2,
51 , 2,
52 PM2H, 2,
53 , 2,
Angel Ponsd85d7e22020-07-07 12:51:57 +020054 Offset (0x93), /* PAM3 */
Patrick Georgi2efc8802012-11-06 11:03:53 +010055 PM3L, 2,
56 , 2,
57 PM3H, 2,
58 , 2,
Angel Ponsd85d7e22020-07-07 12:51:57 +020059 Offset (0x94), /* PAM4 */
Patrick Georgi2efc8802012-11-06 11:03:53 +010060 PM4L, 2,
61 , 2,
62 PM4H, 2,
63 , 2,
Angel Ponsd85d7e22020-07-07 12:51:57 +020064 Offset (0x95), /* PAM5 */
Patrick Georgi2efc8802012-11-06 11:03:53 +010065 PM5L, 2,
66 , 2,
67 PM5H, 2,
68 , 2,
Angel Ponsd85d7e22020-07-07 12:51:57 +020069 Offset (0x96), /* PAM6 */
Patrick Georgi2efc8802012-11-06 11:03:53 +010070 PM6L, 2,
71 , 2,
72 PM6H, 2,
73 , 2,
74
Angel Ponsd85d7e22020-07-07 12:51:57 +020075 Offset (0xa0), /* Top of Memory */
Patrick Georgi2efc8802012-11-06 11:03:53 +010076 TOM, 8,
77
Angel Ponsd85d7e22020-07-07 12:51:57 +020078 Offset (0xb0), /* Top of Low Used Memory */
Patrick Georgi2efc8802012-11-06 11:03:53 +010079 , 4,
80 TLUD, 12,
81 }
Patrick Georgi2efc8802012-11-06 11:03:53 +010082}
83
Martin Rothfc706432015-08-18 16:56:05 -060084Name (MCRS, ResourceTemplate()
85{
Arthur Heymans0cc56a22022-05-11 22:00:59 +020086 /* Bus Numbers. Highest bus gets updated later */
Martin Rothfc706432015-08-18 16:56:05 -060087 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
Arthur Heymans0cc56a22022-05-11 22:00:59 +020088 0x0000, 0x0000, 0x0000, 0x0000,
89 CONFIG_ECAM_MMCONF_BUS_NUMBER,,, PB00)
Martin Rothfc706432015-08-18 16:56:05 -060090
Angel Ponsd85d7e22020-07-07 12:51:57 +020091 /* IO Region 0 */
Martin Rothfc706432015-08-18 16:56:05 -060092 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
93 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8,,, PI00)
94
Angel Ponsd85d7e22020-07-07 12:51:57 +020095 /* PCI Config Space */
Martin Rothfc706432015-08-18 16:56:05 -060096 Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008)
97
Angel Ponsd85d7e22020-07-07 12:51:57 +020098 /* IO Region 1 */
Martin Rothfc706432015-08-18 16:56:05 -060099 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
100 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300,,, PI01)
101
Angel Ponsd85d7e22020-07-07 12:51:57 +0200102 /* VGA memory (0xa0000-0xbffff) */
Martin Rothfc706432015-08-18 16:56:05 -0600103 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
104 Cacheable, ReadWrite,
105 0x00000000, 0x000a0000, 0x000bffff, 0x00000000,
106 0x00020000,,, ASEG)
107
Angel Ponsd85d7e22020-07-07 12:51:57 +0200108 /* OPROM reserved (0xc0000-0xc3fff) */
Martin Rothfc706432015-08-18 16:56:05 -0600109 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
110 Cacheable, ReadWrite,
111 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000,
112 0x00004000,,, OPR0)
113
Angel Ponsd85d7e22020-07-07 12:51:57 +0200114 /* OPROM reserved (0xc4000-0xc7fff) */
Martin Rothfc706432015-08-18 16:56:05 -0600115 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
116 Cacheable, ReadWrite,
117 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000,
118 0x00004000,,, OPR1)
119
Angel Ponsd85d7e22020-07-07 12:51:57 +0200120 /* OPROM reserved (0xc8000-0xcbfff) */
Martin Rothfc706432015-08-18 16:56:05 -0600121 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
122 Cacheable, ReadWrite,
123 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000,
124 0x00004000,,, OPR2)
125
Angel Ponsd85d7e22020-07-07 12:51:57 +0200126 /* OPROM reserved (0xcc000-0xcffff) */
Martin Rothfc706432015-08-18 16:56:05 -0600127 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
128 Cacheable, ReadWrite,
129 0x00000000, 0x000cc000, 0x000cffff, 0x00000000,
130 0x00004000,,, OPR3)
131
Angel Ponsd85d7e22020-07-07 12:51:57 +0200132 /* OPROM reserved (0xd0000-0xd3fff) */
Martin Rothfc706432015-08-18 16:56:05 -0600133 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
134 Cacheable, ReadWrite,
135 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000,
136 0x00004000,,, OPR4)
137
Angel Ponsd85d7e22020-07-07 12:51:57 +0200138 /* OPROM reserved (0xd4000-0xd7fff) */
Martin Rothfc706432015-08-18 16:56:05 -0600139 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
140 Cacheable, ReadWrite,
141 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000,
142 0x00004000,,, OPR5)
143
Angel Ponsd85d7e22020-07-07 12:51:57 +0200144 /* OPROM reserved (0xd8000-0xdbfff) */
Martin Rothfc706432015-08-18 16:56:05 -0600145 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
146 Cacheable, ReadWrite,
147 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000,
148 0x00004000,,, OPR6)
149
Angel Ponsd85d7e22020-07-07 12:51:57 +0200150 /* OPROM reserved (0xdc000-0xdffff) */
Martin Rothfc706432015-08-18 16:56:05 -0600151 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
152 Cacheable, ReadWrite,
153 0x00000000, 0x000dc000, 0x000dffff, 0x00000000,
154 0x00004000,,, OPR7)
155
Angel Ponsd85d7e22020-07-07 12:51:57 +0200156 /* BIOS Extension (0xe0000-0xe3fff) */
Martin Rothfc706432015-08-18 16:56:05 -0600157 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
158 Cacheable, ReadWrite,
159 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000,
160 0x00004000,,, ESG0)
161
Angel Ponsd85d7e22020-07-07 12:51:57 +0200162 /* BIOS Extension (0xe4000-0xe7fff) */
Martin Rothfc706432015-08-18 16:56:05 -0600163 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
164 Cacheable, ReadWrite,
165 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000,
166 0x00004000,,, ESG1)
167
Angel Ponsd85d7e22020-07-07 12:51:57 +0200168 /* BIOS Extension (0xe8000-0xebfff) */
Martin Rothfc706432015-08-18 16:56:05 -0600169 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
170 Cacheable, ReadWrite,
171 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000,
172 0x00004000,,, ESG2)
173
Angel Ponsd85d7e22020-07-07 12:51:57 +0200174 /* BIOS Extension (0xec000-0xeffff) */
Martin Rothfc706432015-08-18 16:56:05 -0600175 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
176 Cacheable, ReadWrite,
177 0x00000000, 0x000ec000, 0x000effff, 0x00000000,
178 0x00004000,,, ESG3)
179
Angel Ponsd85d7e22020-07-07 12:51:57 +0200180 /* System BIOS (0xf0000-0xfffff) */
Martin Rothfc706432015-08-18 16:56:05 -0600181 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
182 Cacheable, ReadWrite,
183 0x00000000, 0x000f0000, 0x000fffff, 0x00000000,
184 0x00010000,,, FSEG)
185
Angel Ponsd85d7e22020-07-07 12:51:57 +0200186 /* PCI Memory Region (Top of memory-0xfebfffff) */
Martin Rothfc706432015-08-18 16:56:05 -0600187 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
188 Cacheable, ReadWrite,
189 0x00000000, 0x00000000, 0xfebfffff, 0x00000000,
190 IO_APIC_ADDR,,, PM01)
191
Arthur Heymans022d2352022-05-06 12:10:39 +0200192 /* PCI Memory Region above 4G TOUUD -> 1 << cpu_addr_bits */
193 QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
194 Cacheable, ReadWrite,
195 0x00000000, 0x00000000, 0x00000000, 0x00000000,
196 0x00000000,,, PM02)
197
Angel Ponsd85d7e22020-07-07 12:51:57 +0200198 /* TPM Area (0xfed40000-0xfed44fff) */
Martin Rothfc706432015-08-18 16:56:05 -0600199 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
200 Cacheable, ReadWrite,
201 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000,
202 0x00005000,,, TPMR)
203})
Patrick Georgi2efc8802012-11-06 11:03:53 +0100204
Arthur Heymans022d2352022-05-06 12:10:39 +0200205External (A4GS, IntObj)
206External (A4GB, IntObj)
207
Angel Ponsd85d7e22020-07-07 12:51:57 +0200208/* Current Resource Settings */
Patrick Georgi2efc8802012-11-06 11:03:53 +0100209Method (_CRS, 0, Serialized)
210{
Arthur Heymans0cc56a22022-05-11 22:00:59 +0200211 /* Set highest PCI bus */
212 CreateWordField(MCRS, ^PB00._MAX, BMAX)
213 CreateWordField(MCRS, ^PB00._LEN, BLEN)
214 BMAX = BLEN - 1
215
Angel Ponsd85d7e22020-07-07 12:51:57 +0200216 /* Find PCI resource area in MCRS */
Martin Rothfc706432015-08-18 16:56:05 -0600217 CreateDwordField(MCRS, ^PM01._MIN, PMIN)
218 CreateDwordField(MCRS, ^PM01._MAX, PMAX)
219 CreateDwordField(MCRS, ^PM01._LEN, PLEN)
Patrick Georgi2efc8802012-11-06 11:03:53 +0100220
Angel Ponsd85d7e22020-07-07 12:51:57 +0200221 /*
222 * Fix up PCI memory region:
223 * Enter actual TOLUD. The TOLUD register contains bits 20-31 of
224 * the top of memory address.
225 */
Angel Pons29cd3502020-07-07 12:54:15 +0200226 PMIN = ^MCHC.TLUD << 20
227 PLEN = PMAX - PMIN + 1
Patrick Georgi2efc8802012-11-06 11:03:53 +0100228
Arthur Heymans022d2352022-05-06 12:10:39 +0200229 if (A4GS != 0) {
230 CreateQwordField(MCRS, ^PM02._MIN, MMIN)
231 CreateQwordField(MCRS, ^PM02._MAX, MMAX)
232 CreateQwordField(MCRS, ^PM02._LEN, MLEN)
233 /* Set 64bit MMIO resource base and length */
234 MLEN = A4GS
235 MMIN = A4GB
236 MMAX = MMIN + MLEN - 1
237 }
238
Patrick Georgi2efc8802012-11-06 11:03:53 +0100239 Return (MCRS)
240}