blob: 842c8fb7d07694d926cfdd7fd13710637fee252b [file] [log] [blame]
Angel Ponsf5627e82020-04-05 15:46:52 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +05302
3#include <assert.h>
Christian Walterb2f8ce72020-03-11 18:04:58 +01004#include <device/pci_def.h>
5#include <device/pci.h>
Lijian Zhao68890b92019-03-27 17:06:41 -07006#include <cpu/x86/msr.h>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +05307#include <console/console.h>
8#include <fsp/util.h>
Michael Niewöhner7736bfc2019-10-22 23:05:06 +02009#include <intelblocks/cpulib.h>
Duncan Laurie52b5b582019-01-23 14:55:47 -080010#include <intelblocks/pmclib.h>
Felix Singer8ba94102021-12-31 00:15:18 +010011#include <option.h>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053012#include <soc/iomap.h>
Lijian Zhao68890b92019-03-27 17:06:41 -070013#include <soc/msr.h>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053014#include <soc/pci_devs.h>
15#include <soc/romstage.h>
Angel Pons3993d382021-04-05 11:40:11 +020016#include <types.h>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053017
Elyes HAOUASc3385072019-03-21 15:38:06 +010018#include "../chip.h"
19
Felix Singer929b65a2021-04-19 01:59:47 +020020void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version)
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053021{
Felix Singer929b65a2021-04-19 01:59:47 +020022 const struct device *dev = pcidev_path_on_root(PCH_DEVFN_LPC);
23 assert(dev != NULL);
24 const config_t *config = config_of(dev);
Christian Walterb2f8ce72020-03-11 18:04:58 +010025 FSP_M_CONFIG *m_cfg = &mupd->FspmConfig;
26 FSP_M_TEST_CONFIG *tconfig = &mupd->FspmTestConfig;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053027 unsigned int i;
28 uint32_t mask = 0;
29
Felix Singer8ba94102021-12-31 00:15:18 +010030 m_cfg->HyperThreading = get_uint_option("hyper_threading", CONFIG(FSP_HYPERTHREADING));
31
Christian Walterb2f8ce72020-03-11 18:04:58 +010032 /*
33 * Probe for no IGD and disable InternalGfx and panel power to prevent a
34 * crash in FSP-M.
35 */
Felix Singer929b65a2021-04-19 01:59:47 +020036 dev = pcidev_path_on_root(SA_DEVFN_IGD);
Angel Pons3993d382021-04-05 11:40:11 +020037 const bool igd_on = !CONFIG(SOC_INTEL_DISABLE_IGD) && dev && dev->enabled;
38 if (igd_on && pci_read_config16(SA_DEV_IGD, PCI_VENDOR_ID) != 0xffff) {
Christian Walterb2f8ce72020-03-11 18:04:58 +010039 /* Set IGD stolen size to 64MB. */
40 m_cfg->InternalGfx = 1;
41 m_cfg->IgdDvmt50PreAlloc = 2;
42 } else {
43 m_cfg->InternalGfx = 0;
44 m_cfg->IgdDvmt50PreAlloc = 0;
45 tconfig->PanelPowerEnable = 0;
46 }
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053047 m_cfg->TsegSize = CONFIG_SMM_TSEG_SIZE;
48 m_cfg->IedSize = CONFIG_IED_REGION_SIZE;
49 m_cfg->SaGv = config->SaGv;
Julius Wernercd49cce2019-03-05 16:53:33 -080050 if (CONFIG(SOC_INTEL_CANNONLAKE_PCH_H))
praveen hodagatta praneshe26c4a42018-09-20 03:49:45 +080051 m_cfg->UserBd = BOARD_TYPE_DESKTOP;
52 else
53 m_cfg->UserBd = BOARD_TYPE_ULT_ULX;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053054 m_cfg->RMT = config->RMT;
55
56 for (i = 0; i < ARRAY_SIZE(config->PcieRpEnable); i++) {
57 if (config->PcieRpEnable[i])
58 mask |= (1 << i);
59 }
60 m_cfg->PcieRpEnableMask = mask;
Michael Niewöhner490546f2020-09-15 12:20:08 +020061 m_cfg->PrmrrSize = get_valid_prmrr_size();
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053062 m_cfg->EnableC6Dram = config->enable_c6dram;
Aamir Bohra2973d1e2019-05-17 12:31:51 +053063#if CONFIG(SOC_INTEL_COMETLAKE)
64 m_cfg->SerialIoUartDebugControllerNumber = CONFIG_UART_FOR_CONSOLE;
Matt DeVillier74b85f22022-01-25 12:16:44 -060065 memcpy(tconfig->PcieRpHotPlug, config->PcieRpHotPlug, sizeof(tconfig->PcieRpHotPlug));
Aamir Bohra2973d1e2019-05-17 12:31:51 +053066#else
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053067 m_cfg->PcdSerialIoUartNumber = CONFIG_UART_FOR_CONSOLE;
Aamir Bohra2973d1e2019-05-17 12:31:51 +053068#endif
Maulik V Vaghelabfe4a592019-03-13 18:16:01 +053069 /*
70 * PcdDebugInterfaceFlags
71 * This config will allow coreboot to pass information to the FSP
72 * regarding which debug interface is being used.
73 * Debug Interfaces:
74 * BIT0-RAM, BIT1-Legacy Uart BIT3-USB3, BIT4-LPSS Uart, BIT5-TraceHub
75 * BIT2 - Not used.
76 */
77 m_cfg->PcdDebugInterfaceFlags =
78 CONFIG(DRIVERS_UART_8250IO) ? 0x02 : 0x10;
79
Ronak Kanabar250dfc02019-03-29 13:25:09 +053080 /* Change VmxEnable UPD value according to ENABLE_VMX Kconfig */
81 m_cfg->VmxEnable = CONFIG(ENABLE_VMX);
Subrata Banikcf32fd12018-12-19 18:02:17 +053082
Martin Rothc25c1eb2020-07-24 12:26:21 -060083 m_cfg->SkipMpInit = !CONFIG(USE_INTEL_FSP_MP_INIT);
Duncan Laurie52b5b582019-01-23 14:55:47 -080084
Subrata Banike1470ea2019-11-18 14:08:08 +053085 if (config->cpu_ratio_override) {
86 m_cfg->CpuRatio = config->cpu_ratio_override;
87 } else {
88 /* Set CpuRatio to match existing MSR value */
89 msr_t flex_ratio;
90 flex_ratio = rdmsr(MSR_FLEX_RATIO);
91 m_cfg->CpuRatio = (flex_ratio.lo >> 8) & 0xff;
92 }
Duncan Laurie52b5b582019-01-23 14:55:47 -080093
Christian Walterb2f8ce72020-03-11 18:04:58 +010094 dev = pcidev_path_on_root(PCH_DEVFN_ISH);
Lijian Zhaofe701ee2018-10-25 09:29:10 -070095 /* If ISH is enabled, enable ISH elements */
96 if (!dev)
97 m_cfg->PchIshEnable = 0;
98 else
99 m_cfg->PchIshEnable = dev->enabled;
Lijian Zhao3ef74492018-12-06 17:29:55 -0800100
101 /* If HDA is enabled, enable HDA elements */
Kyösti Mälkki903b40a2019-07-03 07:25:59 +0300102 dev = pcidev_path_on_root(PCH_DEVFN_HDA);
Lijian Zhao3ef74492018-12-06 17:29:55 -0800103 if (!dev)
104 m_cfg->PchHdaEnable = 0;
105 else
106 m_cfg->PchHdaEnable = dev->enabled;
107
V Sowmya0bc3e3d2019-01-07 13:11:29 +0530108 /* Enable IPU only if the device is enabled */
109 m_cfg->SaIpuEnable = 0;
110 dev = pcidev_path_on_root(SA_DEVFN_IPU);
111 if (dev)
112 m_cfg->SaIpuEnable = dev->enabled;
Jamie Chenc004857da2020-01-15 11:17:21 +0800113
114 /* SATA Gen3 strength */
115 for (i = 0; i < SOC_INTEL_CML_SATA_DEV_MAX; i++) {
116 if (config->sata_port[i].RxGen3EqBoostMagEnable) {
117 m_cfg->PchSataHsioRxGen3EqBoostMagEnable[i] =
118 config->sata_port[i].RxGen3EqBoostMagEnable;
119 m_cfg->PchSataHsioRxGen3EqBoostMag[i] =
120 config->sata_port[i].RxGen3EqBoostMag;
121 }
122 if (config->sata_port[i].TxGen3DownscaleAmpEnable) {
123 m_cfg->PchSataHsioTxGen3DownscaleAmpEnable[i] =
124 config->sata_port[i].TxGen3DownscaleAmpEnable;
125 m_cfg->PchSataHsioTxGen3DownscaleAmp[i] =
126 config->sata_port[i].TxGen3DownscaleAmp;
127 }
128 if (config->sata_port[i].TxGen3DeEmphEnable) {
129 m_cfg->PchSataHsioTxGen3DeEmphEnable[i] =
130 config->sata_port[i].TxGen3DeEmphEnable;
131 m_cfg->PchSataHsioTxGen3DeEmph[i] =
132 config->sata_port[i].TxGen3DeEmph;
133 }
134 }
Christian Waltere01054d2020-04-27 18:11:51 +0200135#if !CONFIG(SOC_INTEL_COMETLAKE)
136 if (config->DisableHeciRetry)
137 tconfig->DisableHeciRetry = config->DisableHeciRetry;
138#endif
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530139
140 /* Enable SMBus controller based on config */
Felix Singerb03e4972021-04-19 01:42:33 +0200141 dev = pcidev_path_on_root(PCH_DEVFN_SMBUS);
142 if (!dev)
Duncan Laurie25b387a2018-11-08 15:48:14 -0700143 m_cfg->SmbusEnable = 0;
144 else
Felix Singerb03e4972021-04-19 01:42:33 +0200145 m_cfg->SmbusEnable = dev->enabled;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530146
Kane Chen37172562019-04-11 21:55:20 +0800147 /* Set debug probe type */
148 m_cfg->PlatformDebugConsent =
149 CONFIG_SOC_INTEL_CANNONLAKE_DEBUG_CONSENT;
John Zhao1159a162019-04-22 10:45:51 -0700150
151 /* Configure VT-d */
152 tconfig->VtdDisable = 0;
153
Sridhar Siricillaa91c9192020-08-05 16:16:52 +0530154 /* Set HECI1 PCI BAR address */
155 m_cfg->Heci1BarAddress = HECI1_BASE_ADDRESS;
156
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530157 mainboard_memory_init_params(mupd);
158}
159
160__weak void mainboard_memory_init_params(FSPM_UPD *mupd)
161{
162 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
163}