drivers/intel/dptf: Add OEM variables support

This adds OEM variables feature under DPTF as per BWG doc #541817. Using
this, platform vendors can expose an array of OEM-specific values as OEM
variables to be used in determining DPTF policy. These are obtained via
the ODVP method, and then simply exposed under sysfs. In addition, these
gets updated when a notification is received or when the DPTF policy is
changed by userspace.

BRANCH=None
BUG=b:187253038
TEST=Built and tested on dedede board

Change-Id: Iaf3cf7b40e9a441b41d0c659d76895a58669c2fb
Signed-off-by: Sumeet R Pawnikar <sumeet.r.pawnikar@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50127
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
This commit is contained in:
Sumeet R Pawnikar 2021-05-11 20:05:20 +05:30 committed by Patrick Georgi
parent b2287718ef
commit 3657187789
2 changed files with 56 additions and 0 deletions

View File

@ -12,6 +12,9 @@
{.source = DPTF_##src, .temp = (tmp), .type = DPTF_CRITICAL_##typ} {.source = DPTF_##src, .temp = (tmp), .type = DPTF_CRITICAL_##typ}
#define TEMP_PCT(t, p) {.temp = (t), .fan_pct = (p)} #define TEMP_PCT(t, p) {.temp = (t), .fan_pct = (p)}
/* Total number of OEM variables */
#define DPTF_OEM_VARIABLE_COUNT 6
struct drivers_intel_dptf_config { struct drivers_intel_dptf_config {
struct { struct {
struct dptf_active_policy active[DPTF_MAX_ACTIVE_POLICIES]; struct dptf_active_policy active[DPTF_MAX_ACTIVE_POLICIES];
@ -51,6 +54,11 @@ struct drivers_intel_dptf_config {
const char *desc; const char *desc;
} tsr[DPTF_MAX_TSR]; } tsr[DPTF_MAX_TSR];
} options; } options;
/* OEM variables */
struct {
uint32_t oem_variables[DPTF_OEM_VARIABLE_COUNT];
} oem_data;
}; };
#endif /* _DRIVERS_INTEL_DPTF_CHIP_H_ */ #endif /* _DRIVERS_INTEL_DPTF_CHIP_H_ */

View File

@ -117,6 +117,53 @@ static void write_fan(const struct drivers_intel_dptf_config *config,
acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Device */
} }
/* \_SB.DPTF */
static void write_oem_variables(const struct drivers_intel_dptf_config *config)
{
int i;
acpigen_write_name("ODVX");
acpigen_write_package(DPTF_OEM_VARIABLE_COUNT);
for (i = 0; i < DPTF_OEM_VARIABLE_COUNT; i++)
acpigen_write_dword(config->oem_data.oem_variables[i]);
acpigen_write_package_end();
/*
* Method (ODUP, 2)
* Arg0 = Index of ODVX to update
* Arg1 = Value to place in ODVX[Arg0]
*/
acpigen_write_method_serialized("ODUP", 2);
/* ODVX[Arg0] = Arg1 */
acpigen_write_store();
acpigen_emit_byte(ARG1_OP);
acpigen_emit_byte(INDEX_OP);
acpigen_emit_namestring("ODVX");
acpigen_emit_byte(ARG0_OP);
acpigen_emit_byte(ZERO_OP); /* Ignore Index() Destination */
acpigen_write_method_end();
/*
* Method (ODGT, 1)
* Arg0 = Index of ODVX to get
*/
acpigen_write_method_serialized("ODGT", 1);
/* Return (ODVX[Arg0]) */
acpigen_emit_byte(RETURN_OP);
acpigen_emit_byte(DEREF_OP);
acpigen_emit_byte(INDEX_OP);
acpigen_emit_namestring("ODVX");
acpigen_emit_byte(ARG0_OP);
acpigen_emit_byte(ZERO_OP); /* Ignore Index() Destination */
acpigen_write_method_end();
/* Method (ODVP) { Return (ODVX) } */
acpigen_write_method_serialized("ODVP", 0);
acpigen_emit_byte(RETURN_OP);
acpigen_emit_namestring("ODVX");
acpigen_write_method_end();
}
/* \_SB.DPTF.xxxx */ /* \_SB.DPTF.xxxx */
static void write_generic_devices(const struct drivers_intel_dptf_config *config, static void write_generic_devices(const struct drivers_intel_dptf_config *config,
const struct dptf_platform_info *platform_info) const struct dptf_platform_info *platform_info)
@ -169,6 +216,7 @@ static void write_device_definitions(const struct device *dev)
write_tcpu(parent, config); write_tcpu(parent, config);
write_open_dptf_device(dev, platform_info); write_open_dptf_device(dev, platform_info);
write_fan(config, platform_info); write_fan(config, platform_info);
write_oem_variables(config);
write_generic_devices(config, platform_info); write_generic_devices(config, platform_info);
acpigen_pop_len(); /* DPTF Device (write_open_dptf_device) */ acpigen_pop_len(); /* DPTF Device (write_open_dptf_device) */