Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpupower: Add AMD P-State sysfs definition and access helper

Introduce the marco definitions and access helper function for
AMD P-State sysfs interfaces such as each performance goals and frequency
levels in amd helper file. They will be used to read the sysfs attribute
from AMD P-State cpufreq driver for cpupower utilities.

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Huang Rui and committed by
Shuah Khan
33e43f36 4a06806e

+30
+30
tools/power/cpupower/utils/helpers/amd.c
··· 8 8 #include <pci/pci.h> 9 9 10 10 #include "helpers/helpers.h" 11 + #include "cpufreq.h" 12 + #include "acpi_cppc.h" 11 13 14 + /* ACPI P-States Helper Functions for AMD Processors ***************/ 12 15 #define MSR_AMD_PSTATE_STATUS 0xc0010063 13 16 #define MSR_AMD_PSTATE 0xc0010064 14 17 #define MSR_AMD_PSTATE_LIMIT 0xc0010061 ··· 149 146 pci_cleanup(pci_acc); 150 147 return 0; 151 148 } 149 + 150 + /* ACPI P-States Helper Functions for AMD Processors ***************/ 151 + 152 + /* AMD P-State Helper Functions ************************************/ 153 + enum amd_pstate_value { 154 + AMD_PSTATE_HIGHEST_PERF, 155 + AMD_PSTATE_MAX_FREQ, 156 + AMD_PSTATE_LOWEST_NONLINEAR_FREQ, 157 + MAX_AMD_PSTATE_VALUE_READ_FILES, 158 + }; 159 + 160 + static const char *amd_pstate_value_files[MAX_AMD_PSTATE_VALUE_READ_FILES] = { 161 + [AMD_PSTATE_HIGHEST_PERF] = "amd_pstate_highest_perf", 162 + [AMD_PSTATE_MAX_FREQ] = "amd_pstate_max_freq", 163 + [AMD_PSTATE_LOWEST_NONLINEAR_FREQ] = "amd_pstate_lowest_nonlinear_freq", 164 + }; 165 + 166 + static unsigned long amd_pstate_get_data(unsigned int cpu, 167 + enum amd_pstate_value value) 168 + { 169 + return cpufreq_get_sysfs_value_from_table(cpu, 170 + amd_pstate_value_files, 171 + value, 172 + MAX_AMD_PSTATE_VALUE_READ_FILES); 173 + } 174 + 175 + /* AMD P-State Helper Functions ************************************/ 152 176 #endif /* defined(__i386__) || defined(__x86_64__) */