1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef ACPI_ACPIGEN_DPTF_H
4 #define ACPI_ACPIGEN_DPTF_H
6 #include <device/device.h>
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_))
14 #define DPTF_DEVICE_PATH "\\_SB.DPTF"
15 #define TCPU_SCOPE "\\_SB.PCI0"
17 #define DPTF_MAX_FAN_PARTICIPANTS 2
19 /* List of available participants (i.e., they can participate in policies) */
20 enum dptf_participant
{
34 DPTF_PARTICIPANT_COUNT
,
37 /* DPTF compile-time constants */
39 /* A device can only define _AC0 .. _AC9 i.e. between 0 and 10 Active Cooling Methods */
41 DPTF_MAX_ACTIVE_POLICIES
= (DPTF_PARTICIPANT_COUNT
-1),
42 DPTF_MAX_PASSIVE_POLICIES
= (DPTF_PARTICIPANT_COUNT
-1),
43 DPTF_MAX_CRITICAL_POLICIES
= (DPTF_PARTICIPANT_COUNT
-1),
45 /* Maximum found by automatic inspection (awk) */
46 DPTF_MAX_CHARGER_PERF_STATES
= 10,
47 DPTF_MAX_FAN_PERF_STATES
= 20,
49 /* From ACPI spec 6.3 */
50 DPTF_FIELD_UNUSED
= 0xFFFFFFFFull
,
52 /* Max supported by DPTF */
57 struct dptf_active_policy
{
58 /* The device that can be throttled */
59 enum dptf_participant source
;
60 /* Device capable of being affected by the fan */
61 enum dptf_participant target
;
62 /* Source's contribution to the Target's cooling capability as a percentage */
64 /* When target reaches temperature 'temp', the source will turn on at 'fan_pct' % */
70 } thresholds
[DPTF_MAX_ACX
];
74 struct dptf_passive_policy
{
75 /* The device that can be throttled */
76 enum dptf_participant source
;
77 /* The device that controls the throttling */
78 enum dptf_participant target
;
79 /* How often to check the temperature for required throttling (ms) */
81 /* The trip point for turning on throttling (degrees C) */
83 /* Relative priority between Policies */
87 /* Critical Policy type: graceful S4 transition or graceful shutdown */
88 enum dptf_critical_policy_type
{
90 DPTF_CRITICAL_SHUTDOWN
,
94 struct dptf_critical_policy
{
95 /* The device that can trigger a critical event */
96 enum dptf_participant source
;
97 /* What type of critical policy */
98 enum dptf_critical_policy_type type
;
99 /* Temperature to activate policy, degrees C */
103 /* Different levels of charging capability, chosen by passive policies */
104 struct dptf_charger_perf
{
107 /* Charging performance, in mA */
111 /* Different levels of fan activity, chosen by active policies */
112 struct dptf_fan_perf
{
113 /* Fan percentage level */
115 /* Fan speed, in RPM */
117 /* Noise level, in 0.1 dBs */
118 uint16_t noise_level
;
123 /* Different levels of fan activity, chosen by active policies */
124 struct dptf_multifan_perf
{
125 /* Fan percentage level */
127 /* Fan speed, in RPM */
129 /* Noise level, in 0.1 dBs */
130 uint16_t noise_level
;
135 /* Running Average Power Limits (RAPL) */
136 struct dptf_power_limit_config
{
137 /* Minimum level of power limit, in mW */
139 /* Maximum level of power limit, in mW */
141 /* Minimum time window running average is over, in seconds */
142 uint32_t time_window_min
;
143 /* Maximum time window running average is over, in seconds */
144 uint32_t time_window_max
;
145 /* Granularity of the power limit setting (between min and max), in mW */
146 uint16_t granularity
;
149 /* Only PL1 and PL2 are controllable via DPTF */
150 struct dptf_power_limits
{
151 struct dptf_power_limit_config pl1
;
152 struct dptf_power_limit_config pl2
;
156 * This function writes out \_SB.DPTF.IDSP, which describes the different DPTF policies that
157 * this implementation is using.
159 void dptf_write_enabled_policies(const struct dptf_active_policy
*active_policies
,
161 const struct dptf_passive_policy
*passive_policies
,
163 const struct dptf_critical_policy
*critical_policies
,
167 * This function provides tables of temperature and corresponding fan or percent. When the
168 * temperature thresholds are met (_AC0 - _AC9), the fan is driven to corresponding percentage
171 void dptf_write_active_policies(const struct dptf_active_policy
*policies
, int max_count
,
172 bool dptf_multifan_support
);
175 * This function uses the definition of the passive policies to write out _PSV Methods on all
176 * participants that define it. It also writes out the Thermal Relationship Table
177 * (\_SB.DPTF._TRT), which describes various passive (i.e., throttling) policies that can be
178 * applies when temperature sensors reach the _PSV threshold.
180 void dptf_write_passive_policies(const struct dptf_passive_policy
*policies
, int max_count
);
183 * Critical policies are temperature thresholds that, when reached, will cause the system to
184 * take some emergency action in order to eliminate excess temperatures from damaging the
185 * system. The emergency actions are a graceful suspend or a graceful shutdown.
187 void dptf_write_critical_policies(const struct dptf_critical_policy
*policies
, int max_count
);
190 * These are various performance levels for battery charging. They can be used in conjunction
191 * with passive policies to lower the charging rate when the _PSV threshold is met.
193 void dptf_write_charger_perf(const struct dptf_charger_perf
*perf
, int max_count
);
196 * This function writes an ACPI table describing various performance levels possible for active
197 * policies. They indicate, for a given fan percentage level:
198 * 1) What the corresponding speed is (in RPM)
199 * 2) The expected noise level (in tenths of decibels AKA centibels, or DPTF_FIELD_UNUSED)
200 * 3) The power consumption (in mW, or DPTF_FIELD_UNUSED to indicate this field is unused).
201 * 4) The corresponding active cooling trip point (from _ART) (typically left as
202 * DPTF_FIELD_UNUSED).
204 void dptf_write_fan_perf(const struct dptf_fan_perf
*perf
, int max_count
,
205 enum dptf_participant participant
);
207 void dptf_write_multifan_perf(
208 const struct dptf_multifan_perf
209 states
[DPTF_MAX_FAN_PARTICIPANTS
][DPTF_MAX_FAN_PERF_STATES
],
210 int max_count
, enum dptf_participant participant
, int fan_num
);
212 int dptf_write_fan_perf_fps(uint8_t percent
, uint16_t power
, uint16_t speed
,
213 uint16_t noise_level
);
216 * This function writes out a PPCC table, which indicates power ranges that different Intel
217 * Running Average Power Limits (RAPLs) can take, as well as the time period they average over
218 * and the minimum adjustment amount.
220 void dptf_write_power_limits(const struct dptf_power_limits
*limits
);
222 /* Set the _STR Name */
223 void dptf_write_STR(const char *str
);
225 /* Set options in the _FIF table */
226 void dptf_write_fan_options(bool fine_grained
, int step_size
, bool low_speed_notify
);
229 * Sets the amount of inherent hysteresis in temperature sensor readings (either from hardware
230 * circuitry or possibly from the EC's firmware implementation.
232 void dptf_write_tsr_hysteresis(uint8_t hysteresis
);
234 /* Helper method to open the scope for a given participant. */
235 void dptf_write_scope(enum dptf_participant participant
);
238 * Write out a _STA that will check the value of the DPTE field in GNVS, and return 0xF if DPTE
239 * is 1, otherwise it will return 0.
241 void dptf_write_STA(void);
243 #endif /* ACPI_ACPIGEN_DPTF_H */