coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
acpigen_dptf.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef ACPI_ACPIGEN_DPTF_H
4 #define ACPI_ACPIGEN_DPTF_H
5 
6 #include <device/device.h>
7 #include <stdbool.h>
8 #include <stdint.h>
9 
10 /* A common idiom is to use a default value if none is provided (i.e., == 0) */
11 #define DEFAULT_IF_0(thing, default_) ((thing) ? (thing) : (default_))
12 
13 /* Hardcoded paths */
14 #define DPTF_DEVICE_PATH "\\_SB.DPTF"
15 #define TCPU_SCOPE "\\_SB.PCI0"
16 
17 /* List of available participants (i.e., they can participate in policies) */
32 };
33 
34 /* DPTF compile-time constants */
35 enum {
36  /* A device can only define _AC0 .. _AC9 i.e. between 0 and 10 Active Cooling Methods */
41 
42  /* Maximum found by automatic inspection (awk) */
45 
46  /* From ACPI spec 6.3 */
47  DPTF_FIELD_UNUSED = 0xFFFFFFFFull,
48 
49  /* Max supported by DPTF */
51 };
52 
53 /* Active Policy */
55  /* Device capable of being affected by the fan */
57  /* Source's contribution to the Target's cooling capability as a percentage */
59  /* When target reaches temperature 'temp', the source will turn on at 'fan_pct' % */
60  struct {
61  /* (degrees C) */
63  /* 0 - 100 */
66 };
67 
68 /* Passive Policy */
70  /* The device that can be throttled */
72  /* The device that controls the throttling */
74  /* How often to check the temperature for required throttling (ms) */
76  /* The trip point for turning on throttling (degrees C) */
78  /* Relative priority between Policies */
80 };
81 
82 /* Critical Policy type: graceful S4 transition or graceful shutdown */
86 };
87 
88 /* Critical Policy */
90  /* The device that can trigger a critical event */
92  /* What type of critical policy */
94  /* Temperature to activate policy, degrees C */
96 };
97 
98 /* Different levels of charging capability, chosen by passive policies */
100  /* Control value */
102  /* Charging performance, in mA */
104 };
105 
106 /* Different levels of fan activity, chosen by active policies */
108  /* Fan percentage level */
110  /* Fan speed, in RPM */
112  /* Noise level, in 0.1 dBs */
114  /* Power in mA */
116 };
117 
118 /* Running Average Power Limits (RAPL) */
120  /* Minimum level of power limit, in mW */
122  /* Maximum level of power limit, in mW */
124  /* Minimum time window running average is over, in seconds */
126  /* Maximum time window running average is over, in seconds */
128  /* Granularity of the power limit setting (between min and max), in mW */
130 };
131 
132 /* Only PL1 and PL2 are controllable via DPTF */
136 };
137 
138 /*
139  * This function writes out \_SB.DPTF.IDSP, which describes the different DPTF policies that
140  * this implementation is using.
141  */
142 void dptf_write_enabled_policies(const struct dptf_active_policy *active_policies,
143  int active_count,
144  const struct dptf_passive_policy *passive_policies,
145  int passive_count,
146  const struct dptf_critical_policy *critical_policies,
147  int critical_count);
148 
149 /*
150  * This function provides tables of temperature and corresponding fan or percent. When the
151  * temperature thresholds are met (_AC0 - _AC9), the fan is driven to corresponding percentage
152  * of full speed.
153  */
154 void dptf_write_active_policies(const struct dptf_active_policy *policies, int max_count);
155 
156 /*
157  * This function uses the definition of the passive policies to write out _PSV Methods on all
158  * participants that define it. It also writes out the Thermal Relationship Table
159  * (\_SB.DPTF._TRT), which describes various passive (i.e., throttling) policies that can be
160  * applies when temperature sensors reach the _PSV threshold.
161  */
162 void dptf_write_passive_policies(const struct dptf_passive_policy *policies, int max_count);
163 
164 /*
165  * Critical policies are temperature thresholds that, when reached, will cause the system to
166  * take some emergency action in order to eliminate excess temperatures from damaging the
167  * system. The emergency actions are a graceful suspend or a graceful shutdown.
168  */
169 void dptf_write_critical_policies(const struct dptf_critical_policy *policies, int max_count);
170 
171 /*
172  * These are various performance levels for battery charging. They can be used in conjunction
173  * with passive policies to lower the charging rate when the _PSV threshold is met.
174  */
175 void dptf_write_charger_perf(const struct dptf_charger_perf *perf, int max_count);
176 
177 /*
178  * This function writes an ACPI table describing various performance levels possible for active
179  * policies. They indicate, for a given fan percentage level:
180  * 1) What the corresponding speed is (in RPM)
181  * 2) The expected noise level (in tenths of decibels AKA centibels, or DPTF_FIELD_UNUSED)
182  * 3) The power consumption (in mW, or DPTF_FIELD_UNUSED to indicate this field is unused).
183  * 4) The corresponding active cooling trip point (from _ART) (typically left as
184  * DPTF_FIELD_UNUSED).
185  */
186 void dptf_write_fan_perf(const struct dptf_fan_perf *perf, int max_count);
187 
188 /*
189  * This function writes out a PPCC table, which indicates power ranges that different Intel
190  * Running Average Power Limits (RAPLs) can take, as well as the time period they average over
191  * and the minimum adjustment amount.
192  */
194 
195 /* Set the _STR Name */
196 void dptf_write_STR(const char *str);
197 
198 /* Set options in the _FIF table */
199 void dptf_write_fan_options(bool fine_grained, int step_size, bool low_speed_notify);
200 
201 /*
202  * Sets the amount of inherent hysteresis in temperature sensor readings (either from hardware
203  * circuitry or possibly from the EC's firmware implementation.
204  */
205 void dptf_write_tsr_hysteresis(uint8_t hysteresis);
206 
207 /* Helper method to open the scope for a given participant. */
208 void dptf_write_scope(enum dptf_participant participant);
209 
210 /*
211  * Write out a _STA that will check the value of the DPTE field in GNVS, and return 0xF if DPTE
212  * is 1, otherwise it will return 0.
213  */
214 void dptf_write_STA(void);
215 
216 #endif /* ACPI_ACPIGEN_DPTF_H */
void dptf_write_enabled_policies(const struct dptf_active_policy *active_policies, int active_count, const struct dptf_passive_policy *passive_policies, int passive_count, const struct dptf_critical_policy *critical_policies, int critical_count)
Definition: acpigen_dptf.c:463
dptf_critical_policy_type
Definition: acpigen_dptf.h:83
@ DPTF_CRITICAL_S4
Definition: acpigen_dptf.h:84
@ DPTF_CRITICAL_SHUTDOWN
Definition: acpigen_dptf.h:85
void dptf_write_active_policies(const struct dptf_active_policy *policies, int max_count)
Definition: acpigen_dptf.c:208
void dptf_write_STR(const char *str)
Definition: acpigen_dptf.c:435
@ DPTF_MAX_CRITICAL_POLICIES
Definition: acpigen_dptf.h:40
@ DPTF_MAX_TSR
Definition: acpigen_dptf.h:50
@ DPTF_MAX_CHARGER_PERF_STATES
Definition: acpigen_dptf.h:43
@ DPTF_MAX_FAN_PERF_STATES
Definition: acpigen_dptf.h:44
@ DPTF_FIELD_UNUSED
Definition: acpigen_dptf.h:47
@ DPTF_MAX_PASSIVE_POLICIES
Definition: acpigen_dptf.h:39
@ DPTF_MAX_ACTIVE_POLICIES
Definition: acpigen_dptf.h:38
@ DPTF_MAX_ACX
Definition: acpigen_dptf.h:37
void dptf_write_fan_options(bool fine_grained, int step_size, bool low_speed_notify)
Definition: acpigen_dptf.c:443
void dptf_write_passive_policies(const struct dptf_passive_policy *policies, int max_count)
Definition: acpigen_dptf.c:292
void dptf_write_tsr_hysteresis(uint8_t hysteresis)
Definition: acpigen_dptf.c:455
void dptf_write_fan_perf(const struct dptf_fan_perf *perf, int max_count)
Definition: acpigen_dptf.c:355
void dptf_write_STA(void)
void dptf_write_charger_perf(const struct dptf_charger_perf *perf, int max_count)
Definition: acpigen_dptf.c:316
dptf_participant
Definition: acpigen_dptf.h:18
@ DPTF_TEMP_SENSOR_0
Definition: acpigen_dptf.h:23
@ DPTF_TPCH
Definition: acpigen_dptf.h:28
@ DPTF_TEMP_SENSOR_4
Definition: acpigen_dptf.h:27
@ DPTF_TEMP_SENSOR_2
Definition: acpigen_dptf.h:25
@ DPTF_PARTICIPANT_COUNT
Definition: acpigen_dptf.h:31
@ DPTF_POWER
Definition: acpigen_dptf.h:29
@ DPTF_TEMP_SENSOR_3
Definition: acpigen_dptf.h:26
@ DPTF_CHARGER
Definition: acpigen_dptf.h:21
@ DPTF_NONE
Definition: acpigen_dptf.h:19
@ DPTF_FAN
Definition: acpigen_dptf.h:22
@ DPTF_BATTERY
Definition: acpigen_dptf.h:30
@ DPTF_CPU
Definition: acpigen_dptf.h:20
@ DPTF_TEMP_SENSOR_1
Definition: acpigen_dptf.h:24
void dptf_write_power_limits(const struct dptf_power_limits *limits)
Definition: acpigen_dptf.c:392
void dptf_write_scope(enum dptf_participant participant)
Definition: acpigen_dptf.c:114
void dptf_write_critical_policies(const struct dptf_critical_policy *policies, int max_count)
Definition: acpigen_dptf.c:298
const struct cpu_power_limits limits[]
Definition: ramstage.c:11
static const struct pnpconfig perf[]
Definition: pnpconfig.c:10
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8
enum dptf_participant target
Definition: acpigen_dptf.h:56
struct dptf_active_policy::@201 thresholds[DPTF_MAX_ACX]
enum dptf_participant source
Definition: acpigen_dptf.h:91
enum dptf_critical_policy_type type
Definition: acpigen_dptf.h:93
uint16_t power
Definition: acpigen_dptf.h:115
uint8_t percent
Definition: acpigen_dptf.h:109
uint16_t speed
Definition: acpigen_dptf.h:111
uint16_t noise_level
Definition: acpigen_dptf.h:113
enum dptf_participant target
Definition: acpigen_dptf.h:73
enum dptf_participant source
Definition: acpigen_dptf.h:71
struct dptf_power_limit_config pl2
Definition: acpigen_dptf.h:135
struct dptf_power_limit_config pl1
Definition: acpigen_dptf.h:134