Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Hannah Williams | 3ff14a0 | 2017-05-05 16:30:22 -0700 | [diff] [blame] | 4 | * Copyright (C) 2015 - 2017 Intel Corp. |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 5 | * (Written by Alexandru Gagniuc <alexandrux.gagniuc@intel.com> for Intel Corp.) |
| 6 | * (Written by Andrey Petrov <andrey.petrov@intel.com> for Intel Corp.) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
Martin Roth | ebabfad | 2016-04-10 11:09:16 -0600 | [diff] [blame] | 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 17 | */ |
| 18 | |
Hannah Williams | 0f61da8 | 2016-04-18 13:47:08 -0700 | [diff] [blame] | 19 | #include <arch/acpi.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 20 | #include <bootstate.h> |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 21 | #include <cbmem.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 22 | #include <console/console.h> |
| 23 | #include <cpu/cpu.h> |
Andrey Petrov | a697c19 | 2016-12-07 10:47:46 -0800 | [diff] [blame] | 24 | #include <cpu/x86/mp.h> |
Barnali Sarkar | 66fe0c4 | 2017-05-23 18:17:14 +0530 | [diff] [blame] | 25 | #include <cpu/x86/msr.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 26 | #include <device/device.h> |
| 27 | #include <device/pci.h> |
Barnali Sarkar | e70142c | 2017-03-28 16:32:33 +0530 | [diff] [blame] | 28 | #include <intelblocks/fast_spi.h> |
Barnali Sarkar | 66fe0c4 | 2017-05-23 18:17:14 +0530 | [diff] [blame] | 29 | #include <intelblocks/msr.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 30 | #include <fsp/api.h> |
| 31 | #include <fsp/util.h> |
Barnali Sarkar | 66fe0c4 | 2017-05-23 18:17:14 +0530 | [diff] [blame] | 32 | #include <intelblocks/cpulib.h> |
Bora Guvendik | 33117ec | 2017-04-10 15:49:02 -0700 | [diff] [blame] | 33 | #include <intelblocks/itss.h> |
Shaunak Saha | 93cdc8b | 2017-04-18 15:42:09 -0700 | [diff] [blame] | 34 | #include <intelblocks/pmclib.h> |
Brandon Breitenstein | c6ec8dd | 2016-11-17 12:23:04 -0800 | [diff] [blame] | 35 | #include <romstage_handoff.h> |
Andrey Petrov | e07e13d | 2016-03-18 14:43:00 -0700 | [diff] [blame] | 36 | #include <soc/iomap.h> |
Bora Guvendik | 33117ec | 2017-04-10 15:49:02 -0700 | [diff] [blame] | 37 | #include <soc/itss.h> |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 38 | #include <soc/intel/common/vbt.h> |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 39 | #include <soc/nvs.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 40 | #include <soc/pci_devs.h> |
Furquan Shaikh | 6ac226d | 2016-06-15 17:13:20 -0700 | [diff] [blame] | 41 | #include <spi-generic.h> |
Aaron Durbin | ac3e482 | 2017-06-14 13:21:00 -0500 | [diff] [blame] | 42 | #include <soc/cpu.h> |
Andrey Petrov | 3dbea29 | 2016-06-14 22:20:28 -0700 | [diff] [blame] | 43 | #include <soc/pm.h> |
Aaron Durbin | fadfc2e | 2016-07-01 16:36:03 -0500 | [diff] [blame] | 44 | #include <soc/p2sb.h> |
Subrata Banik | 7952e28 | 2017-03-14 18:26:27 +0530 | [diff] [blame] | 45 | #include <soc/systemagent.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 46 | |
| 47 | #include "chip.h" |
| 48 | |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 49 | static void *vbt; |
| 50 | static struct region_device vbt_rdev; |
| 51 | |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 52 | static const char *soc_acpi_name(struct device *dev) |
| 53 | { |
| 54 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 55 | return "PCI0"; |
| 56 | |
| 57 | if (dev->path.type != DEVICE_PATH_PCI) |
| 58 | return NULL; |
| 59 | |
| 60 | switch (dev->path.pci.devfn) { |
| 61 | /* DSDT: acpi/northbridge.asl */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 62 | case SA_DEVFN_ROOT: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 63 | return "MCHC"; |
| 64 | /* DSDT: acpi/lpc.asl */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 65 | case PCH_DEVFN_LPC: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 66 | return "LPCB"; |
| 67 | /* DSDT: acpi/xhci.asl */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 68 | case PCH_DEVFN_XHCI: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 69 | return "XHCI"; |
| 70 | /* DSDT: acpi/pch_hda.asl */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 71 | case PCH_DEVFN_HDA: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 72 | return "HDAS"; |
| 73 | /* DSDT: acpi/lpss.asl */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 74 | case PCH_DEVFN_UART0: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 75 | return "URT1"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 76 | case PCH_DEVFN_UART1: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 77 | return "URT2"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 78 | case PCH_DEVFN_UART2: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 79 | return "URT3"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 80 | case PCH_DEVFN_UART3: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 81 | return "URT4"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 82 | case PCH_DEVFN_SPI0: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 83 | return "SPI1"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 84 | case PCH_DEVFN_SPI1: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 85 | return "SPI2"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 86 | case PCH_DEVFN_SPI2: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 87 | return "SPI3"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 88 | case PCH_DEVFN_PWM: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 89 | return "PWM"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 90 | case PCH_DEVFN_I2C0: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 91 | return "I2C0"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 92 | case PCH_DEVFN_I2C1: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 93 | return "I2C1"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 94 | case PCH_DEVFN_I2C2: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 95 | return "I2C2"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 96 | case PCH_DEVFN_I2C3: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 97 | return "I2C3"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 98 | case PCH_DEVFN_I2C4: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 99 | return "I2C4"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 100 | case PCH_DEVFN_I2C5: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 101 | return "I2C5"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 102 | case PCH_DEVFN_I2C6: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 103 | return "I2C6"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 104 | case PCH_DEVFN_I2C7: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 105 | return "I2C7"; |
| 106 | /* Storage */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 107 | case PCH_DEVFN_SDCARD: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 108 | return "SDCD"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 109 | case PCH_DEVFN_EMMC: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 110 | return "EMMC"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 111 | case PCH_DEVFN_SDIO: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 112 | return "SDIO"; |
Vaibhav Shankar | ec9168f | 2016-09-16 14:20:53 -0700 | [diff] [blame] | 113 | /* PCIe */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 114 | case PCH_DEVFN_PCIE1: |
Vaibhav Shankar | ec9168f | 2016-09-16 14:20:53 -0700 | [diff] [blame] | 115 | return "RP01"; |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | return NULL; |
| 119 | } |
| 120 | |
Venkateswarlu Vinjamuri | 6dd7b40 | 2017-02-24 15:37:30 -0800 | [diff] [blame] | 121 | static void pci_set_subsystem(device_t dev, unsigned vendor, unsigned device) |
| 122 | { |
| 123 | if (!vendor || !device) |
| 124 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 125 | pci_read_config32(dev, PCI_VENDOR_ID)); |
| 126 | else |
| 127 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 128 | (device << 16) | vendor); |
| 129 | } |
| 130 | |
| 131 | struct pci_operations soc_pci_ops = { |
| 132 | .set_subsystem = &pci_set_subsystem |
| 133 | }; |
| 134 | |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 135 | static void pci_domain_set_resources(device_t dev) |
| 136 | { |
Lee Leahy | 1d20fe7 | 2017-03-09 09:50:28 -0800 | [diff] [blame] | 137 | assign_resources(dev->link_list); |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | static struct device_operations pci_domain_ops = { |
| 141 | .read_resources = pci_domain_read_resources, |
| 142 | .set_resources = pci_domain_set_resources, |
| 143 | .enable_resources = NULL, |
| 144 | .init = NULL, |
| 145 | .scan_bus = pci_domain_scan_bus, |
| 146 | .ops_pci_bus = pci_bus_default_ops, |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 147 | .acpi_name = &soc_acpi_name, |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | static struct device_operations cpu_bus_ops = { |
| 151 | .read_resources = DEVICE_NOOP, |
| 152 | .set_resources = DEVICE_NOOP, |
| 153 | .enable_resources = DEVICE_NOOP, |
Aaron Durbin | ac3e482 | 2017-06-14 13:21:00 -0500 | [diff] [blame] | 154 | .init = apollolake_init_cpus, |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 155 | .scan_bus = NULL, |
Hannah Williams | 0f61da8 | 2016-04-18 13:47:08 -0700 | [diff] [blame] | 156 | .acpi_fill_ssdt_generator = generate_cpu_entries, |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | static void enable_dev(device_t dev) |
| 160 | { |
| 161 | /* Set the operations if it is a special bus type */ |
Lee Leahy | 4430f9f | 2017-03-09 10:00:30 -0800 | [diff] [blame] | 162 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 163 | dev->ops = &pci_domain_ops; |
Lee Leahy | 4430f9f | 2017-03-09 10:00:30 -0800 | [diff] [blame] | 164 | else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 165 | dev->ops = &cpu_bus_ops; |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 166 | } |
| 167 | |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 168 | /* |
| 169 | * If the PCIe root port at function 0 is disabled, |
| 170 | * the PCIe root ports might be coalesced after FSP silicon init. |
| 171 | * The below function will swap the devfn of the first enabled device |
| 172 | * in devicetree and function 0 resides a pci device |
| 173 | * so that it won't confuse coreboot. |
| 174 | */ |
| 175 | static void pcie_update_device_tree(unsigned int devfn0, int num_funcs) |
| 176 | { |
| 177 | device_t func0; |
| 178 | unsigned int devfn; |
| 179 | int i; |
| 180 | unsigned int inc = PCI_DEVFN(0, 1); |
| 181 | |
| 182 | func0 = dev_find_slot(0, devfn0); |
| 183 | if (func0 == NULL) |
| 184 | return; |
| 185 | |
| 186 | /* No more functions if function 0 is disabled. */ |
| 187 | if (pci_read_config32(func0, PCI_VENDOR_ID) == 0xffffffff) |
| 188 | return; |
| 189 | |
| 190 | devfn = devfn0 + inc; |
| 191 | |
| 192 | /* |
| 193 | * Increase funtion by 1. |
| 194 | * Then find first enabled device to replace func0 |
| 195 | * as that port was move to func0. |
| 196 | */ |
| 197 | for (i = 1; i < num_funcs; i++, devfn += inc) { |
| 198 | device_t dev = dev_find_slot(0, devfn); |
| 199 | if (dev == NULL) |
| 200 | continue; |
| 201 | |
| 202 | if (!dev->enabled) |
| 203 | continue; |
| 204 | /* Found the first enabled device in given dev number */ |
| 205 | func0->path.pci.devfn = dev->path.pci.devfn; |
| 206 | dev->path.pci.devfn = devfn0; |
| 207 | break; |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | static void pcie_override_devicetree_after_silicon_init(void) |
| 212 | { |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 213 | pcie_update_device_tree(PCH_DEVFN_PCIE1, 4); |
| 214 | pcie_update_device_tree(PCH_DEVFN_PCIE5, 2); |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 215 | } |
| 216 | |
Sumeet Pawnikar | a247d8e | 2016-09-27 23:18:35 +0530 | [diff] [blame] | 217 | /* Configure package power limits */ |
| 218 | static void set_power_limits(void) |
Sumeet Pawnikar | 35240eb | 2016-08-23 11:20:20 +0530 | [diff] [blame] | 219 | { |
Sumeet Pawnikar | a247d8e | 2016-09-27 23:18:35 +0530 | [diff] [blame] | 220 | static struct soc_intel_apollolake_config *cfg; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 221 | struct device *dev = SA_DEV_ROOT; |
Sumeet Pawnikar | a247d8e | 2016-09-27 23:18:35 +0530 | [diff] [blame] | 222 | msr_t rapl_msr_reg, limit; |
| 223 | uint32_t power_unit; |
| 224 | uint32_t tdp, min_power, max_power; |
Sumeet Pawnikar | 428f90a | 2016-12-02 18:14:19 +0530 | [diff] [blame] | 225 | uint32_t pl2_val; |
Sumeet Pawnikar | 35240eb | 2016-08-23 11:20:20 +0530 | [diff] [blame] | 226 | |
Mario Scheithauer | 38b6100 | 2017-07-25 10:52:41 +0200 | [diff] [blame] | 227 | if (IS_ENABLED(CONFIG_APL_SKIP_SET_POWER_LIMITS)) { |
| 228 | printk(BIOS_INFO, "Skip the RAPL settings.\n"); |
| 229 | return; |
| 230 | } |
| 231 | |
Sumeet Pawnikar | a247d8e | 2016-09-27 23:18:35 +0530 | [diff] [blame] | 232 | if (!dev || !dev->chip_info) { |
| 233 | printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n"); |
| 234 | return; |
| 235 | } |
Sumeet Pawnikar | 35240eb | 2016-08-23 11:20:20 +0530 | [diff] [blame] | 236 | |
Sumeet Pawnikar | a247d8e | 2016-09-27 23:18:35 +0530 | [diff] [blame] | 237 | cfg = dev->chip_info; |
| 238 | |
| 239 | /* Get units */ |
| 240 | rapl_msr_reg = rdmsr(MSR_PKG_POWER_SKU_UNIT); |
| 241 | power_unit = 1 << (rapl_msr_reg.lo & 0xf); |
| 242 | |
| 243 | /* Get power defaults for this SKU */ |
| 244 | rapl_msr_reg = rdmsr(MSR_PKG_POWER_SKU); |
| 245 | tdp = rapl_msr_reg.lo & PKG_POWER_LIMIT_MASK; |
Sumeet Pawnikar | 428f90a | 2016-12-02 18:14:19 +0530 | [diff] [blame] | 246 | pl2_val = rapl_msr_reg.hi & PKG_POWER_LIMIT_MASK; |
Sumeet Pawnikar | a247d8e | 2016-09-27 23:18:35 +0530 | [diff] [blame] | 247 | min_power = (rapl_msr_reg.lo >> 16) & PKG_POWER_LIMIT_MASK; |
| 248 | max_power = rapl_msr_reg.hi & PKG_POWER_LIMIT_MASK; |
| 249 | |
| 250 | if (min_power > 0 && tdp < min_power) |
| 251 | tdp = min_power; |
| 252 | |
| 253 | if (max_power > 0 && tdp > max_power) |
| 254 | tdp = max_power; |
| 255 | |
| 256 | /* Set PL1 override value */ |
| 257 | tdp = (cfg->tdp_pl1_override_mw == 0) ? |
| 258 | tdp : (cfg->tdp_pl1_override_mw * power_unit) / 1000; |
Sumeet Pawnikar | 428f90a | 2016-12-02 18:14:19 +0530 | [diff] [blame] | 259 | /* Set PL2 override value */ |
| 260 | pl2_val = (cfg->tdp_pl2_override_mw == 0) ? |
| 261 | pl2_val : (cfg->tdp_pl2_override_mw * power_unit) / 1000; |
Sumeet Pawnikar | a247d8e | 2016-09-27 23:18:35 +0530 | [diff] [blame] | 262 | |
| 263 | /* Set long term power limit to TDP */ |
| 264 | limit.lo = tdp & PKG_POWER_LIMIT_MASK; |
Sumeet Pawnikar | a247d8e | 2016-09-27 23:18:35 +0530 | [diff] [blame] | 265 | /* Set PL1 Pkg Power clamp bit */ |
| 266 | limit.lo |= PKG_POWER_LIMIT_CLAMP; |
| 267 | |
| 268 | limit.lo |= PKG_POWER_LIMIT_EN; |
| 269 | limit.lo |= (MB_POWER_LIMIT1_TIME_DEFAULT & |
| 270 | PKG_POWER_LIMIT_TIME_MASK) << PKG_POWER_LIMIT_TIME_SHIFT; |
| 271 | |
Sumeet Pawnikar | 428f90a | 2016-12-02 18:14:19 +0530 | [diff] [blame] | 272 | /* Set short term power limit PL2 */ |
| 273 | limit.hi = pl2_val & PKG_POWER_LIMIT_MASK; |
| 274 | limit.hi |= PKG_POWER_LIMIT_EN; |
| 275 | |
Sumeet Pawnikar | a247d8e | 2016-09-27 23:18:35 +0530 | [diff] [blame] | 276 | /* Program package power limits in RAPL MSR */ |
| 277 | wrmsr(MSR_PKG_POWER_LIMIT, limit); |
| 278 | printk(BIOS_INFO, "RAPL PL1 %d.%dW\n", tdp / power_unit, |
| 279 | 100 * (tdp % power_unit) / power_unit); |
Sumeet Pawnikar | 428f90a | 2016-12-02 18:14:19 +0530 | [diff] [blame] | 280 | printk(BIOS_INFO, "RAPL PL2 %d.%dW\n", pl2_val / power_unit, |
| 281 | 100 * (pl2_val % power_unit) / power_unit); |
Sumeet Pawnikar | a247d8e | 2016-09-27 23:18:35 +0530 | [diff] [blame] | 282 | |
Sumeet Pawnikar | 428f90a | 2016-12-02 18:14:19 +0530 | [diff] [blame] | 283 | /* Setting RAPL MMIO register for Power limits. |
| 284 | * RAPL driver is using MSR instead of MMIO. |
| 285 | * So, disabled LIMIT_EN bit for MMIO. */ |
Subrata Banik | 208587e | 2017-05-19 18:38:24 +0530 | [diff] [blame] | 286 | MCHBAR32(MCHBAR_RAPL_PPL) = limit.lo & ~PKG_POWER_LIMIT_EN; |
| 287 | MCHBAR32(MCHBAR_RAPL_PPL + 4) = limit.hi & ~PKG_POWER_LIMIT_EN; |
Sumeet Pawnikar | 35240eb | 2016-08-23 11:20:20 +0530 | [diff] [blame] | 288 | } |
| 289 | |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 290 | static void soc_init(void *data) |
| 291 | { |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 292 | struct global_nvs_t *gnvs; |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 293 | |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 294 | /* Save VBT info and mapping */ |
Abhay Kumar | ec2947f | 2016-07-14 18:43:54 -0700 | [diff] [blame] | 295 | vbt = vbt_get(&vbt_rdev); |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 296 | |
Aaron Durbin | 81d1e09 | 2016-07-13 01:49:10 -0500 | [diff] [blame] | 297 | /* Snapshot the current GPIO IRQ polarities. FSP is setting a |
| 298 | * default policy that doesn't honor boards' requirements. */ |
| 299 | itss_snapshot_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END); |
| 300 | |
Aaron Durbin | 6c191d8 | 2016-11-29 21:22:42 -0600 | [diff] [blame] | 301 | fsp_silicon_init(romstage_handoff_is_resume()); |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 302 | |
Aaron Durbin | 81d1e09 | 2016-07-13 01:49:10 -0500 | [diff] [blame] | 303 | /* Restore GPIO IRQ polarities back to previous settings. */ |
| 304 | itss_restore_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END); |
| 305 | |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 306 | /* override 'enabled' setting in device tree if needed */ |
| 307 | pcie_override_devicetree_after_silicon_init(); |
| 308 | |
Aaron Durbin | fadfc2e | 2016-07-01 16:36:03 -0500 | [diff] [blame] | 309 | /* |
| 310 | * Keep the P2SB device visible so it and the other devices are |
| 311 | * visible in coreboot for driver support and PCI resource allocation. |
| 312 | * There is a UPD setting for this, but it's more consistent to use |
| 313 | * hide and unhide symmetrically. |
| 314 | */ |
| 315 | p2sb_unhide(); |
| 316 | |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 317 | /* Allocate ACPI NVS in CBMEM */ |
| 318 | gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS, sizeof(*gnvs)); |
Sumeet Pawnikar | 35240eb | 2016-08-23 11:20:20 +0530 | [diff] [blame] | 319 | |
Sumeet Pawnikar | a247d8e | 2016-09-27 23:18:35 +0530 | [diff] [blame] | 320 | /* Set RAPL MSR for Package power limits*/ |
| 321 | set_power_limits(); |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 322 | } |
| 323 | |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 324 | static void soc_final(void *data) |
| 325 | { |
| 326 | if (vbt) |
| 327 | rdev_munmap(&vbt_rdev, vbt); |
Andrey Petrov | 3dbea29 | 2016-06-14 22:20:28 -0700 | [diff] [blame] | 328 | |
| 329 | /* Disable global reset, just in case */ |
Shaunak Saha | 93cdc8b | 2017-04-18 15:42:09 -0700 | [diff] [blame] | 330 | pmc_global_reset_enable(0); |
Andrey Petrov | 3dbea29 | 2016-06-14 22:20:28 -0700 | [diff] [blame] | 331 | /* Make sure payload/OS can't trigger global reset */ |
Shaunak Saha | 93cdc8b | 2017-04-18 15:42:09 -0700 | [diff] [blame] | 332 | pmc_global_reset_lock(); |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 333 | } |
| 334 | |
Lee Leahy | bab8be2 | 2017-03-09 09:53:58 -0800 | [diff] [blame] | 335 | static void disable_dev(struct device *dev, FSP_S_CONFIG *silconfig) |
| 336 | { |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 337 | switch (dev->path.pci.devfn) { |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 338 | case PCH_DEVFN_ISH: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 339 | silconfig->IshEnable = 0; |
| 340 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 341 | case PCH_DEVFN_SATA: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 342 | silconfig->EnableSata = 0; |
| 343 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 344 | case PCH_DEVFN_PCIE5: |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 345 | silconfig->PcieRootPortEn[0] = 0; |
| 346 | silconfig->PcieRpHotPlug[0] = 0; |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 347 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 348 | case PCH_DEVFN_PCIE6: |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 349 | silconfig->PcieRootPortEn[1] = 0; |
| 350 | silconfig->PcieRpHotPlug[1] = 0; |
| 351 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 352 | case PCH_DEVFN_PCIE1: |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 353 | silconfig->PcieRootPortEn[2] = 0; |
| 354 | silconfig->PcieRpHotPlug[2] = 0; |
| 355 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 356 | case PCH_DEVFN_PCIE2: |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 357 | silconfig->PcieRootPortEn[3] = 0; |
| 358 | silconfig->PcieRpHotPlug[3] = 0; |
| 359 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 360 | case PCH_DEVFN_PCIE3: |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 361 | silconfig->PcieRootPortEn[4] = 0; |
| 362 | silconfig->PcieRpHotPlug[4] = 0; |
| 363 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 364 | case PCH_DEVFN_PCIE4: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 365 | silconfig->PcieRootPortEn[5] = 0; |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 366 | silconfig->PcieRpHotPlug[5] = 0; |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 367 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 368 | case PCH_DEVFN_XHCI: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 369 | silconfig->Usb30Mode = 0; |
| 370 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 371 | case PCH_DEVFN_XDCI: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 372 | silconfig->UsbOtg = 0; |
| 373 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 374 | case PCH_DEVFN_I2C0: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 375 | silconfig->I2c0Enable = 0; |
| 376 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 377 | case PCH_DEVFN_I2C1: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 378 | silconfig->I2c1Enable = 0; |
| 379 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 380 | case PCH_DEVFN_I2C2: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 381 | silconfig->I2c2Enable = 0; |
| 382 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 383 | case PCH_DEVFN_I2C3: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 384 | silconfig->I2c3Enable = 0; |
| 385 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 386 | case PCH_DEVFN_I2C4: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 387 | silconfig->I2c4Enable = 0; |
| 388 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 389 | case PCH_DEVFN_I2C5: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 390 | silconfig->I2c5Enable = 0; |
| 391 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 392 | case PCH_DEVFN_I2C6: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 393 | silconfig->I2c6Enable = 0; |
| 394 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 395 | case PCH_DEVFN_I2C7: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 396 | silconfig->I2c7Enable = 0; |
| 397 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 398 | case PCH_DEVFN_UART0: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 399 | silconfig->Hsuart0Enable = 0; |
| 400 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 401 | case PCH_DEVFN_UART1: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 402 | silconfig->Hsuart1Enable = 0; |
| 403 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 404 | case PCH_DEVFN_UART2: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 405 | silconfig->Hsuart2Enable = 0; |
| 406 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 407 | case PCH_DEVFN_UART3: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 408 | silconfig->Hsuart3Enable = 0; |
| 409 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 410 | case PCH_DEVFN_SPI0: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 411 | silconfig->Spi0Enable = 0; |
| 412 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 413 | case PCH_DEVFN_SPI1: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 414 | silconfig->Spi1Enable = 0; |
| 415 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 416 | case PCH_DEVFN_SPI2: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 417 | silconfig->Spi2Enable = 0; |
| 418 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 419 | case PCH_DEVFN_SDCARD: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 420 | silconfig->SdcardEnabled = 0; |
| 421 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 422 | case PCH_DEVFN_EMMC: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 423 | silconfig->eMMCEnabled = 0; |
| 424 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 425 | case PCH_DEVFN_SDIO: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 426 | silconfig->SdioEnabled = 0; |
| 427 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 428 | case PCH_DEVFN_SMBUS: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 429 | silconfig->SmbusEnable = 0; |
| 430 | break; |
| 431 | default: |
| 432 | printk(BIOS_WARNING, "PCI:%02x.%01x: Could not disable the device\n", |
| 433 | PCI_SLOT(dev->path.pci.devfn), |
| 434 | PCI_FUNC(dev->path.pci.devfn)); |
| 435 | break; |
| 436 | } |
| 437 | } |
| 438 | |
Brandon Breitenstein | c31ba0e | 2016-07-27 17:34:45 -0700 | [diff] [blame] | 439 | static void parse_devicetree(FSP_S_CONFIG *silconfig) |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 440 | { |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 441 | struct device *dev = SA_DEV_ROOT; |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 442 | |
| 443 | if (!dev) { |
| 444 | printk(BIOS_ERR, "Could not find root device\n"); |
| 445 | return; |
| 446 | } |
| 447 | /* Only disable bus 0 devices. */ |
| 448 | for (dev = dev->bus->children; dev; dev = dev->sibling) { |
| 449 | if (!dev->enabled) |
| 450 | disable_dev(dev, silconfig); |
| 451 | } |
| 452 | } |
| 453 | |
Hannah Williams | 3ff14a0 | 2017-05-05 16:30:22 -0700 | [diff] [blame] | 454 | static void apl_fsp_silicon_init_params_cb(struct soc_intel_apollolake_config |
| 455 | *cfg, FSP_S_CONFIG *silconfig) |
| 456 | { |
| 457 | #if !IS_ENABLED(CONFIG_SOC_INTEL_GLK) /* GLK FSP does not have these |
| 458 | fields in FspsUpd.h yet */ |
| 459 | uint8_t port; |
| 460 | |
| 461 | for (port = 0; port < APOLLOLAKE_USB2_PORT_MAX; port++) { |
| 462 | if (cfg->usb2eye[port].Usb20PerPortTxPeHalf != 0) |
| 463 | silconfig->PortUsb20PerPortTxPeHalf[port] = |
| 464 | cfg->usb2eye[port].Usb20PerPortTxPeHalf; |
| 465 | |
| 466 | if (cfg->usb2eye[port].Usb20PerPortPeTxiSet != 0) |
| 467 | silconfig->PortUsb20PerPortPeTxiSet[port] = |
| 468 | cfg->usb2eye[port].Usb20PerPortPeTxiSet; |
| 469 | |
| 470 | if (cfg->usb2eye[port].Usb20PerPortTxiSet != 0) |
| 471 | silconfig->PortUsb20PerPortTxiSet[port] = |
| 472 | cfg->usb2eye[port].Usb20PerPortTxiSet; |
| 473 | |
| 474 | if (cfg->usb2eye[port].Usb20HsSkewSel != 0) |
| 475 | silconfig->PortUsb20HsSkewSel[port] = |
| 476 | cfg->usb2eye[port].Usb20HsSkewSel; |
| 477 | |
| 478 | if (cfg->usb2eye[port].Usb20IUsbTxEmphasisEn != 0) |
| 479 | silconfig->PortUsb20IUsbTxEmphasisEn[port] = |
| 480 | cfg->usb2eye[port].Usb20IUsbTxEmphasisEn; |
| 481 | |
| 482 | if (cfg->usb2eye[port].Usb20PerPortRXISet != 0) |
| 483 | silconfig->PortUsb20PerPortRXISet[port] = |
| 484 | cfg->usb2eye[port].Usb20PerPortRXISet; |
| 485 | |
| 486 | if (cfg->usb2eye[port].Usb20HsNpreDrvSel != 0) |
| 487 | silconfig->PortUsb20HsNpreDrvSel[port] = |
| 488 | cfg->usb2eye[port].Usb20HsNpreDrvSel; |
| 489 | } |
| 490 | #endif |
| 491 | } |
| 492 | |
| 493 | static void glk_fsp_silicon_init_params_cb( |
| 494 | struct soc_intel_apollolake_config *cfg, FSP_S_CONFIG *silconfig) |
| 495 | { |
| 496 | silconfig->Gmm = 0; |
| 497 | silconfig->HdaEnable = 0; |
| 498 | } |
| 499 | |
Brandon Breitenstein | c31ba0e | 2016-07-27 17:34:45 -0700 | [diff] [blame] | 500 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd) |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 501 | { |
Lee Leahy | 1d20fe7 | 2017-03-09 09:50:28 -0800 | [diff] [blame] | 502 | FSP_S_CONFIG *silconfig = &silupd->FspsConfig; |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 503 | static struct soc_intel_apollolake_config *cfg; |
| 504 | |
| 505 | /* Load VBT before devicetree-specific config. */ |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 506 | silconfig->GraphicsConfigPtr = (uintptr_t)vbt; |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 507 | |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 508 | struct device *dev = SA_DEV_ROOT; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 509 | |
Patrick Georgi | 831d65d | 2016-04-14 11:53:48 +0200 | [diff] [blame] | 510 | if (!dev || !dev->chip_info) { |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 511 | printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n"); |
| 512 | return; |
| 513 | } |
| 514 | |
| 515 | cfg = dev->chip_info; |
| 516 | |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 517 | /* Parse device tree and disable unused device*/ |
| 518 | parse_devicetree(silconfig); |
| 519 | |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 520 | silconfig->PcieRpClkReqNumber[0] = cfg->pcie_rp0_clkreq_pin; |
| 521 | silconfig->PcieRpClkReqNumber[1] = cfg->pcie_rp1_clkreq_pin; |
| 522 | silconfig->PcieRpClkReqNumber[2] = cfg->pcie_rp2_clkreq_pin; |
| 523 | silconfig->PcieRpClkReqNumber[3] = cfg->pcie_rp3_clkreq_pin; |
| 524 | silconfig->PcieRpClkReqNumber[4] = cfg->pcie_rp4_clkreq_pin; |
| 525 | silconfig->PcieRpClkReqNumber[5] = cfg->pcie_rp5_clkreq_pin; |
Andrey Petrov | e07e13d | 2016-03-18 14:43:00 -0700 | [diff] [blame] | 526 | |
Zhao, Lijian | 1b8ee0b | 2016-05-17 19:01:34 -0700 | [diff] [blame] | 527 | if (cfg->emmc_tx_cmd_cntl != 0) |
| 528 | silconfig->EmmcTxCmdCntl = cfg->emmc_tx_cmd_cntl; |
| 529 | if (cfg->emmc_tx_data_cntl1 != 0) |
| 530 | silconfig->EmmcTxDataCntl1 = cfg->emmc_tx_data_cntl1; |
| 531 | if (cfg->emmc_tx_data_cntl2 != 0) |
| 532 | silconfig->EmmcTxDataCntl2 = cfg->emmc_tx_data_cntl2; |
| 533 | if (cfg->emmc_rx_cmd_data_cntl1 != 0) |
| 534 | silconfig->EmmcRxCmdDataCntl1 = cfg->emmc_rx_cmd_data_cntl1; |
| 535 | if (cfg->emmc_rx_strobe_cntl != 0) |
| 536 | silconfig->EmmcRxStrobeCntl = cfg->emmc_rx_strobe_cntl; |
| 537 | if (cfg->emmc_rx_cmd_data_cntl2 != 0) |
| 538 | silconfig->EmmcRxCmdDataCntl2 = cfg->emmc_rx_cmd_data_cntl2; |
| 539 | |
Saurabh Satija | e46dbcc | 2016-05-03 15:15:31 -0700 | [diff] [blame] | 540 | silconfig->LPSS_S0ixEnable = cfg->lpss_s0ix_enable; |
| 541 | |
Lee Leahy | 07441b5 | 2017-03-09 10:59:25 -0800 | [diff] [blame] | 542 | /* Disable monitor mwait since it is broken due to a hardware bug |
| 543 | * without a fix |
| 544 | */ |
Bora Guvendik | 60cc75d | 2016-07-25 14:44:51 -0700 | [diff] [blame] | 545 | silconfig->MonitorMwaitEnable = 0; |
| 546 | |
Venkateswarlu Vinjamuri | 1a5e32c | 2016-10-31 17:15:30 -0700 | [diff] [blame] | 547 | silconfig->SkipMpInit = 1; |
| 548 | |
Furquan Shaikh | cad9b63 | 2016-06-20 16:08:42 -0700 | [diff] [blame] | 549 | /* Disable setting of EISS bit in FSP. */ |
| 550 | silconfig->SpiEiss = 0; |
Ravi Sarawadi | 3a21d0f | 2016-08-10 11:33:56 -0700 | [diff] [blame] | 551 | |
| 552 | /* Disable FSP from locking access to the RTC NVRAM */ |
| 553 | silconfig->RtcLock = 0; |
Venkateswarlu Vinjamuri | 88df48c | 2016-09-02 16:04:27 -0700 | [diff] [blame] | 554 | |
| 555 | /* Enable Audio clk gate and power gate */ |
| 556 | silconfig->HDAudioClkGate = cfg->hdaudio_clk_gate_enable; |
| 557 | silconfig->HDAudioPwrGate = cfg->hdaudio_pwr_gate_enable; |
| 558 | /* Bios config lockdown Audio clk and power gate */ |
| 559 | silconfig->BiosCfgLockDown = cfg->hdaudio_bios_config_lockdown; |
Hannah Williams | 3ff14a0 | 2017-05-05 16:30:22 -0700 | [diff] [blame] | 560 | if (IS_ENABLED(CONFIG_SOC_INTEL_GLK)) |
| 561 | glk_fsp_silicon_init_params_cb(cfg, silconfig); |
| 562 | else |
| 563 | apl_fsp_silicon_init_params_cb(cfg, silconfig); |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | struct chip_operations soc_intel_apollolake_ops = { |
| 567 | CHIP_NAME("Intel Apollolake SOC") |
| 568 | .enable_dev = &enable_dev, |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 569 | .init = &soc_init, |
| 570 | .final = &soc_final |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 571 | }; |
| 572 | |
Andrey Petrov | a697c19 | 2016-12-07 10:47:46 -0800 | [diff] [blame] | 573 | static void drop_privilege_all(void) |
| 574 | { |
| 575 | /* Drop privilege level on all the CPUs */ |
Barnali Sarkar | 66fe0c4 | 2017-05-23 18:17:14 +0530 | [diff] [blame] | 576 | if (mp_run_on_all_cpus(&cpu_enable_untrusted_mode, 1000) < 0) |
Andrey Petrov | a697c19 | 2016-12-07 10:47:46 -0800 | [diff] [blame] | 577 | printk(BIOS_ERR, "failed to enable untrusted mode\n"); |
| 578 | } |
| 579 | |
Lee Leahy | 806fa24 | 2016-08-01 13:55:02 -0700 | [diff] [blame] | 580 | void platform_fsp_notify_status(enum fsp_notify_phase phase) |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 581 | { |
Andrey Petrov | a697c19 | 2016-12-07 10:47:46 -0800 | [diff] [blame] | 582 | if (phase == END_OF_FIRMWARE) { |
| 583 | /* Hide the P2SB device to align with previous behavior. */ |
Aaron Durbin | fadfc2e | 2016-07-01 16:36:03 -0500 | [diff] [blame] | 584 | p2sb_hide(); |
Andrey Petrov | a697c19 | 2016-12-07 10:47:46 -0800 | [diff] [blame] | 585 | /* |
| 586 | * As per guidelines BIOS is recommended to drop CPU privilege |
| 587 | * level to IA_UNTRUSTED. After that certain device registers |
| 588 | * and MSRs become inaccessible supposedly increasing system |
| 589 | * security. |
| 590 | */ |
| 591 | drop_privilege_all(); |
| 592 | } |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 593 | } |
| 594 | |
Furquan Shaikh | 6ac226d | 2016-06-15 17:13:20 -0700 | [diff] [blame] | 595 | /* |
Furquan Shaikh | d6c5559 | 2016-11-21 12:41:20 -0800 | [diff] [blame] | 596 | * spi_flash init() needs to run unconditionally on every boot (including |
| 597 | * resume) to allow write protect to be disabled for eventlog and nvram |
| 598 | * updates. This needs to be done as early as possible in ramstage. Thus, add a |
| 599 | * callback for entry into BS_PRE_DEVICE. |
Furquan Shaikh | 6ac226d | 2016-06-15 17:13:20 -0700 | [diff] [blame] | 600 | */ |
Furquan Shaikh | d6c5559 | 2016-11-21 12:41:20 -0800 | [diff] [blame] | 601 | static void spi_flash_init_cb(void *unused) |
Furquan Shaikh | 6ac226d | 2016-06-15 17:13:20 -0700 | [diff] [blame] | 602 | { |
Barnali Sarkar | e70142c | 2017-03-28 16:32:33 +0530 | [diff] [blame] | 603 | fast_spi_init(); |
Furquan Shaikh | 6ac226d | 2016-06-15 17:13:20 -0700 | [diff] [blame] | 604 | } |
| 605 | |
Furquan Shaikh | d6c5559 | 2016-11-21 12:41:20 -0800 | [diff] [blame] | 606 | BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, spi_flash_init_cb, NULL); |