blob: 5c74d4a1e03b1a204190bff047b31d852fead430 [file] [log] [blame]
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +05301/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2018 Intel Corp.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <assert.h>
Lijian Zhao68890b92019-03-27 17:06:41 -070017#include <cpu/x86/msr.h>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053018#include <console/console.h>
19#include <fsp/util.h>
Michael Niewöhner7736bfc2019-10-22 23:05:06 +020020#include <intelblocks/cpulib.h>
Duncan Laurie52b5b582019-01-23 14:55:47 -080021#include <intelblocks/pmclib.h>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053022#include <soc/iomap.h>
Lijian Zhao68890b92019-03-27 17:06:41 -070023#include <soc/msr.h>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053024#include <soc/pci_devs.h>
25#include <soc/romstage.h>
Duncan Laurie52b5b582019-01-23 14:55:47 -080026#include <vendorcode/google/chromeos/chromeos.h>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053027
Elyes HAOUASc3385072019-03-21 15:38:06 +010028#include "../chip.h"
29
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053030static void soc_memory_init_params(FSP_M_CONFIG *m_cfg, const config_t *config)
31{
32 unsigned int i;
33 uint32_t mask = 0;
Kyösti Mälkki903b40a2019-07-03 07:25:59 +030034 const struct device *dev = pcidev_path_on_root(PCH_DEVFN_ISH);
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053035
36 /* Set IGD stolen size to 64MB. */
37 m_cfg->IgdDvmt50PreAlloc = 2;
38 m_cfg->TsegSize = CONFIG_SMM_TSEG_SIZE;
39 m_cfg->IedSize = CONFIG_IED_REGION_SIZE;
40 m_cfg->SaGv = config->SaGv;
Julius Wernercd49cce2019-03-05 16:53:33 -080041 if (CONFIG(SOC_INTEL_CANNONLAKE_PCH_H))
praveen hodagatta praneshe26c4a42018-09-20 03:49:45 +080042 m_cfg->UserBd = BOARD_TYPE_DESKTOP;
43 else
44 m_cfg->UserBd = BOARD_TYPE_ULT_ULX;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053045 m_cfg->RMT = config->RMT;
46
47 for (i = 0; i < ARRAY_SIZE(config->PcieRpEnable); i++) {
48 if (config->PcieRpEnable[i])
49 mask |= (1 << i);
50 }
51 m_cfg->PcieRpEnableMask = mask;
Michael Niewöhner7736bfc2019-10-22 23:05:06 +020052 m_cfg->PrmrrSize = get_prmrr_size();
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053053 m_cfg->EnableC6Dram = config->enable_c6dram;
Aamir Bohra2973d1e2019-05-17 12:31:51 +053054#if CONFIG(SOC_INTEL_COMETLAKE)
55 m_cfg->SerialIoUartDebugControllerNumber = CONFIG_UART_FOR_CONSOLE;
56#else
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053057 m_cfg->PcdSerialIoUartNumber = CONFIG_UART_FOR_CONSOLE;
Aamir Bohra2973d1e2019-05-17 12:31:51 +053058#endif
Maulik V Vaghelabfe4a592019-03-13 18:16:01 +053059 /*
60 * PcdDebugInterfaceFlags
61 * This config will allow coreboot to pass information to the FSP
62 * regarding which debug interface is being used.
63 * Debug Interfaces:
64 * BIT0-RAM, BIT1-Legacy Uart BIT3-USB3, BIT4-LPSS Uart, BIT5-TraceHub
65 * BIT2 - Not used.
66 */
67 m_cfg->PcdDebugInterfaceFlags =
68 CONFIG(DRIVERS_UART_8250IO) ? 0x02 : 0x10;
69
Ronak Kanabar250dfc02019-03-29 13:25:09 +053070 /* Change VmxEnable UPD value according to ENABLE_VMX Kconfig */
71 m_cfg->VmxEnable = CONFIG(ENABLE_VMX);
Subrata Banikcf32fd12018-12-19 18:02:17 +053072
Arthur Heymans4821a0e2019-06-18 13:19:29 +020073#if CONFIG(SOC_INTEL_CANNONLAKE_ALTERNATE_HEADERS)
Lijian Zhao7f1a0e62019-04-22 21:17:58 +000074 m_cfg->SkipMpInit = !CONFIG_USE_INTEL_FSP_MP_INIT;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053075#endif
Duncan Laurie52b5b582019-01-23 14:55:47 -080076
Subrata Banike1470ea2019-11-18 14:08:08 +053077 if (config->cpu_ratio_override) {
78 m_cfg->CpuRatio = config->cpu_ratio_override;
79 } else {
80 /* Set CpuRatio to match existing MSR value */
81 msr_t flex_ratio;
82 flex_ratio = rdmsr(MSR_FLEX_RATIO);
83 m_cfg->CpuRatio = (flex_ratio.lo >> 8) & 0xff;
84 }
Duncan Laurie52b5b582019-01-23 14:55:47 -080085
Lijian Zhaofe701ee2018-10-25 09:29:10 -070086 /* If ISH is enabled, enable ISH elements */
87 if (!dev)
88 m_cfg->PchIshEnable = 0;
89 else
90 m_cfg->PchIshEnable = dev->enabled;
Lijian Zhao3ef74492018-12-06 17:29:55 -080091
92 /* If HDA is enabled, enable HDA elements */
Kyösti Mälkki903b40a2019-07-03 07:25:59 +030093 dev = pcidev_path_on_root(PCH_DEVFN_HDA);
Lijian Zhao3ef74492018-12-06 17:29:55 -080094 if (!dev)
95 m_cfg->PchHdaEnable = 0;
96 else
97 m_cfg->PchHdaEnable = dev->enabled;
98
V Sowmya0bc3e3d2019-01-07 13:11:29 +053099 /* Enable IPU only if the device is enabled */
100 m_cfg->SaIpuEnable = 0;
101 dev = pcidev_path_on_root(SA_DEVFN_IPU);
102 if (dev)
103 m_cfg->SaIpuEnable = dev->enabled;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530104}
105
106void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version)
107{
Kyösti Mälkki903b40a2019-07-03 07:25:59 +0300108 const struct device *dev = pcidev_path_on_root(PCH_DEVFN_LPC);
109 const struct device *smbus = pcidev_path_on_root(PCH_DEVFN_SMBUS);
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530110 assert(dev != NULL);
Kyösti Mälkki8950cfb2019-07-13 22:16:25 +0300111 const config_t *config = config_of(dev);
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530112 FSP_M_CONFIG *m_cfg = &mupd->FspmConfig;
John Zhao1159a162019-04-22 10:45:51 -0700113 FSP_M_TEST_CONFIG *tconfig = &mupd->FspmTestConfig;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530114
115 soc_memory_init_params(m_cfg, config);
116
117 /* Enable SMBus controller based on config */
Duncan Laurie25b387a2018-11-08 15:48:14 -0700118 if (!smbus)
119 m_cfg->SmbusEnable = 0;
120 else
121 m_cfg->SmbusEnable = smbus->enabled;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530122
Kane Chen37172562019-04-11 21:55:20 +0800123 /* Set debug probe type */
124 m_cfg->PlatformDebugConsent =
125 CONFIG_SOC_INTEL_CANNONLAKE_DEBUG_CONSENT;
John Zhao1159a162019-04-22 10:45:51 -0700126
127 /* Configure VT-d */
128 tconfig->VtdDisable = 0;
129
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530130 mainboard_memory_init_params(mupd);
131}
132
133__weak void mainboard_memory_init_params(FSPM_UPD *mupd)
134{
135 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
136}