| 1 |
|
| 2 |
|
| 3 |
#include <chip.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <device/device.h> |
| 6 |
#include <delay.h> |
| 7 |
#include <device/pci.h> |
| 8 |
#include <device/pci_ops.h> |
| 9 |
#include <intelblocks/systemagent.h> |
| 10 |
#include <intelblocks/power_limit.h> |
| 11 |
#include <soc/iomap.h> |
| 12 |
#include <soc/soc_chip.h> |
| 13 |
#include <soc/systemagent.h> |
| 14 |
#include <static.h> |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
void soc_add_fixed_mmio_resources(struct device *dev, int *index) |
| 23 |
{ |
| 24 |
static const struct sa_mmio_descriptor soc_fixed_resources[] = { |
| 25 |
{ PCIEXBAR, CONFIG_ECAM_MMCONF_BASE_ADDRESS, CONFIG_ECAM_MMCONF_LENGTH, |
| 26 |
"PCIEXBAR" }, |
| 27 |
{ MCHBAR, MCH_BASE_ADDRESS, MCH_BASE_SIZE, "MCHBAR" }, |
| 28 |
{ DMIBAR, DMI_BASE_ADDRESS, DMI_BASE_SIZE, "DMIBAR" }, |
| 29 |
{ EPBAR, EP_BASE_ADDRESS, EP_BASE_SIZE, "EPBAR" }, |
| 30 |
{ REGBAR, REG_BASE_ADDRESS, REG_BASE_SIZE, "REGBAR" }, |
| 31 |
{ EDRAMBAR, EDRAM_BASE_ADDRESS, EDRAM_BASE_SIZE, "EDRAMBAR" }, |
| 32 |
}; |
| 33 |
|
| 34 |
sa_add_fixed_mmio_resources(dev, index, soc_fixed_resources, |
| 35 |
ARRAY_SIZE(soc_fixed_resources)); |
| 36 |
|
| 37 |
|
| 38 |
if ((pci_read_config32(dev, CAPID0_A) & VTD_DISABLE)) |
| 39 |
return; |
| 40 |
|
| 41 |
sa_add_fixed_mmio_resources(dev, index, soc_vtd_resources, |
| 42 |
ARRAY_SIZE(soc_vtd_resources)); |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
void soc_systemagent_init(struct device *dev) |
| 51 |
{ |
| 52 |
struct soc_power_limits_config *soc_config; |
| 53 |
config_t *config; |
| 54 |
uint16_t sa_pci_id; |
| 55 |
uint8_t tdp; |
| 56 |
size_t i = 0; |
| 57 |
|
| 58 |
|
| 59 |
enable_power_aware_intr(); |
| 60 |
|
| 61 |
|
| 62 |
enable_bios_reset_cpl(); |
| 63 |
|
| 64 |
mdelay(1); |
| 65 |
config = config_of_soc(); |
| 66 |
|
| 67 |
|
| 68 |
sa_pci_id = dev ? pci_read_config16(dev, PCI_DEVICE_ID) : 0xFFFF; |
| 69 |
|
| 70 |
if (sa_pci_id != 0xFFFF) { |
| 71 |
tdp = get_cpu_tdp(); |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
for (i = 0; i < ARRAY_SIZE(cpuid_to_jsl); i++) { |
| 76 |
if (sa_pci_id == cpuid_to_jsl[i].pci_did && |
| 77 |
tdp == cpuid_to_jsl[i].cpu_tdp) { |
| 78 |
soc_config = &config->power_limits_config[cpuid_to_jsl[i].limits]; |
| 79 |
set_power_limits(MOBILE_SKU_PL1_TIME_SEC, soc_config); |
| 80 |
break; |
| 81 |
} |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
if (i == ARRAY_SIZE(cpuid_to_jsl) || sa_pci_id == 0xFFFF) { |
| 86 |
printk(BIOS_ERR, "unknown SA ID: 0x%4x, can't find its TDP." |
| 87 |
" Skipped power limits configuration.\n", |
| 88 |
sa_pci_id); |
| 89 |
return; |
| 90 |
} |
| 91 |
} |