blob: e93e688ea777103cc360183254a59cbf8c4eb441 [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
108 /* Update the UPD data for MemoryInit */
109 upd->AddrMode = config->AddrMode;
110 upd->ChanMask = config->ChanMask;
111 upd->ChanWidth = config->ChanWidth;
112 upd->DramDensity = config->DramDensity;
113 upd->DramRonVal = config->DramRonVal;
114 upd->DramRttNomVal = config->DramRttNomVal;
115 upd->DramRttWrVal = config->DramRttWrVal;
116 upd->DramSpeed = config->DramSpeed;
117 upd->DramType = config->DramType;
118 upd->DramWidth = config->DramWidth;
119 upd->EccScrubBlkSize = config->EccScrubBlkSize;
120 upd->EccScrubInterval = config->EccScrubInterval;
121 upd->Flags = config->Flags;
122 upd->FspReservedMemoryLength = config->FspReservedMemoryLength;
123 upd->RankMask = config->RankMask;
124 upd->RmuBaseAddress = (uintptr_t)rmu_file;
125 upd->RmuLength = rmu_file_len;
Lee Leahy5e07a7e2016-08-06 09:51:35 -0700126 upd->SerialPortWriteChar = console_log_level(BIOS_SPEW)
127 ? (uintptr_t)fsp_write_line : 0;
Lee Leahy01728bb2016-07-20 08:58:58 -0700128 upd->SmmTsegSize = IS_ENABLED(CONFIG_HAVE_SMI_HANDLER) ?
129 config->SmmTsegSize : 0;
130 upd->SocRdOdtVal = config->SocRdOdtVal;
131 upd->SocWrRonVal = config->SocWrRonVal;
132 upd->SocWrSlewRate = config->SocWrSlewRate;
133 upd->SrInt = config->SrInt;
134 upd->SrTemp = config->SrTemp;
135 upd->tCL = config->tCL;
136 upd->tFAW = config->tFAW;
137 upd->tRAS = config->tRAS;
138 upd->tRRD = config->tRRD;
139 upd->tWTR = config->tWTR;
140}
141
142void soc_display_memory_init_params(const MEMORY_INIT_UPD *old,
143 MEMORY_INIT_UPD *new)
144{
145 /* Display the parameters for MemoryInit */
146 printk(BIOS_SPEW, "UPD values for MemoryInit at: 0x%p\n", new);
147 fsp_display_upd_value("AddrMode", sizeof(old->AddrMode),
148 old->AddrMode, new->AddrMode);
149 fsp_display_upd_value("ChanMask", sizeof(old->ChanMask),
150 old->ChanMask, new->ChanMask);
151 fsp_display_upd_value("ChanWidth", sizeof(old->ChanWidth),
152 old->ChanWidth, new->ChanWidth);
153 fsp_display_upd_value("DramDensity", sizeof(old->DramDensity),
154 old->DramDensity, new->DramDensity);
155 fsp_display_upd_value("DramRonVal", sizeof(old->DramRonVal),
156 old->DramRonVal, new->DramRonVal);
157 fsp_display_upd_value("DramRttNomVal", sizeof(old->DramRttNomVal),
158 old->DramRttNomVal, new->DramRttNomVal);
159 fsp_display_upd_value("DramRttWrVal", sizeof(old->DramRttWrVal),
160 old->DramRttWrVal, new->DramRttWrVal);
161 fsp_display_upd_value("DramSpeed", sizeof(old->DramSpeed),
162 old->DramSpeed, new->DramSpeed);
163 fsp_display_upd_value("DramType", sizeof(old->DramType),
164 old->DramType, new->DramType);
165 fsp_display_upd_value("DramWidth", sizeof(old->DramWidth),
166 old->DramWidth, new->DramWidth);
167 fsp_display_upd_value("EccScrubBlkSize", sizeof(old->EccScrubBlkSize),
168 old->EccScrubBlkSize, new->EccScrubBlkSize);
169 fsp_display_upd_value("EccScrubInterval", sizeof(old->EccScrubInterval),
170 old->EccScrubInterval, new->EccScrubInterval);
171 fsp_display_upd_value("Flags", sizeof(old->Flags), old->Flags,
172 new->Flags);
173 fsp_display_upd_value("FspReservedMemoryLength",
174 sizeof(old->FspReservedMemoryLength),
175 old->FspReservedMemoryLength, new->FspReservedMemoryLength);
176 fsp_display_upd_value("RankMask", sizeof(old->RankMask), old->RankMask,
177 new->RankMask);
178 fsp_display_upd_value("RmuBaseAddress", sizeof(old->RmuBaseAddress),
179 old->RmuBaseAddress, new->RmuBaseAddress);
180 fsp_display_upd_value("RmuLength", sizeof(old->RmuLength),
181 old->RmuLength, new->RmuLength);
Lee Leahy5e07a7e2016-08-06 09:51:35 -0700182 fsp_display_upd_value("SerialPortPollForChar",
183 sizeof(old->SerialPortPollForChar),
184 old->SerialPortPollForChar, new->SerialPortPollForChar);
185 fsp_display_upd_value("SerialPortReadChar",
186 sizeof(old->SerialPortReadChar),
187 old->SerialPortReadChar, new->SerialPortReadChar);
188 fsp_display_upd_value("SerialPortWriteChar",
189 sizeof(old->SerialPortWriteChar),
190 old->SerialPortWriteChar, new->SerialPortWriteChar);
Lee Leahy01728bb2016-07-20 08:58:58 -0700191 fsp_display_upd_value("SmmTsegSize", sizeof(old->SmmTsegSize),
192 old->SmmTsegSize, new->SmmTsegSize);
193 fsp_display_upd_value("SocRdOdtVal", sizeof(old->SocRdOdtVal),
194 old->SocRdOdtVal, new->SocRdOdtVal);
195 fsp_display_upd_value("SocWrRonVal", sizeof(old->SocWrRonVal),
196 old->SocWrRonVal, new->SocWrRonVal);
197 fsp_display_upd_value("SocWrSlewRate", sizeof(old->SocWrSlewRate),
198 old->SocWrSlewRate, new->SocWrSlewRate);
199 fsp_display_upd_value("SrInt", sizeof(old->SrInt), old->SrInt,
200 new->SrInt);
201 fsp_display_upd_value("SrTemp", sizeof(old->SrTemp), old->SrTemp,
202 new->SrTemp);
203 fsp_display_upd_value("tCL", sizeof(old->tCL), old->tCL, new->tCL);
204 fsp_display_upd_value("tFAW", sizeof(old->tFAW), old->tFAW, new->tFAW);
205 fsp_display_upd_value("tRAS", sizeof(old->tRAS), old->tRAS, new->tRAS);
206 fsp_display_upd_value("tRRD", sizeof(old->tRRD), old->tRRD, new->tRRD);
207 fsp_display_upd_value("tWTR", sizeof(old->tWTR), old->tWTR, new->tWTR);
208}
209
210void soc_after_ram_init(struct romstage_params *params)
211{
212 /* Disable the ROM shadow 0x000e0000 - 0x000fffff */
213 disable_rom_shadow();
214
215 /* Initialize the PCIe bridges */
216 pcie_init();
217}