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