1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/include/linux/amd-pstate.h
5 * Copyright (C) 2022 Advanced Micro Devices, Inc.
7 * Author: Meng Li <li.meng@amd.com>
10 #ifndef _LINUX_AMD_PSTATE_H
11 #define _LINUX_AMD_PSTATE_H
13 #include <linux/pm_qos.h>
15 #define AMD_CPPC_EPP_PERFORMANCE 0x00
16 #define AMD_CPPC_EPP_BALANCE_PERFORMANCE 0x80
17 #define AMD_CPPC_EPP_BALANCE_POWERSAVE 0xBF
18 #define AMD_CPPC_EPP_POWERSAVE 0xFF
20 /*********************************************************************
21 * AMD P-state INTERFACE *
22 *********************************************************************/
24 * struct amd_aperf_mperf
25 * @aperf: actual performance frequency clock count
26 * @mperf: maximum performance frequency clock count
27 * @tsc: time stamp counter
29 struct amd_aperf_mperf {
36 * struct amd_cpudata - private CPU data for AMD P-State
38 * @req: constraint request to apply
39 * @cppc_req_cached: cached performance request hints
40 * @highest_perf: the maximum performance an individual processor may reach,
41 * assuming ideal conditions
42 * For platforms that do not support the preferred core feature, the
43 * highest_pef may be configured with 166 or 255, to avoid max frequency
44 * calculated wrongly. we take the fixed value as the highest_perf.
45 * @nominal_perf: the maximum sustained performance level of the processor,
46 * assuming ideal operating conditions
47 * @lowest_nonlinear_perf: the lowest performance level at which nonlinear power
48 * savings are achieved
49 * @lowest_perf: the absolute lowest performance level of the processor
50 * @prefcore_ranking: the preferred core ranking, the higher value indicates a higher
52 * @max_freq: the frequency that mapped to highest_perf
53 * @min_freq: the frequency that mapped to lowest_perf
54 * @nominal_freq: the frequency that mapped to nominal_perf
55 * @lowest_nonlinear_freq: the frequency that mapped to lowest_nonlinear_perf
56 * @cur: Difference of Aperf/Mperf/tsc count between last and current sample
57 * @prev: Last Aperf/Mperf/tsc count value read from register
58 * @freq: current cpu frequency value
59 * @boost_supported: check whether the Processor or SBIOS supports boost mode
60 * @hw_prefcore: check whether HW supports preferred core featue.
61 * Only when hw_prefcore and early prefcore param are true,
62 * AMD P-State driver supports preferred core featue.
63 * @epp_policy: Last saved policy used to set energy-performance preference
64 * @epp_cached: Cached CPPC energy-performance preference value
65 * @policy: Cpufreq policy value
66 * @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value
68 * The amd_cpudata is key private data for each CPU thread in AMD P-State, and
69 * represents all the attributes and goals that AMD P-State requests at runtime.
74 struct freq_qos_request req[2];
79 u32 lowest_nonlinear_perf;
90 u32 lowest_nonlinear_freq;
92 struct amd_aperf_mperf cur;
93 struct amd_aperf_mperf prev;
99 /* EPP feature related attributes*/
103 u64 cppc_cap1_cached;
108 * enum amd_pstate_mode - driver working mode of amd pstate
110 enum amd_pstate_mode {
111 AMD_PSTATE_UNDEFINED = 0,
119 static const char * const amd_pstate_mode_string[] = {
120 [AMD_PSTATE_UNDEFINED] = "undefined",
121 [AMD_PSTATE_DISABLE] = "disable",
122 [AMD_PSTATE_PASSIVE] = "passive",
123 [AMD_PSTATE_ACTIVE] = "active",
124 [AMD_PSTATE_GUIDED] = "guided",
127 #endif /* _LINUX_AMD_PSTATE_H */