Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 2 | |
| 3 | #include <arch/ioapic.h> |
| 4 | |
| 5 | Name(_HID,EISAID("PNP0A08")) // PCIe |
| 6 | Name(_CID,EISAID("PNP0A03")) // PCI |
| 7 | |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 8 | Name(_BBN, 0) |
| 9 | |
| 10 | Device (MCHC) |
| 11 | { |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 12 | Name(_ADR, 0x00000000) /* 0:0.0 */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 13 | |
| 14 | OperationRegion(MCHP, PCI_Config, 0x00, 0x100) |
| 15 | Field (MCHP, DWordAcc, NoLock, Preserve) |
| 16 | { |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 17 | Offset (0x40), /* EPBAR */ |
| 18 | EPEN, 1, /* Enable */ |
| 19 | , 11, |
| 20 | EPBR, 24, /* EPBAR */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 21 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 22 | Offset (0x48), /* MCHBAR */ |
| 23 | MHEN, 1, /* Enable */ |
| 24 | , 13, |
| 25 | MHBR, 22, /* MCHBAR */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 26 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 27 | Offset (0x60), /* PCIec BAR */ |
| 28 | PXEN, 1, /* Enable */ |
| 29 | PXSZ, 2, /* BAR size */ |
| 30 | , 23, |
| 31 | PXBR, 10, /* PCIe BAR */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 32 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 33 | Offset (0x68), /* DMIBAR */ |
| 34 | DMEN, 1, /* Enable */ |
| 35 | , 11, |
| 36 | DMBR, 24, /* DMIBAR */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 37 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 38 | /* ... */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 39 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 40 | Offset (0x90), /* PAM0 */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 41 | , 4, |
| 42 | PM0H, 2, |
| 43 | , 2, |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 44 | Offset (0x91), /* PAM1 */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 45 | PM1L, 2, |
| 46 | , 2, |
| 47 | PM1H, 2, |
| 48 | , 2, |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 49 | Offset (0x92), /* PAM2 */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 50 | PM2L, 2, |
| 51 | , 2, |
| 52 | PM2H, 2, |
| 53 | , 2, |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 54 | Offset (0x93), /* PAM3 */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 55 | PM3L, 2, |
| 56 | , 2, |
| 57 | PM3H, 2, |
| 58 | , 2, |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 59 | Offset (0x94), /* PAM4 */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 60 | PM4L, 2, |
| 61 | , 2, |
| 62 | PM4H, 2, |
| 63 | , 2, |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 64 | Offset (0x95), /* PAM5 */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 65 | PM5L, 2, |
| 66 | , 2, |
| 67 | PM5H, 2, |
| 68 | , 2, |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 69 | Offset (0x96), /* PAM6 */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 70 | PM6L, 2, |
| 71 | , 2, |
| 72 | PM6H, 2, |
| 73 | , 2, |
| 74 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 75 | Offset (0xa0), /* Top of Memory */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 76 | TOM, 8, |
| 77 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 78 | Offset (0xb0), /* Top of Low Used Memory */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 79 | , 4, |
| 80 | TLUD, 12, |
| 81 | } |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 82 | } |
| 83 | |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 84 | Name (MCRS, ResourceTemplate() |
| 85 | { |
Arthur Heymans | 0cc56a2 | 2022-05-11 22:00:59 +0200 | [diff] [blame^] | 86 | /* Bus Numbers. Highest bus gets updated later */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 87 | WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, |
Arthur Heymans | 0cc56a2 | 2022-05-11 22:00:59 +0200 | [diff] [blame^] | 88 | 0x0000, 0x0000, 0x0000, 0x0000, |
| 89 | CONFIG_ECAM_MMCONF_BUS_NUMBER,,, PB00) |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 90 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 91 | /* IO Region 0 */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 92 | DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, |
| 93 | 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8,,, PI00) |
| 94 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 95 | /* PCI Config Space */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 96 | Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008) |
| 97 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 98 | /* IO Region 1 */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 99 | DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, |
| 100 | 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300,,, PI01) |
| 101 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 102 | /* VGA memory (0xa0000-0xbffff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 103 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 104 | Cacheable, ReadWrite, |
| 105 | 0x00000000, 0x000a0000, 0x000bffff, 0x00000000, |
| 106 | 0x00020000,,, ASEG) |
| 107 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 108 | /* OPROM reserved (0xc0000-0xc3fff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 109 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 110 | Cacheable, ReadWrite, |
| 111 | 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000, |
| 112 | 0x00004000,,, OPR0) |
| 113 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 114 | /* OPROM reserved (0xc4000-0xc7fff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 115 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 116 | Cacheable, ReadWrite, |
| 117 | 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000, |
| 118 | 0x00004000,,, OPR1) |
| 119 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 120 | /* OPROM reserved (0xc8000-0xcbfff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 121 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 122 | Cacheable, ReadWrite, |
| 123 | 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000, |
| 124 | 0x00004000,,, OPR2) |
| 125 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 126 | /* OPROM reserved (0xcc000-0xcffff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 127 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 128 | Cacheable, ReadWrite, |
| 129 | 0x00000000, 0x000cc000, 0x000cffff, 0x00000000, |
| 130 | 0x00004000,,, OPR3) |
| 131 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 132 | /* OPROM reserved (0xd0000-0xd3fff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 133 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 134 | Cacheable, ReadWrite, |
| 135 | 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000, |
| 136 | 0x00004000,,, OPR4) |
| 137 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 138 | /* OPROM reserved (0xd4000-0xd7fff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 139 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 140 | Cacheable, ReadWrite, |
| 141 | 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000, |
| 142 | 0x00004000,,, OPR5) |
| 143 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 144 | /* OPROM reserved (0xd8000-0xdbfff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 145 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 146 | Cacheable, ReadWrite, |
| 147 | 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000, |
| 148 | 0x00004000,,, OPR6) |
| 149 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 150 | /* OPROM reserved (0xdc000-0xdffff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 151 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 152 | Cacheable, ReadWrite, |
| 153 | 0x00000000, 0x000dc000, 0x000dffff, 0x00000000, |
| 154 | 0x00004000,,, OPR7) |
| 155 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 156 | /* BIOS Extension (0xe0000-0xe3fff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 157 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 158 | Cacheable, ReadWrite, |
| 159 | 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000, |
| 160 | 0x00004000,,, ESG0) |
| 161 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 162 | /* BIOS Extension (0xe4000-0xe7fff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 163 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 164 | Cacheable, ReadWrite, |
| 165 | 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000, |
| 166 | 0x00004000,,, ESG1) |
| 167 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 168 | /* BIOS Extension (0xe8000-0xebfff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 169 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 170 | Cacheable, ReadWrite, |
| 171 | 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000, |
| 172 | 0x00004000,,, ESG2) |
| 173 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 174 | /* BIOS Extension (0xec000-0xeffff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 175 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 176 | Cacheable, ReadWrite, |
| 177 | 0x00000000, 0x000ec000, 0x000effff, 0x00000000, |
| 178 | 0x00004000,,, ESG3) |
| 179 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 180 | /* System BIOS (0xf0000-0xfffff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 181 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 182 | Cacheable, ReadWrite, |
| 183 | 0x00000000, 0x000f0000, 0x000fffff, 0x00000000, |
| 184 | 0x00010000,,, FSEG) |
| 185 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 186 | /* PCI Memory Region (Top of memory-0xfebfffff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 187 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 188 | Cacheable, ReadWrite, |
| 189 | 0x00000000, 0x00000000, 0xfebfffff, 0x00000000, |
| 190 | IO_APIC_ADDR,,, PM01) |
| 191 | |
Arthur Heymans | 022d235 | 2022-05-06 12:10:39 +0200 | [diff] [blame] | 192 | /* 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 Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 198 | /* TPM Area (0xfed40000-0xfed44fff) */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 199 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 200 | Cacheable, ReadWrite, |
| 201 | 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000, |
| 202 | 0x00005000,,, TPMR) |
| 203 | }) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 204 | |
Arthur Heymans | 022d235 | 2022-05-06 12:10:39 +0200 | [diff] [blame] | 205 | External (A4GS, IntObj) |
| 206 | External (A4GB, IntObj) |
| 207 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 208 | /* Current Resource Settings */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 209 | Method (_CRS, 0, Serialized) |
| 210 | { |
Arthur Heymans | 0cc56a2 | 2022-05-11 22:00:59 +0200 | [diff] [blame^] | 211 | /* Set highest PCI bus */ |
| 212 | CreateWordField(MCRS, ^PB00._MAX, BMAX) |
| 213 | CreateWordField(MCRS, ^PB00._LEN, BLEN) |
| 214 | BMAX = BLEN - 1 |
| 215 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 216 | /* Find PCI resource area in MCRS */ |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 217 | CreateDwordField(MCRS, ^PM01._MIN, PMIN) |
| 218 | CreateDwordField(MCRS, ^PM01._MAX, PMAX) |
| 219 | CreateDwordField(MCRS, ^PM01._LEN, PLEN) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 220 | |
Angel Pons | d85d7e2 | 2020-07-07 12:51:57 +0200 | [diff] [blame] | 221 | /* |
| 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 Pons | 29cd350 | 2020-07-07 12:54:15 +0200 | [diff] [blame] | 226 | PMIN = ^MCHC.TLUD << 20 |
| 227 | PLEN = PMAX - PMIN + 1 |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 228 | |
Arthur Heymans | 022d235 | 2022-05-06 12:10:39 +0200 | [diff] [blame] | 229 | 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 Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 239 | Return (MCRS) |
| 240 | } |