aboutsummaryrefslogtreecommitdiff
path: root/src/soc/intel/alderlake/romstage
diff options
context:
space:
mode:
authorSubrata Banik <subrata.banik@intel.com>2020-09-09 13:34:18 +0530
committerSubrata Banik <subrata.banik@intel.com>2020-09-15 15:13:50 +0000
commit292afef2fbb5eaf46dd3efa0c9a54c125f71ad1a (patch)
tree28db1e208bf70d4b58eed14c9f3d120c217bd0d7 /src/soc/intel/alderlake/romstage
parenteb17b475c8be292e6d2b9caa4cef3dd87f21ee42 (diff)
soc/intel/alderlake/romstage: Do initial SoC commit till romstage
List of changes: 1. Add required SoC programming till romstage 2. Include only required headers into include/soc 3. Add SA EDS document number and chapter number 4. Fill required FSP-M UPD to call FSP-M API Change-Id: I4473aed27363c22e92e66cc6770cb55aae83e75c Signed-off-by: Subrata Banik <subrata.banik@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/45192 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'src/soc/intel/alderlake/romstage')
-rw-r--r--src/soc/intel/alderlake/romstage/Makefile.inc7
-rw-r--r--src/soc/intel/alderlake/romstage/fsp_params.c174
-rw-r--r--src/soc/intel/alderlake/romstage/pch.c10
-rw-r--r--src/soc/intel/alderlake/romstage/romstage.c137
-rw-r--r--src/soc/intel/alderlake/romstage/systemagent.c35
5 files changed, 363 insertions, 0 deletions
diff --git a/src/soc/intel/alderlake/romstage/Makefile.inc b/src/soc/intel/alderlake/romstage/Makefile.inc
new file mode 100644
index 0000000000..a1a6c6638d
--- /dev/null
+++ b/src/soc/intel/alderlake/romstage/Makefile.inc
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+romstage-y += fsp_params.c
+romstage-y += ../../../../cpu/intel/car/romstage.c
+romstage-y += romstage.c
+romstage-y += pch.c
+romstage-y += systemagent.c
diff --git a/src/soc/intel/alderlake/romstage/fsp_params.c b/src/soc/intel/alderlake/romstage/fsp_params.c
new file mode 100644
index 0000000000..55980a8790
--- /dev/null
+++ b/src/soc/intel/alderlake/romstage/fsp_params.c
@@ -0,0 +1,174 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <assert.h>
+#include <console/console.h>
+#include <cpu/x86/msr.h>
+#include <device/device.h>
+#include <fsp/util.h>
+#include <intelblocks/cpulib.h>
+#include <intelblocks/mp_init.h>
+#include <soc/gpio_soc_defs.h>
+#include <soc/iomap.h>
+#include <soc/msr.h>
+#include <soc/pci_devs.h>
+#include <soc/romstage.h>
+#include <soc/soc_chip.h>
+#include <string.h>
+
+static void soc_memory_init_params(FSP_M_CONFIG *m_cfg,
+ const struct soc_intel_alderlake_dev_config *config)
+{
+ unsigned int i;
+ uint32_t mask = 0;
+ const struct device *dev;
+
+ /*
+ * If IGD is enabled, set IGD stolen size to 60MB.
+ * Otherwise, skip IGD init in FSP.
+ */
+ dev = pcidev_path_on_root(SA_DEVFN_IGD);
+ m_cfg->InternalGfx = is_dev_enabled(dev);
+ m_cfg->IgdDvmt50PreAlloc = m_cfg->InternalGfx ? IGD_SM_60MB : 0;
+
+ m_cfg->TsegSize = CONFIG_SMM_TSEG_SIZE;
+ m_cfg->SaGv = config->SaGv;
+ m_cfg->RMT = config->RMT;
+
+ /* CpuRatio Settings */
+ if (config->cpu_ratio_override)
+ m_cfg->CpuRatio = config->cpu_ratio_override;
+ else
+ /* Set CpuRatio to match existing MSR value */
+ m_cfg->CpuRatio = (rdmsr(MSR_FLEX_RATIO).lo >> 8) & 0xff;
+
+ for (i = 0; i < ARRAY_SIZE(config->PcieRpEnable); i++) {
+ if (config->PcieRpEnable[i])
+ mask |= (1 << i);
+ }
+ m_cfg->PcieRpEnableMask = mask;
+
+ memcpy(m_cfg->PcieClkSrcUsage, config->PcieClkSrcUsage,
+ sizeof(config->PcieClkSrcUsage));
+
+ memcpy(m_cfg->PcieClkSrcClkReq, config->PcieClkSrcClkReq,
+ sizeof(config->PcieClkSrcClkReq));
+
+ m_cfg->PrmrrSize = get_prmrr_size();
+ m_cfg->EnableC6Dram = config->enable_c6dram;
+ /* Disable BIOS Guard */
+ m_cfg->BiosGuard = 0;
+
+ /* UART Debug Log */
+ m_cfg->PcdDebugInterfaceFlags = CONFIG(DRIVERS_UART_8250IO) ?
+ DEBUG_INTERFACE_UART_8250IO : DEBUG_INTERFACE_LPSS_SERIAL_IO;
+ if (CONFIG(DRIVERS_UART_8250IO))
+ m_cfg->PcdIsaSerialUartBase = ISA_SERIAL_BASE_ADDR_3F8;
+ m_cfg->SerialIoUartDebugMode = PchSerialIoSkipInit;
+ m_cfg->SerialIoUartDebugControllerNumber = CONFIG_UART_FOR_CONSOLE;
+
+ /* DP port config */
+ m_cfg->DdiPortAConfig = config->DdiPortAConfig;
+ m_cfg->DdiPortBConfig = config->DdiPortBConfig;
+ m_cfg->DdiPortAHpd = config->DdiPortAHpd;
+ m_cfg->DdiPortBHpd = config->DdiPortBHpd;
+ m_cfg->DdiPortCHpd = config->DdiPortCHpd;
+ m_cfg->DdiPort1Hpd = config->DdiPort1Hpd;
+ m_cfg->DdiPort2Hpd = config->DdiPort2Hpd;
+ m_cfg->DdiPort3Hpd = config->DdiPort3Hpd;
+ m_cfg->DdiPort4Hpd = config->DdiPort4Hpd;
+ m_cfg->DdiPortADdc = config->DdiPortADdc;
+ m_cfg->DdiPortBDdc = config->DdiPortBDdc;
+ m_cfg->DdiPortCDdc = config->DdiPortCDdc;
+ m_cfg->DdiPort1Ddc = config->DdiPort1Ddc;
+ m_cfg->DdiPort2Ddc = config->DdiPort2Ddc;
+ m_cfg->DdiPort3Ddc = config->DdiPort3Ddc;
+ m_cfg->DdiPort4Ddc = config->DdiPort4Ddc;
+
+ /* Image clock: disable all clocks for bypassing FSP pin mux */
+ memset(m_cfg->ImguClkOutEn, 0, sizeof(m_cfg->ImguClkOutEn));
+
+ /* Enable Hyper Threading */
+ m_cfg->HyperThreading = 1;
+ /* Disable Lock PCU Thermal Management registers */
+ m_cfg->LockPTMregs = 0;
+ /* Channel Hash Mask:0x0001=BIT6 set(Minimal), 0x3FFF=BIT[19:6] set(Maximum) */
+ m_cfg->ChHashMask = 0x30CC;
+ /* Enable SMBus controller */
+ dev = pcidev_path_on_root(PCH_DEVFN_SMBUS);
+ m_cfg->SmbusEnable = is_dev_enabled(dev);
+ /* Set debug probe type */
+ m_cfg->PlatformDebugConsent = CONFIG_SOC_INTEL_ALDERLAKE_DEBUG_CONSENT;
+
+ /* Audio: HDAUDIO_LINK_MODE I2S/SNDW */
+ m_cfg->PchHdaDspEnable = config->PchHdaDspEnable;
+ m_cfg->PchHdaAudioLinkHdaEnable = config->PchHdaAudioLinkHdaEnable;
+ memcpy(m_cfg->PchHdaAudioLinkDmicEnable, config->PchHdaAudioLinkDmicEnable,
+ sizeof(m_cfg->PchHdaAudioLinkDmicEnable));
+ memcpy(m_cfg->PchHdaAudioLinkSspEnable, config->PchHdaAudioLinkSspEnable,
+ sizeof(m_cfg->PchHdaAudioLinkSspEnable));
+ memcpy(m_cfg->PchHdaAudioLinkSndwEnable, config->PchHdaAudioLinkSndwEnable,
+ sizeof(m_cfg->PchHdaAudioLinkSndwEnable));
+ m_cfg->PchHdaIDispLinkTmode = config->PchHdaIDispLinkTmode;
+ m_cfg->PchHdaIDispLinkFrequency = config->PchHdaIDispLinkFrequency;
+ m_cfg->PchHdaIDispCodecDisconnect = config->PchHdaIDispCodecDisconnect;
+
+ /* ISH */
+ dev = pcidev_path_on_root(PCH_DEVFN_ISH);
+ m_cfg->PchIshEnable = is_dev_enabled(dev);
+
+ /* Tcss USB */
+ dev = pcidev_path_on_root(SA_DEVFN_TCSS_XHCI);
+ m_cfg->TcssXhciEn = is_dev_enabled(dev);
+
+ dev = pcidev_path_on_root(SA_DEVFN_TCSS_XDCI);
+ m_cfg->TcssXdciEn = is_dev_enabled(dev);
+
+ /* TCSS DMA */
+ dev = pcidev_path_on_root(SA_DEVFN_TCSS_DMA0);
+ m_cfg->TcssDma0En = is_dev_enabled(dev);
+
+ dev = pcidev_path_on_root(SA_DEVFN_TCSS_DMA1);
+ m_cfg->TcssDma1En = is_dev_enabled(dev);
+
+ /* USB4/TBT */
+ dev = pcidev_path_on_root(SA_DEVFN_TBT0);
+ m_cfg->TcssItbtPcie0En = is_dev_enabled(dev);
+
+ dev = pcidev_path_on_root(SA_DEVFN_TBT1);
+ m_cfg->TcssItbtPcie1En = is_dev_enabled(dev);
+
+ dev = pcidev_path_on_root(SA_DEVFN_TBT2);
+ m_cfg->TcssItbtPcie2En = is_dev_enabled(dev);
+
+ dev = pcidev_path_on_root(SA_DEVFN_TBT3);
+ m_cfg->TcssItbtPcie3En = is_dev_enabled(dev);
+
+ /* Vt-D config */
+ /* Disable VT-d support for pre-QS platform */
+ m_cfg->VtdDisable = 1;
+
+ /* Change VmxEnable UPD value according to ENABLE_VMX Kconfig */
+ m_cfg->VmxEnable = CONFIG(ENABLE_VMX);
+ /* Skip CPU replacement check */
+ m_cfg->SkipCpuReplacementCheck = !config->CpuReplacementCheck;
+
+ /* Skip CPU side PCIe enablement in FSP if device is disabled in devicetree */
+ dev = pcidev_path_on_root(SA_DEVFN_CPU_PCIE);
+ m_cfg->CpuPcieRpEnableMask = is_dev_enabled(dev);
+}
+
+void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version)
+{
+ const struct soc_intel_alderlake_dev_config *config;
+ FSP_M_CONFIG *m_cfg = &mupd->FspmConfig;
+
+ config = config_of_soc();
+
+ soc_memory_init_params(m_cfg, config);
+ mainboard_memory_init_params(mupd);
+}
+
+__weak void mainboard_memory_init_params(FSPM_UPD *mupd)
+{
+ printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
+}
diff --git a/src/soc/intel/alderlake/romstage/pch.c b/src/soc/intel/alderlake/romstage/pch.c
new file mode 100644
index 0000000000..bec6150374
--- /dev/null
+++ b/src/soc/intel/alderlake/romstage/pch.c
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <intelblocks/smbus.h>
+#include <soc/romstage.h>
+
+void romstage_pch_init(void)
+{
+ /* Program SMBus base address and enable it */
+ smbus_common_init();
+}
diff --git a/src/soc/intel/alderlake/romstage/romstage.c b/src/soc/intel/alderlake/romstage/romstage.c
new file mode 100644
index 0000000000..9f4fbb67b0
--- /dev/null
+++ b/src/soc/intel/alderlake/romstage/romstage.c
@@ -0,0 +1,137 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <arch/romstage.h>
+#include <cbmem.h>
+#include <console/console.h>
+#include <fsp/util.h>
+#include <intelblocks/cfg.h>
+#include <intelblocks/cse.h>
+#include <intelblocks/pmclib.h>
+#include <memory_info.h>
+#include <soc/intel/common/smbios.h>
+#include <soc/iomap.h>
+#include <soc/pm.h>
+#include <soc/romstage.h>
+#include <soc/soc_chip.h>
+#include <string.h>
+
+#define FSP_SMBIOS_MEMORY_INFO_GUID \
+{ \
+ 0xd4, 0x71, 0x20, 0x9b, 0x54, 0xb0, 0x0c, 0x4e, \
+ 0x8d, 0x09, 0x11, 0xcf, 0x8b, 0x9f, 0x03, 0x23 \
+}
+
+__weak const char *mainboard_get_dram_part_num(size_t *len)
+{
+ /* Default weak implementation, no need to override part number. */
+ return NULL;
+}
+
+/* Save the DIMM information for SMBIOS table 17 */
+static void save_dimm_info(void)
+{
+ int node, channel, dimm, dimm_max, index;
+ size_t hob_size;
+ const CONTROLLER_INFO *ctrlr_info;
+ const CHANNEL_INFO *channel_info;
+ const DIMM_INFO *src_dimm;
+ struct dimm_info *dest_dimm;
+ struct memory_info *mem_info;
+ const MEMORY_INFO_DATA_HOB *meminfo_hob;
+ const uint8_t smbios_memory_info_guid[sizeof(EFI_GUID)] = FSP_SMBIOS_MEMORY_INFO_GUID;
+ const uint8_t *serial_num;
+ const char *dram_part_num = NULL;
+ size_t dram_part_num_len;
+
+ /* Locate the memory info HOB, presence validated by raminit */
+ meminfo_hob = fsp_find_extension_hob_by_guid(
+ smbios_memory_info_guid,
+ &hob_size);
+ if (meminfo_hob == NULL || hob_size == 0) {
+ printk(BIOS_ERR, "SMBIOS MEMORY_INFO_DATA_HOB not found\n");
+ return;
+ }
+
+ /*
+ * Allocate CBMEM area for DIMM information used to populate SMBIOS
+ * table 17
+ */
+ mem_info = cbmem_add(CBMEM_ID_MEMINFO, sizeof(*mem_info));
+ if (mem_info == NULL) {
+ printk(BIOS_ERR, "CBMEM entry for DIMM info missing\n");
+ return;
+ }
+ memset(mem_info, 0, sizeof(*mem_info));
+
+ /* Allow mainboard to override DRAM part number. */
+ dram_part_num = mainboard_get_dram_part_num(&dram_part_num_len);
+
+ /* Save available DIMM information */
+ index = 0;
+ dimm_max = ARRAY_SIZE(mem_info->dimm);
+ for (node = 0; node < MAX_NODE; node++) {
+ ctrlr_info = &meminfo_hob->Controller[node];
+ for (channel = 0; channel < MAX_CH && index < dimm_max; channel++) {
+ channel_info = &ctrlr_info->ChannelInfo[channel];
+ if (channel_info->Status != CHANNEL_PRESENT)
+ continue;
+
+ for (dimm = 0; dimm < MAX_DIMM && index < dimm_max; dimm++) {
+ src_dimm = &channel_info->DimmInfo[dimm];
+ dest_dimm = &mem_info->dimm[index];
+ if (src_dimm->Status != DIMM_PRESENT)
+ continue;
+
+ /* If there is no DRAM part number overridden by
+ * mainboard then use original one. */
+ if (!dram_part_num) {
+ dram_part_num_len = sizeof(src_dimm->ModulePartNum);
+ dram_part_num = (const char *)
+ &src_dimm->ModulePartNum[0];
+ }
+
+ uint8_t memProfNum = meminfo_hob->MemoryProfile;
+ serial_num = src_dimm->SpdSave + SPD_SAVE_OFFSET_SERIAL;
+
+ /* Populate the DIMM information */
+ dimm_info_fill(dest_dimm,
+ src_dimm->DimmCapacity,
+ meminfo_hob->MemoryType,
+ meminfo_hob->ConfiguredMemoryClockSpeed,
+ src_dimm->RankInDimm,
+ channel_info->ChannelId,
+ src_dimm->DimmId,
+ dram_part_num,
+ dram_part_num_len,
+ serial_num,
+ meminfo_hob->DataWidth,
+ meminfo_hob->VddVoltage[memProfNum],
+ meminfo_hob->EccSupport,
+ src_dimm->MfgId,
+ src_dimm->SpdModuleType);
+ index++;
+ }
+ }
+ }
+ mem_info->dimm_cnt = index;
+ printk(BIOS_DEBUG, "%d DIMMs found\n", mem_info->dimm_cnt);
+}
+
+void mainboard_romstage_entry(void)
+{
+ bool s3wake;
+ struct chipset_power_state *ps = pmc_get_power_state();
+
+ /* Program MCHBAR, DMIBAR, GDXBAR and EDRAMBAR */
+ systemagent_early_init();
+ /* Perform PCH init */
+ romstage_pch_init();
+ /* Initialize HECI interface */
+ heci_init(HECI1_BASE_ADDRESS);
+
+ s3wake = pmc_fill_power_state(ps) == ACPI_S3;
+ fsp_memory_init(s3wake);
+ pmc_set_disb();
+ if (!s3wake)
+ save_dimm_info();
+}
diff --git a/src/soc/intel/alderlake/romstage/systemagent.c b/src/soc/intel/alderlake/romstage/systemagent.c
new file mode 100644
index 0000000000..150ffb5dfa
--- /dev/null
+++ b/src/soc/intel/alderlake/romstage/systemagent.c
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/*
+ * This file is created based on Intel Alder Lake Processor SA Datasheet
+ * Document number: 619503
+ * Chapter number: 3
+ */
+
+#include <intelblocks/systemagent.h>
+#include <soc/iomap.h>
+#include <soc/romstage.h>
+#include <soc/systemagent.h>
+
+void systemagent_early_init(void)
+{
+ static const struct sa_mmio_descriptor soc_fixed_pci_resources[] = {
+ { MCHBAR, MCH_BASE_ADDRESS, MCH_BASE_SIZE, "MCHBAR" },
+ { DMIBAR, DMI_BASE_ADDRESS, DMI_BASE_SIZE, "DMIBAR" },
+ { EPBAR, EP_BASE_ADDRESS, EP_BASE_SIZE, "EPBAR" },
+ };
+
+ static const struct sa_mmio_descriptor soc_fixed_mch_resources[] = {
+ { REGBAR, REG_BASE_ADDRESS, REG_BASE_SIZE, "REGBAR" },
+ { EDRAMBAR, EDRAM_BASE_ADDRESS, EDRAM_BASE_SIZE, "EDRAMBAR" },
+ };
+
+ /* Set Fixed MMIO address into PCI configuration space */
+ sa_set_pci_bar(soc_fixed_pci_resources,
+ ARRAY_SIZE(soc_fixed_pci_resources));
+ /* Set Fixed MMIO address into MCH base address */
+ sa_set_mch_bar(soc_fixed_mch_resources,
+ ARRAY_SIZE(soc_fixed_mch_resources));
+ /* Enable PAM registers */
+ enable_pam_region();
+}