Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/41888 )
Change subject: dptf: Add support for Charger Performance States ......................................................................
dptf: Add support for Charger Performance States
This change generates the DPTF TCHG.PPSS table in the SSDT. This table describes different charging rates which are available to use. DPTF can pick different rates in order to passively cool (or not) the system.
BUG=b:143539650 TEST=compiles
Change-Id: I6df6bfbac628fa4e4d313e38b8e6c53fce70a7f2 Signed-off-by: Tim Wawrzynczak twawrzynczak@chromium.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/41888 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Duncan Laurie dlaurie@chromium.org --- M src/acpi/acpigen_dptf.c M src/drivers/intel/dptf/chip.h M src/drivers/intel/dptf/dptf.c M src/include/acpi/acpigen_dptf.h 4 files changed, 65 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Duncan Laurie: Looks good to me, approved
diff --git a/src/acpi/acpigen_dptf.c b/src/acpi/acpigen_dptf.c index 88cf386..c18caf6 100644 --- a/src/acpi/acpigen_dptf.c +++ b/src/acpi/acpigen_dptf.c @@ -7,6 +7,8 @@ #define TOPLEVEL_DPTF_SCOPE "\_SB.DPTF"
/* Defaults */ +#define DEFAULT_RAW_UNIT "ma" + enum { ART_REVISION = 0, DEFAULT_PRIORITY = 100, @@ -280,3 +282,42 @@ acpigen_pop_len(); /* Scope */ } } + +void dptf_write_charger_perf(const struct dptf_charger_perf *states, int max_count) +{ + char *pkg_count; + int i; + + if (!max_count || !states[0].control) + return; + + dptf_write_scope(DPTF_CHARGER); + + /* PPSS - Participant Performance Supported States */ + acpigen_write_method("PPSS", 0); + acpigen_emit_byte(RETURN_OP); + + pkg_count = acpigen_write_package(0); + for (i = 0; i < max_count; ++i) { + if (!states[i].control) + break; + + (*pkg_count)++; + + /* + * 0, 0, 0, 0, # Reserved + * Control, Raw Performance, Raw Unit, 0 # Reserved + */ + acpigen_write_package(8); + write_zeros(4); + acpigen_write_integer(states[i].control); + acpigen_write_integer(states[i].raw_perf); + acpigen_write_string(DEFAULT_RAW_UNIT); + acpigen_write_integer(0); + acpigen_pop_len(); /* inner Package */ + } + + acpigen_pop_len(); /* outer Package */ + acpigen_pop_len(); /* Method PPSS */ + acpigen_pop_len(); /* Scope */ +} diff --git a/src/drivers/intel/dptf/chip.h b/src/drivers/intel/dptf/chip.h index 8d77603..528ba83 100644 --- a/src/drivers/intel/dptf/chip.h +++ b/src/drivers/intel/dptf/chip.h @@ -11,6 +11,10 @@ struct dptf_critical_policy critical[DPTF_MAX_CRITICAL_POLICIES]; struct dptf_passive_policy passive[DPTF_MAX_PASSIVE_POLICIES]; } policies; + + struct { + struct dptf_charger_perf charger_perf[DPTF_MAX_CHARGER_PERF_STATES]; + } controls; };
#endif /* _DRIVERS_INTEL_DPTF_CHIP_H_ */ diff --git a/src/drivers/intel/dptf/dptf.c b/src/drivers/intel/dptf/dptf.c index 5cad07d..a20087f 100644 --- a/src/drivers/intel/dptf/dptf.c +++ b/src/drivers/intel/dptf/dptf.c @@ -72,6 +72,9 @@ dptf_write_critical_policies(config->policies.critical, DPTF_MAX_CRITICAL_POLICIES);
+ /* Controls */ + dptf_write_charger_perf(config->controls.charger_perf, DPTF_MAX_CHARGER_PERF_STATES); + printk(BIOS_INFO, "\_SB.DPTF: %s at %s\n", dev->chip_ops->name, dev_path(dev)); }
diff --git a/src/include/acpi/acpigen_dptf.h b/src/include/acpi/acpigen_dptf.h index 45fbe8f..7588752 100644 --- a/src/include/acpi/acpigen_dptf.h +++ b/src/include/acpi/acpigen_dptf.h @@ -29,6 +29,9 @@ DPTF_MAX_ACTIVE_POLICIES = (DPTF_PARTICIPANT_COUNT-1), DPTF_MAX_PASSIVE_POLICIES = (DPTF_PARTICIPANT_COUNT-1), DPTF_MAX_CRITICAL_POLICIES = (DPTF_PARTICIPANT_COUNT-1), + + /* Maximum found by automatic inspection (awk) */ + DPTF_MAX_CHARGER_PERF_STATES = 10, };
/* Active Policy */ @@ -76,6 +79,14 @@ uint8_t temp; };
+/* Different levels of charging capability, chosen by passive policies */ +struct dptf_charger_perf { + /* Control value */ + uint8_t control; + /* Charging performance, in mA */ + uint16_t raw_perf; +}; + /* * This function provides tables of temperature and corresponding fan or percent. When the * temperature thresholds are met (_AC0 - _AC9), the fan is driven to corresponding percentage @@ -98,6 +109,12 @@ */ void dptf_write_critical_policies(const struct dptf_critical_policy *policies, int max_count);
+/* + * These are various performance levels for battery charging. They can be used in conjunction + * with passive policies to lower the charging rate when the _PSV threshold is met. + */ +void dptf_write_charger_perf(const struct dptf_charger_perf *perf, int max_count); + /* Helper method to open the scope for a given participant. */ void dptf_write_scope(enum dptf_participant participant);