aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/hwmon-vid.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/hwmon-vid.h')
-rw-r--r--include/linux/hwmon-vid.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/include/linux/hwmon-vid.h b/include/linux/hwmon-vid.h
new file mode 100644
index 000000000000..c45cd872c55e
--- /dev/null
+++ b/include/linux/hwmon-vid.h
@@ -0,0 +1,112 @@
1/*
2 hwmon-vid.h - VID/VRM/VRD voltage conversions
3
4 Originally part of lm_sensors
5 Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
6 With assistance from Trent Piepho <xyzzy@speakeasy.org>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21*/
22
23/*
24 This file contains common code for decoding VID pins.
25 This file is #included in various chip drivers in this directory.
26 As the user is unlikely to load more than one driver which
27 includes this code we don't worry about the wasted space.
28 Reference: VRM x.y DC-DC Converter Design Guidelines,
29 available at http://developer.intel.com
30*/
31
32/*
33 AMD Opteron processors don't follow the Intel VRM spec.
34 I'm going to "make up" 2.4 as the VRM spec for the Opterons.
35 No good reason just a mnemonic for the 24x Opteron processor
36 series
37
38 Opteron VID encoding is:
39
40 00000 = 1.550 V
41 00001 = 1.525 V
42 . . . .
43 11110 = 0.800 V
44 11111 = 0.000 V (off)
45 */
46
47/*
48 Legal val values 0x00 - 0x1f; except for VRD 10.0, 0x00 - 0x3f.
49 vrm is the Intel VRM document version.
50 Note: vrm version is scaled by 10 and the return value is scaled by 1000
51 to avoid floating point in the kernel.
52*/
53
54int vid_which_vrm(void);
55
56#define DEFAULT_VRM 82
57
58static inline int vid_from_reg(int val, int vrm)
59{
60 int vid;
61
62 switch(vrm) {
63
64 case 0:
65 return 0;
66
67 case 100: /* VRD 10.0 */
68 if((val & 0x1f) == 0x1f)
69 return 0;
70 if((val & 0x1f) <= 0x09 || val == 0x0a)
71 vid = 10875 - (val & 0x1f) * 250;
72 else
73 vid = 18625 - (val & 0x1f) * 250;
74 if(val & 0x20)
75 vid -= 125;
76 vid /= 10; /* only return 3 dec. places for now */
77 return vid;
78
79 case 24: /* Opteron processor */
80 return(val == 0x1f ? 0 : 1550 - val * 25);
81
82 case 91: /* VRM 9.1 */
83 case 90: /* VRM 9.0 */
84 return(val == 0x1f ? 0 :
85 1850 - val * 25);
86
87 case 85: /* VRM 8.5 */
88 return((val & 0x10 ? 25 : 0) +
89 ((val & 0x0f) > 0x04 ? 2050 : 1250) -
90 ((val & 0x0f) * 50));
91
92 case 84: /* VRM 8.4 */
93 val &= 0x0f;
94 /* fall through */
95 default: /* VRM 8.2 */
96 return(val == 0x1f ? 0 :
97 val & 0x10 ? 5100 - (val) * 100 :
98 2050 - (val) * 50);
99 }
100}
101
102static inline int vid_to_reg(int val, int vrm)
103{
104 switch (vrm) {
105 case 91: /* VRM 9.1 */
106 case 90: /* VRM 9.0 */
107 return ((val >= 1100) && (val <= 1850) ?
108 ((18499 - val * 10) / 25 + 5) / 10 : -1);
109 default:
110 return -1;
111 }
112}