blob: ad4b5b0b2f5106ff66dea8b561658eb0715b4de2 [file] [log] [blame]
Andrey Petrovb4831462016-02-25 17:42:25 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 Intel Corp.
5 * (Written by Alexandru Gagniuc <alexandrux.gagniuc@intel.com> for Intel Corp.)
6 * (Written by Andrey Petrov <andrey.petrov@intel.com> for Intel Corp.)
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; either version 2 of the License, or
11 * (at your option) any later version.
Martin Rothebabfad2016-04-10 11:09:16 -060012 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
Andrey Petrovb4831462016-02-25 17:42:25 -080017 */
18
Aaron Durbineebe0e02016-03-18 11:19:38 -050019#include <arch/cpu.h>
Ravi Sarawadi2da008a2016-04-27 15:20:14 -070020#include <arch/early_variables.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020021#include <device/pci_ops.h>
Andrey Petrovb4831462016-02-25 17:42:25 -080022#include <arch/symbols.h>
Ravi Sarawadi2da008a2016-04-27 15:20:14 -070023#include <assert.h>
Furquan Shaikhbae63832016-06-17 15:50:24 -070024#include <bootmode.h>
Andrey Petrovb4831462016-02-25 17:42:25 -080025#include <cbmem.h>
Patrick Rudolphf677d172018-10-01 19:17:11 +020026#include <cf9_reset.h>
Andrey Petrovb4831462016-02-25 17:42:25 -080027#include <console/console.h>
Andrey Petrovf748f832016-04-23 13:15:51 -070028#include <cpu/x86/mtrr.h>
Aaron Durbin5c9df702018-04-18 01:05:25 -060029#include <cpu/x86/pae.h>
John Su85376bf2018-11-06 10:51:43 +080030#include <delay.h>
Andrey Petrovb4831462016-02-25 17:42:25 -080031#include <device/pci_def.h>
Ravi Sarawadi2da008a2016-04-27 15:20:14 -070032#include <device/resource.h>
Andrey Petrovb4831462016-02-25 17:42:25 -080033#include <fsp/api.h>
Brandon Breitenstein135eae92016-09-30 13:57:12 -070034#include <fsp/memmap.h>
Andrey Petrovb4831462016-02-25 17:42:25 -080035#include <fsp/util.h>
Barnali Sarkar66fe0c42017-05-23 18:17:14 +053036#include <intelblocks/cpulib.h>
John Su85376bf2018-11-06 10:51:43 +080037#include <intelblocks/lpc_lib.h>
38#include <intelblocks/msr.h>
39#include <intelblocks/pmclib.h>
Subrata Banikce90c782017-08-30 16:53:20 +053040#include <intelblocks/smm.h>
Subrata Banik208587e2017-05-19 18:38:24 +053041#include <intelblocks/systemagent.h>
Aaron Durbindecd0622017-12-15 12:26:40 -070042#include <mrc_cache.h>
Shaunak Sahaa0122542016-10-10 12:34:28 -070043#include <soc/cpu.h>
Ravi Sarawadi2da008a2016-04-27 15:20:14 -070044#include <soc/iomap.h>
Aaron Durbin5c9df702018-04-18 01:05:25 -060045#include <soc/meminit.h>
Ravi Sarawadi2da008a2016-04-27 15:20:14 -070046#include <soc/pci_devs.h>
47#include <soc/pm.h>
Andrey Petrovb4831462016-02-25 17:42:25 -080048#include <soc/romstage.h>
John Su85376bf2018-11-06 10:51:43 +080049#include <soc/systemagent.h>
Furquan Shaikhd6c55592016-11-21 12:41:20 -080050#include <spi_flash.h>
Ravi Sarawadi2da008a2016-04-27 15:20:14 -070051#include <string.h>
Shaunak Sahaa0122542016-10-10 12:34:28 -070052#include <timer.h>
John Su85376bf2018-11-06 10:51:43 +080053#include <timestamp.h>
Shaunak Sahaa0122542016-10-10 12:34:28 -070054#include "chip.h"
Andrey Petrovb4831462016-02-25 17:42:25 -080055
Andrey Petrov96e9ff12016-11-04 16:18:30 -070056static const uint8_t hob_variable_guid[16] = {
57 0x7d, 0x14, 0x34, 0xa0, 0x0c, 0x69, 0x54, 0x41,
58 0x8d, 0xe6, 0xc0, 0x44, 0x64, 0x1d, 0xe9, 0x42,
59};
60
61static uint32_t fsp_version CAR_GLOBAL;
62
Furquan Shaikhc6814092016-05-04 16:03:36 -070063/* High Performance Event Timer Configuration */
64#define P2SB_HPTC 0x60
65#define P2SB_HPTC_ADDRESS_ENABLE (1 << 7)
66/*
67 * ADDRESS_SELECT ENCODING_RANGE
68 * 0 0xFED0 0000 - 0xFED0 03FF
69 * 1 0xFED0 1000 - 0xFED0 13FF
70 * 2 0xFED0 2000 - 0xFED0 23FF
71 * 3 0xFED0 3000 - 0xFED0 33FF
72 */
73#define P2SB_HPTC_ADDRESS_SELECT_0 (0 << 0)
74#define P2SB_HPTC_ADDRESS_SELECT_1 (1 << 0)
75#define P2SB_HPTC_ADDRESS_SELECT_2 (2 << 0)
76#define P2SB_HPTC_ADDRESS_SELECT_3 (3 << 0)
77
Andrey Petrovb4831462016-02-25 17:42:25 -080078/*
79 * Enables several BARs and devices which are needed for memory init
80 * - MCH_BASE_ADDR is needed in order to talk to the memory controller
Andrey Petrovb4831462016-02-25 17:42:25 -080081 * - HPET is enabled because FSP wants to store a pointer to global data in the
82 * HPET comparator register
83 */
84static void soc_early_romstage_init(void)
85{
Subrata Banik208587e2017-05-19 18:38:24 +053086 static const struct sa_mmio_descriptor soc_fixed_pci_resources[] = {
87 { MCHBAR, MCH_BASE_ADDRESS, MCH_BASE_SIZE, "MCHBAR" },
88 };
89
Jonathan Neuschäfer5268b762018-02-12 12:24:25 +010090 /* Set Fixed MMIO address into PCI configuration space */
Subrata Banik208587e2017-05-19 18:38:24 +053091 sa_set_pci_bar(soc_fixed_pci_resources,
92 ARRAY_SIZE(soc_fixed_pci_resources));
Andrey Petrovb4831462016-02-25 17:42:25 -080093
Andrey Petrovb4831462016-02-25 17:42:25 -080094 /* Enable decoding for HPET. Needed for FSP global pointer storage */
Subrata Banik2ee54db2017-03-05 12:37:00 +053095 pci_write_config8(PCH_DEV_P2SB, P2SB_HPTC, P2SB_HPTC_ADDRESS_SELECT_0 |
Furquan Shaikhc6814092016-05-04 16:03:36 -070096 P2SB_HPTC_ADDRESS_ENABLE);
Mario Scheithauer9e9cf272017-05-15 17:24:56 +020097
Ravi Sarawadiefa606b2017-08-04 16:26:09 -070098 if (IS_ENABLED(CONFIG_DRIVERS_UART_8250IO))
99 lpc_io_setup_comm_a_b();
Andrey Petrovb4831462016-02-25 17:42:25 -0800100}
101
John Su85376bf2018-11-06 10:51:43 +0800102/* Thermal throttle activation offset */
103static void configure_thermal_target(void)
104{
105 const struct device *dev = dev_find_slot(0, SA_DEVFN_ROOT);
106 if (!dev) {
107 printk(BIOS_ERR, "Could not find SOC devicetree config\n");
108 return;
109 }
110 const config_t *conf = dev->chip_info;
111 if (!dev->chip_info) {
112 printk(BIOS_ERR, "Could not find chip info\n");
113 return;
114 }
115 msr_t msr;
116
117 if (!conf->tcc_offset)
118 return;
119
120 msr = rdmsr(MSR_TEMPERATURE_TARGET);
121 /* Bits 27:24 */
122 msr.lo &= ~(TEMPERATURE_TCC_MASK << TEMPERATURE_TCC_SHIFT);
123 msr.lo |= (conf->tcc_offset & TEMPERATURE_TCC_MASK)
124 << TEMPERATURE_TCC_SHIFT;
125 wrmsr(MSR_TEMPERATURE_TARGET, msr);
126}
127
Shaunak Sahaa0122542016-10-10 12:34:28 -0700128/*
129 * Punit Initialization code. This all isn't documented, but
130 * this is the recipe.
131 */
132static bool punit_init(void)
133{
134 uint32_t reg;
135 uint32_t data;
136 struct stopwatch sw;
137
John Su85376bf2018-11-06 10:51:43 +0800138 /* Thermal throttle activation offset */
139 configure_thermal_target();
140
Shaunak Sahaa0122542016-10-10 12:34:28 -0700141 /*
142 * Software Core Disable Mask (P_CR_CORE_DISABLE_MASK_0_0_0_MCHBAR).
143 * Enable all cores here.
144 */
Subrata Banik208587e2017-05-19 18:38:24 +0530145 MCHBAR32(CORE_DISABLE_MASK) = 0x0;
Subrata Banikd18b53f2017-05-19 13:44:14 +0530146
Shaunak Sahaa0122542016-10-10 12:34:28 -0700147 /* P-Unit bring up */
Subrata Banik208587e2017-05-19 18:38:24 +0530148 reg = MCHBAR32(BIOS_RESET_CPL);
Shaunak Sahaa0122542016-10-10 12:34:28 -0700149 if (reg == 0xffffffff) {
150 /* P-unit not found */
Lee Leahya4447532017-03-09 10:45:02 -0800151 printk(BIOS_DEBUG, "Punit MMIO not available\n");
Shaunak Sahaa0122542016-10-10 12:34:28 -0700152 return false;
Lee Leahya4447532017-03-09 10:45:02 -0800153 }
154 /* Set Punit interrupt pin IPIN offset 3D */
Subrata Banik2ee54db2017-03-05 12:37:00 +0530155 pci_write_config8(SA_DEV_PUNIT, PCI_INTERRUPT_PIN, 0x2);
Shaunak Sahaa0122542016-10-10 12:34:28 -0700156
Lee Leahya4447532017-03-09 10:45:02 -0800157 /* Set PUINT IRQ to 24 and INTPIN LOCK */
Subrata Banik208587e2017-05-19 18:38:24 +0530158 MCHBAR32(PUNIT_THERMAL_DEVICE_IRQ) =
159 PUINT_THERMAL_DEVICE_IRQ_VEC_NUMBER |
160 PUINT_THERMAL_DEVICE_IRQ_LOCK;
Shaunak Sahaa0122542016-10-10 12:34:28 -0700161
Hannah Williams3ff14a02017-05-05 16:30:22 -0700162 if (!IS_ENABLED(CONFIG_SOC_INTEL_GLK)) {
163 data = MCHBAR32(0x7818);
164 data &= 0xFFFFE01F;
165 data |= 0x20 | 0x200;
166 MCHBAR32(0x7818) = data;
167 }
Shaunak Sahaa0122542016-10-10 12:34:28 -0700168
Lee Leahya4447532017-03-09 10:45:02 -0800169 /* Stage0 BIOS Reset Complete (RST_CPL) */
Subrata Banik208587e2017-05-19 18:38:24 +0530170 enable_bios_reset_cpl();
Shaunak Sahaa0122542016-10-10 12:34:28 -0700171
Lee Leahya4447532017-03-09 10:45:02 -0800172 /*
Subrata Banik208587e2017-05-19 18:38:24 +0530173 * Poll for bit 8 to check if PCODE has completed its action
174 * in reponse to BIOS Reset complete.
Lee Leahya4447532017-03-09 10:45:02 -0800175 * We wait here till 1 ms for the bit to get set.
176 */
177 stopwatch_init_msecs_expire(&sw, 1);
Subrata Banik208587e2017-05-19 18:38:24 +0530178 while (!(MCHBAR32(BIOS_RESET_CPL) & PCODE_INIT_DONE)) {
Lee Leahya4447532017-03-09 10:45:02 -0800179 if (stopwatch_expired(&sw)) {
Subrata Banik208587e2017-05-19 18:38:24 +0530180 printk(BIOS_DEBUG, "PCODE Init Done Failure\n");
Lee Leahya4447532017-03-09 10:45:02 -0800181 return false;
Shaunak Sahaa0122542016-10-10 12:34:28 -0700182 }
Lee Leahya4447532017-03-09 10:45:02 -0800183 udelay(100);
Shaunak Sahaa0122542016-10-10 12:34:28 -0700184 }
Subrata Banik208587e2017-05-19 18:38:24 +0530185
Shaunak Sahaa0122542016-10-10 12:34:28 -0700186 return true;
187}
188
Barnali Sarkar66fe0c42017-05-23 18:17:14 +0530189void set_max_freq(void)
190{
191 if (cpu_get_burst_mode_state() == BURST_MODE_UNAVAILABLE) {
192 /* Burst Mode has been factory configured as disabled
193 * and is not available in this physical processor
194 * package.
195 */
196 printk(BIOS_DEBUG, "Burst Mode is factory disabled\n");
197 return;
198 }
199
200 /* Enable burst mode */
201 cpu_enable_burst_mode();
202
203 /* Enable speed step. */
204 cpu_enable_eist();
205
206 /* Set P-State ratio */
207 cpu_set_p_state_to_turbo_ratio();
208}
209
Andrey Petrovb4831462016-02-25 17:42:25 -0800210asmlinkage void car_stage_entry(void)
211{
Aaron Durbineebe0e02016-03-18 11:19:38 -0500212 struct postcar_frame pcf;
Andrey Petrovf748f832016-04-23 13:15:51 -0700213 uintptr_t top_of_ram;
Aaron Durbinb4302502016-07-17 17:04:37 -0500214 bool s3wake;
Patrick Georgic6202e82017-10-25 18:47:27 -0400215 struct chipset_power_state *ps = pmc_get_power_state();
Brandon Breitenstein135eae92016-09-30 13:57:12 -0700216 void *smm_base;
Andrey Petrov96e9ff12016-11-04 16:18:30 -0700217 size_t smm_size, var_size;
218 const void *new_var_data;
Brandon Breitenstein135eae92016-09-30 13:57:12 -0700219 uintptr_t tseg_base;
Andrey Petrovb4831462016-02-25 17:42:25 -0800220
Alexandru Gagniuceaa0a172016-05-16 16:56:28 -0700221 timestamp_add_now(TS_START_ROMSTAGE);
Andrey Petrovb4831462016-02-25 17:42:25 -0800222
Andrey Petrovb4831462016-02-25 17:42:25 -0800223 soc_early_romstage_init();
Aaron Durbin108cd0e2016-04-11 15:01:58 -0500224
Alexandru Gagniuc766ba772016-05-16 16:52:54 -0700225 console_init();
226
Shaunak Saha93cdc8b2017-04-18 15:42:09 -0700227 s3wake = pmc_fill_power_state(ps) == ACPI_S3;
Lee Leahy9671faa2016-07-24 18:18:52 -0700228 fsp_memory_init(s3wake);
Shaunak Sahaa0122542016-10-10 12:34:28 -0700229
230 if (punit_init())
231 set_max_freq();
232 else
233 printk(BIOS_DEBUG, "Punit failed to initialize properly\n");
234
Andrey Petrov96e9ff12016-11-04 16:18:30 -0700235 /* Stash variable MRC data and let cache system update it later */
236 new_var_data = fsp_find_extension_hob_by_guid(hob_variable_guid,
237 &var_size);
238 if (new_var_data)
Aaron Durbin31be2c92016-12-03 22:08:20 -0600239 mrc_cache_stash_data(MRC_VARIABLE_DATA,
240 car_get_var(fsp_version), new_var_data,
241 var_size);
Andrey Petrov96e9ff12016-11-04 16:18:30 -0700242 else
243 printk(BIOS_ERR, "Failed to determine variable data\n");
244
Aaron Durbineebe0e02016-03-18 11:19:38 -0500245 if (postcar_frame_init(&pcf, 1*KiB))
246 die("Unable to initialize postcar frame.\n");
247
Ravi Sarawadi15f6f3a2016-08-18 13:31:29 -0700248 mainboard_save_dimm_info();
249
Andrey Petrovf748f832016-04-23 13:15:51 -0700250 /*
251 * We need to make sure ramstage will be run cached. At this point exact
252 * location of ramstage in cbmem is not known. Instruct postcar to cache
253 * 16 megs under cbmem top which is a safe bet to cover ramstage.
254 */
255 top_of_ram = (uintptr_t) cbmem_top();
256 /* cbmem_top() needs to be at least 16 MiB aligned */
257 assert(ALIGN_DOWN(top_of_ram, 16*MiB) == top_of_ram);
Lee Leahy07441b52017-03-09 10:59:25 -0800258 postcar_frame_add_mtrr(&pcf, top_of_ram - 16*MiB, 16*MiB,
259 MTRR_TYPE_WRBACK);
Andrey Petrovf748f832016-04-23 13:15:51 -0700260
Aaron Durbindfe614f2016-09-16 11:15:49 -0500261 /* Cache the memory-mapped boot media. */
Nico Huber6ea67752018-05-27 14:37:52 +0200262 postcar_frame_add_romcache(&pcf, MTRR_TYPE_WRPROT);
Aaron Durbindfe614f2016-09-16 11:15:49 -0500263
Brandon Breitenstein135eae92016-09-30 13:57:12 -0700264 /*
265 * Cache the TSEG region at the top of ram. This region is
266 * not restricted to SMM mode until SMM has been relocated.
267 * By setting the region to cacheable it provides faster access
268 * when relocating the SMM handler as well as using the TSEG
269 * region for other purposes.
270 */
Subrata Banikce90c782017-08-30 16:53:20 +0530271 smm_region_info(&smm_base, &smm_size);
Brandon Breitenstein135eae92016-09-30 13:57:12 -0700272 tseg_base = (uintptr_t)smm_base;
273 postcar_frame_add_mtrr(&pcf, tseg_base, smm_size, MTRR_TYPE_WRBACK);
274
Aaron Durbineebe0e02016-03-18 11:19:38 -0500275 run_postcar_phase(&pcf);
Andrey Petrovb4831462016-02-25 17:42:25 -0800276}
277
Brandon Breitensteinc31ba0e2016-07-27 17:34:45 -0700278static void fill_console_params(FSPM_UPD *mupd)
Andrey Petrovb4831462016-02-25 17:42:25 -0800279{
280 if (IS_ENABLED(CONFIG_CONSOLE_SERIAL)) {
Nico Hubera96e66a2018-11-11 02:51:14 +0100281 if (IS_ENABLED(CONFIG_INTEL_LPSS_UART_FOR_CONSOLE)) {
Mario Scheithauer9e9cf272017-05-15 17:24:56 +0200282 mupd->FspmConfig.SerialDebugPortDevice =
283 CONFIG_UART_FOR_CONSOLE;
284 /* use MMIO port type */
285 mupd->FspmConfig.SerialDebugPortType = 2;
286 /* use 4 byte register stride */
287 mupd->FspmConfig.SerialDebugPortStrideSize = 2;
288 /* used only for port type set to external */
289 mupd->FspmConfig.SerialDebugPortAddress = 0;
290 } else if (IS_ENABLED(CONFIG_DRIVERS_UART_8250IO)) {
291 /* use external UART for debug */
292 mupd->FspmConfig.SerialDebugPortDevice = 3;
293 /* use I/O port type */
294 mupd->FspmConfig.SerialDebugPortType = 1;
295 /* use 1 byte register stride */
296 mupd->FspmConfig.SerialDebugPortStrideSize = 0;
297 /* used only for port type set to external */
298 mupd->FspmConfig.SerialDebugPortAddress =
299 CONFIG_TTYS0_BASE;
300 }
Andrey Petrovb4831462016-02-25 17:42:25 -0800301 } else {
302 mupd->FspmConfig.SerialDebugPortType = 0;
303 }
304}
305
Aaron Durbin9c86aafe2017-04-26 15:02:51 -0500306static void check_full_retrain(const FSPM_UPD *mupd)
307{
308 struct chipset_power_state *ps;
309
310 if (mupd->FspmArchUpd.BootMode != FSP_BOOT_WITH_FULL_CONFIGURATION)
311 return;
312
Patrick Georgic6202e82017-10-25 18:47:27 -0400313 ps = pmc_get_power_state();
Aaron Durbin9c86aafe2017-04-26 15:02:51 -0500314
315 if (ps->gen_pmcon1 & WARM_RESET_STS) {
316 printk(BIOS_INFO, "Full retrain unsupported on warm reboot.\n");
Patrick Rudolphf677d172018-10-01 19:17:11 +0200317 full_reset();
Aaron Durbin9c86aafe2017-04-26 15:02:51 -0500318 }
319}
320
Pratik Prajapati4bc6edf2017-08-29 14:11:16 -0700321static void soc_memory_init_params(FSPM_UPD *mupd)
322{
323#if IS_ENABLED(CONFIG_SOC_INTEL_GLK)
324 /* Only for GLK */
325 const struct device *dev = dev_find_slot(0, PCH_DEVFN_LPC);
326 assert(dev != NULL);
327 const config_t *config = dev->chip_info;
328 FSP_M_CONFIG *m_cfg = &mupd->FspmConfig;
329
330 if (!config)
331 die("Can not find SoC devicetree\n");
332
333 m_cfg->PrmrrSize = config->PrmrrSize;
Shamile Khan3d9462a2018-03-21 14:43:42 -0700334
Srinidhi N Kaushik5af546c2018-05-14 23:33:55 -0700335 /*
336 * CpuMemoryTest in FSP tests 0 to 1M of the RAM after MRC init.
337 * With PAGING_IN_CACHE_AS_RAM enabled for GLK, there was no page
338 * table entry for this range which caused a page fault. Since this
339 * test is anyway not exhaustive, skipping the memory test in FSP.
Shamile Khan3d9462a2018-03-21 14:43:42 -0700340 */
Srinidhi N Kaushik5af546c2018-05-14 23:33:55 -0700341 m_cfg->SkipMemoryTestUpd = 1;
342
343 /*
344 * PCIe power sequence can be done from within FSP when provided
345 * with the GPIOs used for PERST to FSP. Since this is done in
346 * coreboot, skipping the PCIe power sequence done by FSP.
347 */
348 m_cfg->SkipPciePowerSequence = 1;
Pratik Prajapati4bc6edf2017-08-29 14:11:16 -0700349#endif
350}
351
Shaunak Saha6681cf02018-03-22 06:29:57 -0700352static void parse_devicetree_setting(FSPM_UPD *m_upd)
353{
354#if IS_ENABLED(CONFIG_SOC_INTEL_GLK)
355 DEVTREE_CONST struct device *dev = dev_find_slot(0, PCH_DEVFN_NPK);
356 if (!dev)
357 return;
358
359 m_upd->FspmConfig.TraceHubEn = dev->enabled;
360#endif
361}
362
Andrey Petrovf796c6e2016-11-18 14:57:51 -0800363void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version)
Andrey Petrovb4831462016-02-25 17:42:25 -0800364{
Aaron Durbin31be2c92016-12-03 22:08:20 -0600365 struct region_device rdev;
Andrey Petrov96e9ff12016-11-04 16:18:30 -0700366
Aaron Durbin9c86aafe2017-04-26 15:02:51 -0500367 check_full_retrain(mupd);
368
Andrey Petrovb4831462016-02-25 17:42:25 -0800369 fill_console_params(mupd);
Pratik Prajapati4bc6edf2017-08-29 14:11:16 -0700370
371 if (IS_ENABLED(CONFIG_SOC_INTEL_GLK))
372 soc_memory_init_params(mupd);
373
Andrey Petrovb4831462016-02-25 17:42:25 -0800374 mainboard_memory_init_params(mupd);
375
Shaunak Saha6681cf02018-03-22 06:29:57 -0700376 parse_devicetree_setting(mupd);
377
Andrey Petrovb4831462016-02-25 17:42:25 -0800378 /* Do NOT let FSP do any GPIO pad configuration */
Bora Guvendikde4b09f2016-05-09 17:18:26 -0700379 mupd->FspmConfig.PreMemGpioTablePtr = (uintptr_t) NULL;
Andrey Petrov24a594f2016-06-28 17:37:09 -0700380
381 /*
382 * Tell CSE we do not need to use Ring Buffer Protocol (RBP) to fetch
383 * firmware for us if we are using memory-mapped SPI. This lets CSE
384 * state machine transition to next boot state, so that it can function
385 * as designed.
386 */
Aaron Durbin16c173f2016-08-11 14:04:10 -0500387 mupd->FspmConfig.SkipCseRbp =
388 IS_ENABLED(CONFIG_BOOT_DEVICE_MEMORY_MAPPED);
Andrey Petrov0910f4e2016-10-03 16:05:20 -0700389
390 /*
391 * Converged Security Engine (CSE) has secure storage functionality.
392 * HECI2 device can be used to access that functionality. However, part
393 * of S3 resume flow involves resetting HECI2 which takes 136ms. Since
394 * coreboot does not use secure storage functionality, instruct FSP to
395 * skip HECI2 reset.
396 */
397 mupd->FspmConfig.EnableS3Heci2 = 0;
Andrey Petrov96e9ff12016-11-04 16:18:30 -0700398
399 /*
400 * Apollolake splits MRC cache into two parts: constant and variable.
401 * The constant part is not expected to change often and variable is.
402 * Currently variable part consists of parameters that change on cold
403 * boots such as scrambler seed and some memory controller registers.
404 * Scrambler seed is vital for S3 resume case because attempt to use
405 * wrong/missing key renders DRAM contents useless.
406 */
407
Aaron Durbin31be2c92016-12-03 22:08:20 -0600408 if (mrc_cache_get_current(MRC_VARIABLE_DATA, version, &rdev) == 0) {
409 /* Assume leaking is ok. */
410 assert(IS_ENABLED(CONFIG_BOOT_DEVICE_MEMORY_MAPPED));
411 mupd->FspmConfig.VariableNvsBufferPtr = rdev_mmap_full(&rdev);
Andrey Petrov96e9ff12016-11-04 16:18:30 -0700412 }
413
414 car_set_var(fsp_version, version);
Aaron Durbin5c9df702018-04-18 01:05:25 -0600415
Andrey Petrovb4831462016-02-25 17:42:25 -0800416}
417
Aaron Durbin64031672018-04-21 14:45:32 -0600418__weak
Brandon Breitensteinc31ba0e2016-07-27 17:34:45 -0700419void mainboard_memory_init_params(FSPM_UPD *mupd)
Andrey Petrovb4831462016-02-25 17:42:25 -0800420{
421 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
422}
Furquan Shaikhbae63832016-06-17 15:50:24 -0700423
Aaron Durbin64031672018-04-21 14:45:32 -0600424__weak
Ravi Sarawadi15f6f3a2016-08-18 13:31:29 -0700425void mainboard_save_dimm_info(void)
426{
427 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
428}