diff options
Diffstat (limited to 'tools/power/cpupower/utils/helpers/amd.c')
-rw-r--r-- | tools/power/cpupower/utils/helpers/amd.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index 6437ef39aeea..5fd5c5b8c7b8 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c | |||
@@ -26,6 +26,15 @@ union msr_pstate { | |||
26 | unsigned res3:21; | 26 | unsigned res3:21; |
27 | unsigned en:1; | 27 | unsigned en:1; |
28 | } bits; | 28 | } bits; |
29 | struct { | ||
30 | unsigned fid:8; | ||
31 | unsigned did:6; | ||
32 | unsigned vid:8; | ||
33 | unsigned iddval:8; | ||
34 | unsigned idddiv:2; | ||
35 | unsigned res1:30; | ||
36 | unsigned en:1; | ||
37 | } fam17h_bits; | ||
29 | unsigned long long val; | 38 | unsigned long long val; |
30 | }; | 39 | }; |
31 | 40 | ||
@@ -35,6 +44,8 @@ static int get_did(int family, union msr_pstate pstate) | |||
35 | 44 | ||
36 | if (family == 0x12) | 45 | if (family == 0x12) |
37 | t = pstate.val & 0xf; | 46 | t = pstate.val & 0xf; |
47 | else if (family == 0x17) | ||
48 | t = pstate.fam17h_bits.did; | ||
38 | else | 49 | else |
39 | t = pstate.bits.did; | 50 | t = pstate.bits.did; |
40 | 51 | ||
@@ -44,16 +55,20 @@ static int get_did(int family, union msr_pstate pstate) | |||
44 | static int get_cof(int family, union msr_pstate pstate) | 55 | static int get_cof(int family, union msr_pstate pstate) |
45 | { | 56 | { |
46 | int t; | 57 | int t; |
47 | int fid, did; | 58 | int fid, did, cof; |
48 | 59 | ||
49 | did = get_did(family, pstate); | 60 | did = get_did(family, pstate); |
50 | 61 | if (family == 0x17) { | |
51 | t = 0x10; | 62 | fid = pstate.fam17h_bits.fid; |
52 | fid = pstate.bits.fid; | 63 | cof = 200 * fid / did; |
53 | if (family == 0x11) | 64 | } else { |
54 | t = 0x8; | 65 | t = 0x10; |
55 | 66 | fid = pstate.bits.fid; | |
56 | return (100 * (fid + t)) >> did; | 67 | if (family == 0x11) |
68 | t = 0x8; | ||
69 | cof = (100 * (fid + t)) >> did; | ||
70 | } | ||
71 | return cof; | ||
57 | } | 72 | } |
58 | 73 | ||
59 | /* Needs: | 74 | /* Needs: |