Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 4 | #include <bootstate.h> |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 5 | #include <cbmem.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 6 | #include <console/console.h> |
Andrey Petrov | a697c19 | 2016-12-07 10:47:46 -0800 | [diff] [blame] | 7 | #include <cpu/x86/mp.h> |
Barnali Sarkar | 66fe0c4 | 2017-05-23 18:17:14 +0530 | [diff] [blame] | 8 | #include <cpu/x86/msr.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 9 | #include <device/mmio.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 10 | #include <device/device.h> |
| 11 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 12 | #include <device/pci_ops.h> |
Mario Scheithauer | 841416f | 2017-09-18 17:08:48 +0200 | [diff] [blame] | 13 | #include <intelblocks/acpi.h> |
Kyösti Mälkki | 32d47eb | 2019-09-28 00:00:30 +0300 | [diff] [blame] | 14 | #include <intelblocks/cfg.h> |
Barnali Sarkar | e70142c | 2017-03-28 16:32:33 +0530 | [diff] [blame] | 15 | #include <intelblocks/fast_spi.h> |
Barnali Sarkar | 66fe0c4 | 2017-05-23 18:17:14 +0530 | [diff] [blame] | 16 | #include <intelblocks/msr.h> |
Subrata Banik | f699c14 | 2018-06-08 17:57:37 +0530 | [diff] [blame] | 17 | #include <intelblocks/p2sb.h> |
Sumeet R Pawnikar | 2adb50d | 2020-05-09 15:37:09 +0530 | [diff] [blame] | 18 | #include <intelblocks/power_limit.h> |
Duncan Laurie | 4c8fbc0 | 2018-03-26 02:19:58 -0700 | [diff] [blame] | 19 | #include <intelblocks/xdci.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 20 | #include <fsp/api.h> |
| 21 | #include <fsp/util.h> |
Barnali Sarkar | 66fe0c4 | 2017-05-23 18:17:14 +0530 | [diff] [blame] | 22 | #include <intelblocks/cpulib.h> |
Bora Guvendik | 33117ec | 2017-04-10 15:49:02 -0700 | [diff] [blame] | 23 | #include <intelblocks/itss.h> |
Shaunak Saha | 93cdc8b | 2017-04-18 15:42:09 -0700 | [diff] [blame] | 24 | #include <intelblocks/pmclib.h> |
Brandon Breitenstein | c6ec8dd | 2016-11-17 12:23:04 -0800 | [diff] [blame] | 25 | #include <romstage_handoff.h> |
Furquan Shaikh | d2c2f83 | 2018-11-07 10:24:31 -0800 | [diff] [blame] | 26 | #include <soc/cpu.h> |
| 27 | #include <soc/heci.h> |
| 28 | #include <soc/intel/common/vbt.h> |
Andrey Petrov | e07e13d | 2016-03-18 14:43:00 -0700 | [diff] [blame] | 29 | #include <soc/iomap.h> |
Bora Guvendik | 33117ec | 2017-04-10 15:49:02 -0700 | [diff] [blame] | 30 | #include <soc/itss.h> |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 31 | #include <soc/nvs.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 32 | #include <soc/pci_devs.h> |
Andrey Petrov | 3dbea29 | 2016-06-14 22:20:28 -0700 | [diff] [blame] | 33 | #include <soc/pm.h> |
Subrata Banik | 7952e28 | 2017-03-14 18:26:27 +0530 | [diff] [blame] | 34 | #include <soc/systemagent.h> |
Furquan Shaikh | d2c2f83 | 2018-11-07 10:24:31 -0800 | [diff] [blame] | 35 | #include <spi-generic.h> |
John Zhao | 7dff726 | 2018-07-30 13:54:25 -0700 | [diff] [blame] | 36 | #include <timer.h> |
Felix Singer | e59ae10 | 2019-05-02 13:57:57 +0200 | [diff] [blame] | 37 | #include <soc/ramstage.h> |
Sumeet R Pawnikar | 2adb50d | 2020-05-09 15:37:09 +0530 | [diff] [blame] | 38 | #include <soc/soc_chip.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 39 | |
| 40 | #include "chip.h" |
| 41 | |
John Zhao | 7dff726 | 2018-07-30 13:54:25 -0700 | [diff] [blame] | 42 | #define DUAL_ROLE_CFG0 0x80d8 |
| 43 | #define SW_VBUS_VALID_MASK (1 << 24) |
| 44 | #define SW_IDPIN_EN_MASK (1 << 21) |
| 45 | #define SW_IDPIN_MASK (1 << 20) |
| 46 | #define SW_IDPIN_HOST (0 << 20) |
| 47 | #define DUAL_ROLE_CFG1 0x80dc |
| 48 | #define DRD_MODE_MASK (1 << 29) |
| 49 | #define DRD_MODE_HOST (1 << 29) |
| 50 | |
John Zhao | 57aa8b6 | 2019-01-14 09:15:50 -0800 | [diff] [blame] | 51 | #define CFG_XHCLKGTEN 0x8650 |
| 52 | /* Naking USB2.0 EPs for Backbone Clock Gating and PLL Shutdown */ |
| 53 | #define NUEFBCGPS (1 << 28) |
| 54 | /* SRAM Power Gate Enable */ |
| 55 | #define SRAMPGTEN (1 << 27) |
| 56 | /* SS Link PLL Shutdown Enable */ |
| 57 | #define SSLSE (1 << 26) |
| 58 | /* USB2 PLL Shutdown Enable */ |
| 59 | #define USB2PLLSE (1 << 25) |
| 60 | /* IOSF Sideband Trunk Clock Gating Enable */ |
| 61 | #define IOSFSTCGE (1 << 24) |
| 62 | /* BIT[23:20] HS Backbone PXP Trunk Clock Gate Enable */ |
| 63 | #define HSTCGE (1 << 23 | 1 << 22) |
| 64 | /* BIT[19:16] SS Backbone PXP Trunk Clock Gate Enable */ |
| 65 | #define SSTCGE (1 << 19 | 1 << 18 | 1 << 17) |
| 66 | /* XHC Ignore_EU3S */ |
| 67 | #define XHCIGEU3S (1 << 15) |
| 68 | /* XHC Frame Timer Clock Shutdown Enable */ |
| 69 | #define XHCFTCLKSE (1 << 14) |
| 70 | /* XHC Backbone PXP Trunk Clock Gate In Presence of ISOCH EP */ |
| 71 | #define XHCBBTCGIPISO (1 << 13) |
| 72 | /* XHC HS Backbone PXP Trunk Clock Gate U2 non RWE */ |
| 73 | #define XHCHSTCGU2NRWE (1 << 12) |
| 74 | /* BIT[11:10] XHC USB2 PLL Shutdown Lx Enable */ |
| 75 | #define XHCUSB2PLLSDLE (1 << 11 | 1 << 10) |
| 76 | /* BIT[9:8] HS Backbone PXP PLL Shutdown Ux Enable */ |
| 77 | #define HSUXDMIPLLSE (1 << 9) |
| 78 | /* BIT[7:5] SS Backbone PXP PLL shutdown Ux Enable */ |
| 79 | #define SSPLLSUE (1 << 6) |
| 80 | /* XHC Backbone Local Clock Gating Enable */ |
| 81 | #define XHCBLCGE (1 << 4) |
| 82 | /* HS Link Trunk Clock Gating Enable */ |
| 83 | #define HSLTCGE (1 << 3) |
| 84 | /* SS Link Trunk Clock Gating Enable */ |
| 85 | #define SSLTCGE (1 << 2) |
| 86 | /* IOSF Backbone Trunk Clock Gating Enable */ |
| 87 | #define IOSFBTCGE (1 << 1) |
| 88 | /* IOSF Gasket Backbone Local Clock Gating Enable */ |
| 89 | #define IOSFGBLCGE (1 << 0) |
| 90 | |
Marx Wang | abc17d1 | 2020-04-07 16:58:38 +0800 | [diff] [blame] | 91 | #define CFG_XHCPMCTRL 0x80a4 |
| 92 | /* BIT[7:4] LFPS periodic sampling for USB3 Ports */ |
| 93 | #define LFPS_PM_DISABLE_MASK 0xFFFFFF0F |
| 94 | |
Duncan Laurie | bf713b0 | 2018-05-07 15:33:18 -0700 | [diff] [blame] | 95 | const char *soc_acpi_name(const struct device *dev) |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 96 | { |
| 97 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 98 | return "PCI0"; |
| 99 | |
Duncan Laurie | bf713b0 | 2018-05-07 15:33:18 -0700 | [diff] [blame] | 100 | if (dev->path.type == DEVICE_PATH_USB) { |
| 101 | switch (dev->path.usb.port_type) { |
| 102 | case 0: |
| 103 | /* Root Hub */ |
| 104 | return "RHUB"; |
| 105 | case 2: |
| 106 | /* USB2 ports */ |
| 107 | switch (dev->path.usb.port_id) { |
| 108 | case 0: return "HS01"; |
| 109 | case 1: return "HS02"; |
| 110 | case 2: return "HS03"; |
| 111 | case 3: return "HS04"; |
| 112 | case 4: return "HS05"; |
| 113 | case 5: return "HS06"; |
| 114 | case 6: return "HS07"; |
| 115 | case 7: return "HS08"; |
Furquan Shaikh | ad62b9a | 2019-01-30 22:47:17 -0800 | [diff] [blame] | 116 | case 8: |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 117 | if (CONFIG(SOC_INTEL_GLK)) |
Furquan Shaikh | ad62b9a | 2019-01-30 22:47:17 -0800 | [diff] [blame] | 118 | return "HS09"; |
Duncan Laurie | bf713b0 | 2018-05-07 15:33:18 -0700 | [diff] [blame] | 119 | } |
| 120 | break; |
| 121 | case 3: |
| 122 | /* USB3 ports */ |
| 123 | switch (dev->path.usb.port_id) { |
| 124 | case 0: return "SS01"; |
| 125 | case 1: return "SS02"; |
| 126 | case 2: return "SS03"; |
| 127 | case 3: return "SS04"; |
| 128 | case 4: return "SS05"; |
| 129 | case 5: return "SS06"; |
| 130 | } |
| 131 | break; |
| 132 | } |
| 133 | return NULL; |
| 134 | } |
| 135 | |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 136 | if (dev->path.type != DEVICE_PATH_PCI) |
| 137 | return NULL; |
| 138 | |
| 139 | switch (dev->path.pci.devfn) { |
| 140 | /* DSDT: acpi/northbridge.asl */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 141 | case SA_DEVFN_ROOT: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 142 | return "MCHC"; |
| 143 | /* DSDT: acpi/lpc.asl */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 144 | case PCH_DEVFN_LPC: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 145 | return "LPCB"; |
| 146 | /* DSDT: acpi/xhci.asl */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 147 | case PCH_DEVFN_XHCI: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 148 | return "XHCI"; |
| 149 | /* DSDT: acpi/pch_hda.asl */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 150 | case PCH_DEVFN_HDA: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 151 | return "HDAS"; |
| 152 | /* DSDT: acpi/lpss.asl */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 153 | case PCH_DEVFN_UART0: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 154 | return "URT1"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 155 | case PCH_DEVFN_UART1: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 156 | return "URT2"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 157 | case PCH_DEVFN_UART2: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 158 | return "URT3"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 159 | case PCH_DEVFN_UART3: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 160 | return "URT4"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 161 | case PCH_DEVFN_SPI0: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 162 | return "SPI1"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 163 | case PCH_DEVFN_SPI1: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 164 | return "SPI2"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 165 | case PCH_DEVFN_SPI2: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 166 | return "SPI3"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 167 | case PCH_DEVFN_PWM: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 168 | return "PWM"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 169 | case PCH_DEVFN_I2C0: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 170 | return "I2C0"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 171 | case PCH_DEVFN_I2C1: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 172 | return "I2C1"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 173 | case PCH_DEVFN_I2C2: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 174 | return "I2C2"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 175 | case PCH_DEVFN_I2C3: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 176 | return "I2C3"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 177 | case PCH_DEVFN_I2C4: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 178 | return "I2C4"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 179 | case PCH_DEVFN_I2C5: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 180 | return "I2C5"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 181 | case PCH_DEVFN_I2C6: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 182 | return "I2C6"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 183 | case PCH_DEVFN_I2C7: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 184 | return "I2C7"; |
| 185 | /* Storage */ |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 186 | case PCH_DEVFN_SDCARD: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 187 | return "SDCD"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 188 | case PCH_DEVFN_EMMC: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 189 | return "EMMC"; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 190 | case PCH_DEVFN_SDIO: |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 191 | return "SDIO"; |
Vaibhav Shankar | ec9168f | 2016-09-16 14:20:53 -0700 | [diff] [blame] | 192 | /* PCIe */ |
Venkateswarlu Vinjamuri | f03c63e | 2018-04-12 10:13:43 -0700 | [diff] [blame] | 193 | case PCH_DEVFN_PCIE1: |
| 194 | return "RP03"; |
Venkateswarlu Vinjamuri | efeb690 | 2018-04-09 11:14:42 -0700 | [diff] [blame] | 195 | case PCH_DEVFN_PCIE5: |
Vaibhav Shankar | ec9168f | 2016-09-16 14:20:53 -0700 | [diff] [blame] | 196 | return "RP01"; |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | return NULL; |
| 200 | } |
| 201 | |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 202 | static struct device_operations pci_domain_ops = { |
| 203 | .read_resources = pci_domain_read_resources, |
| 204 | .set_resources = pci_domain_set_resources, |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 205 | .scan_bus = pci_domain_scan_bus, |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 206 | .acpi_name = &soc_acpi_name, |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 207 | }; |
| 208 | |
| 209 | static struct device_operations cpu_bus_ops = { |
Nico Huber | 2f8ba69 | 2020-04-05 14:05:24 +0200 | [diff] [blame] | 210 | .read_resources = noop_read_resources, |
| 211 | .set_resources = noop_set_resources, |
Aaron Durbin | ac3e482 | 2017-06-14 13:21:00 -0500 | [diff] [blame] | 212 | .init = apollolake_init_cpus, |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 213 | .acpi_fill_ssdt = generate_cpu_entries, |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 214 | }; |
| 215 | |
Elyes HAOUAS | 06e8315 | 2018-05-24 22:48:14 +0200 | [diff] [blame] | 216 | static void enable_dev(struct device *dev) |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 217 | { |
| 218 | /* Set the operations if it is a special bus type */ |
Lee Leahy | 4430f9f | 2017-03-09 10:00:30 -0800 | [diff] [blame] | 219 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 220 | dev->ops = &pci_domain_ops; |
Lee Leahy | 4430f9f | 2017-03-09 10:00:30 -0800 | [diff] [blame] | 221 | else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 222 | dev->ops = &cpu_bus_ops; |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 223 | } |
| 224 | |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 225 | /* |
| 226 | * If the PCIe root port at function 0 is disabled, |
| 227 | * the PCIe root ports might be coalesced after FSP silicon init. |
| 228 | * The below function will swap the devfn of the first enabled device |
| 229 | * in devicetree and function 0 resides a pci device |
| 230 | * so that it won't confuse coreboot. |
| 231 | */ |
| 232 | static void pcie_update_device_tree(unsigned int devfn0, int num_funcs) |
| 233 | { |
Elyes HAOUAS | 06e8315 | 2018-05-24 22:48:14 +0200 | [diff] [blame] | 234 | struct device *func0; |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 235 | unsigned int devfn; |
| 236 | int i; |
| 237 | unsigned int inc = PCI_DEVFN(0, 1); |
| 238 | |
Kyösti Mälkki | 903b40a | 2019-07-03 07:25:59 +0300 | [diff] [blame] | 239 | func0 = pcidev_path_on_root(devfn0); |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 240 | if (func0 == NULL) |
| 241 | return; |
| 242 | |
| 243 | /* No more functions if function 0 is disabled. */ |
| 244 | if (pci_read_config32(func0, PCI_VENDOR_ID) == 0xffffffff) |
| 245 | return; |
| 246 | |
| 247 | devfn = devfn0 + inc; |
| 248 | |
| 249 | /* |
Elyes HAOUAS | 0f82c12 | 2019-12-04 19:23:50 +0100 | [diff] [blame] | 250 | * Increase function by 1. |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 251 | * Then find first enabled device to replace func0 |
| 252 | * as that port was move to func0. |
| 253 | */ |
| 254 | for (i = 1; i < num_funcs; i++, devfn += inc) { |
Kyösti Mälkki | 903b40a | 2019-07-03 07:25:59 +0300 | [diff] [blame] | 255 | struct device *dev = pcidev_path_on_root(devfn); |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 256 | if (dev == NULL) |
| 257 | continue; |
| 258 | |
| 259 | if (!dev->enabled) |
| 260 | continue; |
| 261 | /* Found the first enabled device in given dev number */ |
| 262 | func0->path.pci.devfn = dev->path.pci.devfn; |
| 263 | dev->path.pci.devfn = devfn0; |
| 264 | break; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | static void pcie_override_devicetree_after_silicon_init(void) |
| 269 | { |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 270 | pcie_update_device_tree(PCH_DEVFN_PCIE1, 4); |
| 271 | pcie_update_device_tree(PCH_DEVFN_PCIE5, 2); |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 272 | } |
| 273 | |
Mario Scheithauer | 841416f | 2017-09-18 17:08:48 +0200 | [diff] [blame] | 274 | /* Overwrites the SCI IRQ if another IRQ number is given by device tree. */ |
| 275 | static void set_sci_irq(void) |
| 276 | { |
Kyösti Mälkki | 4af4e7f | 2019-07-14 05:50:20 +0300 | [diff] [blame] | 277 | struct soc_intel_apollolake_config *cfg; |
Mario Scheithauer | 841416f | 2017-09-18 17:08:48 +0200 | [diff] [blame] | 278 | uint32_t scis; |
| 279 | |
Kyösti Mälkki | d5f645c | 2019-09-28 00:20:27 +0300 | [diff] [blame] | 280 | cfg = config_of_soc(); |
Mario Scheithauer | 841416f | 2017-09-18 17:08:48 +0200 | [diff] [blame] | 281 | |
| 282 | /* Change only if a device tree entry exists. */ |
| 283 | if (cfg->sci_irq) { |
| 284 | scis = soc_read_sci_irq_select(); |
| 285 | scis &= ~SCI_IRQ_SEL; |
| 286 | scis |= (cfg->sci_irq << SCI_IRQ_ADJUST) & SCI_IRQ_SEL; |
| 287 | soc_write_sci_irq_select(scis); |
| 288 | } |
| 289 | } |
| 290 | |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 291 | static void soc_init(void *data) |
| 292 | { |
Sumeet R Pawnikar | 2adb50d | 2020-05-09 15:37:09 +0530 | [diff] [blame] | 293 | struct soc_power_limits_config *soc_config; |
| 294 | config_t *config; |
| 295 | |
Aaron Durbin | 81d1e09 | 2016-07-13 01:49:10 -0500 | [diff] [blame] | 296 | /* Snapshot the current GPIO IRQ polarities. FSP is setting a |
| 297 | * default policy that doesn't honor boards' requirements. */ |
| 298 | itss_snapshot_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END); |
| 299 | |
Karthikeyan Ramasubramanian | 6629b4b | 2019-05-01 10:22:22 -0600 | [diff] [blame] | 300 | /* |
| 301 | * Clear the GPI interrupt status and enable registers. These |
| 302 | * registers do not get reset to default state when booting from S5. |
| 303 | */ |
| 304 | gpi_clear_int_cfg(); |
| 305 | |
Aaron Durbin | 6c191d8 | 2016-11-29 21:22:42 -0600 | [diff] [blame] | 306 | fsp_silicon_init(romstage_handoff_is_resume()); |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 307 | |
Aaron Durbin | 81d1e09 | 2016-07-13 01:49:10 -0500 | [diff] [blame] | 308 | /* Restore GPIO IRQ polarities back to previous settings. */ |
| 309 | itss_restore_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END); |
| 310 | |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 311 | /* override 'enabled' setting in device tree if needed */ |
| 312 | pcie_override_devicetree_after_silicon_init(); |
| 313 | |
Aaron Durbin | fadfc2e | 2016-07-01 16:36:03 -0500 | [diff] [blame] | 314 | /* |
| 315 | * Keep the P2SB device visible so it and the other devices are |
| 316 | * visible in coreboot for driver support and PCI resource allocation. |
| 317 | * There is a UPD setting for this, but it's more consistent to use |
| 318 | * hide and unhide symmetrically. |
| 319 | */ |
| 320 | p2sb_unhide(); |
| 321 | |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 322 | /* Allocate ACPI NVS in CBMEM */ |
John Zhao | 5744884 | 2019-05-20 16:10:16 -0700 | [diff] [blame] | 323 | cbmem_add(CBMEM_ID_ACPI_GNVS, sizeof(struct global_nvs_t)); |
Sumeet Pawnikar | 35240eb | 2016-08-23 11:20:20 +0530 | [diff] [blame] | 324 | |
Tim Wawrzynczak | 7c34865 | 2020-05-27 10:22:45 -0600 | [diff] [blame^] | 325 | if (CONFIG(APL_SKIP_SET_POWER_LIMITS)) { |
| 326 | printk(BIOS_INFO, "Skip setting RAPL per configuration\n"); |
| 327 | } else { |
| 328 | config = config_of_soc(); |
| 329 | /* Set RAPL MSR for Package power limits */ |
| 330 | soc_config = &config->power_limits_config; |
| 331 | set_power_limits(MOBILE_SKU_PL1_TIME_SEC, soc_config); |
| 332 | } |
Mario Scheithauer | 841416f | 2017-09-18 17:08:48 +0200 | [diff] [blame] | 333 | |
| 334 | /* |
| 335 | * FSP-S routes SCI to IRQ 9. With the help of this function you can |
| 336 | * select another IRQ for SCI. |
| 337 | */ |
| 338 | set_sci_irq(); |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 339 | } |
| 340 | |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 341 | static void soc_final(void *data) |
| 342 | { |
Andrey Petrov | 3dbea29 | 2016-06-14 22:20:28 -0700 | [diff] [blame] | 343 | /* Make sure payload/OS can't trigger global reset */ |
Michael Niewöhner | 1c6ea92 | 2019-11-02 12:20:53 +0100 | [diff] [blame] | 344 | pmc_global_reset_disable_and_lock(); |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 345 | } |
| 346 | |
Lee Leahy | bab8be2 | 2017-03-09 09:53:58 -0800 | [diff] [blame] | 347 | static void disable_dev(struct device *dev, FSP_S_CONFIG *silconfig) |
| 348 | { |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 349 | switch (dev->path.pci.devfn) { |
Maxim Polyakov | 7b98e3e | 2020-02-16 11:51:57 +0300 | [diff] [blame] | 350 | case PCH_DEVFN_NPK: |
| 351 | /* |
| 352 | * Disable this device in the parse_devicetree_setting() function |
| 353 | * in romstage.c |
| 354 | */ |
| 355 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 356 | case PCH_DEVFN_ISH: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 357 | silconfig->IshEnable = 0; |
| 358 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 359 | case PCH_DEVFN_SATA: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 360 | silconfig->EnableSata = 0; |
| 361 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 362 | case PCH_DEVFN_PCIE5: |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 363 | silconfig->PcieRootPortEn[0] = 0; |
| 364 | silconfig->PcieRpHotPlug[0] = 0; |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 365 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 366 | case PCH_DEVFN_PCIE6: |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 367 | silconfig->PcieRootPortEn[1] = 0; |
| 368 | silconfig->PcieRpHotPlug[1] = 0; |
| 369 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 370 | case PCH_DEVFN_PCIE1: |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 371 | silconfig->PcieRootPortEn[2] = 0; |
| 372 | silconfig->PcieRpHotPlug[2] = 0; |
| 373 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 374 | case PCH_DEVFN_PCIE2: |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 375 | silconfig->PcieRootPortEn[3] = 0; |
| 376 | silconfig->PcieRpHotPlug[3] = 0; |
| 377 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 378 | case PCH_DEVFN_PCIE3: |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 379 | silconfig->PcieRootPortEn[4] = 0; |
| 380 | silconfig->PcieRpHotPlug[4] = 0; |
| 381 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 382 | case PCH_DEVFN_PCIE4: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 383 | silconfig->PcieRootPortEn[5] = 0; |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 384 | silconfig->PcieRpHotPlug[5] = 0; |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 385 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 386 | case PCH_DEVFN_XHCI: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 387 | silconfig->Usb30Mode = 0; |
| 388 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 389 | case PCH_DEVFN_XDCI: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 390 | silconfig->UsbOtg = 0; |
| 391 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 392 | case PCH_DEVFN_I2C0: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 393 | silconfig->I2c0Enable = 0; |
| 394 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 395 | case PCH_DEVFN_I2C1: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 396 | silconfig->I2c1Enable = 0; |
| 397 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 398 | case PCH_DEVFN_I2C2: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 399 | silconfig->I2c2Enable = 0; |
| 400 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 401 | case PCH_DEVFN_I2C3: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 402 | silconfig->I2c3Enable = 0; |
| 403 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 404 | case PCH_DEVFN_I2C4: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 405 | silconfig->I2c4Enable = 0; |
| 406 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 407 | case PCH_DEVFN_I2C5: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 408 | silconfig->I2c5Enable = 0; |
| 409 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 410 | case PCH_DEVFN_I2C6: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 411 | silconfig->I2c6Enable = 0; |
| 412 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 413 | case PCH_DEVFN_I2C7: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 414 | silconfig->I2c7Enable = 0; |
| 415 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 416 | case PCH_DEVFN_UART0: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 417 | silconfig->Hsuart0Enable = 0; |
| 418 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 419 | case PCH_DEVFN_UART1: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 420 | silconfig->Hsuart1Enable = 0; |
| 421 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 422 | case PCH_DEVFN_UART2: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 423 | silconfig->Hsuart2Enable = 0; |
| 424 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 425 | case PCH_DEVFN_UART3: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 426 | silconfig->Hsuart3Enable = 0; |
| 427 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 428 | case PCH_DEVFN_SPI0: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 429 | silconfig->Spi0Enable = 0; |
| 430 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 431 | case PCH_DEVFN_SPI1: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 432 | silconfig->Spi1Enable = 0; |
| 433 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 434 | case PCH_DEVFN_SPI2: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 435 | silconfig->Spi2Enable = 0; |
| 436 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 437 | case PCH_DEVFN_SDCARD: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 438 | silconfig->SdcardEnabled = 0; |
| 439 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 440 | case PCH_DEVFN_EMMC: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 441 | silconfig->eMMCEnabled = 0; |
| 442 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 443 | case PCH_DEVFN_SDIO: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 444 | silconfig->SdioEnabled = 0; |
| 445 | break; |
Subrata Banik | 2ee54db | 2017-03-05 12:37:00 +0530 | [diff] [blame] | 446 | case PCH_DEVFN_SMBUS: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 447 | silconfig->SmbusEnable = 0; |
| 448 | break; |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 449 | #if !CONFIG(SOC_INTEL_GLK) |
Werner Zeh | de3ace0 | 2019-01-15 08:03:43 +0100 | [diff] [blame] | 450 | case SA_DEVFN_IPU: |
| 451 | silconfig->IpuEn = 0; |
| 452 | break; |
| 453 | #endif |
Nico Huber | 4074ce0 | 2019-01-31 16:45:04 +0100 | [diff] [blame] | 454 | case PCH_DEVFN_HDA: |
| 455 | silconfig->HdaEnable = 0; |
| 456 | break; |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 457 | default: |
| 458 | printk(BIOS_WARNING, "PCI:%02x.%01x: Could not disable the device\n", |
| 459 | PCI_SLOT(dev->path.pci.devfn), |
| 460 | PCI_FUNC(dev->path.pci.devfn)); |
| 461 | break; |
| 462 | } |
| 463 | } |
| 464 | |
Brandon Breitenstein | c31ba0e | 2016-07-27 17:34:45 -0700 | [diff] [blame] | 465 | static void parse_devicetree(FSP_S_CONFIG *silconfig) |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 466 | { |
Kyösti Mälkki | 28dc7dc | 2019-07-12 13:10:19 +0300 | [diff] [blame] | 467 | struct device *dev = pcidev_path_on_root(SA_DEVFN_ROOT); |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 468 | |
| 469 | if (!dev) { |
| 470 | printk(BIOS_ERR, "Could not find root device\n"); |
| 471 | return; |
| 472 | } |
| 473 | /* Only disable bus 0 devices. */ |
| 474 | for (dev = dev->bus->children; dev; dev = dev->sibling) { |
| 475 | if (!dev->enabled) |
| 476 | disable_dev(dev, silconfig); |
| 477 | } |
| 478 | } |
| 479 | |
Hannah Williams | 3ff14a0 | 2017-05-05 16:30:22 -0700 | [diff] [blame] | 480 | static void apl_fsp_silicon_init_params_cb(struct soc_intel_apollolake_config |
| 481 | *cfg, FSP_S_CONFIG *silconfig) |
| 482 | { |
Maxim Polyakov | 6704049 | 2020-02-16 11:51:57 +0300 | [diff] [blame] | 483 | #if !CONFIG(SOC_INTEL_GLK) /* GLK FSP does not have these fields in FspsUpd.h yet */ |
Hannah Williams | 3ff14a0 | 2017-05-05 16:30:22 -0700 | [diff] [blame] | 484 | uint8_t port; |
| 485 | |
| 486 | for (port = 0; port < APOLLOLAKE_USB2_PORT_MAX; port++) { |
Maxim Polyakov | 6704049 | 2020-02-16 11:51:57 +0300 | [diff] [blame] | 487 | if (cfg->usb_config_override) { |
| 488 | if (!cfg->usb2_port[port].enable) |
| 489 | continue; |
| 490 | |
| 491 | silconfig->PortUsb20Enable[port] = 1; |
| 492 | silconfig->PortUs20bOverCurrentPin[port] = cfg->usb2_port[port].oc_pin; |
| 493 | } |
| 494 | |
Hannah Williams | 3ff14a0 | 2017-05-05 16:30:22 -0700 | [diff] [blame] | 495 | if (cfg->usb2eye[port].Usb20PerPortTxPeHalf != 0) |
| 496 | silconfig->PortUsb20PerPortTxPeHalf[port] = |
| 497 | cfg->usb2eye[port].Usb20PerPortTxPeHalf; |
| 498 | |
| 499 | if (cfg->usb2eye[port].Usb20PerPortPeTxiSet != 0) |
| 500 | silconfig->PortUsb20PerPortPeTxiSet[port] = |
| 501 | cfg->usb2eye[port].Usb20PerPortPeTxiSet; |
| 502 | |
| 503 | if (cfg->usb2eye[port].Usb20PerPortTxiSet != 0) |
| 504 | silconfig->PortUsb20PerPortTxiSet[port] = |
| 505 | cfg->usb2eye[port].Usb20PerPortTxiSet; |
| 506 | |
| 507 | if (cfg->usb2eye[port].Usb20HsSkewSel != 0) |
| 508 | silconfig->PortUsb20HsSkewSel[port] = |
| 509 | cfg->usb2eye[port].Usb20HsSkewSel; |
| 510 | |
| 511 | if (cfg->usb2eye[port].Usb20IUsbTxEmphasisEn != 0) |
| 512 | silconfig->PortUsb20IUsbTxEmphasisEn[port] = |
| 513 | cfg->usb2eye[port].Usb20IUsbTxEmphasisEn; |
| 514 | |
| 515 | if (cfg->usb2eye[port].Usb20PerPortRXISet != 0) |
| 516 | silconfig->PortUsb20PerPortRXISet[port] = |
| 517 | cfg->usb2eye[port].Usb20PerPortRXISet; |
| 518 | |
| 519 | if (cfg->usb2eye[port].Usb20HsNpreDrvSel != 0) |
| 520 | silconfig->PortUsb20HsNpreDrvSel[port] = |
| 521 | cfg->usb2eye[port].Usb20HsNpreDrvSel; |
| 522 | } |
Maxim Polyakov | 6704049 | 2020-02-16 11:51:57 +0300 | [diff] [blame] | 523 | |
| 524 | if (cfg->usb_config_override) { |
| 525 | for (port = 0; port < APOLLOLAKE_USB3_PORT_MAX; port++) { |
| 526 | if (!cfg->usb3_port[port].enable) |
| 527 | continue; |
| 528 | |
| 529 | silconfig->PortUsb30Enable[port] = 1; |
| 530 | silconfig->PortUs30bOverCurrentPin[port] = cfg->usb3_port[port].oc_pin; |
| 531 | } |
| 532 | } |
Hannah Williams | 3ff14a0 | 2017-05-05 16:30:22 -0700 | [diff] [blame] | 533 | #endif |
| 534 | } |
| 535 | |
| 536 | static void glk_fsp_silicon_init_params_cb( |
| 537 | struct soc_intel_apollolake_config *cfg, FSP_S_CONFIG *silconfig) |
| 538 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 539 | #if CONFIG(SOC_INTEL_GLK) |
Seunghwan Kim | f7fd9b1 | 2019-01-24 16:17:44 +0900 | [diff] [blame] | 540 | uint8_t port; |
Franklin He | 117a660 | 2020-03-16 12:31:01 +1100 | [diff] [blame] | 541 | struct device *dev; |
Seunghwan Kim | f7fd9b1 | 2019-01-24 16:17:44 +0900 | [diff] [blame] | 542 | |
| 543 | for (port = 0; port < APOLLOLAKE_USB2_PORT_MAX; port++) { |
| 544 | if (!cfg->usb2eye[port].Usb20OverrideEn) |
| 545 | continue; |
| 546 | |
| 547 | silconfig->Usb2AfePehalfbit[port] = |
| 548 | cfg->usb2eye[port].Usb20PerPortTxPeHalf; |
| 549 | silconfig->Usb2AfePetxiset[port] = |
| 550 | cfg->usb2eye[port].Usb20PerPortPeTxiSet; |
| 551 | silconfig->Usb2AfeTxiset[port] = |
| 552 | cfg->usb2eye[port].Usb20PerPortTxiSet; |
| 553 | silconfig->Usb2AfePredeemp[port] = |
| 554 | cfg->usb2eye[port].Usb20IUsbTxEmphasisEn; |
| 555 | } |
| 556 | |
Franklin He | 117a660 | 2020-03-16 12:31:01 +1100 | [diff] [blame] | 557 | dev = pcidev_path_on_root(SA_GLK_DEVFN_GMM); |
| 558 | silconfig->Gmm = dev ? dev->enabled : 0; |
Shamile Khan | c4276a3 | 2018-03-14 18:09:19 -0700 | [diff] [blame] | 559 | |
| 560 | /* On Geminilake, we need to override the default FSP PCIe de-emphasis |
| 561 | * settings using the device tree settings. This is because PCIe |
| 562 | * de-emphasis is enabled by default and Thunderpeak PCIe WiFi detection |
| 563 | * requires de-emphasis disabled. If we make this change common to both |
| 564 | * Apollolake and Geminilake, then we need to add mainboard device tree |
| 565 | * de-emphasis settings of 1 to Apollolake systems. |
| 566 | */ |
| 567 | memcpy(silconfig->PcieRpSelectableDeemphasis, |
| 568 | cfg->pcie_rp_deemphasis_enable, |
| 569 | sizeof(silconfig->PcieRpSelectableDeemphasis)); |
Srinidhi N Kaushik | 5af546c | 2018-05-14 23:33:55 -0700 | [diff] [blame] | 570 | /* |
| 571 | * FSP does not know what the clock requirements are for the |
| 572 | * device on SPI bus, hence it should not modify what coreboot |
| 573 | * has set up. Hence skipping in FSP. |
| 574 | */ |
| 575 | silconfig->SkipSpiPCP = 1; |
John Zhao | e673e5c | 2018-10-30 15:12:11 -0700 | [diff] [blame] | 576 | |
| 577 | /* |
| 578 | * FSP provides UPD interface to execute IPC command. In order to |
| 579 | * improve boot performance, configure PmicPmcIpcCtrl for PMC to program |
| 580 | * PMIC PCH_PWROK delay. |
John Zhao | 91600a3 | 2019-01-10 12:13:38 -0800 | [diff] [blame] | 581 | */ |
John Zhao | e673e5c | 2018-10-30 15:12:11 -0700 | [diff] [blame] | 582 | silconfig->PmicPmcIpcCtrl = cfg->PmicPmcIpcCtrl; |
John Zhao | 91600a3 | 2019-01-10 12:13:38 -0800 | [diff] [blame] | 583 | |
| 584 | /* |
| 585 | * Options to disable XHCI Link Compliance Mode. |
| 586 | */ |
| 587 | silconfig->DisableComplianceMode = cfg->DisableComplianceMode; |
John Zhao | 9a4beb4 | 2019-01-28 16:04:35 -0800 | [diff] [blame] | 588 | |
| 589 | /* |
| 590 | * Options to change USB3 ModPhy setting for Integrated Filter value. |
| 591 | */ |
| 592 | silconfig->ModPhyIfValue = cfg->ModPhyIfValue; |
| 593 | |
| 594 | /* |
| 595 | * Options to bump USB3 LDO voltage with 40mv. |
| 596 | */ |
| 597 | silconfig->ModPhyVoltageBump = cfg->ModPhyVoltageBump; |
| 598 | |
| 599 | /* |
| 600 | * Options to adjust PMIC Vdd2 voltage. |
| 601 | */ |
| 602 | silconfig->PmicVdd2Voltage = cfg->PmicVdd2Voltage; |
Srinidhi N Kaushik | 5af546c | 2018-05-14 23:33:55 -0700 | [diff] [blame] | 603 | #endif |
Hannah Williams | 3ff14a0 | 2017-05-05 16:30:22 -0700 | [diff] [blame] | 604 | } |
| 605 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 606 | void __weak mainboard_devtree_update(struct device *dev) |
Kane Chen | 5bddcc4 | 2017-08-22 11:37:18 +0800 | [diff] [blame] | 607 | { |
Elyes HAOUAS | 88607a4 | 2018-10-05 10:36:45 +0200 | [diff] [blame] | 608 | /* Override dev tree settings per board */ |
Kane Chen | 5bddcc4 | 2017-08-22 11:37:18 +0800 | [diff] [blame] | 609 | } |
| 610 | |
Brandon Breitenstein | c31ba0e | 2016-07-27 17:34:45 -0700 | [diff] [blame] | 611 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd) |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 612 | { |
Lee Leahy | 1d20fe7 | 2017-03-09 09:50:28 -0800 | [diff] [blame] | 613 | FSP_S_CONFIG *silconfig = &silupd->FspsConfig; |
Kyösti Mälkki | 4af4e7f | 2019-07-14 05:50:20 +0300 | [diff] [blame] | 614 | struct soc_intel_apollolake_config *cfg; |
Kyösti Mälkki | 28dc7dc | 2019-07-12 13:10:19 +0300 | [diff] [blame] | 615 | struct device *dev; |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 616 | |
| 617 | /* Load VBT before devicetree-specific config. */ |
Patrick Georgi | 2257959 | 2017-10-06 17:36:09 +0200 | [diff] [blame] | 618 | silconfig->GraphicsConfigPtr = (uintptr_t)vbt_get(); |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 619 | |
Kyösti Mälkki | 28dc7dc | 2019-07-12 13:10:19 +0300 | [diff] [blame] | 620 | dev = pcidev_path_on_root(SA_DEVFN_ROOT); |
| 621 | cfg = config_of(dev); |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 622 | |
Kane Chen | 5bddcc4 | 2017-08-22 11:37:18 +0800 | [diff] [blame] | 623 | mainboard_devtree_update(dev); |
| 624 | |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 625 | /* Parse device tree and disable unused device*/ |
| 626 | parse_devicetree(silconfig); |
| 627 | |
Furquan Shaikh | 6d5e10c | 2018-03-14 19:57:16 -0700 | [diff] [blame] | 628 | memcpy(silconfig->PcieRpClkReqNumber, cfg->pcie_rp_clkreq_pin, |
| 629 | sizeof(silconfig->PcieRpClkReqNumber)); |
Andrey Petrov | e07e13d | 2016-03-18 14:43:00 -0700 | [diff] [blame] | 630 | |
Furquan Shaikh | 2cfc862 | 2018-03-14 21:43:04 -0700 | [diff] [blame] | 631 | memcpy(silconfig->PcieRpHotPlug, cfg->pcie_rp_hotplug_enable, |
| 632 | sizeof(silconfig->PcieRpHotPlug)); |
| 633 | |
Nico Huber | 8885529 | 2018-11-27 15:13:22 +0100 | [diff] [blame] | 634 | switch (cfg->serirq_mode) { |
| 635 | case SERIRQ_QUIET: |
| 636 | silconfig->SirqEnable = 1; |
| 637 | silconfig->SirqMode = 0; |
| 638 | break; |
| 639 | case SERIRQ_CONTINUOUS: |
| 640 | silconfig->SirqEnable = 1; |
| 641 | silconfig->SirqMode = 1; |
| 642 | break; |
| 643 | case SERIRQ_OFF: |
| 644 | default: |
| 645 | silconfig->SirqEnable = 0; |
| 646 | break; |
| 647 | } |
| 648 | |
Zhao, Lijian | 1b8ee0b | 2016-05-17 19:01:34 -0700 | [diff] [blame] | 649 | if (cfg->emmc_tx_cmd_cntl != 0) |
| 650 | silconfig->EmmcTxCmdCntl = cfg->emmc_tx_cmd_cntl; |
| 651 | if (cfg->emmc_tx_data_cntl1 != 0) |
| 652 | silconfig->EmmcTxDataCntl1 = cfg->emmc_tx_data_cntl1; |
| 653 | if (cfg->emmc_tx_data_cntl2 != 0) |
| 654 | silconfig->EmmcTxDataCntl2 = cfg->emmc_tx_data_cntl2; |
| 655 | if (cfg->emmc_rx_cmd_data_cntl1 != 0) |
| 656 | silconfig->EmmcRxCmdDataCntl1 = cfg->emmc_rx_cmd_data_cntl1; |
| 657 | if (cfg->emmc_rx_strobe_cntl != 0) |
| 658 | silconfig->EmmcRxStrobeCntl = cfg->emmc_rx_strobe_cntl; |
| 659 | if (cfg->emmc_rx_cmd_data_cntl2 != 0) |
| 660 | silconfig->EmmcRxCmdDataCntl2 = cfg->emmc_rx_cmd_data_cntl2; |
Mario Scheithauer | 9116eb6 | 2018-08-23 11:39:19 +0200 | [diff] [blame] | 661 | if (cfg->emmc_host_max_speed != 0) |
| 662 | silconfig->eMMCHostMaxSpeed = cfg->emmc_host_max_speed; |
Zhao, Lijian | 1b8ee0b | 2016-05-17 19:01:34 -0700 | [diff] [blame] | 663 | |
Saurabh Satija | e46dbcc | 2016-05-03 15:15:31 -0700 | [diff] [blame] | 664 | silconfig->LPSS_S0ixEnable = cfg->lpss_s0ix_enable; |
| 665 | |
Lee Leahy | 07441b5 | 2017-03-09 10:59:25 -0800 | [diff] [blame] | 666 | /* Disable monitor mwait since it is broken due to a hardware bug |
Cole Nelson | f357c25 | 2017-05-16 11:38:59 -0700 | [diff] [blame] | 667 | * without a fix. Specific to Apollolake. |
Lee Leahy | 07441b5 | 2017-03-09 10:59:25 -0800 | [diff] [blame] | 668 | */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 669 | if (!CONFIG(SOC_INTEL_GLK)) |
Cole Nelson | f357c25 | 2017-05-16 11:38:59 -0700 | [diff] [blame] | 670 | silconfig->MonitorMwaitEnable = 0; |
Bora Guvendik | 60cc75d | 2016-07-25 14:44:51 -0700 | [diff] [blame] | 671 | |
Subrata Banik | cf32fd1 | 2018-12-19 18:02:17 +0530 | [diff] [blame] | 672 | silconfig->SkipMpInit = !CONFIG_USE_INTEL_FSP_MP_INIT; |
Venkateswarlu Vinjamuri | 1a5e32c | 2016-10-31 17:15:30 -0700 | [diff] [blame] | 673 | |
Furquan Shaikh | cad9b63 | 2016-06-20 16:08:42 -0700 | [diff] [blame] | 674 | /* Disable setting of EISS bit in FSP. */ |
| 675 | silconfig->SpiEiss = 0; |
Ravi Sarawadi | 3a21d0f | 2016-08-10 11:33:56 -0700 | [diff] [blame] | 676 | |
| 677 | /* Disable FSP from locking access to the RTC NVRAM */ |
| 678 | silconfig->RtcLock = 0; |
Venkateswarlu Vinjamuri | 88df48c | 2016-09-02 16:04:27 -0700 | [diff] [blame] | 679 | |
| 680 | /* Enable Audio clk gate and power gate */ |
| 681 | silconfig->HDAudioClkGate = cfg->hdaudio_clk_gate_enable; |
| 682 | silconfig->HDAudioPwrGate = cfg->hdaudio_pwr_gate_enable; |
Elyes HAOUAS | 6dc9d03 | 2020-02-16 16:22:52 +0100 | [diff] [blame] | 683 | /* BIOS config lockdown Audio clk and power gate */ |
Venkateswarlu Vinjamuri | 88df48c | 2016-09-02 16:04:27 -0700 | [diff] [blame] | 684 | silconfig->BiosCfgLockDown = cfg->hdaudio_bios_config_lockdown; |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 685 | if (CONFIG(SOC_INTEL_GLK)) |
Hannah Williams | 3ff14a0 | 2017-05-05 16:30:22 -0700 | [diff] [blame] | 686 | glk_fsp_silicon_init_params_cb(cfg, silconfig); |
| 687 | else |
| 688 | apl_fsp_silicon_init_params_cb(cfg, silconfig); |
Duncan Laurie | 4c8fbc0 | 2018-03-26 02:19:58 -0700 | [diff] [blame] | 689 | |
| 690 | /* Enable xDCI controller if enabled in devicetree and allowed */ |
Kyösti Mälkki | 903b40a | 2019-07-03 07:25:59 +0300 | [diff] [blame] | 691 | dev = pcidev_path_on_root(PCH_DEVFN_XDCI); |
Duncan Laurie | 4c8fbc0 | 2018-03-26 02:19:58 -0700 | [diff] [blame] | 692 | if (!xdci_can_enable()) |
| 693 | dev->enabled = 0; |
| 694 | silconfig->UsbOtg = dev->enabled; |
Werner Zeh | 279afdc | 2019-02-01 12:32:51 +0100 | [diff] [blame] | 695 | |
| 696 | /* Set VTD feature according to devicetree */ |
| 697 | silconfig->VtdEnable = cfg->enable_vtd; |
Felix Singer | e59ae10 | 2019-05-02 13:57:57 +0200 | [diff] [blame] | 698 | |
Michael Niewöhner | 9b8d28f | 2019-10-26 10:44:33 +0200 | [diff] [blame] | 699 | dev = pcidev_path_on_root(SA_DEVFN_IGD); |
| 700 | if (CONFIG(RUN_FSP_GOP) && dev && dev->enabled) |
| 701 | silconfig->PeiGraphicsPeimInit = 1; |
| 702 | else |
| 703 | silconfig->PeiGraphicsPeimInit = 0; |
| 704 | |
Felix Singer | e59ae10 | 2019-05-02 13:57:57 +0200 | [diff] [blame] | 705 | mainboard_silicon_init_params(silconfig); |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 706 | } |
| 707 | |
| 708 | struct chip_operations soc_intel_apollolake_ops = { |
| 709 | CHIP_NAME("Intel Apollolake SOC") |
John Zhao | 57aa8b6 | 2019-01-14 09:15:50 -0800 | [diff] [blame] | 710 | .enable_dev = &enable_dev, |
| 711 | .init = &soc_init, |
| 712 | .final = &soc_final |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 713 | }; |
| 714 | |
Andrey Petrov | a697c19 | 2016-12-07 10:47:46 -0800 | [diff] [blame] | 715 | static void drop_privilege_all(void) |
| 716 | { |
| 717 | /* Drop privilege level on all the CPUs */ |
Patrick Rudolph | 5ec97ce | 2019-07-26 14:47:32 +0200 | [diff] [blame] | 718 | if (mp_run_on_all_cpus(&cpu_enable_untrusted_mode, NULL) < 0) |
Andrey Petrov | a697c19 | 2016-12-07 10:47:46 -0800 | [diff] [blame] | 719 | printk(BIOS_ERR, "failed to enable untrusted mode\n"); |
| 720 | } |
| 721 | |
John Zhao | 7dff726 | 2018-07-30 13:54:25 -0700 | [diff] [blame] | 722 | static void configure_xhci_host_mode_port0(void) |
| 723 | { |
| 724 | uint32_t *cfg0; |
| 725 | uint32_t *cfg1; |
| 726 | const struct resource *res; |
| 727 | uint32_t reg; |
| 728 | struct stopwatch sw; |
| 729 | struct device *xhci_dev = PCH_DEV_XHCI; |
| 730 | |
| 731 | printk(BIOS_INFO, "Putting xHCI port 0 into host mode.\n"); |
| 732 | res = find_resource(xhci_dev, PCI_BASE_ADDRESS_0); |
| 733 | cfg0 = (void *)(uintptr_t)(res->base + DUAL_ROLE_CFG0); |
| 734 | cfg1 = (void *)(uintptr_t)(res->base + DUAL_ROLE_CFG1); |
| 735 | reg = read32(cfg0); |
John Zhao | db2f91b | 2018-08-21 15:02:54 -0700 | [diff] [blame] | 736 | if (!(reg & SW_IDPIN_EN_MASK)) |
John Zhao | 7dff726 | 2018-07-30 13:54:25 -0700 | [diff] [blame] | 737 | return; |
| 738 | |
| 739 | reg &= ~(SW_IDPIN_MASK | SW_VBUS_VALID_MASK); |
| 740 | write32(cfg0, reg); |
| 741 | |
| 742 | stopwatch_init_msecs_expire(&sw, 10); |
| 743 | /* Wait for the host mode status bit. */ |
| 744 | while ((read32(cfg1) & DRD_MODE_MASK) != DRD_MODE_HOST) { |
| 745 | if (stopwatch_expired(&sw)) { |
| 746 | printk(BIOS_ERR, "Timed out waiting for host mode.\n"); |
| 747 | return; |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | printk(BIOS_INFO, "xHCI port 0 host switch over took %lu ms\n", |
| 752 | stopwatch_duration_msecs(&sw)); |
| 753 | } |
| 754 | |
| 755 | static int check_xdci_enable(void) |
| 756 | { |
| 757 | struct device *dev = PCH_DEV_XDCI; |
| 758 | |
| 759 | return !!dev->enabled; |
| 760 | } |
| 761 | |
Marx Wang | abc17d1 | 2020-04-07 16:58:38 +0800 | [diff] [blame] | 762 | static void disable_xhci_lfps_pm(void) |
| 763 | { |
| 764 | struct soc_intel_apollolake_config *cfg; |
| 765 | |
| 766 | cfg = config_of_soc(); |
| 767 | |
| 768 | if (cfg->disable_xhci_lfps_pm) { |
| 769 | void *addr; |
| 770 | const struct resource *res; |
| 771 | uint32_t reg; |
| 772 | struct device *xhci_dev = PCH_DEV_XHCI; |
| 773 | |
| 774 | res = find_resource(xhci_dev, PCI_BASE_ADDRESS_0); |
| 775 | addr = (void *)(uintptr_t)(res->base + CFG_XHCPMCTRL); |
| 776 | reg = read32(addr); |
| 777 | printk(BIOS_DEBUG, "XHCI PM: control reg=0x%x.\n", reg); |
| 778 | if (reg) { |
| 779 | reg &= LFPS_PM_DISABLE_MASK; |
| 780 | write32(addr, reg); |
| 781 | printk(BIOS_INFO, "XHCI PM: Disable xHCI LFPS as configured in devicetree.\n"); |
| 782 | } |
| 783 | } |
| 784 | } |
| 785 | |
Lee Leahy | 806fa24 | 2016-08-01 13:55:02 -0700 | [diff] [blame] | 786 | void platform_fsp_notify_status(enum fsp_notify_phase phase) |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 787 | { |
Andrey Petrov | a697c19 | 2016-12-07 10:47:46 -0800 | [diff] [blame] | 788 | if (phase == END_OF_FIRMWARE) { |
Furquan Shaikh | d2c2f83 | 2018-11-07 10:24:31 -0800 | [diff] [blame] | 789 | |
| 790 | /* |
| 791 | * Before hiding P2SB device and dropping privilege level, |
| 792 | * dump CSE status and disable HECI1 interface. |
| 793 | */ |
| 794 | heci_cse_lockdown(); |
| 795 | |
Andrey Petrov | a697c19 | 2016-12-07 10:47:46 -0800 | [diff] [blame] | 796 | /* Hide the P2SB device to align with previous behavior. */ |
Aaron Durbin | fadfc2e | 2016-07-01 16:36:03 -0500 | [diff] [blame] | 797 | p2sb_hide(); |
Furquan Shaikh | d2c2f83 | 2018-11-07 10:24:31 -0800 | [diff] [blame] | 798 | |
Andrey Petrov | a697c19 | 2016-12-07 10:47:46 -0800 | [diff] [blame] | 799 | /* |
| 800 | * As per guidelines BIOS is recommended to drop CPU privilege |
| 801 | * level to IA_UNTRUSTED. After that certain device registers |
| 802 | * and MSRs become inaccessible supposedly increasing system |
| 803 | * security. |
| 804 | */ |
| 805 | drop_privilege_all(); |
John Zhao | 7dff726 | 2018-07-30 13:54:25 -0700 | [diff] [blame] | 806 | |
| 807 | /* |
| 808 | * When USB OTG is set, GLK FSP enables xHCI SW ID pin and |
| 809 | * configures USB-C as device mode. Force USB-C into host mode. |
| 810 | */ |
| 811 | if (check_xdci_enable()) |
| 812 | configure_xhci_host_mode_port0(); |
John Zhao | 57aa8b6 | 2019-01-14 09:15:50 -0800 | [diff] [blame] | 813 | |
| 814 | /* |
| 815 | * Override GLK xhci clock gating register(XHCLKGTEN) to |
Elyes HAOUAS | 44f558e | 2020-02-24 13:26:04 +0100 | [diff] [blame] | 816 | * mitigate USB device suspend and resume failure. |
John Zhao | 57aa8b6 | 2019-01-14 09:15:50 -0800 | [diff] [blame] | 817 | */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 818 | if (CONFIG(SOC_INTEL_GLK)) { |
John Zhao | 57aa8b6 | 2019-01-14 09:15:50 -0800 | [diff] [blame] | 819 | uint32_t *cfg; |
| 820 | const struct resource *res; |
| 821 | uint32_t reg; |
| 822 | struct device *xhci_dev = PCH_DEV_XHCI; |
| 823 | |
| 824 | res = find_resource(xhci_dev, PCI_BASE_ADDRESS_0); |
| 825 | cfg = (void *)(uintptr_t)(res->base + CFG_XHCLKGTEN); |
| 826 | reg = SRAMPGTEN | SSLSE | USB2PLLSE | IOSFSTCGE | |
| 827 | HSTCGE | HSUXDMIPLLSE | SSTCGE | XHCFTCLKSE | |
| 828 | XHCBBTCGIPISO | XHCUSB2PLLSDLE | SSPLLSUE | |
| 829 | XHCBLCGE | HSLTCGE | SSLTCGE | IOSFBTCGE | |
| 830 | IOSFGBLCGE; |
| 831 | write32(cfg, reg); |
| 832 | } |
Marx Wang | abc17d1 | 2020-04-07 16:58:38 +0800 | [diff] [blame] | 833 | |
| 834 | /* Disable XHCI LFPS power management if the option in dev tree is set. */ |
| 835 | disable_xhci_lfps_pm(); |
Andrey Petrov | a697c19 | 2016-12-07 10:47:46 -0800 | [diff] [blame] | 836 | } |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 837 | } |
| 838 | |
Furquan Shaikh | 6ac226d | 2016-06-15 17:13:20 -0700 | [diff] [blame] | 839 | /* |
Furquan Shaikh | d6c5559 | 2016-11-21 12:41:20 -0800 | [diff] [blame] | 840 | * spi_flash init() needs to run unconditionally on every boot (including |
| 841 | * resume) to allow write protect to be disabled for eventlog and nvram |
| 842 | * updates. This needs to be done as early as possible in ramstage. Thus, add a |
| 843 | * callback for entry into BS_PRE_DEVICE. |
Furquan Shaikh | 6ac226d | 2016-06-15 17:13:20 -0700 | [diff] [blame] | 844 | */ |
Furquan Shaikh | d6c5559 | 2016-11-21 12:41:20 -0800 | [diff] [blame] | 845 | static void spi_flash_init_cb(void *unused) |
Furquan Shaikh | 6ac226d | 2016-06-15 17:13:20 -0700 | [diff] [blame] | 846 | { |
Barnali Sarkar | e70142c | 2017-03-28 16:32:33 +0530 | [diff] [blame] | 847 | fast_spi_init(); |
Furquan Shaikh | 6ac226d | 2016-06-15 17:13:20 -0700 | [diff] [blame] | 848 | } |
| 849 | |
Felix Singer | e59ae10 | 2019-05-02 13:57:57 +0200 | [diff] [blame] | 850 | __weak |
| 851 | void mainboard_silicon_init_params(FSP_S_CONFIG *silconfig) |
| 852 | { |
| 853 | printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 854 | } |
| 855 | |
Wim Vervoorn | d137150 | 2019-12-17 14:10:16 +0100 | [diff] [blame] | 856 | /* Handle FSP logo params */ |
| 857 | const struct cbmem_entry *soc_load_logo(FSPS_UPD *supd) |
| 858 | { |
| 859 | return fsp_load_logo(&supd->FspsConfig.LogoPtr, &supd->FspsConfig.LogoSize); |
| 860 | } |
| 861 | |
Furquan Shaikh | d6c5559 | 2016-11-21 12:41:20 -0800 | [diff] [blame] | 862 | BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, spi_flash_init_cb, NULL); |