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