blob: 3f264ff5ec6036e6d47e56401986a1781e8ddda5 [file] [log] [blame]
Duncan Lauriec88c54c2014-04-30 16:36:13 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Duncan Lauriec88c54c2014-04-30 16:36:13 -070014 */
15
16#include <stddef.h>
17#include <stdint.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070018#include <arch/cbfs.h>
Kyösti Mälkkia963acd2019-08-16 20:34:25 +030019#include <arch/romstage.h>
Kyösti Mälkkic641f7e2018-12-28 16:54:54 +020020#include <bootblock_common.h>
Julius Wernerb04cc6b2017-03-17 14:14:14 -070021#include <bootmode.h>
Arthur Heymans90cca542018-11-29 13:36:54 +010022#include <cbmem.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070023#include <console/console.h>
Arthur Heymans56f76872019-05-12 14:01:13 +020024#include <cpu/intel/romstage.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070025#include <cpu/x86/mtrr.h>
26#include <elog.h>
Kyösti Mälkki65e8f642016-06-27 11:27:56 +030027#include <program_loading.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070028#include <romstage_handoff.h>
Aaron Durbinbd74a4b2015-03-06 23:17:33 -060029#include <stage_cache.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070030#include <timestamp.h>
Arthur Heymanscadc70f2019-05-12 13:44:22 +020031#include <soc/gpio.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -070032#include <soc/me.h>
33#include <soc/pei_data.h>
34#include <soc/pm.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -070035#include <soc/romstage.h>
36#include <soc/spi.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070037
Kyösti Mälkki5bc641a2019-08-09 09:37:49 +030038void fill_postcar_frame(struct postcar_frame *pcf)
Arthur Heymans90cca542018-11-29 13:36:54 +010039{
Arthur Heymans90cca542018-11-29 13:36:54 +010040 uintptr_t top_of_ram;
41
Arthur Heymans90cca542018-11-29 13:36:54 +010042 /* Cache at least 8 MiB below the top of ram, and at most 8 MiB
43 * above top of the ram. This satisfies MTRR alignment requirement
44 * with different TSEG size configurations.
45 */
46 top_of_ram = ALIGN_DOWN((uintptr_t)cbmem_top(), 8*MiB);
Kyösti Mälkki5bc641a2019-08-09 09:37:49 +030047 postcar_frame_add_mtrr(pcf, top_of_ram - 8*MiB, 16*MiB,
Arthur Heymans90cca542018-11-29 13:36:54 +010048 MTRR_TYPE_WRBACK);
Arthur Heymans90cca542018-11-29 13:36:54 +010049}
50
Arthur Heymans56f76872019-05-12 14:01:13 +020051/* Entry from cpu/intel/car/romstage.c. */
Kyösti Mälkki157b1892019-08-16 14:02:25 +030052void mainboard_romstage_entry(void)
Duncan Lauriec88c54c2014-04-30 16:36:13 -070053{
Arthur Heymans5bb15f12018-12-22 16:02:25 +010054 struct romstage_params rp = { 0 };
Duncan Lauriec88c54c2014-04-30 16:36:13 -070055
56 post_code(0x30);
57
Duncan Lauriec88c54c2014-04-30 16:36:13 -070058 /* System Agent Early Initialization */
59 systemagent_early_init();
60
61 /* PCH Early Initialization */
62 pch_early_init();
63
Duncan Laurie61680272014-05-05 12:42:35 -050064 /* Get power state */
65 rp.power_state = fill_power_state();
66
Duncan Lauriec88c54c2014-04-30 16:36:13 -070067 /* Print useful platform information */
68 report_platform_info();
69
70 /* Set CPU frequency to maximum */
71 set_max_freq();
72
Arthur Heymanscadc70f2019-05-12 13:44:22 +020073 /* Initialize GPIOs */
74 init_gpios(mainboard_gpio_config);
75
Arthur Heymans97e9e562019-05-12 13:47:35 +020076 /* Fill in mainboard pei_date. */
77 mainboard_pre_raminit(&rp);
78
79 post_code(0x32);
80
81 timestamp_add_now(TS_BEFORE_INITRAM);
82
83 rp.pei_data.boot_mode = rp.power_state->prev_sleep_state;
84
85 if (CONFIG(ELOG_BOOT_COUNT)
86 && rp.power_state->prev_sleep_state != ACPI_S3)
87 boot_count_increment();
88
89 /* Print ME state before MRC */
90 intel_me_status();
91
92 /* Save ME HSIO version */
93 intel_me_hsio_version(&rp.power_state->hsio_version,
94 &rp.power_state->hsio_checksum);
95
96 /* Initialize RAM */
97 raminit(&rp.pei_data);
98
99 timestamp_add_now(TS_AFTER_INITRAM);
100
101 romstage_handoff_init(rp.power_state->prev_sleep_state == ACPI_S3);
102
103 mainboard_post_raminit(&rp);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700104}