diff options
author | Jean Delvare <khali@linux-fr.org> | 2005-07-31 15:52:01 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-09-05 12:14:22 -0400 |
commit | 303760b44a7a142cb9f4c9df4609fb63bbda98db (patch) | |
tree | 8097f99cd993bc005b25e14a5690770b6e351195 /include/linux/hwmon-vid.h | |
parent | f4b50261207c987913f076d867c2e154d71fd012 (diff) |
[PATCH] hwmon: hwmon vs i2c, second round (07/11)
The only part left in i2c-sensor is the VRM/VRD/VID handling code.
This is in no way related to i2c, so it doesn't belong there. Move
the code to hwmon, where it belongs.
Note that not all hardware monitoring drivers do VRM/VRD/VID
operations, so less drivers depend on hwmon-vid than there were
depending on i2c-sensor.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/hwmon-vid.h')
-rw-r--r-- | include/linux/hwmon-vid.h | 112 |
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 | |||
54 | int vid_which_vrm(void); | ||
55 | |||
56 | #define DEFAULT_VRM 82 | ||
57 | |||
58 | static 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 | |||
102 | static 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 | } | ||