1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2022 Advanced Micro Devices, Inc. 4 * 5 * Author: Meng Li <li.meng@amd.com> 6 */ 7 8 #ifndef _LINUX_AMD_PSTATE_H 9 #define _LINUX_AMD_PSTATE_H 10 11 #include <linux/pm_qos.h> 12 13 /********************************************************************* 14 * AMD P-state INTERFACE * 15 *********************************************************************/ 16 /** 17 * struct amd_aperf_mperf 18 * @aperf: actual performance frequency clock count 19 * @mperf: maximum performance frequency clock count 20 * @tsc: time stamp counter 21 */ 22 struct amd_aperf_mperf { 23 u64 aperf; 24 u64 mperf; 25 u64 tsc; 26 }; 27 28 /** 29 * struct amd_cpudata - private CPU data for AMD P-State 30 * @cpu: CPU number 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 44 * priority. 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_cached: Cached CPPC energy-performance preference value 61 * @policy: Cpufreq policy value 62 * @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value 63 * 64 * The amd_cpudata is key private data for each CPU thread in AMD P-State, and 65 * represents all the attributes and goals that AMD P-State requests at runtime. 66 */ 67 struct amd_cpudata { 68 int cpu; 69 70 struct freq_qos_request req[2]; 71 u64 cppc_req_cached; 72 73 u32 highest_perf; 74 u32 nominal_perf; 75 u32 lowest_nonlinear_perf; 76 u32 lowest_perf; 77 u32 prefcore_ranking; 78 u32 min_limit_perf; 79 u32 max_limit_perf; 80 u32 min_limit_freq; 81 u32 max_limit_freq; 82 83 u32 max_freq; 84 u32 min_freq; 85 u32 nominal_freq; 86 u32 lowest_nonlinear_freq; 87 88 struct amd_aperf_mperf cur; 89 struct amd_aperf_mperf prev; 90 91 u64 freq; 92 bool boost_supported; 93 bool hw_prefcore; 94 95 /* EPP feature related attributes*/ 96 s16 epp_cached; 97 u32 policy; 98 u64 cppc_cap1_cached; 99 bool suspended; 100 s16 epp_default; 101 }; 102 103 /* 104 * enum amd_pstate_mode - driver working mode of amd pstate 105 */ 106 enum amd_pstate_mode { 107 AMD_PSTATE_UNDEFINED = 0, 108 AMD_PSTATE_DISABLE, 109 AMD_PSTATE_PASSIVE, 110 AMD_PSTATE_ACTIVE, 111 AMD_PSTATE_GUIDED, 112 AMD_PSTATE_MAX, 113 }; 114 const char *amd_pstate_get_mode_string(enum amd_pstate_mode mode); 115 int amd_pstate_update_status(const char *buf, size_t size); 116 117 #endif /* _LINUX_AMD_PSTATE_H */ 118