Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 1 | /* |
| 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 Zhao | 68890b9 | 2019-03-27 17:06:41 -0700 | [diff] [blame] | 17 | #include <cpu/x86/msr.h> |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 18 | #include <console/console.h> |
| 19 | #include <fsp/util.h> |
Michael Niewöhner | 7736bfc | 2019-10-22 23:05:06 +0200 | [diff] [blame] | 20 | #include <intelblocks/cpulib.h> |
Duncan Laurie | 52b5b58 | 2019-01-23 14:55:47 -0800 | [diff] [blame] | 21 | #include <intelblocks/pmclib.h> |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 22 | #include <soc/iomap.h> |
Lijian Zhao | 68890b9 | 2019-03-27 17:06:41 -0700 | [diff] [blame] | 23 | #include <soc/msr.h> |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 24 | #include <soc/pci_devs.h> |
| 25 | #include <soc/romstage.h> |
Duncan Laurie | 52b5b58 | 2019-01-23 14:55:47 -0800 | [diff] [blame] | 26 | #include <vendorcode/google/chromeos/chromeos.h> |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 27 | |
Elyes HAOUAS | c338507 | 2019-03-21 15:38:06 +0100 | [diff] [blame] | 28 | #include "../chip.h" |
| 29 | |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 30 | static 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älkki | 903b40a | 2019-07-03 07:25:59 +0300 | [diff] [blame] | 34 | const struct device *dev = pcidev_path_on_root(PCH_DEVFN_ISH); |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 35 | |
| 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 Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 41 | if (CONFIG(SOC_INTEL_CANNONLAKE_PCH_H)) |
praveen hodagatta pranesh | e26c4a4 | 2018-09-20 03:49:45 +0800 | [diff] [blame] | 42 | m_cfg->UserBd = BOARD_TYPE_DESKTOP; |
| 43 | else |
| 44 | m_cfg->UserBd = BOARD_TYPE_ULT_ULX; |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 45 | 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öhner | 7736bfc | 2019-10-22 23:05:06 +0200 | [diff] [blame] | 52 | m_cfg->PrmrrSize = get_prmrr_size(); |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 53 | m_cfg->EnableC6Dram = config->enable_c6dram; |
Aamir Bohra | 2973d1e | 2019-05-17 12:31:51 +0530 | [diff] [blame] | 54 | #if CONFIG(SOC_INTEL_COMETLAKE) |
| 55 | m_cfg->SerialIoUartDebugControllerNumber = CONFIG_UART_FOR_CONSOLE; |
| 56 | #else |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 57 | m_cfg->PcdSerialIoUartNumber = CONFIG_UART_FOR_CONSOLE; |
Aamir Bohra | 2973d1e | 2019-05-17 12:31:51 +0530 | [diff] [blame] | 58 | #endif |
Maulik V Vaghela | bfe4a59 | 2019-03-13 18:16:01 +0530 | [diff] [blame] | 59 | /* |
| 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 Kanabar | 250dfc0 | 2019-03-29 13:25:09 +0530 | [diff] [blame] | 70 | /* Change VmxEnable UPD value according to ENABLE_VMX Kconfig */ |
| 71 | m_cfg->VmxEnable = CONFIG(ENABLE_VMX); |
Subrata Banik | cf32fd1 | 2018-12-19 18:02:17 +0530 | [diff] [blame] | 72 | |
Arthur Heymans | 4821a0e | 2019-06-18 13:19:29 +0200 | [diff] [blame] | 73 | #if CONFIG(SOC_INTEL_CANNONLAKE_ALTERNATE_HEADERS) |
Lijian Zhao | 7f1a0e6 | 2019-04-22 21:17:58 +0000 | [diff] [blame] | 74 | m_cfg->SkipMpInit = !CONFIG_USE_INTEL_FSP_MP_INIT; |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 75 | #endif |
Duncan Laurie | 52b5b58 | 2019-01-23 14:55:47 -0800 | [diff] [blame] | 76 | |
Lijian Zhao | 68890b9 | 2019-03-27 17:06:41 -0700 | [diff] [blame] | 77 | /* Set CpuRatio to match existing MSR value */ |
| 78 | msr_t flex_ratio; |
| 79 | flex_ratio = rdmsr(MSR_FLEX_RATIO); |
| 80 | m_cfg->CpuRatio = (flex_ratio.lo >> 8) & 0xff; |
Duncan Laurie | 52b5b58 | 2019-01-23 14:55:47 -0800 | [diff] [blame] | 81 | |
Lijian Zhao | fe701ee | 2018-10-25 09:29:10 -0700 | [diff] [blame] | 82 | /* If ISH is enabled, enable ISH elements */ |
| 83 | if (!dev) |
| 84 | m_cfg->PchIshEnable = 0; |
| 85 | else |
| 86 | m_cfg->PchIshEnable = dev->enabled; |
Lijian Zhao | 3ef7449 | 2018-12-06 17:29:55 -0800 | [diff] [blame] | 87 | |
| 88 | /* If HDA is enabled, enable HDA elements */ |
Kyösti Mälkki | 903b40a | 2019-07-03 07:25:59 +0300 | [diff] [blame] | 89 | dev = pcidev_path_on_root(PCH_DEVFN_HDA); |
Lijian Zhao | 3ef7449 | 2018-12-06 17:29:55 -0800 | [diff] [blame] | 90 | if (!dev) |
| 91 | m_cfg->PchHdaEnable = 0; |
| 92 | else |
| 93 | m_cfg->PchHdaEnable = dev->enabled; |
| 94 | |
V Sowmya | 0bc3e3d | 2019-01-07 13:11:29 +0530 | [diff] [blame] | 95 | /* Enable IPU only if the device is enabled */ |
| 96 | m_cfg->SaIpuEnable = 0; |
| 97 | dev = pcidev_path_on_root(SA_DEVFN_IPU); |
| 98 | if (dev) |
| 99 | m_cfg->SaIpuEnable = dev->enabled; |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version) |
| 103 | { |
Kyösti Mälkki | 903b40a | 2019-07-03 07:25:59 +0300 | [diff] [blame] | 104 | const struct device *dev = pcidev_path_on_root(PCH_DEVFN_LPC); |
| 105 | const struct device *smbus = pcidev_path_on_root(PCH_DEVFN_SMBUS); |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 106 | assert(dev != NULL); |
Kyösti Mälkki | 8950cfb | 2019-07-13 22:16:25 +0300 | [diff] [blame] | 107 | const config_t *config = config_of(dev); |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 108 | FSP_M_CONFIG *m_cfg = &mupd->FspmConfig; |
John Zhao | 1159a16 | 2019-04-22 10:45:51 -0700 | [diff] [blame] | 109 | FSP_M_TEST_CONFIG *tconfig = &mupd->FspmTestConfig; |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 110 | |
| 111 | soc_memory_init_params(m_cfg, config); |
| 112 | |
| 113 | /* Enable SMBus controller based on config */ |
Duncan Laurie | 25b387a | 2018-11-08 15:48:14 -0700 | [diff] [blame] | 114 | if (!smbus) |
| 115 | m_cfg->SmbusEnable = 0; |
| 116 | else |
| 117 | m_cfg->SmbusEnable = smbus->enabled; |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 118 | |
Kane Chen | 3717256 | 2019-04-11 21:55:20 +0800 | [diff] [blame] | 119 | /* Set debug probe type */ |
| 120 | m_cfg->PlatformDebugConsent = |
| 121 | CONFIG_SOC_INTEL_CANNONLAKE_DEBUG_CONSENT; |
John Zhao | 1159a16 | 2019-04-22 10:45:51 -0700 | [diff] [blame] | 122 | |
| 123 | /* Configure VT-d */ |
| 124 | tconfig->VtdDisable = 0; |
| 125 | |
Rizwan Qureshi | 742c6fe | 2018-09-18 22:43:41 +0530 | [diff] [blame] | 126 | mainboard_memory_init_params(mupd); |
| 127 | } |
| 128 | |
| 129 | __weak void mainboard_memory_init_params(FSPM_UPD *mupd) |
| 130 | { |
| 131 | printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 132 | } |