Skip to content

Commit 33e43f3

Browse files
huangruishuahkh
authored andcommitted
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>
1 parent 4a06806 commit 33e43f3

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

  • tools/power/cpupower/utils/helpers

tools/power/cpupower/utils/helpers/amd.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
#include <pci/pci.h>
99

1010
#include "helpers/helpers.h"
11+
#include "cpufreq.h"
12+
#include "acpi_cppc.h"
1113

14+
/* ACPI P-States Helper Functions for AMD Processors ***************/
1215
#define MSR_AMD_PSTATE_STATUS 0xc0010063
1316
#define MSR_AMD_PSTATE 0xc0010064
1417
#define MSR_AMD_PSTATE_LIMIT 0xc0010061
@@ -146,4 +149,31 @@ int amd_pci_get_num_boost_states(int *active, int *states)
146149
pci_cleanup(pci_acc);
147150
return 0;
148151
}
152+
153+
/* ACPI P-States Helper Functions for AMD Processors ***************/
154+
155+
/* AMD P-State Helper Functions ************************************/
156+
enum amd_pstate_value {
157+
AMD_PSTATE_HIGHEST_PERF,
158+
AMD_PSTATE_MAX_FREQ,
159+
AMD_PSTATE_LOWEST_NONLINEAR_FREQ,
160+
MAX_AMD_PSTATE_VALUE_READ_FILES,
161+
};
162+
163+
static const char *amd_pstate_value_files[MAX_AMD_PSTATE_VALUE_READ_FILES] = {
164+
[AMD_PSTATE_HIGHEST_PERF] = "amd_pstate_highest_perf",
165+
[AMD_PSTATE_MAX_FREQ] = "amd_pstate_max_freq",
166+
[AMD_PSTATE_LOWEST_NONLINEAR_FREQ] = "amd_pstate_lowest_nonlinear_freq",
167+
};
168+
169+
static unsigned long amd_pstate_get_data(unsigned int cpu,
170+
enum amd_pstate_value value)
171+
{
172+
return cpufreq_get_sysfs_value_from_table(cpu,
173+
amd_pstate_value_files,
174+
value,
175+
MAX_AMD_PSTATE_VALUE_READ_FILES);
176+
}
177+
178+
/* AMD P-State Helper Functions ************************************/
149179
#endif /* defined(__i386__) || defined(__x86_64__) */

0 commit comments

Comments
 (0)