blob: c3a2509063278e9b7da6ba8b16f06f8650c9f6ad [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>
20#include <soc/iomap.h>
21#include <soc/pci_devs.h>
22#include <soc/romstage.h>
23
24static void soc_memory_init_params(FSP_M_CONFIG *m_cfg, const config_t *config)
25{
26 unsigned int i;
27 uint32_t mask = 0;
Lijian Zhaofe701ee2018-10-25 09:29:10 -070028 const struct device *dev = dev_find_slot(0, PCH_DEVFN_ISH);
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053029
30 /* Set IGD stolen size to 64MB. */
31 m_cfg->IgdDvmt50PreAlloc = 2;
32 m_cfg->TsegSize = CONFIG_SMM_TSEG_SIZE;
33 m_cfg->IedSize = CONFIG_IED_REGION_SIZE;
34 m_cfg->SaGv = config->SaGv;
praveen hodagatta pranesh521e48c2018-09-27 00:00:13 +080035 if (IS_ENABLED(CONFIG_SOC_INTEL_CANNONLAKE_PCH_H))
praveen hodagatta praneshe26c4a42018-09-20 03:49:45 +080036 m_cfg->UserBd = BOARD_TYPE_DESKTOP;
37 else
38 m_cfg->UserBd = BOARD_TYPE_ULT_ULX;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053039 m_cfg->RMT = config->RMT;
40
41 for (i = 0; i < ARRAY_SIZE(config->PcieRpEnable); i++) {
42 if (config->PcieRpEnable[i])
43 mask |= (1 << i);
44 }
45 m_cfg->PcieRpEnableMask = mask;
46 m_cfg->PrmrrSize = config->PrmrrSize;
47 m_cfg->EnableC6Dram = config->enable_c6dram;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053048 m_cfg->PcdSerialIoUartNumber = CONFIG_UART_FOR_CONSOLE;
49 /* Disable Vmx if Vt-d is already disabled */
50 if (config->VtdDisable)
51 m_cfg->VmxEnable = 0;
52 else
53 m_cfg->VmxEnable = config->VmxEnable;
54#if IS_ENABLED(CONFIG_SOC_INTEL_COFFEELAKE)
55 m_cfg->SkipMpInit = !chip_get_fsp_mp_init();
56#endif
Lijian Zhaofe701ee2018-10-25 09:29:10 -070057 /* If ISH is enabled, enable ISH elements */
58 if (!dev)
59 m_cfg->PchIshEnable = 0;
60 else
61 m_cfg->PchIshEnable = dev->enabled;
Lijian Zhao3ef74492018-12-06 17:29:55 -080062
63 /* If HDA is enabled, enable HDA elements */
64 dev = dev_find_slot(0, PCH_DEVFN_HDA);
65 if (!dev)
66 m_cfg->PchHdaEnable = 0;
67 else
68 m_cfg->PchHdaEnable = dev->enabled;
69
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053070}
71
72void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version)
73{
74 const struct device *dev = dev_find_slot(0, PCH_DEVFN_LPC);
Duncan Laurie25b387a2018-11-08 15:48:14 -070075 const struct device *smbus = dev_find_slot(0, PCH_DEVFN_SMBUS);
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053076 assert(dev != NULL);
77 const config_t *config = dev->chip_info;
78 FSP_M_CONFIG *m_cfg = &mupd->FspmConfig;
79
80 soc_memory_init_params(m_cfg, config);
81
82 /* Enable SMBus controller based on config */
Duncan Laurie25b387a2018-11-08 15:48:14 -070083 if (!smbus)
84 m_cfg->SmbusEnable = 0;
85 else
86 m_cfg->SmbusEnable = smbus->enabled;
Rizwan Qureshi742c6fe2018-09-18 22:43:41 +053087 /* Set debug probe type */
88 m_cfg->PlatformDebugConsent = config->DebugConsent;
89
90 mainboard_memory_init_params(mupd);
91}
92
93__weak void mainboard_memory_init_params(FSPM_UPD *mupd)
94{
95 printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__);
96}