Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2010 coresystems GmbH |
| 5 | * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. |
| 6 | * Copyright (C) 2014 Vladimir Serbinenko |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | */ |
| 17 | |
| 18 | #include <stdint.h> |
| 19 | #include <console/console.h> |
| 20 | #include <cf9_reset.h> |
| 21 | #include <device/pci_ops.h> |
| 22 | #include <cpu/x86/lapic.h> |
| 23 | #include <timestamp.h> |
| 24 | #include <romstage_handoff.h> |
| 25 | #include "nehalem.h" |
| 26 | #include <arch/romstage.h> |
| 27 | #include <device/pci_def.h> |
| 28 | #include <device/device.h> |
| 29 | #include <northbridge/intel/nehalem/chip.h> |
| 30 | #include <northbridge/intel/nehalem/raminit.h> |
| 31 | #include <southbridge/intel/ibexpeak/pch.h> |
| 32 | #include <southbridge/intel/ibexpeak/me.h> |
Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 33 | |
| 34 | /* Platform has no romstage entry point under mainboard directory, |
| 35 | * so this one is named with prefix mainboard. |
| 36 | */ |
| 37 | void mainboard_romstage_entry(void) |
| 38 | { |
| 39 | u32 reg32; |
| 40 | int s3resume = 0; |
| 41 | u8 spd_addrmap[4] = {}; |
| 42 | |
| 43 | enable_lapic(); |
| 44 | |
| 45 | /* TODO, make this configurable */ |
| 46 | nehalem_early_initialization(NEHALEM_MOBILE); |
| 47 | |
Arthur Heymans | 3b452e0 | 2019-10-03 09:16:10 +0200 | [diff] [blame^] | 48 | early_pch_init(); |
Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 49 | |
| 50 | /* Initialize console device(s) */ |
| 51 | console_init(); |
| 52 | |
| 53 | /* Read PM1_CNT, DON'T CLEAR IT or raminit will fail! */ |
| 54 | reg32 = inl(DEFAULT_PMBASE + 0x04); |
| 55 | printk(BIOS_DEBUG, "PM1_CNT: %08x\n", reg32); |
| 56 | if (((reg32 >> 10) & 7) == 5) { |
| 57 | u8 reg8; |
| 58 | reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa2); |
| 59 | printk(BIOS_DEBUG, "a2: %02x\n", reg8); |
| 60 | if (!(reg8 & 0x20)) { |
| 61 | outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04); |
| 62 | printk(BIOS_DEBUG, "Bad resume from S3 detected.\n"); |
| 63 | } else { |
| 64 | if (acpi_s3_resume_allowed()) { |
| 65 | printk(BIOS_DEBUG, "Resume from S3 detected.\n"); |
| 66 | s3resume = 1; |
| 67 | } else { |
| 68 | printk(BIOS_DEBUG, |
| 69 | "Resume from S3 detected, but disabled.\n"); |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | /* Enable SMBUS. */ |
| 75 | enable_smbus(); |
| 76 | |
| 77 | early_thermal_init(); |
| 78 | |
| 79 | timestamp_add_now(TS_BEFORE_INITRAM); |
| 80 | |
| 81 | chipset_init(s3resume); |
| 82 | |
| 83 | mainboard_pre_raminit(); |
| 84 | |
| 85 | mainboard_get_spd_map(spd_addrmap); |
| 86 | |
| 87 | raminit(s3resume, spd_addrmap); |
| 88 | |
| 89 | timestamp_add_now(TS_AFTER_INITRAM); |
| 90 | |
| 91 | intel_early_me_status(); |
| 92 | |
| 93 | if (s3resume) { |
| 94 | /* Clear SLP_TYPE. This will break stage2 but |
| 95 | * we care for that when we get there. |
| 96 | */ |
| 97 | reg32 = inl(DEFAULT_PMBASE + 0x04); |
| 98 | outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04); |
| 99 | } |
| 100 | |
| 101 | romstage_handoff_init(s3resume); |
| 102 | } |