Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Subrata Banik | a4b11e5c | 2017-02-03 18:57:49 +0530 | [diff] [blame] | 4 | * Copyright (C) 2016-2017 Intel Corporation. |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 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. |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
Duncan Laurie | 7d48410 | 2017-01-09 22:23:39 -0800 | [diff] [blame] | 16 | #include <bootmode.h> |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 17 | #include <bootstate.h> |
| 18 | #include <device/pci.h> |
| 19 | #include <fsp/api.h> |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 20 | #include <arch/acpi.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 21 | #include <device/pci_ops.h> |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 22 | #include <console/console.h> |
| 23 | #include <device/device.h> |
Gaggery Tsai | 711fb81 | 2018-05-22 12:32:48 -0700 | [diff] [blame] | 24 | #include <device/pci_ids.h> |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 25 | #include <fsp/util.h> |
Subrata Banik | f699c14 | 2018-06-08 17:57:37 +0530 | [diff] [blame] | 26 | #include <intelblocks/chip.h> |
Subrata Banik | 46caf09 | 2018-09-28 19:54:30 +0530 | [diff] [blame] | 27 | #include <intelblocks/itss.h> |
Nico Huber | 44e89af | 2019-02-23 19:24:51 +0100 | [diff] [blame] | 28 | #include <intelblocks/lpc_lib.h> |
Subrata Banik | cf32fd1 | 2018-12-19 18:02:17 +0530 | [diff] [blame] | 29 | #include <intelblocks/mp_init.h> |
Duncan Laurie | f511695 | 2018-03-26 02:24:18 -0700 | [diff] [blame] | 30 | #include <intelblocks/xdci.h> |
Subrata Banik | 9cd99a1 | 2018-05-28 16:12:03 +0530 | [diff] [blame] | 31 | #include <intelpch/lockdown.h> |
Brandon Breitenstein | c6ec8dd | 2016-11-17 12:23:04 -0800 | [diff] [blame] | 32 | #include <romstage_handoff.h> |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 33 | #include <soc/acpi.h> |
Patrick Georgi | c6a0050 | 2017-10-05 18:19:29 +0200 | [diff] [blame] | 34 | #include <soc/intel/common/vbt.h> |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 35 | #include <soc/interrupt.h> |
Nico Huber | 2afe4dc | 2017-09-19 09:36:03 +0200 | [diff] [blame] | 36 | #include <soc/iomap.h> |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 37 | #include <soc/irq.h> |
Subrata Banik | 46caf09 | 2018-09-28 19:54:30 +0530 | [diff] [blame] | 38 | #include <soc/itss.h> |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 39 | #include <soc/pci_devs.h> |
| 40 | #include <soc/ramstage.h> |
Nico Huber | 2afe4dc | 2017-09-19 09:36:03 +0200 | [diff] [blame] | 41 | #include <soc/systemagent.h> |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 42 | #include <string.h> |
| 43 | |
Elyes HAOUAS | c338507 | 2019-03-21 15:38:06 +0100 | [diff] [blame] | 44 | #include "chip.h" |
| 45 | |
Gaggery Tsai | 711fb81 | 2018-05-22 12:32:48 -0700 | [diff] [blame] | 46 | struct pcie_entry { |
| 47 | unsigned int devfn; |
| 48 | unsigned int func_count; |
| 49 | }; |
| 50 | |
| 51 | /* |
| 52 | * According to table 2-2 in doc#546717: |
| 53 | * PCI bus[function] ID |
| 54 | * D28:[F0 - F7] 0xA110 - 0xA117 |
| 55 | * D29:[F0 - F7] 0xA118 - 0xA11F |
| 56 | * D27:[F0 - F3] 0xA167 - 0xA16A |
| 57 | */ |
| 58 | static const struct pcie_entry pcie_table_skl_pch_h[] = { |
| 59 | {PCH_DEVFN_PCIE1, 8}, |
| 60 | {PCH_DEVFN_PCIE9, 8}, |
| 61 | {PCH_DEVFN_PCIE17, 4}, |
| 62 | }; |
| 63 | |
| 64 | /* |
| 65 | * According to table 2-2 in doc#564464: |
| 66 | * PCI bus[function] ID |
| 67 | * D28:[F0 - F7] 0xA290 - 0xA297 |
| 68 | * D29:[F0 - F7] 0xA298 - 0xA29F |
| 69 | * D27:[F0 - F7] 0xA2E7 - 0xA2EE |
| 70 | */ |
| 71 | static const struct pcie_entry pcie_table_kbl_pch_h[] = { |
| 72 | {PCH_DEVFN_PCIE1, 8}, |
| 73 | {PCH_DEVFN_PCIE9, 8}, |
| 74 | {PCH_DEVFN_PCIE17, 8}, |
| 75 | }; |
| 76 | |
| 77 | /* |
| 78 | * According to table 2-2 in doc#567995/545659: |
| 79 | * PCI bus[function] ID |
| 80 | * D28:[F0 - F7] 0x9D10 - 0x9D17 |
| 81 | * D29:[F0 - F3] 0x9D18 - 0x9D1B |
| 82 | */ |
| 83 | static const struct pcie_entry pcie_table_skl_pch_lp[] = { |
| 84 | {PCH_DEVFN_PCIE1, 8}, |
| 85 | {PCH_DEVFN_PCIE9, 4}, |
| 86 | }; |
| 87 | |
| 88 | /* |
| 89 | * If the PCIe root port at function 0 is disabled, |
| 90 | * the PCIe root ports might be coalesced after FSP silicon init. |
| 91 | * The below function will swap the devfn of the first enabled device |
| 92 | * in devicetree and function 0 resides a pci device |
| 93 | * so that it won't confuse coreboot. |
| 94 | */ |
| 95 | static void pcie_update_device_tree(const struct pcie_entry *pcie_rp_group, |
| 96 | size_t pci_groups) |
| 97 | { |
| 98 | struct device *func0; |
| 99 | unsigned int devfn, devfn0; |
| 100 | int i, group; |
| 101 | unsigned int inc = PCI_DEVFN(0, 1); |
| 102 | |
| 103 | for (group = 0; group < pci_groups; group++) { |
| 104 | devfn0 = pcie_rp_group[group].devfn; |
Kyösti Mälkki | 903b40a | 2019-07-03 07:25:59 +0300 | [diff] [blame] | 105 | func0 = pcidev_path_on_root(devfn0); |
Gaggery Tsai | 711fb81 | 2018-05-22 12:32:48 -0700 | [diff] [blame] | 106 | if (func0 == NULL) |
| 107 | continue; |
| 108 | |
| 109 | /* No more functions if function 0 is disabled. */ |
| 110 | if (pci_read_config32(func0, PCI_VENDOR_ID) == 0xffffffff) |
| 111 | continue; |
| 112 | |
| 113 | devfn = devfn0 + inc; |
| 114 | |
| 115 | /* |
| 116 | * Increase function by 1. |
| 117 | * Then find first enabled device to replace func0 |
| 118 | * as that port was move to func0. |
| 119 | */ |
| 120 | for (i = 1; i < pcie_rp_group[group].func_count; |
| 121 | i++, devfn += inc) { |
Kyösti Mälkki | 903b40a | 2019-07-03 07:25:59 +0300 | [diff] [blame] | 122 | struct device *dev = pcidev_path_on_root(devfn); |
Gaggery Tsai | 711fb81 | 2018-05-22 12:32:48 -0700 | [diff] [blame] | 123 | if (dev == NULL || !dev->enabled) |
| 124 | continue; |
| 125 | |
| 126 | /* |
| 127 | * Found the first enabled device in |
| 128 | * a given dev number. |
| 129 | */ |
| 130 | printk(BIOS_INFO, "PCI func %d was swapped" |
| 131 | " to func 0.\n", i); |
| 132 | func0->path.pci.devfn = dev->path.pci.devfn; |
| 133 | dev->path.pci.devfn = devfn0; |
| 134 | break; |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | static void pcie_override_devicetree_after_silicon_init(void) |
| 140 | { |
| 141 | uint16_t id, id_mask; |
| 142 | |
| 143 | id = pci_read_config16(PCH_DEV_PCIE1, PCI_DEVICE_ID); |
| 144 | /* |
| 145 | * We may read an ID other than func 0 after FSP-S. |
| 146 | * Strip out 4 least significant bits. |
| 147 | */ |
| 148 | id_mask = id & ~0xf; |
| 149 | printk(BIOS_INFO, "Override DT after FSP-S, PCH is "); |
| 150 | if (id_mask == (PCI_DEVICE_ID_INTEL_SPT_LP_PCIE_RP1 & ~0xf)) { |
| 151 | printk(BIOS_INFO, "KBL/SKL PCH-LP SKU\n"); |
| 152 | pcie_update_device_tree(&pcie_table_skl_pch_lp[0], |
| 153 | ARRAY_SIZE(pcie_table_skl_pch_lp)); |
| 154 | } else if (id_mask == (PCI_DEVICE_ID_INTEL_KBP_H_PCIE_RP1 & ~0xf)) { |
| 155 | printk(BIOS_INFO, "KBL PCH-H SKU\n"); |
| 156 | pcie_update_device_tree(&pcie_table_kbl_pch_h[0], |
| 157 | ARRAY_SIZE(pcie_table_kbl_pch_h)); |
| 158 | } else if (id_mask == (PCI_DEVICE_ID_INTEL_SPT_H_PCIE_RP1 & ~0xf)) { |
| 159 | printk(BIOS_INFO, "SKL PCH-H SKU\n"); |
| 160 | pcie_update_device_tree(&pcie_table_skl_pch_h[0], |
| 161 | ARRAY_SIZE(pcie_table_skl_pch_h)); |
| 162 | } else { |
| 163 | printk(BIOS_ERR, "[BUG] PCIE Root Port id 0x%x" |
| 164 | " is not found\n", id); |
| 165 | return; |
| 166 | } |
| 167 | } |
| 168 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 169 | void soc_init_pre_device(void *chip_info) |
| 170 | { |
Subrata Banik | 46caf09 | 2018-09-28 19:54:30 +0530 | [diff] [blame] | 171 | /* Snapshot the current GPIO IRQ polarities. FSP is setting a |
| 172 | * default policy that doesn't honor boards' requirements. */ |
| 173 | itss_snapshot_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END); |
| 174 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 175 | /* Perform silicon specific init. */ |
Aaron Durbin | 6c191d8 | 2016-11-29 21:22:42 -0600 | [diff] [blame] | 176 | fsp_silicon_init(romstage_handoff_is_resume()); |
Subrata Banik | 46caf09 | 2018-09-28 19:54:30 +0530 | [diff] [blame] | 177 | |
| 178 | /* Restore GPIO IRQ polarities back to previous settings. */ |
| 179 | itss_restore_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END); |
| 180 | |
Gaggery Tsai | 711fb81 | 2018-05-22 12:32:48 -0700 | [diff] [blame] | 181 | /* swap enabled PCI ports in device tree if needed */ |
| 182 | pcie_override_devicetree_after_silicon_init(); |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 183 | } |
| 184 | |
Furquan Shaikh | c248044 | 2017-02-20 13:41:56 -0800 | [diff] [blame] | 185 | void soc_fsp_load(void) |
| 186 | { |
| 187 | fsps_load(romstage_handoff_is_resume()); |
| 188 | } |
| 189 | |
Elyes HAOUAS | 143fb46 | 2018-05-25 12:56:45 +0200 | [diff] [blame] | 190 | static void pci_domain_set_resources(struct device *dev) |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 191 | { |
| 192 | assign_resources(dev->link_list); |
| 193 | } |
| 194 | |
| 195 | static struct device_operations pci_domain_ops = { |
| 196 | .read_resources = &pci_domain_read_resources, |
| 197 | .set_resources = &pci_domain_set_resources, |
| 198 | .scan_bus = &pci_domain_scan_bus, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 199 | #if CONFIG(HAVE_ACPI_TABLES) |
Nico Huber | c37b0e3 | 2017-09-18 20:03:46 +0200 | [diff] [blame] | 200 | .write_acpi_tables = &northbridge_write_acpi_tables, |
| 201 | .acpi_name = &soc_acpi_name, |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 202 | #endif |
| 203 | }; |
| 204 | |
| 205 | static struct device_operations cpu_bus_ops = { |
| 206 | .read_resources = DEVICE_NOOP, |
| 207 | .set_resources = DEVICE_NOOP, |
| 208 | .enable_resources = DEVICE_NOOP, |
Subrata Banik | a4b11e5c | 2017-02-03 18:57:49 +0530 | [diff] [blame] | 209 | .init = DEVICE_NOOP, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 210 | #if CONFIG(HAVE_ACPI_TABLES) |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 211 | .acpi_fill_ssdt_generator = generate_cpu_entries, |
| 212 | #endif |
| 213 | }; |
| 214 | |
Elyes HAOUAS | 143fb46 | 2018-05-25 12:56:45 +0200 | [diff] [blame] | 215 | static void soc_enable(struct device *dev) |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 216 | { |
| 217 | /* Set the operations if it is a special bus type */ |
Subrata Banik | 3c838c7 | 2017-12-06 18:14:01 +0530 | [diff] [blame] | 218 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 219 | dev->ops = &pci_domain_ops; |
Subrata Banik | 3c838c7 | 2017-12-06 18:14:01 +0530 | [diff] [blame] | 220 | else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 221 | dev->ops = &cpu_bus_ops; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | struct chip_operations soc_intel_skylake_ops = { |
| 225 | CHIP_NAME("Intel 6th Gen") |
| 226 | .enable_dev = &soc_enable, |
| 227 | .init = &soc_init_pre_device, |
| 228 | }; |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 229 | |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 230 | /* UPD parameters to be initialized before SiliconInit */ |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 231 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd) |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 232 | { |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 233 | FSP_S_CONFIG *params = &supd->FspsConfig; |
| 234 | FSP_S_TEST_CONFIG *tconfig = &supd->FspsTestConfig; |
Kyösti Mälkki | 4af4e7f | 2019-07-14 05:50:20 +0300 | [diff] [blame] | 235 | struct soc_intel_skylake_config *config; |
Kyösti Mälkki | 28dc7dc | 2019-07-12 13:10:19 +0300 | [diff] [blame] | 236 | struct device *dev; |
Patrick Georgi | d2990ff | 2018-05-03 18:06:15 +0200 | [diff] [blame] | 237 | uintptr_t vbt_data = (uintptr_t)vbt_get(); |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 238 | int i; |
| 239 | |
Kyösti Mälkki | 28dc7dc | 2019-07-12 13:10:19 +0300 | [diff] [blame] | 240 | config = config_of_path(SA_DEVFN_ROOT); |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 241 | |
| 242 | mainboard_silicon_init_params(params); |
Gaggery Tsai | da6f4ae | 2018-01-15 15:03:01 +0800 | [diff] [blame] | 243 | /* Set PsysPmax if it is available from DT */ |
| 244 | if (config->psys_pmax) { |
| 245 | /* PsysPmax is in unit of 1/8 Watt */ |
| 246 | tconfig->PsysPmax = config->psys_pmax * 8; |
| 247 | printk(BIOS_DEBUG, "psys_pmax = %d\n", tconfig->PsysPmax); |
| 248 | } |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 249 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 250 | params->GraphicsConfigPtr = (u32) vbt_data; |
| 251 | |
| 252 | for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) { |
| 253 | params->PortUsb20Enable[i] = |
| 254 | config->usb2_ports[i].enable; |
Subrata Banik | 2c3054c | 2016-11-22 20:21:49 +0530 | [diff] [blame] | 255 | params->Usb2OverCurrentPin[i] = |
| 256 | config->usb2_ports[i].ocpin; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 257 | params->Usb2AfePetxiset[i] = |
| 258 | config->usb2_ports[i].pre_emp_bias; |
| 259 | params->Usb2AfeTxiset[i] = |
| 260 | config->usb2_ports[i].tx_bias; |
| 261 | params->Usb2AfePredeemp[i] = |
| 262 | config->usb2_ports[i].tx_emp_enable; |
| 263 | params->Usb2AfePehalfbit[i] = |
| 264 | config->usb2_ports[i].pre_emp_bit; |
| 265 | } |
| 266 | |
| 267 | for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) { |
| 268 | params->PortUsb30Enable[i] = config->usb3_ports[i].enable; |
Subrata Banik | 2c3054c | 2016-11-22 20:21:49 +0530 | [diff] [blame] | 269 | params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 270 | if (config->usb3_ports[i].tx_de_emp) { |
| 271 | params->Usb3HsioTxDeEmphEnable[i] = 1; |
| 272 | params->Usb3HsioTxDeEmph[i] = |
| 273 | config->usb3_ports[i].tx_de_emp; |
| 274 | } |
| 275 | if (config->usb3_ports[i].tx_downscale_amp) { |
| 276 | params->Usb3HsioTxDownscaleAmpEnable[i] = 1; |
| 277 | params->Usb3HsioTxDownscaleAmp[i] = |
| 278 | config->usb3_ports[i].tx_downscale_amp; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | memcpy(params->SataPortsEnable, config->SataPortsEnable, |
| 283 | sizeof(params->SataPortsEnable)); |
| 284 | memcpy(params->SataPortsDevSlp, config->SataPortsDevSlp, |
| 285 | sizeof(params->SataPortsDevSlp)); |
| 286 | memcpy(params->PcieRpClkReqSupport, config->PcieRpClkReqSupport, |
| 287 | sizeof(params->PcieRpClkReqSupport)); |
| 288 | memcpy(params->PcieRpClkReqNumber, config->PcieRpClkReqNumber, |
| 289 | sizeof(params->PcieRpClkReqNumber)); |
Rizwan Qureshi | 6ab4ed4 | 2017-09-05 14:18:25 +0530 | [diff] [blame] | 290 | memcpy(params->PcieRpAdvancedErrorReporting, |
| 291 | config->PcieRpAdvancedErrorReporting, |
| 292 | sizeof(params->PcieRpAdvancedErrorReporting)); |
Rizwan Qureshi | 0393739 | 2017-09-16 01:54:20 +0530 | [diff] [blame] | 293 | memcpy(params->PcieRpLtrEnable, config->PcieRpLtrEnable, |
| 294 | sizeof(params->PcieRpLtrEnable)); |
Duncan Laurie | 74ea48e | 2018-01-29 12:00:47 -0800 | [diff] [blame] | 295 | memcpy(params->PcieRpHotPlug, config->PcieRpHotPlug, |
| 296 | sizeof(params->PcieRpHotPlug)); |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 297 | |
Divya Chellap | e7fb7ce | 2017-12-19 20:16:50 +0530 | [diff] [blame] | 298 | /* |
| 299 | * PcieRpClkSrcNumber UPD is set to clock source number(0-6) for |
| 300 | * all the enabled PCIe root ports, invalid(0x1F) is set for |
| 301 | * disabled PCIe root ports. |
| 302 | */ |
| 303 | for (i = 0; i < CONFIG_MAX_ROOT_PORTS; i++) { |
| 304 | if (config->PcieRpClkReqSupport[i]) |
| 305 | params->PcieRpClkSrcNumber[i] = |
| 306 | config->PcieRpClkSrcNumber[i]; |
| 307 | else |
| 308 | params->PcieRpClkSrcNumber[i] = 0x1F; |
| 309 | } |
| 310 | |
Naresh G Solanki | eedf6d8 | 2016-11-16 21:27:38 +0530 | [diff] [blame] | 311 | /* disable Legacy PME */ |
| 312 | memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci)); |
| 313 | |
Subrata Banik | 10a9432 | 2019-07-08 14:49:22 +0530 | [diff] [blame] | 314 | /* Legacy 8254 timer support */ |
| 315 | params->Early8254ClockGatingEnable = !CONFIG_USE_LEGACY_8254_TIMER; |
| 316 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 317 | memcpy(params->SerialIoDevMode, config->SerialIoDevMode, |
| 318 | sizeof(params->SerialIoDevMode)); |
| 319 | |
| 320 | params->PchCio2Enable = config->Cio2Enable; |
Rizwan Qureshi | c2c8a74 | 2017-01-13 22:04:11 +0530 | [diff] [blame] | 321 | params->SaImguEnable = config->SaImguEnable; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 322 | params->Heci3Enabled = config->Heci3Enabled; |
| 323 | |
| 324 | params->LogoPtr = config->LogoPtr; |
| 325 | params->LogoSize = config->LogoSize; |
| 326 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 327 | params->CpuConfig.Bits.VmxEnable = CONFIG(ENABLE_VMX); |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 328 | |
| 329 | params->PchPmWoWlanEnable = config->PchPmWoWlanEnable; |
| 330 | params->PchPmWoWlanDeepSxEnable = config->PchPmWoWlanDeepSxEnable; |
| 331 | params->PchPmLanWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx; |
| 332 | |
| 333 | params->PchLanEnable = config->EnableLan; |
Duncan Laurie | 14485ef | 2017-12-13 13:58:35 -0800 | [diff] [blame] | 334 | if (config->EnableLan) { |
| 335 | params->PchLanLtrEnable = config->EnableLanLtr; |
| 336 | params->PchLanK1OffEnable = config->EnableLanK1Off; |
| 337 | params->PchLanClkReqSupported = config->LanClkReqSupported; |
| 338 | params->PchLanClkReqNumber = config->LanClkReqNumber; |
| 339 | } |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 340 | params->SataSalpSupport = config->SataSalpSupport; |
| 341 | params->SsicPortEnable = config->SsicPortEnable; |
| 342 | params->ScsEmmcEnabled = config->ScsEmmcEnabled; |
| 343 | params->ScsEmmcHs400Enabled = config->ScsEmmcHs400Enabled; |
| 344 | params->ScsSdCardEnabled = config->ScsSdCardEnabled; |
li feng | 2106638 | 2018-05-22 12:49:53 -0700 | [diff] [blame] | 345 | |
Pratik Prajapati | e072247 | 2018-08-22 18:58:38 -0700 | [diff] [blame] | 346 | if (!!params->ScsEmmcHs400Enabled && !!config->EmmcHs400DllNeed) { |
| 347 | params->PchScsEmmcHs400DllDataValid = |
| 348 | !!config->EmmcHs400DllNeed; |
| 349 | params->PchScsEmmcHs400RxStrobeDll1 = |
| 350 | config->ScsEmmcHs400RxStrobeDll1; |
| 351 | params->PchScsEmmcHs400TxDataDll = |
| 352 | config->ScsEmmcHs400TxDataDll; |
| 353 | } |
| 354 | |
li feng | 2106638 | 2018-05-22 12:49:53 -0700 | [diff] [blame] | 355 | /* If ISH is enabled, enable ISH elements */ |
Kyösti Mälkki | 903b40a | 2019-07-03 07:25:59 +0300 | [diff] [blame] | 356 | dev = pcidev_path_on_root(PCH_DEVFN_ISH); |
li feng | 2106638 | 2018-05-22 12:49:53 -0700 | [diff] [blame] | 357 | if (dev) |
| 358 | params->PchIshEnable = dev->enabled; |
| 359 | else |
| 360 | params->PchIshEnable = 0; |
| 361 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 362 | params->PchHdaEnable = config->EnableAzalia; |
| 363 | params->PchHdaIoBufferOwnership = config->IoBufferOwnership; |
| 364 | params->PchHdaDspEnable = config->DspEnable; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 365 | params->Device4Enable = config->Device4Enable; |
| 366 | params->SataEnable = config->EnableSata; |
| 367 | params->SataMode = config->SataMode; |
Matt DeVillier | 9e0d69b | 2017-10-10 14:03:36 -0500 | [diff] [blame] | 368 | params->SataSpeedLimit = config->SataSpeedLimit; |
Kane Chen | 14e0fa5 | 2017-12-27 12:11:23 +0800 | [diff] [blame] | 369 | params->SataPwrOptEnable = config->SataPwrOptEnable; |
Naresh G Solanki | 84fbc30 | 2018-10-15 15:37:15 +0530 | [diff] [blame] | 370 | params->EnableTcoTimer = !config->PmTimerDisabled; |
Matt DeVillier | 9e0d69b | 2017-10-10 14:03:36 -0500 | [diff] [blame] | 371 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 372 | tconfig->PchLockDownGlobalSmi = config->LockDownConfigGlobalSmi; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 373 | tconfig->PchLockDownRtcLock = config->LockDownConfigRtcLock; |
Praveen hodagatta pranesh | 015b3dc | 2018-11-23 17:41:46 +0800 | [diff] [blame] | 374 | tconfig->PowerLimit4 = config->PowerLimit4; |
Barnali Sarkar | fbf1018 | 2017-08-11 18:38:38 +0530 | [diff] [blame] | 375 | /* |
| 376 | * To disable HECI, the Psf needs to be left unlocked |
| 377 | * by FSP till end of post sequence. Based on the devicetree |
| 378 | * setting, we set the appropriate PsfUnlock policy in FSP, |
| 379 | * do the changes and then lock it back in coreboot during finalize. |
| 380 | */ |
| 381 | tconfig->PchSbAccessUnlock = (config->HeciEnabled == 0) ? 1 : 0; |
Subrata Banik | c4986eb | 2018-05-09 14:55:09 +0530 | [diff] [blame] | 382 | if (get_lockdown_config() == CHIPSET_LOCKDOWN_COREBOOT) { |
Subrata Banik | c204aaa | 2017-08-17 15:49:58 +0530 | [diff] [blame] | 383 | tconfig->PchLockDownBiosInterface = 0; |
| 384 | params->PchLockDownBiosLock = 0; |
| 385 | params->PchLockDownSpiEiss = 0; |
| 386 | /* |
| 387 | * Skip Spi Flash Lockdown from inside FSP. |
| 388 | * Making this config "0" means FSP won't set the FLOCKDN bit |
| 389 | * of SPIBAR + 0x04 (i.e., Bit 15 of BIOS_HSFSTS_CTL). |
| 390 | * So, it becomes coreboot's responsibility to set this bit |
| 391 | * before end of POST for security concerns. |
| 392 | */ |
| 393 | params->SpiFlashCfgLockDown = 0; |
| 394 | } |
Matt Delco | dfffcad | 2018-07-23 12:44:15 -0700 | [diff] [blame] | 395 | /* only replacing preexisting subsys ID defaults when non-zero */ |
Elyes HAOUAS | b58e99d | 2019-01-23 12:04:43 +0100 | [diff] [blame] | 396 | if (CONFIG_SUBSYSTEM_VENDOR_ID != 0) { |
| 397 | params->DefaultSvid = CONFIG_SUBSYSTEM_VENDOR_ID; |
| 398 | params->PchSubSystemVendorId = CONFIG_SUBSYSTEM_VENDOR_ID; |
| 399 | } |
| 400 | |
| 401 | if (CONFIG_SUBSYSTEM_DEVICE_ID != 0) { |
| 402 | params->DefaultSid = CONFIG_SUBSYSTEM_DEVICE_ID; |
| 403 | params->PchSubSystemId = CONFIG_SUBSYSTEM_DEVICE_ID; |
| 404 | } |
| 405 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 406 | params->PchPmWolEnableOverride = config->WakeConfigWolEnableOverride; |
| 407 | params->PchPmPcieWakeFromDeepSx = config->WakeConfigPcieWakeFromDeepSx; |
| 408 | params->PchPmDeepSxPol = config->PmConfigDeepSxPol; |
Duncan Laurie | 25c7d93 | 2017-02-17 17:16:43 -0800 | [diff] [blame] | 409 | params->PchPmSlpS0Enable = config->s0ix_enable; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 410 | params->PchPmSlpS3MinAssert = config->PmConfigSlpS3MinAssert; |
| 411 | params->PchPmSlpS4MinAssert = config->PmConfigSlpS4MinAssert; |
| 412 | params->PchPmSlpSusMinAssert = config->PmConfigSlpSusMinAssert; |
| 413 | params->PchPmSlpAMinAssert = config->PmConfigSlpAMinAssert; |
| 414 | params->PchPmLpcClockRun = config->PmConfigPciClockRun; |
| 415 | params->PchPmSlpStrchSusUp = config->PmConfigSlpStrchSusUp; |
| 416 | params->PchPmPwrBtnOverridePeriod = |
| 417 | config->PmConfigPwrBtnOverridePeriod; |
| 418 | params->PchPmPwrCycDur = config->PmConfigPwrCycDur; |
Rizwan Qureshi | 0da186c | 2017-02-23 14:43:39 +0530 | [diff] [blame] | 419 | |
| 420 | /* Indicate whether platform supports Voltage Margining */ |
| 421 | params->PchPmSlpS0VmEnable = config->PchPmSlpS0VmEnable; |
| 422 | |
Nico Huber | 44e89af | 2019-02-23 19:24:51 +0100 | [diff] [blame] | 423 | params->PchSirqEnable = config->serirq_mode != SERIRQ_OFF; |
| 424 | params->PchSirqMode = config->serirq_mode == SERIRQ_CONTINUOUS; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 425 | |
Subrata Banik | cf32fd1 | 2018-12-19 18:02:17 +0530 | [diff] [blame] | 426 | params->CpuConfig.Bits.SkipMpInit = !CONFIG_USE_INTEL_FSP_MP_INIT; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 427 | |
Subrata Banik | c4986eb | 2018-05-09 14:55:09 +0530 | [diff] [blame] | 428 | for (i = 0; i < ARRAY_SIZE(config->i2c_voltage); i++) |
Aaron Durbin | ed14a4e | 2016-11-09 17:04:15 -0600 | [diff] [blame] | 429 | params->SerialIoI2cVoltage[i] = config->i2c_voltage[i]; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 430 | |
| 431 | for (i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++) |
| 432 | fill_vr_domain_config(params, i, &config->domain_vr_config[i]); |
| 433 | |
| 434 | /* Show SPI controller if enabled in devicetree.cb */ |
Kyösti Mälkki | 903b40a | 2019-07-03 07:25:59 +0300 | [diff] [blame] | 435 | dev = pcidev_path_on_root(PCH_DEVFN_SPI); |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 436 | params->ShowSpiController = dev->enabled; |
| 437 | |
Duncan Laurie | f511695 | 2018-03-26 02:24:18 -0700 | [diff] [blame] | 438 | /* Enable xDCI controller if enabled in devicetree and allowed */ |
Kyösti Mälkki | 903b40a | 2019-07-03 07:25:59 +0300 | [diff] [blame] | 439 | dev = pcidev_path_on_root(PCH_DEVFN_USBOTG); |
Duncan Laurie | f511695 | 2018-03-26 02:24:18 -0700 | [diff] [blame] | 440 | if (!xdci_can_enable()) |
| 441 | dev->enabled = 0; |
| 442 | params->XdciEnable = dev->enabled; |
| 443 | |
Rizwan Qureshi | 6467014 | 2016-11-23 15:25:19 +0530 | [diff] [blame] | 444 | /* |
| 445 | * Send VR specific mailbox commands: |
| 446 | * 000b - no VR specific command sent |
| 447 | * 001b - VR mailbox command specifically for the MPS IMPV8 VR |
Lee Leahy | f4c4ab9 | 2017-03-16 17:08:03 -0700 | [diff] [blame] | 448 | * will be sent |
Rizwan Qureshi | 6467014 | 2016-11-23 15:25:19 +0530 | [diff] [blame] | 449 | * 010b - VR specific command sent for PS4 exit issue |
| 450 | * 100b - VR specific command sent for MPS VR decay issue |
| 451 | */ |
| 452 | params->SendVrMbxCmd1 = config->SendVrMbxCmd; |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 453 | |
Rizwan Qureshi | b3e18c7 | 2017-09-25 17:35:15 +0530 | [diff] [blame] | 454 | /* |
| 455 | * Activates VR mailbox command for Intersil VR C-state issues. |
| 456 | * 0 - no mailbox command sent. |
| 457 | * 1 - VR mailbox command sent for IA/GT rails only. |
| 458 | * 2 - VR mailbox command sent for IA/GT/SA rails. |
| 459 | */ |
| 460 | params->IslVrCmd = config->IslVrCmd; |
| 461 | |
Duncan Laurie | b2aac85 | 2017-03-07 19:12:02 -0800 | [diff] [blame] | 462 | /* Acoustic Noise Mitigation */ |
| 463 | params->AcousticNoiseMitigation = config->AcousticNoiseMitigation; |
| 464 | params->SlowSlewRateForIa = config->SlowSlewRateForIa; |
| 465 | params->SlowSlewRateForGt = config->SlowSlewRateForGt; |
| 466 | params->SlowSlewRateForSa = config->SlowSlewRateForSa; |
| 467 | params->FastPkgCRampDisableIa = config->FastPkgCRampDisableIa; |
| 468 | params->FastPkgCRampDisableGt = config->FastPkgCRampDisableGt; |
| 469 | params->FastPkgCRampDisableSa = config->FastPkgCRampDisableSa; |
| 470 | |
Rizwan Qureshi | ffe5810 | 2017-02-10 15:58:24 +0530 | [diff] [blame] | 471 | /* Enable PMC XRAM read */ |
| 472 | tconfig->PchPmPmcReadDisable = config->PchPmPmcReadDisable; |
| 473 | |
Subrata Banik | 6b45ee4 | 2017-05-12 11:43:57 +0530 | [diff] [blame] | 474 | /* Enable/Disable EIST */ |
| 475 | tconfig->Eist = config->eist_enable; |
| 476 | |
marxwang | ec5a947 | 2017-12-11 14:57:49 +0800 | [diff] [blame] | 477 | /* Set TccActivationOffset */ |
| 478 | tconfig->TccActivationOffset = config->tcc_offset; |
| 479 | |
Nico Huber | 2afe4dc | 2017-09-19 09:36:03 +0200 | [diff] [blame] | 480 | /* Enable VT-d and X2APIC */ |
| 481 | if (!config->ignore_vtd && soc_is_vtd_capable()) { |
| 482 | params->VtdBaseAddress[0] = GFXVT_BASE_ADDRESS; |
| 483 | params->VtdBaseAddress[1] = VTVC0_BASE_ADDRESS; |
| 484 | params->X2ApicOptOut = 0; |
| 485 | tconfig->VtdDisable = 0; |
| 486 | |
| 487 | params->PchIoApicBdfValid = 1; |
| 488 | params->PchIoApicBusNumber = 250; |
| 489 | params->PchIoApicDeviceNumber = 31; |
| 490 | params->PchIoApicFunctionNumber = 0; |
| 491 | } |
| 492 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 493 | soc_irq_settings(params); |
Rizwan Qureshi | 1222a73 | 2016-08-23 14:31:23 +0530 | [diff] [blame] | 494 | } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 495 | |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 496 | /* Mainboard GPIO Configuration */ |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 497 | __weak void mainboard_silicon_init_params(FSP_S_CONFIG *params) |
Naresh G Solanki | a2d4062 | 2016-08-30 20:47:13 +0530 | [diff] [blame] | 498 | { |
| 499 | printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 500 | } |