soc/intel/xeon_sp: Drop unused code
[coreboot2.git] / src / soc / intel / xeon_sp / cpx / soc_acpi.c
blob58e67fcbd6e4e253aed437e6b0ef66091460dfe2
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpigen.h>
4 #include <arch/smp/mpspec.h>
5 #include <arch/vga.h>
6 #include <cpu/intel/turbo.h>
7 #include <device/mmio.h>
8 #include <device/pci.h>
9 #include <intelblocks/acpi.h>
10 #include <intelblocks/cpulib.h>
11 #include <soc/acpi.h>
12 #include <soc/iomap.h>
13 #include <soc/msr.h>
14 #include <soc/pci_devs.h>
15 #include <soc/pm.h>
16 #include <soc/soc_util.h>
17 #include <soc/util.h>
19 int soc_madt_sci_irq_polarity(int sci)
21 if (sci >= 20)
22 return MP_IRQ_POLARITY_LOW;
23 else
24 return MP_IRQ_POLARITY_HIGH;
27 uint32_t soc_read_sci_irq_select(void)
29 struct device *dev = PCH_DEV_PMC;
31 if (!dev)
32 return 0;
34 return pci_read_config32(dev, PMC_ACPI_CNT);
37 void soc_fill_fadt(acpi_fadt_t *fadt)
39 /* Clear flags set by common/block/acpi/acpi.c acpi_fill_fadt() */
40 fadt->flags &= ~(ACPI_FADT_SEALED_CASE | ACPI_FADT_S4_RTC_WAKE);
43 /* TODO: See if we can use the common generate_p_state_entries */
44 void soc_power_states_generation(int core, int cores_per_package)
46 int ratio_min, ratio_max, ratio_turbo, ratio_step;
47 int coord_type, power_max, power_unit, num_entries;
48 int ratio, power, clock, clock_max;
49 msr_t msr;
51 /* Determine P-state coordination type from MISC_PWR_MGMT[0] */
52 msr = rdmsr(MSR_MISC_PWR_MGMT);
53 if (msr.lo & MISC_PWR_MGMT_EIST_HW_DIS)
54 coord_type = SW_ANY;
55 else
56 coord_type = HW_ALL;
58 /* Get bus ratio limits and calculate clock speeds */
59 msr = rdmsr(MSR_PLATFORM_INFO);
60 ratio_min = (msr.hi >> (40-32)) & 0xff; /* Max Efficiency Ratio */
62 /* Determine if this CPU has configurable TDP */
63 if (cpu_config_tdp_levels()) {
64 /* Set max ratio to nominal TDP ratio */
65 msr = rdmsr(MSR_CONFIG_TDP_NOMINAL);
66 ratio_max = msr.lo & 0xff;
67 } else {
68 /* Max Non-Turbo Ratio */
69 ratio_max = (msr.lo >> 8) & 0xff;
71 clock_max = ratio_max * CONFIG_CPU_BCLK_MHZ;
73 /* Calculate CPU TDP in mW */
74 msr = rdmsr(MSR_PKG_POWER_SKU_UNIT);
75 power_unit = 2 << ((msr.lo & 0xf) - 1);
76 msr = rdmsr(MSR_PKG_POWER_SKU);
77 power_max = ((msr.lo & 0x7fff) / power_unit) * 1000;
79 /* Write _PCT indicating use of FFixedHW */
80 acpigen_write_empty_PCT();
82 /* Write _PPC with no limit on supported P-state */
83 acpigen_write_PPC_NVS();
85 /* Write PSD indicating configured coordination type */
86 acpigen_write_PSD_package(core, 1, coord_type);
88 /* Add P-state entries in _PSS table */
89 acpigen_write_name("_PSS");
91 /* Determine ratio points */
92 ratio_step = PSS_RATIO_STEP;
93 num_entries = ((ratio_max - ratio_min) / ratio_step) + 1;
94 if (num_entries > PSS_MAX_ENTRIES) {
95 ratio_step += 1;
96 num_entries = ((ratio_max - ratio_min) / ratio_step) + 1;
99 /* P[T] is Turbo state if enabled */
100 if (get_turbo_state() == TURBO_ENABLED) {
101 /* _PSS package count including Turbo */
102 acpigen_write_package(num_entries + 2);
104 msr = rdmsr(MSR_TURBO_RATIO_LIMIT);
105 ratio_turbo = msr.lo & 0xff;
107 /* Add entry for Turbo ratio */
108 acpigen_write_PSS_package(
109 clock_max + 1, /* MHz */
110 power_max, /* mW */
111 PSS_LATENCY_TRANSITION, /* lat1 */
112 PSS_LATENCY_BUSMASTER, /* lat2 */
113 ratio_turbo << 8, /* control */
114 ratio_turbo << 8); /* status */
115 } else {
116 /* _PSS package count without Turbo */
117 acpigen_write_package(num_entries + 1);
120 /* First regular entry is max non-turbo ratio */
121 acpigen_write_PSS_package(
122 clock_max, /* MHz */
123 power_max, /* mW */
124 PSS_LATENCY_TRANSITION, /* lat1 */
125 PSS_LATENCY_BUSMASTER, /* lat2 */
126 ratio_max << 8, /* control */
127 ratio_max << 8); /* status */
129 /* Generate the remaining entries */
130 for (ratio = ratio_min + ((num_entries - 1) * ratio_step);
131 ratio >= ratio_min; ratio -= ratio_step) {
132 /* Calculate power at this ratio */
133 power = common_calculate_power_ratio(power_max, ratio_max, ratio);
134 clock = ratio * CONFIG_CPU_BCLK_MHZ;
135 //clock = 1;
136 acpigen_write_PSS_package(
137 clock, /* MHz */
138 power, /* mW */
139 PSS_LATENCY_TRANSITION, /* lat1 */
140 PSS_LATENCY_BUSMASTER, /* lat2 */
141 ratio << 8, /* control */
142 ratio << 8); /* status */
145 /* Fix package length */
146 acpigen_pop_len();