Sean Rhodes has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/59707 )
Change subject: mainboard/starlabs/labtop: Change TDP based on AC & DC state ......................................................................
mainboard/starlabs/labtop: Change TDP based on AC & DC state
Signed-off-by: Sean Rhodes sean@starlabs.systems Change-Id: I149e7a5a48b6b4a3e5607c4399681602b04a097f --- M src/mainboard/starlabs/labtop/variants/tgl/Makefile.inc A src/mainboard/starlabs/labtop/variants/tgl/smihandler.c A src/mainboard/starlabs/labtop/variants/tgl/smihandler.h 3 files changed, 113 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/07/59707/1
diff --git a/src/mainboard/starlabs/labtop/variants/tgl/Makefile.inc b/src/mainboard/starlabs/labtop/variants/tgl/Makefile.inc index 2a505c3..7c50b7b7 100644 --- a/src/mainboard/starlabs/labtop/variants/tgl/Makefile.inc +++ b/src/mainboard/starlabs/labtop/variants/tgl/Makefile.inc @@ -7,3 +7,5 @@ ramstage-y += devtree.c ramstage-y += gpio.c ramstage-y += hda_verb.c + +smm-y += smihandler.c diff --git a/src/mainboard/starlabs/labtop/variants/tgl/smihandler.c b/src/mainboard/starlabs/labtop/variants/tgl/smihandler.c new file mode 100644 index 0000000..b6ccb38 --- /dev/null +++ b/src/mainboard/starlabs/labtop/variants/tgl/smihandler.c @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <chip.h> +#include <cpu/x86/smm.h> +#include <option.h> +#include <types.h> + +#include "smihandler.h" + +int mainboard_smi_apmc(u8 data) +{ + uint8_t val; + const uint8_t events[] = { + EC_SMI_AC_AND_DC, + EC_SMI_DC_BELOW_100, + EC_SMI_DC_BELOW_60, + EC_SMI_DC_BELOW_20, + EC_SMI_AC_ONLY, + } + + /* + * Update PL1 & PL2 based on AC & DC states + * and CMOS settings + */ + switch (get_uint_option("power_profile", 0)) { + case 1: + /* Use balanced_tdp */ + soc_conf_2core->tdp_pl1_override = 15; + soc_conf_4core->tdp_pl1_override = 15; + soc_conf_2core->tdp_pl2_override = 25; + soc_conf_4core->tdp_pl2_override = 25; + break; + case 2: + /* Use performance_tdp */ + soc_conf_2core->tdp_pl1_override = 28; + soc_conf_4core->tdp_pl1_override = 28; + soc_conf_2core->tdp_pl2_override = 40; + soc_conf_4core->tdp_pl2_override = 40; + break; + default: + /* Use power_saving_tdp */ + disable_turbo(); + soc_conf_2core->tdp_pl1_override = 15; + soc_conf_4core->tdp_pl1_override = 15; + soc_conf_2core->tdp_pl2_override = 15; + soc_conf_4core->tdp_pl2_override = 15; + break; + } +} diff --git a/src/mainboard/starlabs/labtop/variants/tgl/smihandler.h b/src/mainboard/starlabs/labtop/variants/tgl/smihandler.h new file mode 100644 index 0000000..dedea7c --- /dev/null +++ b/src/mainboard/starlabs/labtop/variants/tgl/smihandler.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* Events */ +#define EC_SMI_AC_AND_DC = 0xc6 +#define EC_SMI_DC_BELOW_100 = 0xc9 +#define EC_SMI_DC_BELOW_60 = 0xc8 +#define EC_SMI_DC_BELOW_20 = 0xc7 +#define EC_SMI_AC_ONLY = 0xca + +/* Performance */ +enum performance_tdp { + PL1_AC_AND_DC = 35 + PL2_AC_AND_DC = 64 + + PL1_DC_BELOW_100 = 35 + PL2_DC_BELOW_100 = 51 + + PL1_DC_BELOW_60 = 28 + PL2_DC_BELOW_60 = 35 + + PL1_DC_BELOW_20 = 15 + PL2_DC_BELOW_20 = 15 + + PL1_AC_ONLY = 28 + PL2_AC_ONLY = 40 +} + +/* Balanced */ +enum balanced_tdp { + PL1_AC_AND_DC = 15 + PL2_AC_AND_DC = 45 + + PL1_DC_BELOW_100 = 15 + PL2_DC_BELOW_100 = 35 + + PL1_DC_BELOW_60 = 15 + PL2_DC_BELOW_60 = 25 + + PL1_DC_BELOW_20 = 15 + PL2_DC_BELOW_20 = 15 + + PL1_AC_ONLY = 15 + PL2_AC_ONLY = 25 +} + +/* Power Saving */ +enum power_saving_tdp { + PL1_AC_AND_DC = 15 + PL2_AC_AND_DC = 35 + + PL1_DC_BELOW_100 = 15 + PL2_DC_BELOW_100 = 35 + + PL1_DC_BELOW_60 = 15 + PL2_DC_BELOW_60 = 25 + + PL1_DC_BELOW_20 = 15 + PL2_DC_BELOW_20 = 15 + + PL1_AC_ONLY = 15 + PL2_AC_ONLY = 25 +}