blob: 3e3aa5e22a68ad94956842652ab3d6dd85262373 [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>
17#include <chip.h>
18#include <console/console.h>
19#include <fsp/util.h>
Duncan Laurie52b5b582019-01-23 14:55:47 -080020#include <intelblocks/pmclib.h>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053021#include <soc/iomap.h>
22#include <soc/pci_devs.h>
23#include <soc/romstage.h>
Duncan Laurie52b5b582019-01-23 14:55:47 -080024#include <vendorcode/google/chromeos/chromeos.h>
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053025
26static void soc_memory_init_params(FSP_M_CONFIG *m_cfg, const config_t *config)
27{
28 unsigned int i;
29 uint32_t mask = 0;
Lijian Zhaofe701ee2018-10-25 09:29:10 -070030 const struct device *dev = dev_find_slot(0, PCH_DEVFN_ISH);
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053031
32 /* Set IGD stolen size to 64MB. */
33 m_cfg->IgdDvmt50PreAlloc = 2;
34 m_cfg->TsegSize = CONFIG_SMM_TSEG_SIZE;
35 m_cfg->IedSize = CONFIG_IED_REGION_SIZE;
36 m_cfg->SaGv = config->SaGv;
Julius Wernercd49cce2019-03-05 16:53:33 -080037 if (CONFIG(SOC_INTEL_CANNONLAKE_PCH_H))
praveen hodagatta praneshe26c4a42018-09-20 03:49:45 +080038 m_cfg->UserBd = BOARD_TYPE_DESKTOP;
39 else
40 m_cfg->UserBd = BOARD_TYPE_ULT_ULX;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053041 m_cfg->RMT = config->RMT;
42
43 for (i = 0; i < ARRAY_SIZE(config->PcieRpEnable); i++) {
44 if (config->PcieRpEnable[i])
45 mask |= (1 << i);
46 }
47 m_cfg->PcieRpEnableMask = mask;
48 m_cfg->PrmrrSize = config->PrmrrSize;
49 m_cfg->EnableC6Dram = config->enable_c6dram;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053050 m_cfg->PcdSerialIoUartNumber = CONFIG_UART_FOR_CONSOLE;
Maulik V Vaghelabfe4a592019-03-13 18:16:01 +053051 /*
52 * PcdDebugInterfaceFlags
53 * This config will allow coreboot to pass information to the FSP
54 * regarding which debug interface is being used.
55 * Debug Interfaces:
56 * BIT0-RAM, BIT1-Legacy Uart BIT3-USB3, BIT4-LPSS Uart, BIT5-TraceHub
57 * BIT2 - Not used.
58 */
59 m_cfg->PcdDebugInterfaceFlags =
60 CONFIG(DRIVERS_UART_8250IO) ? 0x02 : 0x10;
61
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053062 /* Disable Vmx if Vt-d is already disabled */
63 if (config->VtdDisable)
64 m_cfg->VmxEnable = 0;
65 else
66 m_cfg->VmxEnable = config->VmxEnable;
Subrata Banikcf32fd12018-12-19 18:02:17 +053067
Julius Wernercd49cce2019-03-05 16:53:33 -080068#if CONFIG(SOC_INTEL_COMMON_CANNONLAKE_BASE)
Subrata Banikcf32fd12018-12-19 18:02:17 +053069 m_cfg->SkipMpInit = !CONFIG_USE_INTEL_FSP_MP_INIT;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053070#endif
Duncan Laurie52b5b582019-01-23 14:55:47 -080071
72 /* Disable CPU Flex Ratio and SaGv in recovery mode */
73 if (vboot_recovery_mode_enabled()) {
74 struct chipset_power_state *ps = pmc_get_power_state();
75
76 /*
77 * Only disable when coming from S5 (cold reset) otherwise
78 * the flex ratio may be locked and FSP will return an error.
79 */
80 if (ps && ps->prev_sleep_state == ACPI_S5) {
81 m_cfg->CpuRatio = 0;
82 m_cfg->SaGv = 0;
83 }
84 }
85
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 */
93 dev = dev_find_slot(0, PCH_DEVFN_HDA);
94 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{
108 const struct device *dev = dev_find_slot(0, PCH_DEVFN_LPC);
Duncan Laurie25b387a2018-11-08 15:48:14 -0700109 const struct device *smbus = dev_find_slot(0, PCH_DEVFN_SMBUS);
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530110 assert(dev != NULL);
111 const config_t *config = dev->chip_info;
112 FSP_M_CONFIG *m_cfg = &mupd->FspmConfig;
113
114 soc_memory_init_params(m_cfg, config);
115
116 /* Enable SMBus controller based on config */
Duncan Laurie25b387a2018-11-08 15:48:14 -0700117 if (!smbus)
118 m_cfg->SmbusEnable = 0;
119 else
120 m_cfg->SmbusEnable = smbus->enabled;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +0530121 /* Set debug probe type */
122 m_cfg->PlatformDebugConsent = config->DebugConsent;
123
124 mainboard_memory_init_params(mupd);
125}
126
127__weak void mainboard_memory_init_params(FSPM_UPD *mupd)
128{
129 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
130}