Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2009 coresystems GmbH |
| 5 | * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
Paul Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include <console/console.h> |
| 22 | #include <arch/acpi.h> |
| 23 | #include <arch/io.h> |
| 24 | #include <stdint.h> |
| 25 | #include <delay.h> |
| 26 | #include <cpu/intel/model_206ax/model_206ax.h> |
Duncan Laurie | 77dbbac | 2012-06-25 09:51:59 -0700 | [diff] [blame] | 27 | #include <cpu/x86/msr.h> |
Aaron Durbin | c6f2722 | 2013-04-03 09:56:57 -0500 | [diff] [blame] | 28 | #include <cpu/x86/mtrr.h> |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 29 | #include <device/device.h> |
| 30 | #include <device/pci.h> |
| 31 | #include <device/pci_ids.h> |
| 32 | #include <device/hypertransport.h> |
| 33 | #include <stdlib.h> |
| 34 | #include <string.h> |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 35 | #include <cpu/cpu.h> |
Stefan Reinauer | bb11e60 | 2012-05-10 12:15:18 -0700 | [diff] [blame] | 36 | #include <cbmem.h> |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 37 | #include "chip.h" |
| 38 | #include "sandybridge.h" |
| 39 | |
| 40 | static int bridge_revision_id = -1; |
| 41 | |
Kyösti Mälkki | f7bfc34 | 2013-10-18 11:02:46 +0300 | [diff] [blame] | 42 | /* IGD UMA memory */ |
| 43 | static uint64_t uma_memory_base = 0; |
| 44 | static uint64_t uma_memory_size = 0; |
| 45 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 46 | int bridge_silicon_revision(void) |
| 47 | { |
| 48 | if (bridge_revision_id < 0) { |
| 49 | uint8_t stepping = cpuid_eax(1) & 0xf; |
| 50 | uint8_t bridge_id = pci_read_config16( |
| 51 | dev_find_slot(0, PCI_DEVFN(0, 0)), |
| 52 | PCI_DEVICE_ID) & 0xf0; |
| 53 | bridge_revision_id = bridge_id | stepping; |
| 54 | } |
| 55 | return bridge_revision_id; |
| 56 | } |
| 57 | |
| 58 | /* Reserve everything between A segment and 1MB: |
| 59 | * |
| 60 | * 0xa0000 - 0xbffff: legacy VGA |
| 61 | * 0xc0000 - 0xcffff: VGA OPROM (needed by kernel) |
| 62 | * 0xe0000 - 0xfffff: SeaBIOS, if used, otherwise DMI |
| 63 | */ |
| 64 | static const int legacy_hole_base_k = 0xa0000 / 1024; |
| 65 | static const int legacy_hole_size_k = 384; |
| 66 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 67 | static int get_pcie_bar(u32 *base, u32 *len) |
| 68 | { |
| 69 | device_t dev; |
| 70 | u32 pciexbar_reg; |
| 71 | |
| 72 | *base = 0; |
| 73 | *len = 0; |
| 74 | |
| 75 | dev = dev_find_slot(0, PCI_DEVFN(0, 0)); |
| 76 | if (!dev) |
| 77 | return 0; |
| 78 | |
| 79 | pciexbar_reg = pci_read_config32(dev, PCIEXBAR); |
| 80 | |
| 81 | if (!(pciexbar_reg & (1 << 0))) |
| 82 | return 0; |
| 83 | |
| 84 | switch ((pciexbar_reg >> 1) & 3) { |
| 85 | case 0: // 256MB |
| 86 | *base = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)); |
| 87 | *len = 256 * 1024 * 1024; |
| 88 | return 1; |
| 89 | case 1: // 128M |
| 90 | *base = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)|(1 << 27)); |
| 91 | *len = 128 * 1024 * 1024; |
| 92 | return 1; |
| 93 | case 2: // 64M |
| 94 | *base = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)|(1 << 27)|(1 << 26)); |
| 95 | *len = 64 * 1024 * 1024; |
| 96 | return 1; |
| 97 | } |
| 98 | |
| 99 | return 0; |
| 100 | } |
| 101 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 102 | static void add_fixed_resources(struct device *dev, int index) |
| 103 | { |
| 104 | struct resource *resource; |
| 105 | u32 pcie_config_base, pcie_config_size; |
| 106 | |
Kyösti Mälkki | 7f189cc | 2012-07-27 13:12:03 +0300 | [diff] [blame] | 107 | mmio_resource(dev, index++, uma_memory_base >> 10, uma_memory_size >> 10); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 108 | |
| 109 | if (get_pcie_bar(&pcie_config_base, &pcie_config_size)) { |
| 110 | printk(BIOS_DEBUG, "Adding PCIe config bar base=0x%08x " |
| 111 | "size=0x%x\n", pcie_config_base, pcie_config_size); |
Kyösti Mälkki | 1ec5e74 | 2012-07-26 23:51:20 +0300 | [diff] [blame] | 112 | resource = new_resource(dev, index++); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 113 | resource->base = (resource_t) pcie_config_base; |
| 114 | resource->size = (resource_t) pcie_config_size; |
| 115 | resource->flags = IORESOURCE_MEM | IORESOURCE_RESERVE | |
| 116 | IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED; |
| 117 | } |
Kyösti Mälkki | 1ec5e74 | 2012-07-26 23:51:20 +0300 | [diff] [blame] | 118 | |
Aaron Durbin | c965076 | 2013-03-22 22:03:09 -0500 | [diff] [blame] | 119 | mmio_resource(dev, index++, legacy_hole_base_k, |
| 120 | (0xc0000 >> 10) - legacy_hole_base_k); |
| 121 | reserved_ram_resource(dev, index++, 0xc0000 >> 10, |
| 122 | (0x100000 - 0xc0000) >> 10); |
Kyösti Mälkki | 1ec5e74 | 2012-07-26 23:51:20 +0300 | [diff] [blame] | 123 | |
| 124 | #if CONFIG_CHROMEOS_RAMOOPS |
Aaron Durbin | c965076 | 2013-03-22 22:03:09 -0500 | [diff] [blame] | 125 | reserved_ram_resource(dev, index++, |
| 126 | CONFIG_CHROMEOS_RAMOOPS_RAM_START >> 10, |
Kyösti Mälkki | 1ec5e74 | 2012-07-26 23:51:20 +0300 | [diff] [blame] | 127 | CONFIG_CHROMEOS_RAMOOPS_RAM_SIZE >> 10); |
| 128 | #endif |
| 129 | |
| 130 | /* Required for SandyBridge sighting 3715511 */ |
| 131 | bad_ram_resource(dev, index++, 0x20000000 >> 10, 0x00200000 >> 10); |
| 132 | bad_ram_resource(dev, index++, 0x40000000 >> 10, 0x00200000 >> 10); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 133 | } |
| 134 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 135 | static void pci_domain_set_resources(device_t dev) |
| 136 | { |
| 137 | uint64_t tom, me_base, touud; |
| 138 | uint32_t tseg_base, uma_size, tolud; |
| 139 | uint16_t ggc; |
| 140 | unsigned long long tomk; |
| 141 | |
| 142 | /* Total Memory 2GB example: |
| 143 | * |
| 144 | * 00000000 0000MB-1992MB 1992MB RAM (writeback) |
| 145 | * 7c800000 1992MB-2000MB 8MB TSEG (SMRR) |
| 146 | * 7d000000 2000MB-2002MB 2MB GFX GTT (uncached) |
| 147 | * 7d200000 2002MB-2034MB 32MB GFX UMA (uncached) |
| 148 | * 7f200000 2034MB TOLUD |
| 149 | * 7f800000 2040MB MEBASE |
| 150 | * 7f800000 2040MB-2048MB 8MB ME UMA (uncached) |
| 151 | * 80000000 2048MB TOM |
| 152 | * 100000000 4096MB-4102MB 6MB RAM (writeback) |
| 153 | * |
| 154 | * Total Memory 4GB example: |
| 155 | * |
| 156 | * 00000000 0000MB-2768MB 2768MB RAM (writeback) |
| 157 | * ad000000 2768MB-2776MB 8MB TSEG (SMRR) |
| 158 | * ad800000 2776MB-2778MB 2MB GFX GTT (uncached) |
| 159 | * ada00000 2778MB-2810MB 32MB GFX UMA (uncached) |
| 160 | * afa00000 2810MB TOLUD |
| 161 | * ff800000 4088MB MEBASE |
| 162 | * ff800000 4088MB-4096MB 8MB ME UMA (uncached) |
| 163 | * 100000000 4096MB TOM |
| 164 | * 100000000 4096MB-5374MB 1278MB RAM (writeback) |
| 165 | * 14fe00000 5368MB TOUUD |
| 166 | */ |
| 167 | |
| 168 | /* Top of Upper Usable DRAM, including remap */ |
| 169 | touud = pci_read_config32(dev, TOUUD+4); |
| 170 | touud <<= 32; |
| 171 | touud |= pci_read_config32(dev, TOUUD); |
| 172 | |
| 173 | /* Top of Lower Usable DRAM */ |
| 174 | tolud = pci_read_config32(dev, TOLUD); |
| 175 | |
| 176 | /* Top of Memory - does not account for any UMA */ |
| 177 | tom = pci_read_config32(dev, 0xa4); |
| 178 | tom <<= 32; |
| 179 | tom |= pci_read_config32(dev, 0xa0); |
| 180 | |
| 181 | printk(BIOS_DEBUG, "TOUUD 0x%llx TOLUD 0x%08x TOM 0x%llx\n", |
| 182 | touud, tolud, tom); |
| 183 | |
| 184 | /* ME UMA needs excluding if total memory <4GB */ |
| 185 | me_base = pci_read_config32(dev, 0x74); |
| 186 | me_base <<= 32; |
| 187 | me_base |= pci_read_config32(dev, 0x70); |
| 188 | |
| 189 | printk(BIOS_DEBUG, "MEBASE 0x%llx\n", me_base); |
| 190 | |
| 191 | tomk = tolud >> 10; |
| 192 | if (me_base == tolud) { |
| 193 | /* ME is from MEBASE-TOM */ |
| 194 | uma_size = (tom - me_base) >> 10; |
| 195 | /* Increment TOLUD to account for ME as RAM */ |
| 196 | tolud += uma_size << 10; |
| 197 | /* UMA starts at old TOLUD */ |
| 198 | uma_memory_base = tomk * 1024ULL; |
| 199 | uma_memory_size = uma_size * 1024ULL; |
| 200 | printk(BIOS_DEBUG, "ME UMA base 0x%llx size %uM\n", |
| 201 | me_base, uma_size >> 10); |
| 202 | } |
| 203 | |
| 204 | /* Graphics memory comes next */ |
| 205 | ggc = pci_read_config16(dev, GGC); |
| 206 | if (!(ggc & 2)) { |
| 207 | printk(BIOS_DEBUG, "IGD decoded, subtracting "); |
| 208 | |
| 209 | /* Graphics memory */ |
| 210 | uma_size = ((ggc >> 3) & 0x1f) * 32 * 1024ULL; |
| 211 | printk(BIOS_DEBUG, "%uM UMA", uma_size >> 10); |
| 212 | tomk -= uma_size; |
| 213 | uma_memory_base = tomk * 1024ULL; |
| 214 | uma_memory_size += uma_size * 1024ULL; |
| 215 | |
| 216 | /* GTT Graphics Stolen Memory Size (GGMS) */ |
| 217 | uma_size = ((ggc >> 8) & 0x3) * 1024ULL; |
| 218 | tomk -= uma_size; |
| 219 | uma_memory_base = tomk * 1024ULL; |
| 220 | uma_memory_size += uma_size * 1024ULL; |
| 221 | printk(BIOS_DEBUG, " and %uM GTT\n", uma_size >> 10); |
| 222 | } |
| 223 | |
| 224 | /* Calculate TSEG size from its base which must be below GTT */ |
| 225 | tseg_base = pci_read_config32(dev, 0xb8); |
| 226 | uma_size = (uma_memory_base - tseg_base) >> 10; |
| 227 | tomk -= uma_size; |
| 228 | uma_memory_base = tomk * 1024ULL; |
| 229 | uma_memory_size += uma_size * 1024ULL; |
| 230 | printk(BIOS_DEBUG, "TSEG base 0x%08x size %uM\n", |
| 231 | tseg_base, uma_size >> 10); |
| 232 | |
| 233 | printk(BIOS_INFO, "Available memory below 4GB: %lluM\n", tomk >> 10); |
| 234 | |
| 235 | /* Report the memory regions */ |
| 236 | ram_resource(dev, 3, 0, legacy_hole_base_k); |
| 237 | ram_resource(dev, 4, legacy_hole_base_k + legacy_hole_size_k, |
| 238 | (tomk - (legacy_hole_base_k + legacy_hole_size_k))); |
| 239 | |
| 240 | /* |
| 241 | * If >= 4GB installed then memory from TOLUD to 4GB |
| 242 | * is remapped above TOM, TOUUD will account for both |
| 243 | */ |
| 244 | touud >>= 10; /* Convert to KB */ |
| 245 | if (touud > 4096 * 1024) { |
| 246 | ram_resource(dev, 5, 4096 * 1024, touud - (4096 * 1024)); |
| 247 | printk(BIOS_INFO, "Available memory above 4GB: %lluM\n", |
| 248 | (touud >> 10) - 4096); |
| 249 | } |
| 250 | |
| 251 | add_fixed_resources(dev, 6); |
| 252 | |
| 253 | assign_resources(dev->link_list); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | /* TODO We could determine how many PCIe busses we need in |
| 257 | * the bar. For now that number is hardcoded to a max of 64. |
| 258 | * See e7525/northbridge.c for an example. |
| 259 | */ |
| 260 | static struct device_operations pci_domain_ops = { |
| 261 | .read_resources = pci_domain_read_resources, |
| 262 | .set_resources = pci_domain_set_resources, |
| 263 | .enable_resources = NULL, |
| 264 | .init = NULL, |
| 265 | .scan_bus = pci_domain_scan_bus, |
Kyösti Mälkki | 872c922 | 2013-07-03 09:44:28 +0300 | [diff] [blame] | 266 | .ops_pci_bus = pci_bus_default_ops, |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 267 | }; |
| 268 | |
| 269 | static void mc_read_resources(device_t dev) |
| 270 | { |
| 271 | struct resource *resource; |
| 272 | |
| 273 | pci_dev_read_resources(dev); |
| 274 | |
| 275 | /* So, this is one of the big mysteries in the coreboot resource |
| 276 | * allocator. This resource should make sure that the address space |
| 277 | * of the PCIe memory mapped config space bar. But it does not. |
| 278 | */ |
| 279 | |
| 280 | /* We use 0xcf as an unused index for our PCIe bar so that we find it again */ |
| 281 | resource = new_resource(dev, 0xcf); |
| 282 | resource->base = DEFAULT_PCIEXBAR; |
| 283 | resource->size = 64 * 1024 * 1024; /* 64MB hard coded PCIe config space */ |
| 284 | resource->flags = |
| 285 | IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED | |
| 286 | IORESOURCE_ASSIGNED; |
| 287 | printk(BIOS_DEBUG, "Adding PCIe enhanced config space BAR 0x%08lx-0x%08lx.\n", |
| 288 | (unsigned long)(resource->base), (unsigned long)(resource->base + resource->size)); |
| 289 | } |
| 290 | |
| 291 | static void mc_set_resources(device_t dev) |
| 292 | { |
| 293 | struct resource *resource; |
| 294 | |
| 295 | /* Report the PCIe BAR */ |
| 296 | resource = find_resource(dev, 0xcf); |
| 297 | if (resource) { |
| 298 | report_resource_stored(dev, resource, "<mmconfig>"); |
| 299 | } |
| 300 | |
| 301 | /* And call the normal set_resources */ |
| 302 | pci_dev_set_resources(dev); |
| 303 | } |
| 304 | |
| 305 | static void intel_set_subsystem(device_t dev, unsigned vendor, unsigned device) |
| 306 | { |
| 307 | if (!vendor || !device) { |
| 308 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 309 | pci_read_config32(dev, PCI_VENDOR_ID)); |
| 310 | } else { |
| 311 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 312 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | static void northbridge_dmi_init(struct device *dev) |
| 317 | { |
| 318 | u32 reg32; |
| 319 | |
| 320 | /* Clear error status bits */ |
| 321 | DMIBAR32(0x1c4) = 0xffffffff; |
| 322 | DMIBAR32(0x1d0) = 0xffffffff; |
| 323 | |
| 324 | /* Steps prior to DMI ASPM */ |
Vincent Palatin | 0ff99b7 | 2012-03-28 16:10:29 -0700 | [diff] [blame] | 325 | if ((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_SNB) { |
| 326 | reg32 = DMIBAR32(0x250); |
| 327 | reg32 &= ~((1 << 22)|(1 << 20)); |
| 328 | reg32 |= (1 << 21); |
| 329 | DMIBAR32(0x250) = reg32; |
| 330 | } |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 331 | |
| 332 | reg32 = DMIBAR32(0x238); |
| 333 | reg32 |= (1 << 29); |
| 334 | DMIBAR32(0x238) = reg32; |
| 335 | |
| 336 | if (bridge_silicon_revision() >= SNB_STEP_D0) { |
| 337 | reg32 = DMIBAR32(0x1f8); |
| 338 | reg32 |= (1 << 16); |
| 339 | DMIBAR32(0x1f8) = reg32; |
| 340 | } else if (bridge_silicon_revision() >= SNB_STEP_D1) { |
| 341 | reg32 = DMIBAR32(0x1f8); |
| 342 | reg32 &= ~(1 << 26); |
| 343 | reg32 |= (1 << 16); |
| 344 | DMIBAR32(0x1f8) = reg32; |
| 345 | |
| 346 | reg32 = DMIBAR32(0x1fc); |
| 347 | reg32 |= (1 << 12) | (1 << 23); |
| 348 | DMIBAR32(0x1fc) = reg32; |
| 349 | } |
| 350 | |
| 351 | /* Enable ASPM on SNB link, should happen before PCH link */ |
Vincent Palatin | 0ff99b7 | 2012-03-28 16:10:29 -0700 | [diff] [blame] | 352 | if ((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_SNB) { |
| 353 | reg32 = DMIBAR32(0xd04); |
| 354 | reg32 |= (1 << 4); |
| 355 | DMIBAR32(0xd04) = reg32; |
| 356 | } |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 357 | |
| 358 | reg32 = DMIBAR32(0x88); |
| 359 | reg32 |= (1 << 1) | (1 << 0); |
| 360 | DMIBAR32(0x88) = reg32; |
| 361 | } |
| 362 | |
| 363 | static void northbridge_init(struct device *dev) |
| 364 | { |
| 365 | u8 bios_reset_cpl; |
Duncan Laurie | fe7b5d2 | 2012-06-23 20:14:07 -0700 | [diff] [blame] | 366 | u32 bridge_type; |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 367 | |
| 368 | northbridge_dmi_init(dev); |
| 369 | |
Duncan Laurie | fe7b5d2 | 2012-06-23 20:14:07 -0700 | [diff] [blame] | 370 | bridge_type = MCHBAR32(0x5f10); |
| 371 | bridge_type &= ~0xff; |
| 372 | |
| 373 | if ((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_IVB) { |
| 374 | /* Enable Power Aware Interrupt Routing */ |
| 375 | u8 pair = MCHBAR8(0x5418); |
| 376 | pair &= ~0xf; /* Clear 3:0 */ |
| 377 | pair |= 0x4; /* Fixed Priority */ |
| 378 | MCHBAR8(0x5418) = pair; |
| 379 | |
| 380 | /* 30h for IvyBridge */ |
| 381 | bridge_type |= 0x30; |
| 382 | } else { |
| 383 | /* 20h for Sandybridge */ |
| 384 | bridge_type |= 0x20; |
| 385 | } |
| 386 | MCHBAR32(0x5f10) = bridge_type; |
| 387 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 388 | /* |
| 389 | * Set bit 0 of BIOS_RESET_CPL to indicate to the CPU |
| 390 | * that BIOS has initialized memory and power management |
| 391 | */ |
| 392 | bios_reset_cpl = MCHBAR8(BIOS_RESET_CPL); |
| 393 | bios_reset_cpl |= 1; |
| 394 | MCHBAR8(BIOS_RESET_CPL) = bios_reset_cpl; |
| 395 | printk(BIOS_DEBUG, "Set BIOS_RESET_CPL\n"); |
| 396 | |
| 397 | /* Configure turbo power limits 1ms after reset complete bit */ |
| 398 | mdelay(1); |
| 399 | set_power_limits(28); |
| 400 | |
Duncan Laurie | 77dbbac | 2012-06-25 09:51:59 -0700 | [diff] [blame] | 401 | /* |
| 402 | * CPUs with configurable TDP also need power limits set |
| 403 | * in MCHBAR. Use same values from MSR_PKG_POWER_LIMIT. |
| 404 | */ |
| 405 | if (cpu_config_tdp_levels()) { |
| 406 | msr_t msr = rdmsr(MSR_PKG_POWER_LIMIT); |
| 407 | MCHBAR32(0x59A0) = msr.lo; |
| 408 | MCHBAR32(0x59A4) = msr.hi; |
| 409 | } |
| 410 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 411 | /* Set here before graphics PM init */ |
| 412 | MCHBAR32(0x5500) = 0x00100001; |
| 413 | } |
| 414 | |
| 415 | static void northbridge_enable(device_t dev) |
| 416 | { |
| 417 | #if CONFIG_HAVE_ACPI_RESUME |
| 418 | switch (pci_read_config32(dev, SKPAD)) { |
| 419 | case 0xcafebabe: |
| 420 | printk(BIOS_DEBUG, "Normal boot.\n"); |
| 421 | acpi_slp_type=0; |
| 422 | break; |
| 423 | case 0xcafed00d: |
| 424 | printk(BIOS_DEBUG, "S3 Resume.\n"); |
| 425 | acpi_slp_type=3; |
| 426 | break; |
| 427 | default: |
| 428 | printk(BIOS_DEBUG, "Unknown boot method, assuming normal.\n"); |
| 429 | acpi_slp_type=0; |
| 430 | break; |
| 431 | } |
| 432 | #endif |
| 433 | } |
| 434 | |
| 435 | static struct pci_operations intel_pci_ops = { |
| 436 | .set_subsystem = intel_set_subsystem, |
| 437 | }; |
| 438 | |
| 439 | static struct device_operations mc_ops = { |
| 440 | .read_resources = mc_read_resources, |
| 441 | .set_resources = mc_set_resources, |
| 442 | .enable_resources = pci_dev_enable_resources, |
| 443 | .init = northbridge_init, |
| 444 | .enable = northbridge_enable, |
| 445 | .scan_bus = 0, |
| 446 | .ops_pci = &intel_pci_ops, |
Vladimir Serbinenko | 0a66991 | 2014-10-05 14:34:17 +0200 | [diff] [blame] | 447 | .acpi_fill_ssdt_generator = generate_cpu_entries, |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 448 | }; |
| 449 | |
Walter Murphy | 496f4a0 | 2012-04-23 11:08:03 -0700 | [diff] [blame] | 450 | static const struct pci_driver mc_driver_0100 __pci_driver = { |
| 451 | .ops = &mc_ops, |
| 452 | .vendor = PCI_VENDOR_ID_INTEL, |
| 453 | .device = 0x0100, |
| 454 | }; |
| 455 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 456 | static const struct pci_driver mc_driver __pci_driver = { |
| 457 | .ops = &mc_ops, |
| 458 | .vendor = PCI_VENDOR_ID_INTEL, |
| 459 | .device = 0x0104, /* Sandy bridge */ |
| 460 | }; |
| 461 | |
| 462 | static const struct pci_driver mc_driver_1 __pci_driver = { |
| 463 | .ops = &mc_ops, |
| 464 | .vendor = PCI_VENDOR_ID_INTEL, |
| 465 | .device = 0x0154, /* Ivy bridge */ |
| 466 | }; |
| 467 | |
| 468 | static void cpu_bus_init(device_t dev) |
| 469 | { |
| 470 | initialize_cpus(dev->link_list); |
| 471 | } |
| 472 | |
| 473 | static void cpu_bus_noop(device_t dev) |
| 474 | { |
| 475 | } |
| 476 | |
| 477 | static struct device_operations cpu_bus_ops = { |
| 478 | .read_resources = cpu_bus_noop, |
| 479 | .set_resources = cpu_bus_noop, |
| 480 | .enable_resources = cpu_bus_noop, |
| 481 | .init = cpu_bus_init, |
| 482 | .scan_bus = 0, |
| 483 | }; |
| 484 | |
| 485 | static void enable_dev(device_t dev) |
| 486 | { |
| 487 | /* Set the operations if it is a special bus type */ |
Stefan Reinauer | 4aff445 | 2013-02-12 14:17:15 -0800 | [diff] [blame] | 488 | if (dev->path.type == DEVICE_PATH_DOMAIN) { |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 489 | dev->ops = &pci_domain_ops; |
Stefan Reinauer | 0aa37c4 | 2013-02-12 15:20:54 -0800 | [diff] [blame] | 490 | } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 491 | dev->ops = &cpu_bus_ops; |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | struct chip_operations northbridge_intel_sandybridge_ops = { |
Stefan Reinauer | 9ca1c0a | 2012-07-25 16:10:36 -0700 | [diff] [blame] | 496 | CHIP_NAME("Intel i7 (SandyBridge/IvyBridge) integrated Northbridge") |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 497 | .enable_dev = enable_dev, |
| 498 | }; |