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