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