blob: a2bea45bf940a5df1811ce6dd56be53932c5322b [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[] = {
Shelley Chen4e9bb332021-10-20 15:43:45 -070023 { PCIEXBAR, CONFIG_ECAM_MMCONF_BASE_ADDRESS, CONFIG_ECAM_MMCONF_LENGTH,
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -070024 "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" },
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -070030 };
31
32 sa_add_fixed_mmio_resources(dev, index, soc_fixed_resources,
33 ARRAY_SIZE(soc_fixed_resources));
John Zhaodb3f0e32019-03-15 16:54:27 -070034
35 /* Add Vt-d resources if VT-d is enabled. */
36 if ((pci_read_config32(dev, CAPID0_A) & VTD_DISABLE))
37 return;
38
John Zhao1159a162019-04-22 10:45:51 -070039 sa_add_fixed_mmio_resources(dev, index, soc_vtd_resources,
John Zhaodb3f0e32019-03-15 16:54:27 -070040 ARRAY_SIZE(soc_vtd_resources));
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -070041}
42
43/*
44 * SoC implementation
45 *
46 * Perform System Agent Initialization during Ramstage phase.
47 */
48void soc_systemagent_init(struct device *dev)
49{
Sumeet R Pawnikar309ccf72020-05-09 16:37:30 +053050 struct soc_power_limits_config *soc_config;
51 config_t *config;
52
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -070053 /* Enable Power Aware Interrupt Routing */
54 enable_power_aware_intr();
55
56 /* Enable BIOS Reset CPL */
57 enable_bios_reset_cpl();
Sumeet Pawnikarc896e92e2019-01-08 19:52:54 +053058
59 /* Configure turbo power limits 1ms after reset complete bit */
60 mdelay(1);
Sumeet R Pawnikar309ccf72020-05-09 16:37:30 +053061 config = config_of_soc();
62 soc_config = &config->power_limits_config;
63 set_power_limits(MOBILE_SKU_PL1_TIME_SEC, soc_config);
Lijian Zhaoaa3d78d2017-08-08 11:32:35 -070064}
Patrick Rudolphbf72dcb2020-05-12 16:04:47 +020065
66uint32_t soc_systemagent_max_chan_capacity_mib(u8 capid0_a_ddrsz)
67{
68 switch (capid0_a_ddrsz) {
69 case 1:
70 return 8192;
71 case 2:
72 return 4096;
73 case 3:
74 return 2048;
75 default:
76 return 32768;
77 }
78}