coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
fsp_params.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <arch/romstage.h>
4 #include <arch/symbols.h>
5 #include <console/console.h>
6 #include <cbmem.h>
7 #include "../chip.h"
8 #include <fsp/util.h>
9 #include <soc/iomap.h>
10 #include <soc/pci_devs.h>
11 #include <soc/pm.h>
12 #include <soc/romstage.h>
13 #include <soc/reg_access.h>
14 #include <soc/storage_test.h>
15 
17 {
18  bool s3wake;
19 
20  post_code(0x20);
21  console_init();
22 
23  if (CONFIG(STORAGE_TEST)) {
24  uint32_t bar;
25  pci_devfn_t dev;
26  uint32_t previous_bar;
27  uint16_t previous_command;
28 
29  /* Enable the SD/MMC controller and run the test. Restore
30  * the BAR and command registers upon completion.
31  */
32  dev = PCI_DEV(0, SD_MMC_DEV, SD_MMC_FUNC);
33  bar = storage_test_init(dev, &previous_bar, &previous_command);
34  storage_test(bar, 1);
35  storage_test_complete(dev, previous_bar, previous_command);
36  }
37 
38  /* Initialize DRAM */
39  s3wake = fill_power_state() == ACPI_S3;
40  fsp_memory_init(s3wake);
41 
42  /* Disable the ROM shadow 0x000e0000 - 0x000fffff */
44 
45  /* Initialize the PCIe bridges */
46  pcie_init();
47 }
48 
49 static struct chipset_power_state power_state;
50 
52 {
53  return &power_state;
54 }
55 
57 {
59  printk(BIOS_SPEW, "prev_sleep_state %d\n",
62 }
63 
65 {
66  FSPM_ARCH_UPD *aupd;
67  const struct soc_intel_quark_config *config;
68  void *rmu_data;
69  size_t rmu_data_len;
70  FSP_M_CONFIG *upd;
71 
72  /* Clear SMI and wake events */
74 
75  /* Locate the RMU data file in flash */
76  rmu_data = locate_rmu_file(&rmu_data_len);
77  if (!rmu_data)
79  "Microcode file (rmu.bin) not found.");
80 
81  /* Locate the configuration data from devicetree.cb */
83 
84  /* Update the architectural UPD values. */
85  aupd = &fspm_upd->FspmArchUpd;
86  aupd->BootLoaderTolumSize = cbmem_overhead_size();
87  aupd->StackBase = (uintptr_t)(CONFIG_FSP_ESRAM_LOC - aupd->StackSize);
88  aupd->BootMode = FSP_BOOT_WITH_FULL_CONFIGURATION;
89 
90  /* Display the ESRAM layout */
91  if (CONFIG(DISPLAY_ESRAM_LAYOUT)) {
92  printk(BIOS_SPEW, "\nESRAM Layout:\n\n");
94  "+-------------------+ 0x80080000 - ESRAM end\n");
95  printk(BIOS_SPEW, "| FSP binary |\n");
97  "+-------------------+ 0x%08x (CONFIG_FSP_ESRAM_LOC)\n",
98  CONFIG_FSP_ESRAM_LOC);
99  printk(BIOS_SPEW, "| FSP stack |\n");
100  printk(BIOS_SPEW, "+-------------------+ 0x%zx\n",
101  (size_t)aupd->StackBase);
102  printk(BIOS_SPEW, "| |\n");
103  printk(BIOS_SPEW, "+-------------------+ %p\n",
105  printk(BIOS_SPEW, "| coreboot data |\n");
106  printk(BIOS_SPEW, "+-------------------+ %p\n",
107  _ecar_stack);
108  printk(BIOS_SPEW, "| coreboot stack |\n");
110  "+-------------------+ 0x80000000 - ESRAM start\n\n");
111  }
112 
113  /* Update the UPD data for MemoryInit */
114  upd = &fspm_upd->FspmConfig;
115  upd->AddrMode = config->AddrMode;
116  upd->ChanMask = config->ChanMask;
117  upd->ChanWidth = config->ChanWidth;
118  upd->DramDensity = config->DramDensity;
119  upd->DramRonVal = config->DramRonVal;
120  upd->DramRttNomVal = config->DramRttNomVal;
121  upd->DramRttWrVal = config->DramRttWrVal;
122  upd->DramSpeed = config->DramSpeed;
123  upd->DramType = config->DramType;
124  upd->DramWidth = config->DramWidth;
125  upd->EccScrubBlkSize = config->EccScrubBlkSize;
126  upd->EccScrubInterval = config->EccScrubInterval;
127  upd->Flags = config->Flags;
128  upd->FspReservedMemoryLength = config->FspReservedMemoryLength;
129  upd->RankMask = config->RankMask;
130  upd->RmuBaseAddress = (uintptr_t)rmu_data;
131  upd->RmuLength = rmu_data_len;
132  upd->SerialPortWriteChar = !!console_log_level(BIOS_SPEW)
133  ? (uintptr_t)fsp_write_line : 0;
134  upd->SmmTsegSize = CONFIG(HAVE_SMI_HANDLER) ?
135  config->SmmTsegSize : 0;
136  upd->SocRdOdtVal = config->SocRdOdtVal;
137  upd->SocWrRonVal = config->SocWrRonVal;
138  upd->SocWrSlewRate = config->SocWrSlewRate;
139  upd->SrInt = config->SrInt;
140  upd->SrTemp = config->SrTemp;
141  upd->tCL = config->tCL;
142  upd->tFAW = config->tFAW;
143  upd->tRAS = config->tRAS;
144  upd->tRRD = config->tRRD;
145  upd->tWTR = config->tWTR;
146 }
void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version)
Definition: fsp_params.c:361
char _car_unallocated_start[]
char _ecar_stack[]
static size_t cbmem_overhead_size(void)
Definition: cbmem.h:38
#define printk(level,...)
Definition: stdlib.h:16
#define die_with_post_code(value, fmt,...)
Definition: console.h:21
asmlinkage size_t fsp_write_line(uint8_t *buffer, size_t number_of_bytes)
Definition: debug.c:10
@ CONFIG
Definition: dsi_common.h:201
@ FSP_BOOT_WITH_FULL_CONFIGURATION
Definition: api.h:19
void fsp_memory_init(bool s3wake)
Definition: memory_init.c:350
#define FSP_M_CONFIG
Definition: fsp_upd.h:8
@ ACPI_S3
Definition: acpi.h:1383
#define config_of_soc()
Definition: device.h:394
int console_log_level(int msg_level)
Definition: init.c:33
void console_init(void)
Definition: init.c:49
unsigned int version[2]
Definition: edid.c:55
#define BIOS_SPEW
BIOS_SPEW - Excessively verbose output.
Definition: loglevel.h:142
enum board_config config
Definition: memory.c:448
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
u32 pci_devfn_t
Definition: pci_type.h:8
#define post_code(value)
Definition: post_code.h:12
#define POST_INVALID_CBFS
Invalid or corrupt CBFS.
Definition: post_codes.h:330
int fill_power_state(void)
Definition: fsp_params.c:56
void mainboard_romstage_entry(void)
Definition: fsp_params.c:16
struct chipset_power_state * get_power_state(void)
Definition: fsp_params.c:51
static struct chipset_power_state power_state
Definition: fsp_params.c:49
static void pcie_init(struct device *dev)
Definition: pcie.c:29
#define SD_MMC_DEV
Definition: pci_devs.h:22
#define SD_MMC_FUNC
Definition: pci_devs.h:25
void * locate_rmu_file(size_t *rmu_file_len)
Definition: romstage.c:50
void clear_smi_and_wake_events(void)
Definition: romstage.c:20
void disable_rom_shadow(void)
Definition: romstage.c:33
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
unsigned long uintptr_t
Definition: stdint.h:21
void storage_test(uint32_t bar, int full_initialization)
Definition: storage_test.c:147
void storage_test_complete(struct device *dev, uint32_t previous_bar, uint16_t previous_command)
Definition: storage_test.c:65
uint32_t storage_test_init(struct device *dev, uint32_t *previous_bar, uint16_t *previous_command)
Definition: storage_test.c:32
uint32_t prev_sleep_state
Definition: pm.h:153