blob: 8cb6c92a654b6117348063fe57ce4203c409cd10 [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>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053011#include <soc/iomap.h>
Lijian Zhao68890b92019-03-27 17:06:41 -070012#include <soc/msr.h>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053013#include <soc/pci_devs.h>
14#include <soc/romstage.h>
Angel Pons3993d382021-04-05 11:40:11 +020015#include <types.h>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053016
Elyes HAOUASc3385072019-03-21 15:38:06 +010017#include "../chip.h"
18
Felix Singer929b65a2021-04-19 01:59:47 +020019void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version)
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053020{
Felix Singer929b65a2021-04-19 01:59:47 +020021 const struct device *dev = pcidev_path_on_root(PCH_DEVFN_LPC);
22 assert(dev != NULL);
23 const config_t *config = config_of(dev);
Christian Walterb2f8ce72020-03-11 18:04:58 +010024 FSP_M_CONFIG *m_cfg = &mupd->FspmConfig;
25 FSP_M_TEST_CONFIG *tconfig = &mupd->FspmTestConfig;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053026 unsigned int i;
27 uint32_t mask = 0;
28
Christian Walterb2f8ce72020-03-11 18:04:58 +010029 /*
30 * Probe for no IGD and disable InternalGfx and panel power to prevent a
31 * crash in FSP-M.
32 */
Felix Singer929b65a2021-04-19 01:59:47 +020033 dev = pcidev_path_on_root(SA_DEVFN_IGD);
Angel Pons3993d382021-04-05 11:40:11 +020034 const bool igd_on = !CONFIG(SOC_INTEL_DISABLE_IGD) && dev && dev->enabled;
35 if (igd_on && pci_read_config16(SA_DEV_IGD, PCI_VENDOR_ID) != 0xffff) {
Christian Walterb2f8ce72020-03-11 18:04:58 +010036 /* Set IGD stolen size to 64MB. */
37 m_cfg->InternalGfx = 1;
38 m_cfg->IgdDvmt50PreAlloc = 2;
39 } else {
40 m_cfg->InternalGfx = 0;
41 m_cfg->IgdDvmt50PreAlloc = 0;
42 tconfig->PanelPowerEnable = 0;
43 }
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053044 m_cfg->TsegSize = CONFIG_SMM_TSEG_SIZE;
45 m_cfg->IedSize = CONFIG_IED_REGION_SIZE;
46 m_cfg->SaGv = config->SaGv;
Julius Wernercd49cce2019-03-05 16:53:33 -080047 if (CONFIG(SOC_INTEL_CANNONLAKE_PCH_H))
praveen hodagatta praneshe26c4a42018-09-20 03:49:45 +080048 m_cfg->UserBd = BOARD_TYPE_DESKTOP;
49 else
50 m_cfg->UserBd = BOARD_TYPE_ULT_ULX;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053051 m_cfg->RMT = config->RMT;
52
53 for (i = 0; i < ARRAY_SIZE(config->PcieRpEnable); i++) {
54 if (config->PcieRpEnable[i])
55 mask |= (1 << i);
56 }
57 m_cfg->PcieRpEnableMask = mask;
Michael Niewöhner490546f2020-09-15 12:20:08 +020058 m_cfg->PrmrrSize = get_valid_prmrr_size();
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053059 m_cfg->EnableC6Dram = config->enable_c6dram;
Aamir Bohra2973d1e2019-05-17 12:31:51 +053060#if CONFIG(SOC_INTEL_COMETLAKE)
61 m_cfg->SerialIoUartDebugControllerNumber = CONFIG_UART_FOR_CONSOLE;
62#else
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053063 m_cfg->PcdSerialIoUartNumber = CONFIG_UART_FOR_CONSOLE;
Aamir Bohra2973d1e2019-05-17 12:31:51 +053064#endif
Maulik V Vaghelabfe4a592019-03-13 18:16:01 +053065 /*
66 * PcdDebugInterfaceFlags
67 * This config will allow coreboot to pass information to the FSP
68 * regarding which debug interface is being used.
69 * Debug Interfaces:
70 * BIT0-RAM, BIT1-Legacy Uart BIT3-USB3, BIT4-LPSS Uart, BIT5-TraceHub
71 * BIT2 - Not used.
72 */
73 m_cfg->PcdDebugInterfaceFlags =
74 CONFIG(DRIVERS_UART_8250IO) ? 0x02 : 0x10;
75
Ronak Kanabar250dfc02019-03-29 13:25:09 +053076 /* Change VmxEnable UPD value according to ENABLE_VMX Kconfig */
77 m_cfg->VmxEnable = CONFIG(ENABLE_VMX);
Subrata Banikcf32fd12018-12-19 18:02:17 +053078
Martin Rothc25c1eb2020-07-24 12:26:21 -060079 m_cfg->SkipMpInit = !CONFIG(USE_INTEL_FSP_MP_INIT);
Duncan Laurie52b5b582019-01-23 14:55:47 -080080
Subrata Banike1470ea2019-11-18 14:08:08 +053081 if (config->cpu_ratio_override) {
82 m_cfg->CpuRatio = config->cpu_ratio_override;
83 } else {
84 /* Set CpuRatio to match existing MSR value */
85 msr_t flex_ratio;
86 flex_ratio = rdmsr(MSR_FLEX_RATIO);
87 m_cfg->CpuRatio = (flex_ratio.lo >> 8) & 0xff;
88 }
Duncan Laurie52b5b582019-01-23 14:55:47 -080089
Christian Walterb2f8ce72020-03-11 18:04:58 +010090 dev = pcidev_path_on_root(PCH_DEVFN_ISH);
Lijian Zhaofe701ee2018-10-25 09:29:10 -070091 /* If ISH is enabled, enable ISH elements */
92 if (!dev)
93 m_cfg->PchIshEnable = 0;
94 else
95 m_cfg->PchIshEnable = dev->enabled;
Lijian Zhao3ef74492018-12-06 17:29:55 -080096
97 /* If HDA is enabled, enable HDA elements */
Kyösti Mälkki903b40a2019-07-03 07:25:59 +030098 dev = pcidev_path_on_root(PCH_DEVFN_HDA);
Lijian Zhao3ef74492018-12-06 17:29:55 -080099 if (!dev)
100 m_cfg->PchHdaEnable = 0;
101 else
102 m_cfg->PchHdaEnable = dev->enabled;
103
V Sowmya0bc3e3d2019-01-07 13:11:29 +0530104 /* Enable IPU only if the device is enabled */
105 m_cfg->SaIpuEnable = 0;
106 dev = pcidev_path_on_root(SA_DEVFN_IPU);
107 if (dev)
108 m_cfg->SaIpuEnable = dev->enabled;
Jamie Chenc004857da2020-01-15 11:17:21 +0800109
110 /* SATA Gen3 strength */
111 for (i = 0; i < SOC_INTEL_CML_SATA_DEV_MAX; i++) {
112 if (config->sata_port[i].RxGen3EqBoostMagEnable) {
113 m_cfg->PchSataHsioRxGen3EqBoostMagEnable[i] =
114 config->sata_port[i].RxGen3EqBoostMagEnable;
115 m_cfg->PchSataHsioRxGen3EqBoostMag[i] =
116 config->sata_port[i].RxGen3EqBoostMag;
117 }
118 if (config->sata_port[i].TxGen3DownscaleAmpEnable) {
119 m_cfg->PchSataHsioTxGen3DownscaleAmpEnable[i] =
120 config->sata_port[i].TxGen3DownscaleAmpEnable;
121 m_cfg->PchSataHsioTxGen3DownscaleAmp[i] =
122 config->sata_port[i].TxGen3DownscaleAmp;
123 }
124 if (config->sata_port[i].TxGen3DeEmphEnable) {
125 m_cfg->PchSataHsioTxGen3DeEmphEnable[i] =
126 config->sata_port[i].TxGen3DeEmphEnable;
127 m_cfg->PchSataHsioTxGen3DeEmph[i] =
128 config->sata_port[i].TxGen3DeEmph;
129 }
130 }
Christian Waltere01054d2020-04-27 18:11:51 +0200131#if !CONFIG(SOC_INTEL_COMETLAKE)
132 if (config->DisableHeciRetry)
133 tconfig->DisableHeciRetry = config->DisableHeciRetry;
134#endif
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530135
136 /* Enable SMBus controller based on config */
Felix Singerb03e4972021-04-19 01:42:33 +0200137 dev = pcidev_path_on_root(PCH_DEVFN_SMBUS);
138 if (!dev)
Duncan Laurie25b387a2018-11-08 15:48:14 -0700139 m_cfg->SmbusEnable = 0;
140 else
Felix Singerb03e4972021-04-19 01:42:33 +0200141 m_cfg->SmbusEnable = dev->enabled;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530142
Kane Chen37172562019-04-11 21:55:20 +0800143 /* Set debug probe type */
144 m_cfg->PlatformDebugConsent =
145 CONFIG_SOC_INTEL_CANNONLAKE_DEBUG_CONSENT;
John Zhao1159a162019-04-22 10:45:51 -0700146
147 /* Configure VT-d */
148 tconfig->VtdDisable = 0;
149
Sridhar Siricillaa91c9192020-08-05 16:16:52 +0530150 /* Set HECI1 PCI BAR address */
151 m_cfg->Heci1BarAddress = HECI1_BASE_ADDRESS;
152
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530153 mainboard_memory_init_params(mupd);
154}
155
156__weak void mainboard_memory_init_params(FSPM_UPD *mupd)
157{
158 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
159}