Merge tag 'ceph-for-6.8-rc8' of https://github.com/ceph/ceph-client
[linux-2.6-microblaze.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 <li.meng@amd.com>
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  * @nominal_perf: the maximum sustained performance level of the processor,
43  *                assuming ideal operating conditions
44  * @lowest_nonlinear_perf: the lowest performance level at which nonlinear power
45  *                         savings are achieved
46  * @lowest_perf: the absolute lowest performance level of the processor
47  * @max_freq: the frequency that mapped to highest_perf
48  * @min_freq: the frequency that mapped to lowest_perf
49  * @nominal_freq: the frequency that mapped to nominal_perf
50  * @lowest_nonlinear_freq: the frequency that mapped to lowest_nonlinear_perf
51  * @cur: Difference of Aperf/Mperf/tsc count between last and current sample
52  * @prev: Last Aperf/Mperf/tsc count value read from register
53  * @freq: current cpu frequency value
54  * @boost_supported: check whether the Processor or SBIOS supports boost mode
55  * @epp_policy: Last saved policy used to set energy-performance preference
56  * @epp_cached: Cached CPPC energy-performance preference value
57  * @policy: Cpufreq policy value
58  * @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value
59  *
60  * The amd_cpudata is key private data for each CPU thread in AMD P-State, and
61  * represents all the attributes and goals that AMD P-State requests at runtime.
62  */
63 struct amd_cpudata {
64         int     cpu;
65
66         struct  freq_qos_request req[2];
67         u64     cppc_req_cached;
68
69         u32     highest_perf;
70         u32     nominal_perf;
71         u32     lowest_nonlinear_perf;
72         u32     lowest_perf;
73         u32     min_limit_perf;
74         u32     max_limit_perf;
75         u32     min_limit_freq;
76         u32     max_limit_freq;
77
78         u32     max_freq;
79         u32     min_freq;
80         u32     nominal_freq;
81         u32     lowest_nonlinear_freq;
82
83         struct amd_aperf_mperf cur;
84         struct amd_aperf_mperf prev;
85
86         u64     freq;
87         bool    boost_supported;
88
89         /* EPP feature related attributes*/
90         s16     epp_policy;
91         s16     epp_cached;
92         u32     policy;
93         u64     cppc_cap1_cached;
94         bool    suspended;
95 };
96
97 /*
98  * enum amd_pstate_mode - driver working mode of amd pstate
99  */
100 enum amd_pstate_mode {
101         AMD_PSTATE_UNDEFINED = 0,
102         AMD_PSTATE_DISABLE,
103         AMD_PSTATE_PASSIVE,
104         AMD_PSTATE_ACTIVE,
105         AMD_PSTATE_GUIDED,
106         AMD_PSTATE_MAX,
107 };
108
109 static const char * const amd_pstate_mode_string[] = {
110         [AMD_PSTATE_UNDEFINED]   = "undefined",
111         [AMD_PSTATE_DISABLE]     = "disable",
112         [AMD_PSTATE_PASSIVE]     = "passive",
113         [AMD_PSTATE_ACTIVE]      = "active",
114         [AMD_PSTATE_GUIDED]      = "guided",
115         NULL,
116 };
117 #endif /* _LINUX_AMD_PSTATE_H */