blob: c225651649a239e7eb87d1790d0e062599d27889 [file] [log] [blame]
Angel Ponsf5627e82020-04-05 15:46:52 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -07002
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -07003#include <device/device.h>
Sumeet Pawnikarc896e92e2019-01-08 19:52:54 +05304#include <delay.h>
Subrata Banik0baad612017-11-23 13:58:34 +05305#include <device/pci.h>
John Zhaodb3f0e32019-03-15 16:54:27 -07006#include <device/pci_ops.h>
Sumeet R Pawnikar309ccf72020-05-09 16:37:30 +05307#include <intelblocks/power_limit.h>
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -07008#include <intelblocks/systemagent.h>
Sumeet Pawnikarc896e92e2019-01-08 19:52:54 +05309#include <soc/cpu.h>
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -070010#include <soc/iomap.h>
11#include <soc/systemagent.h>
John Zhaodb3f0e32019-03-15 16:54:27 -070012#include "chip.h"
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -070013
14/*
15 * SoC implementation
16 *
Jonathan Neuschäfer5268b762018-02-12 12:24:25 +010017 * Add all known fixed memory ranges for Host Controller/Memory
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -070018 * controller.
19 */
20void soc_add_fixed_mmio_resources(struct device *dev, int *index)
21{
22 static const struct sa_mmio_descriptor soc_fixed_resources[] = {
23 { PCIEXBAR, CONFIG_MMCONF_BASE_ADDRESS, CONFIG_SA_PCIEX_LENGTH,
24 "PCIEXBAR" },
25 { MCHBAR, MCH_BASE_ADDRESS, MCH_BASE_SIZE, "MCHBAR" },
26 { DMIBAR, DMI_BASE_ADDRESS, DMI_BASE_SIZE, "DMIBAR" },
27 { EPBAR, EP_BASE_ADDRESS, EP_BASE_SIZE, "EPBAR" },
28 { REGBAR, REG_BASE_ADDRESS, REG_BASE_SIZE, "REGBAR" },
29 { EDRAMBAR, EDRAM_BASE_ADDRESS, EDRAM_BASE_SIZE, "EDRAMBAR" },
Subrata Banik0baad612017-11-23 13:58:34 +053030 /*
31 * PMC pci device gets hidden from PCI bus due to Silicon
32 * policy hence binding PMCBAR aka PWRMBASE (offset 0x10) with
33 * SA resources to ensure that PMCBAR falls under PCI reserved
34 * memory range.
35 *
36 * Note: Don't add any more resource with same offset 0x10
37 * under this device space.
38 */
39 { PCI_BASE_ADDRESS_0, PCH_PWRM_BASE_ADDRESS, PCH_PWRM_BASE_SIZE,
40 "PMCBAR" },
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -070041 };
42
43 sa_add_fixed_mmio_resources(dev, index, soc_fixed_resources,
44 ARRAY_SIZE(soc_fixed_resources));
John Zhaodb3f0e32019-03-15 16:54:27 -070045
46 /* Add Vt-d resources if VT-d is enabled. */
47 if ((pci_read_config32(dev, CAPID0_A) & VTD_DISABLE))
48 return;
49
John Zhao1159a162019-04-22 10:45:51 -070050 sa_add_fixed_mmio_resources(dev, index, soc_vtd_resources,
John Zhaodb3f0e32019-03-15 16:54:27 -070051 ARRAY_SIZE(soc_vtd_resources));
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -070052}
53
54/*
55 * SoC implementation
56 *
57 * Perform System Agent Initialization during Ramstage phase.
58 */
59void soc_systemagent_init(struct device *dev)
60{
Sumeet R Pawnikar309ccf72020-05-09 16:37:30 +053061 struct soc_power_limits_config *soc_config;
62 config_t *config;
63
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -070064 /* Enable Power Aware Interrupt Routing */
65 enable_power_aware_intr();
66
67 /* Enable BIOS Reset CPL */
68 enable_bios_reset_cpl();
Sumeet Pawnikarc896e92e2019-01-08 19:52:54 +053069
70 /* Configure turbo power limits 1ms after reset complete bit */
71 mdelay(1);
Sumeet R Pawnikar309ccf72020-05-09 16:37:30 +053072 config = config_of_soc();
73 soc_config = &config->power_limits_config;
74 set_power_limits(MOBILE_SKU_PL1_TIME_SEC, soc_config);
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -070075}