Lijian Zhao | aa3d78d | 2017-08-08 11:32:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2009 coresystems GmbH |
| 5 | * Copyright (C) 2014 Google Inc. |
| 6 | * Copyright (C) 2015-2017 Intel Corporation. |
| 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; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | */ |
| 17 | |
Lijian Zhao | aa3d78d | 2017-08-08 11:32:35 -0700 | [diff] [blame] | 18 | #include <device/device.h> |
Sumeet Pawnikar | c896e92e | 2019-01-08 19:52:54 +0530 | [diff] [blame] | 19 | #include <delay.h> |
Subrata Banik | 0baad61 | 2017-11-23 13:58:34 +0530 | [diff] [blame] | 20 | #include <device/pci.h> |
John Zhao | db3f0e3 | 2019-03-15 16:54:27 -0700 | [diff] [blame^] | 21 | #include <device/pci_ops.h> |
Lijian Zhao | aa3d78d | 2017-08-08 11:32:35 -0700 | [diff] [blame] | 22 | #include <intelblocks/systemagent.h> |
Sumeet Pawnikar | c896e92e | 2019-01-08 19:52:54 +0530 | [diff] [blame] | 23 | #include <soc/cpu.h> |
Lijian Zhao | aa3d78d | 2017-08-08 11:32:35 -0700 | [diff] [blame] | 24 | #include <soc/iomap.h> |
| 25 | #include <soc/systemagent.h> |
John Zhao | db3f0e3 | 2019-03-15 16:54:27 -0700 | [diff] [blame^] | 26 | #include "chip.h" |
Lijian Zhao | aa3d78d | 2017-08-08 11:32:35 -0700 | [diff] [blame] | 27 | |
| 28 | /* |
| 29 | * SoC implementation |
| 30 | * |
Jonathan Neuschäfer | 5268b76 | 2018-02-12 12:24:25 +0100 | [diff] [blame] | 31 | * Add all known fixed memory ranges for Host Controller/Memory |
Lijian Zhao | aa3d78d | 2017-08-08 11:32:35 -0700 | [diff] [blame] | 32 | * controller. |
| 33 | */ |
| 34 | void soc_add_fixed_mmio_resources(struct device *dev, int *index) |
| 35 | { |
John Zhao | db3f0e3 | 2019-03-15 16:54:27 -0700 | [diff] [blame^] | 36 | const struct soc_intel_cannonlake_config *const config = dev->chip_info; |
| 37 | |
Lijian Zhao | aa3d78d | 2017-08-08 11:32:35 -0700 | [diff] [blame] | 38 | static const struct sa_mmio_descriptor soc_fixed_resources[] = { |
| 39 | { PCIEXBAR, CONFIG_MMCONF_BASE_ADDRESS, CONFIG_SA_PCIEX_LENGTH, |
| 40 | "PCIEXBAR" }, |
| 41 | { MCHBAR, MCH_BASE_ADDRESS, MCH_BASE_SIZE, "MCHBAR" }, |
| 42 | { DMIBAR, DMI_BASE_ADDRESS, DMI_BASE_SIZE, "DMIBAR" }, |
| 43 | { EPBAR, EP_BASE_ADDRESS, EP_BASE_SIZE, "EPBAR" }, |
| 44 | { REGBAR, REG_BASE_ADDRESS, REG_BASE_SIZE, "REGBAR" }, |
| 45 | { EDRAMBAR, EDRAM_BASE_ADDRESS, EDRAM_BASE_SIZE, "EDRAMBAR" }, |
Subrata Banik | 0baad61 | 2017-11-23 13:58:34 +0530 | [diff] [blame] | 46 | /* |
| 47 | * PMC pci device gets hidden from PCI bus due to Silicon |
| 48 | * policy hence binding PMCBAR aka PWRMBASE (offset 0x10) with |
| 49 | * SA resources to ensure that PMCBAR falls under PCI reserved |
| 50 | * memory range. |
| 51 | * |
| 52 | * Note: Don't add any more resource with same offset 0x10 |
| 53 | * under this device space. |
| 54 | */ |
| 55 | { PCI_BASE_ADDRESS_0, PCH_PWRM_BASE_ADDRESS, PCH_PWRM_BASE_SIZE, |
| 56 | "PMCBAR" }, |
Lijian Zhao | aa3d78d | 2017-08-08 11:32:35 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | sa_add_fixed_mmio_resources(dev, index, soc_fixed_resources, |
| 60 | ARRAY_SIZE(soc_fixed_resources)); |
John Zhao | db3f0e3 | 2019-03-15 16:54:27 -0700 | [diff] [blame^] | 61 | |
| 62 | /* Add Vt-d resources if VT-d is enabled. */ |
| 63 | if ((pci_read_config32(dev, CAPID0_A) & VTD_DISABLE)) |
| 64 | return; |
| 65 | |
| 66 | if (!(config && config->VtdDisable)) { |
| 67 | sa_add_fixed_mmio_resources(dev, index, soc_vtd_resources, |
| 68 | ARRAY_SIZE(soc_vtd_resources)); |
| 69 | } |
Lijian Zhao | aa3d78d | 2017-08-08 11:32:35 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | /* |
| 73 | * SoC implementation |
| 74 | * |
| 75 | * Perform System Agent Initialization during Ramstage phase. |
| 76 | */ |
| 77 | void soc_systemagent_init(struct device *dev) |
| 78 | { |
| 79 | /* Enable Power Aware Interrupt Routing */ |
| 80 | enable_power_aware_intr(); |
| 81 | |
| 82 | /* Enable BIOS Reset CPL */ |
| 83 | enable_bios_reset_cpl(); |
Sumeet Pawnikar | c896e92e | 2019-01-08 19:52:54 +0530 | [diff] [blame] | 84 | |
| 85 | /* Configure turbo power limits 1ms after reset complete bit */ |
| 86 | mdelay(1); |
| 87 | set_power_limits(28); |
Lijian Zhao | aa3d78d | 2017-08-08 11:32:35 -0700 | [diff] [blame] | 88 | } |