From 7eb1136c27a839a18a4224b970b5a61587e29bd7 Mon Sep 17 00:00:00 2001
From: Tim Wawrzynczak <twawrzynczak@chromium.org>
Date: Fri, 29 May 2020 14:10:53 -0600
Subject: dptf: Add support for Passive Policies

This patch adds support for emitting the Thermal Relationship Table, as
well as _PSV Methods, which together form the basis for DPTF Passive
Policies.

BUG=b:143539650
TEST=compiles

Change-Id: I82e1c9022999b0a2a733aa6cd9c98a850e6f5408
Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41886
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
---
 src/include/acpi/acpigen_dptf.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

(limited to 'src/include/acpi')

diff --git a/src/include/acpi/acpigen_dptf.h b/src/include/acpi/acpigen_dptf.h
index a082b62fd9..214578a4c1 100644
--- a/src/include/acpi/acpigen_dptf.h
+++ b/src/include/acpi/acpigen_dptf.h
@@ -27,6 +27,7 @@ enum {
 	/* A device can only define _AC0 .. _AC9 i.e. between 0 and 10 Active Cooling Methods */
 	DPTF_MAX_ACX			= 10,
 	DPTF_MAX_ACTIVE_POLICIES	= (DPTF_PARTICIPANT_COUNT-1),
+	DPTF_MAX_PASSIVE_POLICIES	= (DPTF_PARTICIPANT_COUNT-1),
 };
 
 /* Active Policy */
@@ -44,6 +45,20 @@ struct dptf_active_policy {
 	} thresholds[DPTF_MAX_ACX];
 };
 
+/* Passive Policy */
+struct dptf_passive_policy {
+	/* The device that can be throttled */
+	enum dptf_participant source;
+	/* The device that controls the throttling */
+	enum dptf_participant target;
+	/* How often to check the temperature for required throttling (ms) */
+	uint16_t period;
+	/* The trip point for turning on throttling (degrees C) */
+	uint8_t temp;
+	/* Relative priority between Policies */
+	uint8_t priority;
+};
+
 /*
  * 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
@@ -51,6 +66,14 @@ struct dptf_active_policy {
  */
 void dptf_write_active_policies(const struct dptf_active_policy *policies, int max_count);
 
+/*
+ * This function uses the definition of the passive policies to write out _PSV Methods on all
+ * participants that define it.  It also writes out the Thermal Relationship Table
+ * (\_SB.DPTF._TRT), which describes various passive (i.e., throttling) policies that can be
+ * applies when temperature sensors reach the _PSV threshold.
+ */
+void dptf_write_passive_policies(const struct dptf_passive_policy *policies, int max_count);
+
 /* Helper method to open the scope for a given participant. */
 void dptf_write_scope(enum dptf_participant participant);
 
-- 
cgit v1.2.3