Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 2 | |
| 3 | #include <cbmem.h> |
| 4 | #include <console/console.h> |
Elyes HAOUAS | 32da343 | 2020-05-17 17:15:31 +0200 | [diff] [blame] | 5 | #include <cpu/x86/lapic_def.h> |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 6 | #include <device/pci.h> |
| 7 | #include <device/pci_ids.h> |
Marc Jones | 521a03f | 2020-10-19 13:46:59 -0600 | [diff] [blame] | 8 | #include <soc/acpi.h> |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 9 | #include <soc/iomap.h> |
| 10 | #include <soc/pci_devs.h> |
| 11 | #include <soc/ramstage.h> |
Andrey Petrov | 662da6c | 2020-03-16 22:46:57 -0700 | [diff] [blame] | 12 | #include <soc/util.h> |
| 13 | #include <fsp/util.h> |
Arthur Heymans | 77509be | 2020-10-22 17:11:22 +0200 | [diff] [blame] | 14 | #include <security/intel/txt/txt_platform.h> |
Arthur Heymans | 9d8a455 | 2021-02-02 19:21:24 +0100 | [diff] [blame] | 15 | #include <security/intel/txt/txt.h> |
Arthur Heymans | 6366059 | 2022-01-06 12:28:44 +0100 | [diff] [blame] | 16 | #include <stdint.h> |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 17 | |
| 18 | struct map_entry { |
| 19 | uint32_t reg; |
| 20 | int is_64_bit; |
| 21 | int is_limit; |
| 22 | int mask_bits; |
| 23 | const char *description; |
| 24 | }; |
| 25 | |
| 26 | enum { |
| 27 | TOHM_REG, |
| 28 | MMIOL_REG, |
| 29 | MMCFG_BASE_REG, |
| 30 | MMCFG_LIMIT_REG, |
| 31 | TOLM_REG, |
| 32 | ME_BASE_REG, |
| 33 | ME_LIMIT_REG, |
| 34 | TSEG_BASE_REG, |
| 35 | TSEG_LIMIT_REG, |
| 36 | /* Must be last. */ |
| 37 | NUM_MAP_ENTRIES |
| 38 | }; |
| 39 | |
| 40 | static struct map_entry memory_map[NUM_MAP_ENTRIES] = { |
| 41 | [TOHM_REG] = MAP_ENTRY_LIMIT_64(VTD_TOHM_CSR, 26, "TOHM"), |
| 42 | [MMIOL_REG] = MAP_ENTRY_BASE_32(VTD_MMIOL_CSR, "MMIOL"), |
| 43 | [MMCFG_BASE_REG] = MAP_ENTRY_BASE_64(VTD_MMCFG_BASE_CSR, "MMCFG_BASE"), |
| 44 | [MMCFG_LIMIT_REG] = MAP_ENTRY_LIMIT_64(VTD_MMCFG_LIMIT_CSR, 26, "MMCFG_LIMIT"), |
| 45 | [TOLM_REG] = MAP_ENTRY_LIMIT_32(VTD_TOLM_CSR, 26, "TOLM"), |
| 46 | [ME_BASE_REG] = MAP_ENTRY_BASE_64(VTD_ME_BASE_CSR, "ME_BASE"), |
| 47 | [ME_LIMIT_REG] = MAP_ENTRY_LIMIT_64(VTD_ME_LIMIT_CSR, 19, "ME_LIMIT"), |
| 48 | [TSEG_BASE_REG] = MAP_ENTRY_BASE_32(VTD_TSEG_BASE_CSR, "TSEGMB_BASE"), |
| 49 | [TSEG_LIMIT_REG] = MAP_ENTRY_LIMIT_32(VTD_TSEG_LIMIT_CSR, 20, "TSEGMB_LIMIT"), |
| 50 | }; |
| 51 | |
| 52 | static void read_map_entry(struct device *dev, struct map_entry *entry, |
| 53 | uint64_t *result) |
| 54 | { |
| 55 | uint64_t value; |
| 56 | uint64_t mask; |
| 57 | |
| 58 | /* All registers are on a 1MiB granularity. */ |
| 59 | mask = ((1ULL << entry->mask_bits) - 1); |
| 60 | mask = ~mask; |
| 61 | |
| 62 | value = 0; |
| 63 | |
| 64 | if (entry->is_64_bit) { |
| 65 | value = pci_read_config32(dev, entry->reg + sizeof(uint32_t)); |
| 66 | value <<= 32; |
| 67 | } |
| 68 | |
| 69 | value |= (uint64_t)pci_read_config32(dev, entry->reg); |
| 70 | value &= mask; |
| 71 | |
| 72 | if (entry->is_limit) |
| 73 | value |= ~mask; |
| 74 | |
| 75 | *result = value; |
| 76 | } |
| 77 | |
| 78 | static void mc_read_map_entries(struct device *dev, uint64_t *values) |
| 79 | { |
| 80 | int i; |
| 81 | for (i = 0; i < NUM_MAP_ENTRIES; i++) |
| 82 | read_map_entry(dev, &memory_map[i], &values[i]); |
| 83 | } |
| 84 | |
| 85 | static void mc_report_map_entries(struct device *dev, uint64_t *values) |
| 86 | { |
| 87 | int i; |
| 88 | for (i = 0; i < NUM_MAP_ENTRIES; i++) { |
| 89 | printk(BIOS_DEBUG, "MC MAP: %s: 0x%llx\n", |
| 90 | memory_map[i].description, values[i]); |
| 91 | } |
| 92 | } |
| 93 | |
Arthur Heymans | 77509be | 2020-10-22 17:11:22 +0200 | [diff] [blame] | 94 | static void configure_dpr(struct device *dev) |
| 95 | { |
| 96 | const uintptr_t cbmem_top_mb = ALIGN_UP((uintptr_t)cbmem_top(), MiB) / MiB; |
| 97 | union dpr_register dpr = { .raw = pci_read_config32(dev, VTD_LTDPR) }; |
| 98 | |
| 99 | /* The DPR lock bit has to be set sufficiently early. It looks like |
| 100 | * it cannot be set anymore after FSP-S. |
| 101 | */ |
| 102 | dpr.lock = 1; |
| 103 | dpr.epm = 1; |
| 104 | dpr.size = dpr.top - cbmem_top_mb; |
| 105 | pci_write_config32(dev, VTD_LTDPR, dpr.raw); |
| 106 | } |
| 107 | |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 108 | /* |
| 109 | * Host Memory Map: |
| 110 | * |
| 111 | * +--------------------------+ TOCM (2 pow 46 - 1) |
| 112 | * | Reserved | |
| 113 | * +--------------------------+ |
| 114 | * | MMIOH (relocatable) | |
| 115 | * +--------------------------+ |
| 116 | * | PCISeg | |
| 117 | * +--------------------------+ TOHM |
| 118 | * | High DRAM Memory | |
| 119 | * +--------------------------+ 4GiB (0x100000000) |
| 120 | * +--------------------------+ 0xFFFF_FFFF |
| 121 | * | Firmware | |
| 122 | * +--------------------------+ 0xFF00_0000 |
| 123 | * | Reserved | |
| 124 | * +--------------------------+ 0xFEF0_0000 |
| 125 | * | Local xAPIC | |
| 126 | * +--------------------------+ 0xFEE0_0000 |
| 127 | * | HPET/LT/TPM/Others | |
| 128 | * +--------------------------+ 0xFED0_0000 |
| 129 | * | I/O xAPIC | |
| 130 | * +--------------------------+ 0xFEC0_0000 |
| 131 | * | Reserved | |
| 132 | * +--------------------------+ 0xFEB8_0000 |
| 133 | * | Reserved | |
| 134 | * +--------------------------+ 0xFEB0_0000 |
| 135 | * | Reserved | |
| 136 | * +--------------------------+ 0xFE00_0000 |
| 137 | * | MMIOL (relocatable) | |
| 138 | * | P2SB PCR cfg BAR | (0xfd000000 - 0xfdffffff |
| 139 | * | BAR space | [mem 0x90000000-0xfcffffff] available for PCI devices |
| 140 | * +--------------------------+ 0x9000_0000 |
Shelley Chen | 4e9bb33 | 2021-10-20 15:43:45 -0700 | [diff] [blame] | 141 | * |PCIe MMCFG (relocatable) | CONFIG_ECAM_MMCONF_BASE_ADDRESS 64 or 256MB |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 142 | * | | (0x80000000 - 0x8fffffff, 0x40000) |
| 143 | * +--------------------------+ TOLM |
| 144 | * | MEseg (relocatable) | 32, 64, 128 or 256 MB (0x78000000 - 0x7fffffff, 0x20000) |
| 145 | * +--------------------------+ |
| 146 | * | Tseg (relocatable) | N x 8MB (0x70000000 - 0x77ffffff, 0x20000) |
Arthur Heymans | 77509be | 2020-10-22 17:11:22 +0200 | [diff] [blame] | 147 | * +--------------------------+ |
| 148 | * | DPR | |
Jonathan Zhang | 43b0ed7 | 2022-12-19 15:42:56 -0800 | [diff] [blame] | 149 | * +--------------------------+ 1M aligned DPR base |
| 150 | * | Unused memory | |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 151 | * +--------------------------+ cbmem_top |
| 152 | * | Reserved - CBMEM | (0x6fffe000 - 0x6fffffff, 0x2000) |
| 153 | * +--------------------------+ |
| 154 | * | Reserved - FSP | (0x6fbfe000 - 0x6fffdfff, 0x400000) |
| 155 | * +--------------------------+ top_of_ram (0x6fbfdfff) |
| 156 | * | Low DRAM Memory | |
| 157 | * +--------------------------+ FFFFF (1MB) |
| 158 | * | E & F segments | |
| 159 | * +--------------------------+ E0000 |
| 160 | * | C & D segments | |
| 161 | * +--------------------------+ C0000 |
| 162 | * | VGA & SMM Memory | |
| 163 | * +--------------------------+ A0000 |
| 164 | * | Conventional Memory | |
| 165 | * | (DOS Range) | |
| 166 | * +--------------------------+ 0 |
| 167 | */ |
| 168 | |
| 169 | static void mc_add_dram_resources(struct device *dev, int *res_count) |
| 170 | { |
Kyösti Mälkki | 6f9c357 | 2021-06-14 00:40:22 +0300 | [diff] [blame] | 171 | const struct resource *res; |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 172 | uint64_t mc_values[NUM_MAP_ENTRIES]; |
Jonathan Zhang | 43b0ed7 | 2022-12-19 15:42:56 -0800 | [diff] [blame] | 173 | uint64_t top_of_ram; |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 174 | int index = *res_count; |
Jonathan Zhang | 43b0ed7 | 2022-12-19 15:42:56 -0800 | [diff] [blame] | 175 | struct range_entry fsp_mem; |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 176 | |
Marc Jones | 662ac54 | 2020-11-02 21:26:41 -0700 | [diff] [blame] | 177 | /* Only add dram resources once. */ |
| 178 | if (dev->bus->secondary != 0) |
| 179 | return; |
| 180 | |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 181 | /* Read in the MAP registers and report their values. */ |
| 182 | mc_read_map_entries(dev, &mc_values[0]); |
| 183 | mc_report_map_entries(dev, &mc_values[0]); |
| 184 | |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 185 | /* Conventional Memory (DOS region, 0x0 to 0x9FFFF) */ |
Kyösti Mälkki | 6f9c357 | 2021-06-14 00:40:22 +0300 | [diff] [blame] | 186 | res = ram_from_to(dev, index++, 0, 0xa0000); |
| 187 | LOG_RESOURCE("legacy_ram", dev, res); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 188 | |
Jonathan Zhang | 43b0ed7 | 2022-12-19 15:42:56 -0800 | [diff] [blame] | 189 | /* 1MB -> top_of_ram */ |
| 190 | fsp_find_reserved_memory(&fsp_mem); |
| 191 | top_of_ram = range_entry_base(&fsp_mem) - 1; |
| 192 | res = ram_from_to(dev, index++, 1 * MiB, top_of_ram); |
Kyösti Mälkki | 6f9c357 | 2021-06-14 00:40:22 +0300 | [diff] [blame] | 193 | LOG_RESOURCE("low_ram", dev, res); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 194 | |
Jonathan Zhang | 43b0ed7 | 2022-12-19 15:42:56 -0800 | [diff] [blame] | 195 | /* top_of_ram -> cbmem_top */ |
| 196 | res = ram_from_to(dev, index++, top_of_ram, (uintptr_t)cbmem_top()); |
| 197 | LOG_RESOURCE("cbmem_ram", dev, res); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 198 | |
Jonathan Zhang | da538cb | 2022-12-19 15:49:33 -0800 | [diff] [blame] | 199 | /* Reserve DPR region */ |
Arthur Heymans | 77509be | 2020-10-22 17:11:22 +0200 | [diff] [blame] | 200 | union dpr_register dpr = { .raw = pci_read_config32(dev, VTD_LTDPR) }; |
| 201 | if (dpr.size) { |
Jonathan Zhang | 43b0ed7 | 2022-12-19 15:42:56 -0800 | [diff] [blame] | 202 | /* |
| 203 | * cbmem_top -> DPR base: |
| 204 | * DPR has a 1M granularity so it's possible if cbmem_top is not 1M |
| 205 | * aligned that some memory does not get marked as assigned. |
| 206 | */ |
| 207 | res = reserved_ram_from_to(dev, index++, (uintptr_t)cbmem_top(), |
| 208 | (dpr.top - dpr.size) * MiB); |
| 209 | LOG_RESOURCE("unused_dram", dev, res); |
| 210 | |
| 211 | /* DPR base -> DPR top */ |
Kyösti Mälkki | 6f9c357 | 2021-06-14 00:40:22 +0300 | [diff] [blame] | 212 | res = reserved_ram_from_to(dev, index++, (dpr.top - dpr.size) * MiB, |
| 213 | dpr.top * MiB); |
| 214 | LOG_RESOURCE("dpr", dev, res); |
Jonathan Zhang | 43b0ed7 | 2022-12-19 15:42:56 -0800 | [diff] [blame] | 215 | |
Arthur Heymans | 77509be | 2020-10-22 17:11:22 +0200 | [diff] [blame] | 216 | } |
| 217 | |
Jonathan Zhang | 43b0ed7 | 2022-12-19 15:42:56 -0800 | [diff] [blame] | 218 | /* Mark TSEG/SMM region as reserved */ |
| 219 | res = reserved_ram_from_to(dev, index++, mc_values[TSEG_BASE_REG], |
| 220 | mc_values[TSEG_LIMIT_REG] + 1); |
| 221 | LOG_RESOURCE("mmio_tseg", dev, res); |
| 222 | |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 223 | /* Mark region between TSEG - TOLM (eg. MESEG) as reserved */ |
Kyösti Mälkki | 6f9c357 | 2021-06-14 00:40:22 +0300 | [diff] [blame] | 224 | res = reserved_ram_from_to(dev, index++, mc_values[TSEG_LIMIT_REG] + 1, |
| 225 | mc_values[TOLM_REG]); |
| 226 | LOG_RESOURCE("mmio_tolm", dev, res); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 227 | |
| 228 | /* 4GiB -> TOHM */ |
Kyösti Mälkki | 6f9c357 | 2021-06-14 00:40:22 +0300 | [diff] [blame] | 229 | res = upper_ram_end(dev, index++, mc_values[TOHM_REG] + 1); |
| 230 | LOG_RESOURCE("high_ram", dev, res); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 231 | |
| 232 | /* add MMIO CFG resource */ |
Kyösti Mälkki | 6f9c357 | 2021-06-14 00:40:22 +0300 | [diff] [blame] | 233 | res = mmio_from_to(dev, index++, mc_values[MMCFG_BASE_REG], |
| 234 | mc_values[MMCFG_LIMIT_REG] + 1); |
| 235 | LOG_RESOURCE("mmiocfg_res", dev, res); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 236 | |
| 237 | /* add Local APIC resource */ |
Kyösti Mälkki | 6f9c357 | 2021-06-14 00:40:22 +0300 | [diff] [blame] | 238 | res = mmio_range(dev, index++, LAPIC_DEFAULT_BASE, 0x00001000); |
| 239 | LOG_RESOURCE("apic_res", dev, res); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 240 | |
| 241 | /* |
| 242 | * Add legacy region as reserved - 0xa000 - 1MB |
| 243 | * Reserve everything between A segment and 1MB: |
| 244 | * |
| 245 | * 0xa0000 - 0xbffff: legacy VGA |
| 246 | * 0xc0000 - 0xfffff: RAM |
| 247 | */ |
Kyösti Mälkki | 6f9c357 | 2021-06-14 00:40:22 +0300 | [diff] [blame] | 248 | res = mmio_range(dev, index++, VGA_BASE_ADDRESS, VGA_BASE_SIZE); |
| 249 | LOG_RESOURCE("legacy_mmio", dev, res); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 250 | |
Kyösti Mälkki | 6f9c357 | 2021-06-14 00:40:22 +0300 | [diff] [blame] | 251 | res = reserved_ram_from_to(dev, index++, 0xc0000, 1 * MiB); |
| 252 | LOG_RESOURCE("legacy_write_protect", dev, res); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 253 | |
| 254 | *res_count = index; |
| 255 | } |
| 256 | |
| 257 | static void mmapvtd_read_resources(struct device *dev) |
| 258 | { |
| 259 | int index = 0; |
| 260 | |
| 261 | /* Read standard PCI resources. */ |
| 262 | pci_dev_read_resources(dev); |
| 263 | |
Jonathan Zhang | da538cb | 2022-12-19 15:49:33 -0800 | [diff] [blame] | 264 | /* set up DPR */ |
| 265 | configure_dpr(dev); |
| 266 | |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 267 | /* Calculate and add DRAM resources. */ |
| 268 | mc_add_dram_resources(dev, &index); |
| 269 | } |
| 270 | |
| 271 | static void mmapvtd_init(struct device *dev) |
| 272 | { |
| 273 | } |
| 274 | |
| 275 | static struct device_operations mmapvtd_ops = { |
| 276 | .read_resources = mmapvtd_read_resources, |
| 277 | .set_resources = pci_dev_set_resources, |
| 278 | .enable_resources = pci_dev_enable_resources, |
| 279 | .init = mmapvtd_init, |
| 280 | .ops_pci = &soc_pci_ops, |
Marc Jones | 521a03f | 2020-10-19 13:46:59 -0600 | [diff] [blame] | 281 | #if CONFIG(HAVE_ACPI_TABLES) |
| 282 | .acpi_inject_dsdt = uncore_inject_dsdt, |
| 283 | #endif |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 284 | }; |
| 285 | |
| 286 | static const unsigned short mmapvtd_ids[] = { |
| 287 | MMAP_VTD_CFG_REG_DEVID, /* Memory Map/Intel® VT-d Configuration Registers */ |
| 288 | 0 |
| 289 | }; |
| 290 | |
| 291 | static const struct pci_driver mmapvtd_driver __pci_driver = { |
| 292 | .ops = &mmapvtd_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 293 | .vendor = PCI_VID_INTEL, |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 294 | .devices = mmapvtd_ids |
| 295 | }; |
Arthur Heymans | 77509be | 2020-10-22 17:11:22 +0200 | [diff] [blame] | 296 | |
| 297 | static void vtd_read_resources(struct device *dev) |
| 298 | { |
| 299 | pci_dev_read_resources(dev); |
| 300 | |
| 301 | configure_dpr(dev); |
| 302 | } |
| 303 | |
| 304 | static struct device_operations vtd_ops = { |
| 305 | .read_resources = vtd_read_resources, |
| 306 | .set_resources = pci_dev_set_resources, |
| 307 | .enable_resources = pci_dev_enable_resources, |
| 308 | .ops_pci = &soc_pci_ops, |
| 309 | }; |
| 310 | |
| 311 | /* VTD devices on other stacks */ |
| 312 | static const struct pci_driver vtd_driver __pci_driver = { |
| 313 | .ops = &vtd_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 314 | .vendor = PCI_VID_INTEL, |
Arthur Heymans | 77509be | 2020-10-22 17:11:22 +0200 | [diff] [blame] | 315 | .device = MMAP_VTD_STACK_CFG_REG_DEVID, |
| 316 | }; |
Arthur Heymans | 42a6f7e | 2020-11-10 16:46:18 +0100 | [diff] [blame] | 317 | |
| 318 | static void dmi3_init(struct device *dev) |
| 319 | { |
Arthur Heymans | 9d8a455 | 2021-02-02 19:21:24 +0100 | [diff] [blame] | 320 | if (CONFIG(INTEL_TXT) && skip_intel_txt_lockdown()) |
| 321 | return; |
Arthur Heymans | 42a6f7e | 2020-11-10 16:46:18 +0100 | [diff] [blame] | 322 | /* Disable error injection */ |
| 323 | pci_or_config16(dev, ERRINJCON, 1 << 0); |
| 324 | |
| 325 | /* |
| 326 | * DMIRCBAR registers are not TXT lockable, but the BAR enable |
| 327 | * bit is. TXT requires that DMIRCBAR be disabled for security. |
| 328 | */ |
| 329 | pci_and_config32(dev, DMIRCBAR, ~(1 << 0)); |
| 330 | } |
| 331 | |
| 332 | static struct device_operations dmi3_ops = { |
| 333 | .read_resources = pci_dev_read_resources, |
| 334 | .set_resources = pci_dev_set_resources, |
| 335 | .enable_resources = pci_dev_enable_resources, |
| 336 | .init = dmi3_init, |
| 337 | .ops_pci = &soc_pci_ops, |
| 338 | }; |
| 339 | |
| 340 | static const struct pci_driver dmi3_driver __pci_driver = { |
| 341 | .ops = &dmi3_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 342 | .vendor = PCI_VID_INTEL, |
Arthur Heymans | 42a6f7e | 2020-11-10 16:46:18 +0100 | [diff] [blame] | 343 | .device = DMI3_DEVID, |
| 344 | }; |
Arthur Heymans | 7a36ca5 | 2020-11-10 15:55:31 +0100 | [diff] [blame] | 345 | |
| 346 | static void iio_dfx_global_init(struct device *dev) |
| 347 | { |
Arthur Heymans | 9d8a455 | 2021-02-02 19:21:24 +0100 | [diff] [blame] | 348 | if (CONFIG(INTEL_TXT) && skip_intel_txt_lockdown()) |
| 349 | return; |
| 350 | |
Arthur Heymans | 7a36ca5 | 2020-11-10 15:55:31 +0100 | [diff] [blame] | 351 | uint16_t reg16; |
| 352 | pci_or_config16(dev, IIO_DFX_LCK_CTL, 0x3ff); |
| 353 | reg16 = pci_read_config16(dev, IIO_DFX_TSWCTL0); |
| 354 | reg16 &= ~(1 << 4); // allow ib mmio cfg |
| 355 | reg16 &= ~(1 << 5); // ignore acs p2p ma lpbk |
| 356 | reg16 |= (1 << 3); // me disable |
| 357 | pci_write_config16(dev, IIO_DFX_TSWCTL0, reg16); |
| 358 | } |
| 359 | |
| 360 | static const unsigned short iio_dfx_global_ids[] = { |
| 361 | 0x202d, |
| 362 | 0x203d, |
| 363 | 0 |
| 364 | }; |
| 365 | |
| 366 | static struct device_operations iio_dfx_global_ops = { |
| 367 | .read_resources = pci_dev_read_resources, |
| 368 | .set_resources = pci_dev_set_resources, |
| 369 | .enable_resources = pci_dev_enable_resources, |
| 370 | .init = iio_dfx_global_init, |
| 371 | .ops_pci = &soc_pci_ops, |
| 372 | }; |
| 373 | |
| 374 | static const struct pci_driver iio_dfx_global_driver __pci_driver = { |
| 375 | .ops = &iio_dfx_global_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 376 | .vendor = PCI_VID_INTEL, |
Arthur Heymans | 7a36ca5 | 2020-11-10 15:55:31 +0100 | [diff] [blame] | 377 | .devices = iio_dfx_global_ids, |
| 378 | }; |