Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; version 2 of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | */ |
| 14 | |
| 15 | #include <stdint.h> |
| 16 | #include <console/console.h> |
| 17 | #include <cf9_reset.h> |
| 18 | #include <device/pci_ops.h> |
| 19 | #include <cpu/x86/lapic.h> |
| 20 | #include <timestamp.h> |
| 21 | #include <romstage_handoff.h> |
Angel Pons | 95de231 | 2020-02-17 13:08:53 +0100 | [diff] [blame] | 22 | #include "ironlake.h" |
Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 23 | #include <arch/romstage.h> |
| 24 | #include <device/pci_def.h> |
| 25 | #include <device/device.h> |
Angel Pons | 95de231 | 2020-02-17 13:08:53 +0100 | [diff] [blame] | 26 | #include <northbridge/intel/ironlake/chip.h> |
| 27 | #include <northbridge/intel/ironlake/raminit.h> |
Arthur Heymans | 2878c0b | 2019-10-14 18:42:00 +0200 | [diff] [blame] | 28 | #include <southbridge/intel/common/pmclib.h> |
Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 29 | #include <southbridge/intel/ibexpeak/pch.h> |
| 30 | #include <southbridge/intel/ibexpeak/me.h> |
Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 31 | |
| 32 | /* Platform has no romstage entry point under mainboard directory, |
| 33 | * so this one is named with prefix mainboard. |
| 34 | */ |
| 35 | void mainboard_romstage_entry(void) |
| 36 | { |
| 37 | u32 reg32; |
| 38 | int s3resume = 0; |
| 39 | u8 spd_addrmap[4] = {}; |
| 40 | |
| 41 | enable_lapic(); |
| 42 | |
| 43 | /* TODO, make this configurable */ |
Angel Pons | 95de231 | 2020-02-17 13:08:53 +0100 | [diff] [blame] | 44 | ironlake_early_initialization(IRONLAKE_MOBILE); |
Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 45 | |
Arthur Heymans | b9c9cd7 | 2019-10-10 15:06:33 +0200 | [diff] [blame] | 46 | early_pch_init(); |
| 47 | |
Arthur Heymans | 2878c0b | 2019-10-14 18:42:00 +0200 | [diff] [blame] | 48 | s3resume = southbridge_detect_s3_resume(); |
| 49 | if (s3resume) { |
| 50 | u8 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa2); |
Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 51 | if (!(reg8 & 0x20)) { |
Arthur Heymans | 2878c0b | 2019-10-14 18:42:00 +0200 | [diff] [blame] | 52 | s3resume = 0; |
Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 53 | printk(BIOS_DEBUG, "Bad resume from S3 detected.\n"); |
Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 54 | } |
| 55 | } |
| 56 | |
Arthur Heymans | cea4fd9 | 2019-10-03 08:54:35 +0200 | [diff] [blame] | 57 | early_thermal_init(); |
| 58 | |
| 59 | timestamp_add_now(TS_BEFORE_INITRAM); |
| 60 | |
| 61 | chipset_init(s3resume); |
| 62 | |
| 63 | mainboard_pre_raminit(); |
| 64 | |
| 65 | mainboard_get_spd_map(spd_addrmap); |
| 66 | |
| 67 | raminit(s3resume, spd_addrmap); |
| 68 | |
| 69 | timestamp_add_now(TS_AFTER_INITRAM); |
| 70 | |
| 71 | intel_early_me_status(); |
| 72 | |
| 73 | if (s3resume) { |
| 74 | /* Clear SLP_TYPE. This will break stage2 but |
| 75 | * we care for that when we get there. |
| 76 | */ |
| 77 | reg32 = inl(DEFAULT_PMBASE + 0x04); |
| 78 | outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04); |
| 79 | } |
| 80 | |
| 81 | romstage_handoff_init(s3resume); |
| 82 | } |