]> Git Repo - linux.git/blob - include/linux/amd-pstate.h
Merge patch series "riscv: Extension parsing fixes"
[linux.git] / include / linux / amd-pstate.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * linux/include/linux/amd-pstate.h
4  *
5  * Copyright (C) 2022 Advanced Micro Devices, Inc.
6  *
7  * Author: Meng Li <[email protected]>
8  */
9
10 #ifndef _LINUX_AMD_PSTATE_H
11 #define _LINUX_AMD_PSTATE_H
12
13 #include <linux/pm_qos.h>
14
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
19
20 /*********************************************************************
21  *                        AMD P-state INTERFACE                       *
22  *********************************************************************/
23 /**
24  * struct  amd_aperf_mperf
25  * @aperf: actual performance frequency clock count
26  * @mperf: maximum performance frequency clock count
27  * @tsc:   time stamp counter
28  */
29 struct amd_aperf_mperf {
30         u64 aperf;
31         u64 mperf;
32         u64 tsc;
33 };
34
35 /**
36  * struct amd_cpudata - private CPU data for AMD P-State
37  * @cpu: CPU number
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
51  *                priority.
52  * @min_limit_perf: Cached value of the performance corresponding to policy->min
53  * @max_limit_perf: Cached value of the performance corresponding to policy->max
54  * @min_limit_freq: Cached value of policy->min (in khz)
55  * @max_limit_freq: Cached value of policy->max (in khz)
56  * @max_freq: the frequency (in khz) that mapped to highest_perf
57  * @min_freq: the frequency (in khz) that mapped to lowest_perf
58  * @nominal_freq: the frequency (in khz) that mapped to nominal_perf
59  * @lowest_nonlinear_freq: the frequency (in khz) that mapped to lowest_nonlinear_perf
60  * @cur: Difference of Aperf/Mperf/tsc count between last and current sample
61  * @prev: Last Aperf/Mperf/tsc count value read from register
62  * @freq: current cpu frequency value (in khz)
63  * @boost_supported: check whether the Processor or SBIOS supports boost mode
64  * @hw_prefcore: check whether HW supports preferred core featue.
65  *                Only when hw_prefcore and early prefcore param are true,
66  *                AMD P-State driver supports preferred core featue.
67  * @epp_policy: Last saved policy used to set energy-performance preference
68  * @epp_cached: Cached CPPC energy-performance preference value
69  * @policy: Cpufreq policy value
70  * @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value
71  *
72  * The amd_cpudata is key private data for each CPU thread in AMD P-State, and
73  * represents all the attributes and goals that AMD P-State requests at runtime.
74  */
75 struct amd_cpudata {
76         int     cpu;
77
78         struct  freq_qos_request req[2];
79         u64     cppc_req_cached;
80
81         u32     highest_perf;
82         u32     nominal_perf;
83         u32     lowest_nonlinear_perf;
84         u32     lowest_perf;
85         u32     prefcore_ranking;
86         u32     min_limit_perf;
87         u32     max_limit_perf;
88         u32     min_limit_freq;
89         u32     max_limit_freq;
90
91         u32     max_freq;
92         u32     min_freq;
93         u32     nominal_freq;
94         u32     lowest_nonlinear_freq;
95
96         struct amd_aperf_mperf cur;
97         struct amd_aperf_mperf prev;
98
99         u64     freq;
100         bool    boost_supported;
101         bool    hw_prefcore;
102
103         /* EPP feature related attributes*/
104         s16     epp_policy;
105         s16     epp_cached;
106         u32     policy;
107         u64     cppc_cap1_cached;
108         bool    suspended;
109 };
110
111 /*
112  * enum amd_pstate_mode - driver working mode of amd pstate
113  */
114 enum amd_pstate_mode {
115         AMD_PSTATE_UNDEFINED = 0,
116         AMD_PSTATE_DISABLE,
117         AMD_PSTATE_PASSIVE,
118         AMD_PSTATE_ACTIVE,
119         AMD_PSTATE_GUIDED,
120         AMD_PSTATE_MAX,
121 };
122
123 static const char * const amd_pstate_mode_string[] = {
124         [AMD_PSTATE_UNDEFINED]   = "undefined",
125         [AMD_PSTATE_DISABLE]     = "disable",
126         [AMD_PSTATE_PASSIVE]     = "passive",
127         [AMD_PSTATE_ACTIVE]      = "active",
128         [AMD_PSTATE_GUIDED]      = "guided",
129         NULL,
130 };
131
132 struct quirk_entry {
133         u32 nominal_freq;
134         u32 lowest_freq;
135 };
136
137 #endif /* _LINUX_AMD_PSTATE_H */
This page took 0.043422 seconds and 4 git commands to generate.