1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2022 Advanced Micro Devices, Inc.
5 * Author: Meng Li <li.meng@amd.com>
8 #ifndef _LINUX_AMD_PSTATE_H
9 #define _LINUX_AMD_PSTATE_H
11 #include <linux/pm_qos.h>
13 /*********************************************************************
14 * AMD P-state INTERFACE *
15 *********************************************************************/
17 * struct amd_aperf_mperf
18 * @aperf: actual performance frequency clock count
19 * @mperf: maximum performance frequency clock count
20 * @tsc: time stamp counter
22 struct amd_aperf_mperf
{
29 * struct amd_cpudata - private CPU data for AMD P-State
31 * @req: constraint request to apply
32 * @cppc_req_cached: cached performance request hints
33 * @highest_perf: the maximum performance an individual processor may reach,
34 * assuming ideal conditions
35 * For platforms that do not support the preferred core feature, the
36 * highest_pef may be configured with 166 or 255, to avoid max frequency
37 * calculated wrongly. we take the fixed value as the highest_perf.
38 * @nominal_perf: the maximum sustained performance level of the processor,
39 * assuming ideal operating conditions
40 * @lowest_nonlinear_perf: the lowest performance level at which nonlinear power
41 * savings are achieved
42 * @lowest_perf: the absolute lowest performance level of the processor
43 * @prefcore_ranking: the preferred core ranking, the higher value indicates a higher
45 * @min_limit_perf: Cached value of the performance corresponding to policy->min
46 * @max_limit_perf: Cached value of the performance corresponding to policy->max
47 * @min_limit_freq: Cached value of policy->min (in khz)
48 * @max_limit_freq: Cached value of policy->max (in khz)
49 * @max_freq: the frequency (in khz) that mapped to highest_perf
50 * @min_freq: the frequency (in khz) that mapped to lowest_perf
51 * @nominal_freq: the frequency (in khz) that mapped to nominal_perf
52 * @lowest_nonlinear_freq: the frequency (in khz) that mapped to lowest_nonlinear_perf
53 * @cur: Difference of Aperf/Mperf/tsc count between last and current sample
54 * @prev: Last Aperf/Mperf/tsc count value read from register
55 * @freq: current cpu frequency value (in khz)
56 * @boost_supported: check whether the Processor or SBIOS supports boost mode
57 * @hw_prefcore: check whether HW supports preferred core featue.
58 * Only when hw_prefcore and early prefcore param are true,
59 * AMD P-State driver supports preferred core featue.
60 * @epp_policy: Last saved policy used to set energy-performance preference
61 * @epp_cached: Cached CPPC energy-performance preference value
62 * @policy: Cpufreq policy value
63 * @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value
65 * The amd_cpudata is key private data for each CPU thread in AMD P-State, and
66 * represents all the attributes and goals that AMD P-State requests at runtime.
71 struct freq_qos_request req
[2];
76 u32 lowest_nonlinear_perf
;
87 u32 lowest_nonlinear_freq
;
89 struct amd_aperf_mperf cur
;
90 struct amd_aperf_mperf prev
;
96 /* EPP feature related attributes*/
100 u64 cppc_cap1_cached
;
107 * enum amd_pstate_mode - driver working mode of amd pstate
109 enum amd_pstate_mode
{
110 AMD_PSTATE_UNDEFINED
= 0,
117 const char *amd_pstate_get_mode_string(enum amd_pstate_mode mode
);
118 int amd_pstate_update_status(const char *buf
, size_t size
);
120 #endif /* _LINUX_AMD_PSTATE_H */