blob: aa728c708ec7c182ac0e105c4ffc540030026774 [file] [log] [blame]
Aaron Durbine6af4be2015-09-24 12:26:31 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2015 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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc.
18 */
19
Aaron Durbin909c5122015-09-29 17:41:30 -050020#include <arch/early_variables.h>
21#include <assets.h>
Aaron Durbine6af4be2015-09-24 12:26:31 -050022#include <console/console.h>
23#include <ec/google/chromeec/ec.h>
24#include <fsp/car.h>
Aaron Durbin909c5122015-09-29 17:41:30 -050025#include <fsp/util.h>
Aaron Durbine6af4be2015-09-24 12:26:31 -050026#include <soc/intel/common/util.h>
27#include <timestamp.h>
28
Aaron Durbin909c5122015-09-29 17:41:30 -050029FSP_INFO_HEADER *fih_car CAR_GLOBAL;
30
31/* Save FSP_INFO_HEADER for TempRamExit() call in assembly. */
32static inline void set_fih_car(FSP_INFO_HEADER *fih)
33{
34 /* This variable is written in the raw form because it's only
35 * ever accessed in code that that has the cache-as-ram enabled. The
36 * assembly routine which tears down cache-as-ram utilizes this
37 * variable for determining where to find FSP. */
38 fih_car = fih;
39}
40
Aaron Durbine6af4be2015-09-24 12:26:31 -050041asmlinkage void *cache_as_ram_main(struct cache_as_ram_params *car_params)
42{
43 /* Initialize timestamp book keeping only once. */
44 timestamp_init(car_params->tsc);
45
46 /* Call into pre-console init code then initialize console. */
47 car_soc_pre_console_init();
48 car_mainboard_pre_console_init();
49 console_init();
50
51 printk(BIOS_DEBUG, "FSP TempRamInit successful\n");
52
53 printk(BIOS_SPEW, "bist: 0x%08x\n", car_params->bist);
54 printk(BIOS_SPEW, "tsc: 0x%016llx\n", car_params->tsc);
55
56 if (car_params->bootloader_car_start != CONFIG_DCACHE_RAM_BASE ||
57 car_params->bootloader_car_end !=
58 (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE)) {
59 printk(BIOS_INFO, "CAR mismatch: %08x--%08x vs %08lx--%08lx\n",
60 CONFIG_DCACHE_RAM_BASE,
61 CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE,
62 (long)car_params->bootloader_car_start,
63 (long)car_params->bootloader_car_end);
64 }
65
66 car_soc_post_console_init();
67 car_mainboard_post_console_init();
68
69 /* Ensure the EC is in the right mode for recovery */
Aaron Durbin909c5122015-09-29 17:41:30 -050070 if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC) &&
71 !IS_ENABLED(CONFIG_SEPARATE_VERSTAGE))
Aaron Durbine6af4be2015-09-24 12:26:31 -050072 google_chromeec_early_init();
73
Aaron Durbin909c5122015-09-29 17:41:30 -050074 set_fih_car(car_params->fih);
75
Aaron Durbine6af4be2015-09-24 12:26:31 -050076 /* Return new stack value in ram back to assembly stub. */
77 return cache_as_ram_stage_main(car_params->fih);
78}
79
Aaron Durbin909c5122015-09-29 17:41:30 -050080/* Entry point taken when romstage is called after a separate verstage. */
81asmlinkage void *romstage_after_verstage(void)
82{
83 /* Need to locate the current FSP_INFO_HEADER. The cache-as-ram
84 * is still enabled. We can directly access work buffer here. */
85 FSP_INFO_HEADER *fih;
86 struct asset fsp = ASSET_INIT(ASSET_REFCODE, "fsp.bin");
87
88 console_init();
89
90 if (asset_locate(&fsp)) {
91 fih = NULL;
92 printk(BIOS_ERR, "Unable to locate %s\n", asset_name(&fsp));
93 } else
94 fih = find_fsp((uintptr_t)asset_mmap(&fsp));
95
96 set_fih_car(fih);
97
98 /* Return new stack value in ram back to assembly stub. */
99 return cache_as_ram_stage_main(fih);
100}
101
Aaron Durbine6af4be2015-09-24 12:26:31 -0500102asmlinkage void after_cache_as_ram(void *chipset_context)
103{
104 timestamp_add_now(TS_FSP_TEMP_RAM_EXIT_END);
105 printk(BIOS_DEBUG, "FspTempRamExit returned successfully\n");
106 soc_display_mtrrs();
107
108 after_cache_as_ram_stage();
109}
110
111void __attribute__((weak)) car_mainboard_pre_console_init(void)
112{
113}
114
115void __attribute__((weak)) car_soc_pre_console_init(void)
116{
117}
118
119void __attribute__((weak)) car_mainboard_post_console_init(void)
120{
121}
122
123void __attribute__((weak)) car_soc_post_console_init(void)
124{
125}