Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2015 Intel Corp. |
| 5 | * (Written by Alexandru Gagniuc <alexandrux.gagniuc@intel.com> for Intel Corp.) |
| 6 | * (Written by Andrey Petrov <andrey.petrov@intel.com> for Intel Corp.) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
Martin Roth | ebabfad | 2016-04-10 11:09:16 -0600 | [diff] [blame] | 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 17 | */ |
| 18 | |
Hannah Williams | 0f61da8 | 2016-04-18 13:47:08 -0700 | [diff] [blame] | 19 | #include <arch/acpi.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 20 | #include <bootstate.h> |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 21 | #include <cbmem.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 22 | #include <console/console.h> |
| 23 | #include <cpu/cpu.h> |
| 24 | #include <device/device.h> |
| 25 | #include <device/pci.h> |
| 26 | #include <fsp/api.h> |
| 27 | #include <fsp/util.h> |
Andrey Petrov | e07e13d | 2016-03-18 14:43:00 -0700 | [diff] [blame] | 28 | #include <soc/iomap.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 29 | #include <soc/cpu.h> |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 30 | #include <soc/intel/common/vbt.h> |
Aaron Durbin | 81d1e09 | 2016-07-13 01:49:10 -0500 | [diff] [blame] | 31 | #include <soc/itss.h> |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 32 | #include <soc/nvs.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 33 | #include <soc/pci_devs.h> |
Furquan Shaikh | 6ac226d | 2016-06-15 17:13:20 -0700 | [diff] [blame] | 34 | #include <spi-generic.h> |
Andrey Petrov | 3dbea29 | 2016-06-14 22:20:28 -0700 | [diff] [blame] | 35 | #include <soc/pm.h> |
Aaron Durbin | fadfc2e | 2016-07-01 16:36:03 -0500 | [diff] [blame] | 36 | #include <soc/p2sb.h> |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 37 | |
| 38 | #include "chip.h" |
| 39 | |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 40 | static void *vbt; |
| 41 | static struct region_device vbt_rdev; |
| 42 | |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 43 | static const char *soc_acpi_name(struct device *dev) |
| 44 | { |
| 45 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 46 | return "PCI0"; |
| 47 | |
| 48 | if (dev->path.type != DEVICE_PATH_PCI) |
| 49 | return NULL; |
| 50 | |
| 51 | switch (dev->path.pci.devfn) { |
| 52 | /* DSDT: acpi/northbridge.asl */ |
| 53 | case NB_DEVFN: |
| 54 | return "MCHC"; |
| 55 | /* DSDT: acpi/lpc.asl */ |
| 56 | case LPC_DEVFN: |
| 57 | return "LPCB"; |
| 58 | /* DSDT: acpi/xhci.asl */ |
| 59 | case XHCI_DEVFN: |
| 60 | return "XHCI"; |
| 61 | /* DSDT: acpi/pch_hda.asl */ |
| 62 | case HDA_DEVFN: |
| 63 | return "HDAS"; |
| 64 | /* DSDT: acpi/lpss.asl */ |
| 65 | case LPSS_DEVFN_UART0: |
| 66 | return "URT1"; |
| 67 | case LPSS_DEVFN_UART1: |
| 68 | return "URT2"; |
| 69 | case LPSS_DEVFN_UART2: |
| 70 | return "URT3"; |
| 71 | case LPSS_DEVFN_UART3: |
| 72 | return "URT4"; |
| 73 | case LPSS_DEVFN_SPI0: |
| 74 | return "SPI1"; |
| 75 | case LPSS_DEVFN_SPI1: |
| 76 | return "SPI2"; |
| 77 | case LPSS_DEVFN_SPI2: |
| 78 | return "SPI3"; |
| 79 | case LPSS_DEVFN_PWM: |
| 80 | return "PWM"; |
| 81 | case LPSS_DEVFN_I2C0: |
| 82 | return "I2C0"; |
| 83 | case LPSS_DEVFN_I2C1: |
| 84 | return "I2C1"; |
| 85 | case LPSS_DEVFN_I2C2: |
| 86 | return "I2C2"; |
| 87 | case LPSS_DEVFN_I2C3: |
| 88 | return "I2C3"; |
| 89 | case LPSS_DEVFN_I2C4: |
| 90 | return "I2C4"; |
| 91 | case LPSS_DEVFN_I2C5: |
| 92 | return "I2C5"; |
| 93 | case LPSS_DEVFN_I2C6: |
| 94 | return "I2C6"; |
| 95 | case LPSS_DEVFN_I2C7: |
| 96 | return "I2C7"; |
| 97 | /* Storage */ |
| 98 | case SDCARD_DEVFN: |
| 99 | return "SDCD"; |
| 100 | case EMMC_DEVFN: |
| 101 | return "EMMC"; |
| 102 | case SDIO_DEVFN: |
| 103 | return "SDIO"; |
| 104 | } |
| 105 | |
| 106 | return NULL; |
| 107 | } |
| 108 | |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 109 | static void pci_domain_set_resources(device_t dev) |
| 110 | { |
| 111 | assign_resources(dev->link_list); |
| 112 | } |
| 113 | |
| 114 | static struct device_operations pci_domain_ops = { |
| 115 | .read_resources = pci_domain_read_resources, |
| 116 | .set_resources = pci_domain_set_resources, |
| 117 | .enable_resources = NULL, |
| 118 | .init = NULL, |
| 119 | .scan_bus = pci_domain_scan_bus, |
| 120 | .ops_pci_bus = pci_bus_default_ops, |
Duncan Laurie | 02fcc88 | 2016-06-27 10:51:17 -0700 | [diff] [blame] | 121 | .acpi_name = &soc_acpi_name, |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | static struct device_operations cpu_bus_ops = { |
| 125 | .read_resources = DEVICE_NOOP, |
| 126 | .set_resources = DEVICE_NOOP, |
| 127 | .enable_resources = DEVICE_NOOP, |
| 128 | .init = apollolake_init_cpus, |
| 129 | .scan_bus = NULL, |
Hannah Williams | 0f61da8 | 2016-04-18 13:47:08 -0700 | [diff] [blame] | 130 | .acpi_fill_ssdt_generator = generate_cpu_entries, |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | static void enable_dev(device_t dev) |
| 134 | { |
| 135 | /* Set the operations if it is a special bus type */ |
| 136 | if (dev->path.type == DEVICE_PATH_DOMAIN) { |
| 137 | dev->ops = &pci_domain_ops; |
| 138 | } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
| 139 | dev->ops = &cpu_bus_ops; |
| 140 | } |
| 141 | } |
| 142 | |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 143 | /* |
| 144 | * If the PCIe root port at function 0 is disabled, |
| 145 | * the PCIe root ports might be coalesced after FSP silicon init. |
| 146 | * The below function will swap the devfn of the first enabled device |
| 147 | * in devicetree and function 0 resides a pci device |
| 148 | * so that it won't confuse coreboot. |
| 149 | */ |
| 150 | static void pcie_update_device_tree(unsigned int devfn0, int num_funcs) |
| 151 | { |
| 152 | device_t func0; |
| 153 | unsigned int devfn; |
| 154 | int i; |
| 155 | unsigned int inc = PCI_DEVFN(0, 1); |
| 156 | |
| 157 | func0 = dev_find_slot(0, devfn0); |
| 158 | if (func0 == NULL) |
| 159 | return; |
| 160 | |
| 161 | /* No more functions if function 0 is disabled. */ |
| 162 | if (pci_read_config32(func0, PCI_VENDOR_ID) == 0xffffffff) |
| 163 | return; |
| 164 | |
| 165 | devfn = devfn0 + inc; |
| 166 | |
| 167 | /* |
| 168 | * Increase funtion by 1. |
| 169 | * Then find first enabled device to replace func0 |
| 170 | * as that port was move to func0. |
| 171 | */ |
| 172 | for (i = 1; i < num_funcs; i++, devfn += inc) { |
| 173 | device_t dev = dev_find_slot(0, devfn); |
| 174 | if (dev == NULL) |
| 175 | continue; |
| 176 | |
| 177 | if (!dev->enabled) |
| 178 | continue; |
| 179 | /* Found the first enabled device in given dev number */ |
| 180 | func0->path.pci.devfn = dev->path.pci.devfn; |
| 181 | dev->path.pci.devfn = devfn0; |
| 182 | break; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | static void pcie_override_devicetree_after_silicon_init(void) |
| 187 | { |
| 188 | pcie_update_device_tree(PCIEA0_DEVFN, 4); |
| 189 | pcie_update_device_tree(PCIEB0_DEVFN, 2); |
| 190 | } |
| 191 | |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 192 | static void soc_init(void *data) |
| 193 | { |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 194 | struct global_nvs_t *gnvs; |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 195 | |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 196 | /* Save VBT info and mapping */ |
Abhay Kumar | ec2947f | 2016-07-14 18:43:54 -0700 | [diff] [blame] | 197 | vbt = vbt_get(&vbt_rdev); |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 198 | |
Aaron Durbin | 81d1e09 | 2016-07-13 01:49:10 -0500 | [diff] [blame] | 199 | /* Snapshot the current GPIO IRQ polarities. FSP is setting a |
| 200 | * default policy that doesn't honor boards' requirements. */ |
| 201 | itss_snapshot_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END); |
| 202 | |
Lee Leahy | 9671faa | 2016-07-24 18:18:52 -0700 | [diff] [blame^] | 203 | fsp_silicon_init(); |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 204 | |
Aaron Durbin | 81d1e09 | 2016-07-13 01:49:10 -0500 | [diff] [blame] | 205 | /* Restore GPIO IRQ polarities back to previous settings. */ |
| 206 | itss_restore_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END); |
| 207 | |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 208 | /* override 'enabled' setting in device tree if needed */ |
| 209 | pcie_override_devicetree_after_silicon_init(); |
| 210 | |
Aaron Durbin | fadfc2e | 2016-07-01 16:36:03 -0500 | [diff] [blame] | 211 | /* |
| 212 | * Keep the P2SB device visible so it and the other devices are |
| 213 | * visible in coreboot for driver support and PCI resource allocation. |
| 214 | * There is a UPD setting for this, but it's more consistent to use |
| 215 | * hide and unhide symmetrically. |
| 216 | */ |
| 217 | p2sb_unhide(); |
| 218 | |
Lance Zhao | 1bd0c0c | 2016-04-19 18:04:21 -0700 | [diff] [blame] | 219 | /* Allocate ACPI NVS in CBMEM */ |
| 220 | gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS, sizeof(*gnvs)); |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 221 | } |
| 222 | |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 223 | static void soc_final(void *data) |
| 224 | { |
| 225 | if (vbt) |
| 226 | rdev_munmap(&vbt_rdev, vbt); |
Andrey Petrov | 3dbea29 | 2016-06-14 22:20:28 -0700 | [diff] [blame] | 227 | |
| 228 | /* Disable global reset, just in case */ |
| 229 | global_reset_enable(0); |
| 230 | /* Make sure payload/OS can't trigger global reset */ |
| 231 | global_reset_lock(); |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 234 | static void disable_dev(struct device *dev, struct FSP_S_CONFIG *silconfig) { |
| 235 | |
| 236 | switch (dev->path.pci.devfn) { |
| 237 | case ISH_DEVFN: |
| 238 | silconfig->IshEnable = 0; |
| 239 | break; |
| 240 | case SATA_DEVFN: |
| 241 | silconfig->EnableSata = 0; |
| 242 | break; |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 243 | case PCIEB0_DEVFN: |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 244 | silconfig->PcieRootPortEn[0] = 0; |
| 245 | silconfig->PcieRpHotPlug[0] = 0; |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 246 | break; |
| 247 | case PCIEB1_DEVFN: |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 248 | silconfig->PcieRootPortEn[1] = 0; |
| 249 | silconfig->PcieRpHotPlug[1] = 0; |
| 250 | break; |
| 251 | case PCIEA0_DEVFN: |
| 252 | silconfig->PcieRootPortEn[2] = 0; |
| 253 | silconfig->PcieRpHotPlug[2] = 0; |
| 254 | break; |
| 255 | case PCIEA1_DEVFN: |
| 256 | silconfig->PcieRootPortEn[3] = 0; |
| 257 | silconfig->PcieRpHotPlug[3] = 0; |
| 258 | break; |
| 259 | case PCIEA2_DEVFN: |
| 260 | silconfig->PcieRootPortEn[4] = 0; |
| 261 | silconfig->PcieRpHotPlug[4] = 0; |
| 262 | break; |
| 263 | case PCIEA3_DEVFN: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 264 | silconfig->PcieRootPortEn[5] = 0; |
Kane Chen | d779605 | 2016-07-11 12:17:13 +0800 | [diff] [blame] | 265 | silconfig->PcieRpHotPlug[5] = 0; |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 266 | break; |
| 267 | case XHCI_DEVFN: |
| 268 | silconfig->Usb30Mode = 0; |
| 269 | break; |
| 270 | case XDCI_DEVFN: |
| 271 | silconfig->UsbOtg = 0; |
| 272 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 273 | case LPSS_DEVFN_I2C0: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 274 | silconfig->I2c0Enable = 0; |
| 275 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 276 | case LPSS_DEVFN_I2C1: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 277 | silconfig->I2c1Enable = 0; |
| 278 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 279 | case LPSS_DEVFN_I2C2: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 280 | silconfig->I2c2Enable = 0; |
| 281 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 282 | case LPSS_DEVFN_I2C3: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 283 | silconfig->I2c3Enable = 0; |
| 284 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 285 | case LPSS_DEVFN_I2C4: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 286 | silconfig->I2c4Enable = 0; |
| 287 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 288 | case LPSS_DEVFN_I2C5: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 289 | silconfig->I2c5Enable = 0; |
| 290 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 291 | case LPSS_DEVFN_I2C6: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 292 | silconfig->I2c6Enable = 0; |
| 293 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 294 | case LPSS_DEVFN_I2C7: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 295 | silconfig->I2c7Enable = 0; |
| 296 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 297 | case LPSS_DEVFN_UART0: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 298 | silconfig->Hsuart0Enable = 0; |
| 299 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 300 | case LPSS_DEVFN_UART1: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 301 | silconfig->Hsuart1Enable = 0; |
| 302 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 303 | case LPSS_DEVFN_UART2: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 304 | silconfig->Hsuart2Enable = 0; |
| 305 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 306 | case LPSS_DEVFN_UART3: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 307 | silconfig->Hsuart3Enable = 0; |
| 308 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 309 | case LPSS_DEVFN_SPI0: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 310 | silconfig->Spi0Enable = 0; |
| 311 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 312 | case LPSS_DEVFN_SPI1: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 313 | silconfig->Spi1Enable = 0; |
| 314 | break; |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 315 | case LPSS_DEVFN_SPI2: |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 316 | silconfig->Spi2Enable = 0; |
| 317 | break; |
| 318 | case SDCARD_DEVFN: |
| 319 | silconfig->SdcardEnabled = 0; |
| 320 | break; |
| 321 | case EMMC_DEVFN: |
| 322 | silconfig->eMMCEnabled = 0; |
| 323 | break; |
| 324 | case SDIO_DEVFN: |
| 325 | silconfig->SdioEnabled = 0; |
| 326 | break; |
| 327 | case SMBUS_DEVFN: |
| 328 | silconfig->SmbusEnable = 0; |
| 329 | break; |
| 330 | default: |
| 331 | printk(BIOS_WARNING, "PCI:%02x.%01x: Could not disable the device\n", |
| 332 | PCI_SLOT(dev->path.pci.devfn), |
| 333 | PCI_FUNC(dev->path.pci.devfn)); |
| 334 | break; |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | static void parse_devicetree(struct FSP_S_CONFIG *silconfig) |
| 339 | { |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 340 | struct device *dev = NB_DEV_ROOT; |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 341 | |
| 342 | if (!dev) { |
| 343 | printk(BIOS_ERR, "Could not find root device\n"); |
| 344 | return; |
| 345 | } |
| 346 | /* Only disable bus 0 devices. */ |
| 347 | for (dev = dev->bus->children; dev; dev = dev->sibling) { |
| 348 | if (!dev->enabled) |
| 349 | disable_dev(dev, silconfig); |
| 350 | } |
| 351 | } |
| 352 | |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 353 | void platform_fsp_silicon_init_params_cb(struct FSPS_UPD *silupd) |
| 354 | { |
| 355 | struct FSP_S_CONFIG *silconfig = &silupd->FspsConfig; |
| 356 | static struct soc_intel_apollolake_config *cfg; |
| 357 | |
| 358 | /* Load VBT before devicetree-specific config. */ |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 359 | silconfig->GraphicsConfigPtr = (uintptr_t)vbt; |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 360 | |
Andrey Petrov | 78461a9 | 2016-06-28 12:14:33 -0700 | [diff] [blame] | 361 | struct device *dev = NB_DEV_ROOT; |
| 362 | |
Patrick Georgi | 831d65d | 2016-04-14 11:53:48 +0200 | [diff] [blame] | 363 | if (!dev || !dev->chip_info) { |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 364 | printk(BIOS_ERR, "BUG! Could not find SOC devicetree config\n"); |
| 365 | return; |
| 366 | } |
| 367 | |
| 368 | cfg = dev->chip_info; |
| 369 | |
Jagadish Krishnamoorthy | b023e5e | 2016-06-22 18:32:17 -0700 | [diff] [blame] | 370 | /* Parse device tree and disable unused device*/ |
| 371 | parse_devicetree(silconfig); |
| 372 | |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 373 | silconfig->PcieRpClkReqNumber[0] = cfg->pcie_rp0_clkreq_pin; |
| 374 | silconfig->PcieRpClkReqNumber[1] = cfg->pcie_rp1_clkreq_pin; |
| 375 | silconfig->PcieRpClkReqNumber[2] = cfg->pcie_rp2_clkreq_pin; |
| 376 | silconfig->PcieRpClkReqNumber[3] = cfg->pcie_rp3_clkreq_pin; |
| 377 | silconfig->PcieRpClkReqNumber[4] = cfg->pcie_rp4_clkreq_pin; |
| 378 | silconfig->PcieRpClkReqNumber[5] = cfg->pcie_rp5_clkreq_pin; |
Andrey Petrov | e07e13d | 2016-03-18 14:43:00 -0700 | [diff] [blame] | 379 | |
Zhao, Lijian | 1b8ee0b | 2016-05-17 19:01:34 -0700 | [diff] [blame] | 380 | if (cfg->emmc_tx_cmd_cntl != 0) |
| 381 | silconfig->EmmcTxCmdCntl = cfg->emmc_tx_cmd_cntl; |
| 382 | if (cfg->emmc_tx_data_cntl1 != 0) |
| 383 | silconfig->EmmcTxDataCntl1 = cfg->emmc_tx_data_cntl1; |
| 384 | if (cfg->emmc_tx_data_cntl2 != 0) |
| 385 | silconfig->EmmcTxDataCntl2 = cfg->emmc_tx_data_cntl2; |
| 386 | if (cfg->emmc_rx_cmd_data_cntl1 != 0) |
| 387 | silconfig->EmmcRxCmdDataCntl1 = cfg->emmc_rx_cmd_data_cntl1; |
| 388 | if (cfg->emmc_rx_strobe_cntl != 0) |
| 389 | silconfig->EmmcRxStrobeCntl = cfg->emmc_rx_strobe_cntl; |
| 390 | if (cfg->emmc_rx_cmd_data_cntl2 != 0) |
| 391 | silconfig->EmmcRxCmdDataCntl2 = cfg->emmc_rx_cmd_data_cntl2; |
| 392 | |
Saurabh Satija | e46dbcc | 2016-05-03 15:15:31 -0700 | [diff] [blame] | 393 | silconfig->LPSS_S0ixEnable = cfg->lpss_s0ix_enable; |
| 394 | |
Bora Guvendik | 60cc75d | 2016-07-25 14:44:51 -0700 | [diff] [blame] | 395 | /* Disable monitor mwait since it is broken due to a hardware bug without a fix */ |
| 396 | silconfig->MonitorMwaitEnable = 0; |
| 397 | |
Furquan Shaikh | cad9b63 | 2016-06-20 16:08:42 -0700 | [diff] [blame] | 398 | /* Disable setting of EISS bit in FSP. */ |
| 399 | silconfig->SpiEiss = 0; |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | struct chip_operations soc_intel_apollolake_ops = { |
| 403 | CHIP_NAME("Intel Apollolake SOC") |
| 404 | .enable_dev = &enable_dev, |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 405 | .init = &soc_init, |
| 406 | .final = &soc_final |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 407 | }; |
| 408 | |
| 409 | static void fsp_notify_dummy(void *arg) |
| 410 | { |
| 411 | |
| 412 | enum fsp_notify_phase ph = (enum fsp_notify_phase) arg; |
| 413 | |
Lee Leahy | 9671faa | 2016-07-24 18:18:52 -0700 | [diff] [blame^] | 414 | fsp_notify(ph); |
| 415 | |
Hannah Williams | 5d9cc78 | 2016-04-29 14:48:20 -0700 | [diff] [blame] | 416 | /* Call END_OF_FIRMWARE Notify after READY_TO_BOOT Notify */ |
Aaron Durbin | fadfc2e | 2016-07-01 16:36:03 -0500 | [diff] [blame] | 417 | if (ph == READY_TO_BOOT) { |
Hannah Williams | 5d9cc78 | 2016-04-29 14:48:20 -0700 | [diff] [blame] | 418 | fsp_notify_dummy((void *)END_OF_FIRMWARE); |
Aaron Durbin | fadfc2e | 2016-07-01 16:36:03 -0500 | [diff] [blame] | 419 | /* Hide the P2SB device to align with previous behavior. */ |
| 420 | p2sb_hide(); |
| 421 | } |
Andrey Petrov | 70efecd | 2016-03-04 21:41:13 -0800 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | BOOT_STATE_INIT_ENTRY(BS_DEV_RESOURCES, BS_ON_EXIT, fsp_notify_dummy, |
| 425 | (void *) AFTER_PCI_ENUM); |
| 426 | BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, fsp_notify_dummy, |
| 427 | (void *) READY_TO_BOOT); |
| 428 | BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, fsp_notify_dummy, |
| 429 | (void *) READY_TO_BOOT); |
Furquan Shaikh | 6ac226d | 2016-06-15 17:13:20 -0700 | [diff] [blame] | 430 | |
| 431 | /* |
| 432 | * spi_init() needs to run unconditionally on every boot (including resume) to |
| 433 | * allow write protect to be disabled for eventlog and nvram updates. This needs |
| 434 | * to be done as early as possible in ramstage. Thus, add a callback for entry |
| 435 | * into BS_PRE_DEVICE. |
| 436 | */ |
| 437 | static void spi_init_cb(void *unused) |
| 438 | { |
| 439 | spi_init(); |
| 440 | } |
| 441 | |
| 442 | BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, spi_init_cb, NULL); |