blob: 84fc5a55baffec88eef468cd3739410bc523df46 [file] [log] [blame]
Lee Leahy01728bb2016-07-20 08:58:58 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google Inc.
5 * Copyright (C) 2015-2016 Intel Corp.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16#define __SIMPLE_DEVICE__
17
18#include <arch/early_variables.h>
19#include <console/console.h>
20#include <cbfs.h>
21#include "../chip.h"
Lee Leahy102f6252016-07-25 07:41:54 -070022#include <fsp/memmap.h>
Lee Leahy01728bb2016-07-20 08:58:58 -070023#include <fsp/util.h>
Lee Leahy01728bb2016-07-20 08:58:58 -070024#include <soc/pci_devs.h>
Lee Leahy102f6252016-07-25 07:41:54 -070025#include <soc/QuarkNcSocId.h>
Lee Leahy01728bb2016-07-20 08:58:58 -070026#include <soc/romstage.h>
27#include <string.h>
28
Lee Leahya7650902016-12-28 11:43:10 -080029extern void asmlinkage light_sd_led(void);
30
Lee Leahy01728bb2016-07-20 08:58:58 -070031asmlinkage void *car_stage_c_entry(void)
32{
33 FSP_INFO_HEADER *fih;
34 struct cache_as_ram_params car_params = {0};
35 void *top_of_stack;
36
37 post_code(0x20);
38
39 /* Copy the FSP binary into ESRAM */
40 memcpy((void *)CONFIG_FSP_ESRAM_LOC, (void *)CONFIG_FSP_LOC,
41 0x00040000);
42
43 /* Locate the FSP header in ESRAM */
44 fih = find_fsp(CONFIG_FSP_ESRAM_LOC);
Lee Leahya7650902016-12-28 11:43:10 -080045 if (IS_ENABLED(CONFIG_ENABLE_DEBUG_LED_FINDFSP))
46 light_sd_led();
Lee Leahy01728bb2016-07-20 08:58:58 -070047
48 /* Start the early verstage/romstage code */
49 post_code(0x2A);
50 car_params.fih = fih;
51 top_of_stack = cache_as_ram_main(&car_params);
52
53 /* Initialize MTRRs and switch stacks after RAM initialized */
54 return top_of_stack;
55}
56
57static struct chipset_power_state power_state CAR_GLOBAL;
58
59struct chipset_power_state *get_power_state(void)
60{
61 return (struct chipset_power_state *)car_get_var_ptr(&power_state);
62}
63
64struct chipset_power_state *fill_power_state(void)
65{
66 struct chipset_power_state *ps = get_power_state();
67
68 ps->prev_sleep_state = 0;
69 printk(BIOS_SPEW, "prev_sleep_state %d\n", ps->prev_sleep_state);
70 return ps;
71}
72
Lee Leahy102f6252016-07-25 07:41:54 -070073size_t mmap_region_granularity(void)
74{
75 /* Align to 8 MiB by default */
76 return 8 << 20;
77}
78
Lee Leahy01728bb2016-07-20 08:58:58 -070079/* Initialize the UPD parameters for MemoryInit */
80void soc_memory_init_params(struct romstage_params *params,
81 MEMORY_INIT_UPD *upd)
82{
83 const struct device *dev;
84 const struct soc_intel_quark_config *config;
85 char *rmu_file;
86 size_t rmu_file_len;
87
88 /* Locate the configuration data from devicetree.cb */
89 dev = dev_find_slot(0, LPC_DEV_FUNC);
90 if (!dev) {
91 printk(BIOS_CRIT,
92 "Error! Device (PCI:0:%02x.%01x) not found, "
93 "soc_memory_init_params!\n", PCI_DEVICE_NUMBER_QNC_LPC,
94 PCI_FUNCTION_NUMBER_QNC_LPC);
95 return;
96 }
97 config = dev->chip_info;
98
99 /* Clear SMI and wake events */
100 clear_smi_and_wake_events();
101
102 /* Locate the RMU data file in flash */
103 rmu_file = cbfs_boot_map_with_leak("rmu.bin", CBFS_TYPE_RAW,
104 &rmu_file_len);
105 if (!rmu_file)
106 die("Microcode file (rmu.bin) not found.");
107
Lee Leahy66b0d552017-03-13 17:03:31 -0700108 /* Display the ESRAM layout */
109 if (IS_ENABLED(CONFIG_DISPLAY_ESRAM_LAYOUT)) {
110 printk(BIOS_SPEW, "\nESRAM Layout:\n\n");
111 printk(BIOS_SPEW,
112 "+-------------------+ 0x80080000 - ESRAM end\n");
113 if (_car_relocatable_data_end != (void *)0x80080000) {
114 printk(BIOS_SPEW, "| |\n");
115 printk(BIOS_SPEW, "+-------------------+ 0x%p\n",
116 _car_relocatable_data_end);
117 }
118 printk(BIOS_SPEW, "| coreboot data |\n");
119 printk(BIOS_SPEW, "+-------------------+ 0x%p\n",
120 _car_stack_end);
121 printk(BIOS_SPEW, "| coreboot stack |\n");
122 printk(BIOS_SPEW, "+-------------------+ 0x%p",
123 _car_stack_start);
124 if (IS_ENABLED(CONFIG_SEPARATE_VERSTAGE)) {
125 printk(BIOS_SPEW, "\n");
126 printk(BIOS_SPEW, "| vboot data |\n");
127 printk(BIOS_SPEW, "+-------------------+ 0x%08x",
128 CONFIG_DCACHE_RAM_BASE);
129 }
130 printk(BIOS_SPEW, " (CONFIG_DCACHE_RAM_BASE)\n");
131
132 printk(BIOS_SPEW, "| FSP data |\n");
133 printk(BIOS_SPEW, "+-------------------+\n");
134 printk(BIOS_SPEW, "| FSP stack |\n");
135 printk(BIOS_SPEW, "+-------------------+\n");
136 printk(BIOS_SPEW, "| FSP binary |\n");
137 printk(BIOS_SPEW,
138 "+-------------------+ 0x80000000 - ESRAM start\n\n");
139 }
140
Lee Leahy01728bb2016-07-20 08:58:58 -0700141 /* Update the UPD data for MemoryInit */
142 upd->AddrMode = config->AddrMode;
143 upd->ChanMask = config->ChanMask;
144 upd->ChanWidth = config->ChanWidth;
145 upd->DramDensity = config->DramDensity;
146 upd->DramRonVal = config->DramRonVal;
147 upd->DramRttNomVal = config->DramRttNomVal;
148 upd->DramRttWrVal = config->DramRttWrVal;
149 upd->DramSpeed = config->DramSpeed;
150 upd->DramType = config->DramType;
151 upd->DramWidth = config->DramWidth;
152 upd->EccScrubBlkSize = config->EccScrubBlkSize;
153 upd->EccScrubInterval = config->EccScrubInterval;
154 upd->Flags = config->Flags;
155 upd->FspReservedMemoryLength = config->FspReservedMemoryLength;
156 upd->RankMask = config->RankMask;
157 upd->RmuBaseAddress = (uintptr_t)rmu_file;
158 upd->RmuLength = rmu_file_len;
Lee Leahy5e07a7e2016-08-06 09:51:35 -0700159 upd->SerialPortWriteChar = console_log_level(BIOS_SPEW)
160 ? (uintptr_t)fsp_write_line : 0;
Lee Leahy01728bb2016-07-20 08:58:58 -0700161 upd->SmmTsegSize = IS_ENABLED(CONFIG_HAVE_SMI_HANDLER) ?
162 config->SmmTsegSize : 0;
163 upd->SocRdOdtVal = config->SocRdOdtVal;
164 upd->SocWrRonVal = config->SocWrRonVal;
165 upd->SocWrSlewRate = config->SocWrSlewRate;
166 upd->SrInt = config->SrInt;
167 upd->SrTemp = config->SrTemp;
168 upd->tCL = config->tCL;
169 upd->tFAW = config->tFAW;
170 upd->tRAS = config->tRAS;
171 upd->tRRD = config->tRRD;
172 upd->tWTR = config->tWTR;
173}
174
175void soc_display_memory_init_params(const MEMORY_INIT_UPD *old,
176 MEMORY_INIT_UPD *new)
177{
178 /* Display the parameters for MemoryInit */
179 printk(BIOS_SPEW, "UPD values for MemoryInit at: 0x%p\n", new);
180 fsp_display_upd_value("AddrMode", sizeof(old->AddrMode),
181 old->AddrMode, new->AddrMode);
182 fsp_display_upd_value("ChanMask", sizeof(old->ChanMask),
183 old->ChanMask, new->ChanMask);
184 fsp_display_upd_value("ChanWidth", sizeof(old->ChanWidth),
185 old->ChanWidth, new->ChanWidth);
186 fsp_display_upd_value("DramDensity", sizeof(old->DramDensity),
187 old->DramDensity, new->DramDensity);
188 fsp_display_upd_value("DramRonVal", sizeof(old->DramRonVal),
189 old->DramRonVal, new->DramRonVal);
190 fsp_display_upd_value("DramRttNomVal", sizeof(old->DramRttNomVal),
191 old->DramRttNomVal, new->DramRttNomVal);
192 fsp_display_upd_value("DramRttWrVal", sizeof(old->DramRttWrVal),
193 old->DramRttWrVal, new->DramRttWrVal);
194 fsp_display_upd_value("DramSpeed", sizeof(old->DramSpeed),
195 old->DramSpeed, new->DramSpeed);
196 fsp_display_upd_value("DramType", sizeof(old->DramType),
197 old->DramType, new->DramType);
198 fsp_display_upd_value("DramWidth", sizeof(old->DramWidth),
199 old->DramWidth, new->DramWidth);
200 fsp_display_upd_value("EccScrubBlkSize", sizeof(old->EccScrubBlkSize),
201 old->EccScrubBlkSize, new->EccScrubBlkSize);
202 fsp_display_upd_value("EccScrubInterval", sizeof(old->EccScrubInterval),
203 old->EccScrubInterval, new->EccScrubInterval);
204 fsp_display_upd_value("Flags", sizeof(old->Flags), old->Flags,
205 new->Flags);
206 fsp_display_upd_value("FspReservedMemoryLength",
207 sizeof(old->FspReservedMemoryLength),
208 old->FspReservedMemoryLength, new->FspReservedMemoryLength);
209 fsp_display_upd_value("RankMask", sizeof(old->RankMask), old->RankMask,
210 new->RankMask);
211 fsp_display_upd_value("RmuBaseAddress", sizeof(old->RmuBaseAddress),
212 old->RmuBaseAddress, new->RmuBaseAddress);
213 fsp_display_upd_value("RmuLength", sizeof(old->RmuLength),
214 old->RmuLength, new->RmuLength);
Lee Leahy5e07a7e2016-08-06 09:51:35 -0700215 fsp_display_upd_value("SerialPortPollForChar",
216 sizeof(old->SerialPortPollForChar),
217 old->SerialPortPollForChar, new->SerialPortPollForChar);
218 fsp_display_upd_value("SerialPortReadChar",
219 sizeof(old->SerialPortReadChar),
220 old->SerialPortReadChar, new->SerialPortReadChar);
221 fsp_display_upd_value("SerialPortWriteChar",
222 sizeof(old->SerialPortWriteChar),
223 old->SerialPortWriteChar, new->SerialPortWriteChar);
Lee Leahy01728bb2016-07-20 08:58:58 -0700224 fsp_display_upd_value("SmmTsegSize", sizeof(old->SmmTsegSize),
225 old->SmmTsegSize, new->SmmTsegSize);
226 fsp_display_upd_value("SocRdOdtVal", sizeof(old->SocRdOdtVal),
227 old->SocRdOdtVal, new->SocRdOdtVal);
228 fsp_display_upd_value("SocWrRonVal", sizeof(old->SocWrRonVal),
229 old->SocWrRonVal, new->SocWrRonVal);
230 fsp_display_upd_value("SocWrSlewRate", sizeof(old->SocWrSlewRate),
231 old->SocWrSlewRate, new->SocWrSlewRate);
232 fsp_display_upd_value("SrInt", sizeof(old->SrInt), old->SrInt,
233 new->SrInt);
234 fsp_display_upd_value("SrTemp", sizeof(old->SrTemp), old->SrTemp,
235 new->SrTemp);
236 fsp_display_upd_value("tCL", sizeof(old->tCL), old->tCL, new->tCL);
237 fsp_display_upd_value("tFAW", sizeof(old->tFAW), old->tFAW, new->tFAW);
238 fsp_display_upd_value("tRAS", sizeof(old->tRAS), old->tRAS, new->tRAS);
239 fsp_display_upd_value("tRRD", sizeof(old->tRRD), old->tRRD, new->tRRD);
240 fsp_display_upd_value("tWTR", sizeof(old->tWTR), old->tWTR, new->tWTR);
241}
242
243void soc_after_ram_init(struct romstage_params *params)
244{
245 /* Disable the ROM shadow 0x000e0000 - 0x000fffff */
246 disable_rom_shadow();
247
248 /* Initialize the PCIe bridges */
249 pcie_init();
250}