| 1 |
|
| 2 |
|
| 3 |
#include <fsp/api.h> |
| 4 |
#include <intelblocks/aspm.h> |
| 5 |
#include <intelblocks/pcie_rp.h> |
| 6 |
#include <option.h> |
| 7 |
#include <soc/soc_chip.h> |
| 8 |
#include <soc/pcie.h> |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
static unsigned int aspm_control_to_upd(enum ASPM_control aspm_control, bool is_cpu_rp) |
| 44 |
{ |
| 45 |
|
| 46 |
if (!CONFIG(PCIEXP_ASPM)) |
| 47 |
return UPD_INDEX(ASPM_DISABLE); |
| 48 |
|
| 49 |
|
| 50 |
if (!aspm_control) |
| 51 |
return is_cpu_rp ? UPD_INDEX(ASPM_L0S_L1) : UPD_INDEX(ASPM_AUTO); |
| 52 |
|
| 53 |
return UPD_INDEX(aspm_control); |
| 54 |
} |
| 55 |
|
| 56 |
static unsigned int l1ss_control_to_upd(enum L1_substates_control l1_substates_control) |
| 57 |
{ |
| 58 |
|
| 59 |
if (!CONFIG(PCIEXP_ASPM)) |
| 60 |
return UPD_INDEX(L1_SS_DISABLED); |
| 61 |
|
| 62 |
|
| 63 |
if (!CONFIG(PCIEXP_L1_SUB_STATE)) |
| 64 |
return UPD_INDEX(L1_SS_DISABLED); |
| 65 |
|
| 66 |
|
| 67 |
if (CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE)) |
| 68 |
return UPD_INDEX(L1_SS_DISABLED); |
| 69 |
|
| 70 |
|
| 71 |
if (!l1_substates_control) |
| 72 |
return UPD_INDEX(L1_SS_L1_2); |
| 73 |
|
| 74 |
return UPD_INDEX(l1_substates_control); |
| 75 |
} |
| 76 |
|
| 77 |
static unsigned int pcie_speed_control_to_upd(enum PCIE_SPEED_control pcie_speed_control) |
| 78 |
{ |
| 79 |
|
| 80 |
if (!pcie_speed_control) |
| 81 |
return UPD_INDEX(SPEED_AUTO); |
| 82 |
|
| 83 |
return UPD_INDEX(pcie_speed_control); |
| 84 |
} |
| 85 |
|
| 86 |
void configure_pch_rp_power_management(FSP_S_CONFIG *s_cfg, |
| 87 |
const struct pcie_rp_config *rp_cfg, |
| 88 |
unsigned int index) |
| 89 |
{ |
| 90 |
s_cfg->PcieRpEnableCpm[index] = |
| 91 |
get_uint_option("pciexp_clk_pm", CONFIG(PCIEXP_CLK_PM)); |
| 92 |
s_cfg->PcieRpAspm[index] = |
| 93 |
aspm_control_to_upd(get_uint_option("pciexp_aspm", rp_cfg->pcie_rp_aspm), false); |
| 94 |
s_cfg->PcieRpL1Substates[index] = |
| 95 |
l1ss_control_to_upd(get_uint_option("pciexp_l1ss", rp_cfg->PcieRpL1Substates)); |
| 96 |
s_cfg->PcieRpPcieSpeed[index] = |
| 97 |
pcie_speed_control_to_upd(get_uint_option("pciexp_speed", rp_cfg->pcie_rp_pcie_speed)); |
| 98 |
} |
| 99 |
|
| 100 |
#if CONFIG(HAS_INTEL_CPU_ROOT_PORTS) |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
void configure_cpu_rp_power_management(FSP_S_CONFIG *s_cfg, |
| 115 |
const struct pcie_rp_config *rp_cfg, |
| 116 |
unsigned int index) |
| 117 |
{ |
| 118 |
bool pciexp_clk_pm = get_uint_option("pciexp_clk_pm", CONFIG(PCIEXP_CLK_PM)); |
| 119 |
s_cfg->CpuPcieRpEnableCpm[index] = pciexp_clk_pm; |
| 120 |
s_cfg->CpuPcieClockGating[index] = pciexp_clk_pm; |
| 121 |
s_cfg->CpuPciePowerGating[index] = pciexp_clk_pm; |
| 122 |
s_cfg->CpuPcieRpAspm[index] = |
| 123 |
aspm_control_to_upd(get_uint_option("pciexp_aspm_cpu", rp_cfg->pcie_rp_aspm), true); |
| 124 |
s_cfg->CpuPcieRpL1Substates[index] = |
| 125 |
l1ss_control_to_upd(get_uint_option("pciexp_l1ss", rp_cfg->PcieRpL1Substates)); |
| 126 |
} |
| 127 |
|
| 128 |
#endif |