Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 16706
b: refs/heads/master
c: 734a12a
h: refs/heads/master
v: v3
  • Loading branch information
Rudolf Marek authored and Greg Kroah-Hartman committed Jan 6, 2006
1 parent e1c1a4f commit 5f30ed7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 99d855602c1d7968ca6b6cc99b773b0b47909690
refs/heads/master: 734a12a36676ad3b9418fa5a829c518afec02b8a
69 changes: 42 additions & 27 deletions trunk/drivers/hwmon/hwmon-vid.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,22 @@
. . . .
11110 = 0.800 V
11111 = 0.000 V (off)
The 17 specification is in fact Intel Mobile Voltage Positioning -
(IMVP-II). You can find more information in the datasheet of Max1718
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452
*/

/* vrm is the VRM/VRD document version multiplied by 10.
val is the 4-, 5- or 6-bit VID code.
Returned value is in mV to avoid floating point in the kernel. */
int vid_from_reg(int val, int vrm)
int vid_from_reg(int val, u8 vrm)
{
int vid;

switch(vrm) {

case 0:
return 0;

case 100: /* VRD 10.0 */
if((val & 0x1f) == 0x1f)
return 0;
Expand Down Expand Up @@ -91,10 +93,16 @@ int vid_from_reg(int val, int vrm)
case 84: /* VRM 8.4 */
val &= 0x0f;
/* fall through */
default: /* VRM 8.2 */
case 82: /* VRM 8.2 */
return(val == 0x1f ? 0 :
val & 0x10 ? 5100 - (val) * 100 :
2050 - (val) * 50);
case 17: /* Intel IMVP-II */
return(val & 0x10 ? 975 - (val & 0xF) * 25 :
1750 - val * 50);
default: /* report 0 for unknown */
printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n");
return 0;
}
}

Expand All @@ -108,72 +116,79 @@ struct vrm_model {
u8 vendor;
u8 eff_family;
u8 eff_model;
int vrm_type;
u8 eff_stepping;
u8 vrm_type;
};

#define ANY 0xFF

#ifdef CONFIG_X86

/* the stepping parameter is highest acceptable stepping for current line */

static struct vrm_model vrm_models[] = {
{X86_VENDOR_AMD, 0x6, ANY, 90}, /* Athlon Duron etc */
{X86_VENDOR_AMD, 0xF, ANY, 24}, /* Athlon 64, Opteron */
{X86_VENDOR_INTEL, 0x6, 0x9, 85}, /* 0.13um too */
{X86_VENDOR_INTEL, 0x6, 0xB, 85}, /* Tualatin */
{X86_VENDOR_INTEL, 0x6, ANY, 82}, /* any P6 */
{X86_VENDOR_INTEL, 0x7, ANY, 0}, /* Itanium */
{X86_VENDOR_INTEL, 0xF, 0x0, 90}, /* P4 */
{X86_VENDOR_INTEL, 0xF, 0x1, 90}, /* P4 Willamette */
{X86_VENDOR_INTEL, 0xF, 0x2, 90}, /* P4 Northwood */
{X86_VENDOR_INTEL, 0xF, 0x3, 100}, /* P4 Prescott */
{X86_VENDOR_INTEL, 0xF, 0x4, 100}, /* P4 Prescott */
{X86_VENDOR_INTEL, 0x10,ANY, 0}, /* Itanium 2 */
{X86_VENDOR_UNKNOWN, ANY, ANY, 0} /* stop here */
{X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */
{X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */
{X86_VENDOR_INTEL, 0x6, 0x9, ANY, 85}, /* 0.13um too */
{X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */
{X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */
{X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */
{X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */
{X86_VENDOR_INTEL, 0xF, 0x1, ANY, 90}, /* P4 Willamette */
{X86_VENDOR_INTEL, 0xF, 0x2, ANY, 90}, /* P4 Northwood */
{X86_VENDOR_INTEL, 0xF, ANY, ANY, 100}, /* Prescott and above assume VRD 10 */
{X86_VENDOR_INTEL, 0x10, ANY, ANY, 0}, /* Itanium 2 */
{X86_VENDOR_CENTAUR, 0x6, 0x7, ANY, 85}, /* Eden ESP/Ezra */
{X86_VENDOR_CENTAUR, 0x6, 0x8, 0x7, 85}, /* Ezra T */
{X86_VENDOR_CENTAUR, 0x6, 0x9, 0x7, 85}, /* Nemiah */
{X86_VENDOR_CENTAUR, 0x6, 0x9, ANY, 17}, /* C3-M */
{X86_VENDOR_UNKNOWN, ANY, ANY, ANY, 0} /* stop here */
};

static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor)
static u8 find_vrm(u8 eff_family, u8 eff_model, u8 eff_stepping, u8 vendor)
{
int i = 0;

while (vrm_models[i].vendor!=X86_VENDOR_UNKNOWN) {
if (vrm_models[i].vendor==vendor)
if ((vrm_models[i].eff_family==eff_family)
&& ((vrm_models[i].eff_model==eff_model) ||
(vrm_models[i].eff_model==ANY)))
(vrm_models[i].eff_model==ANY)) &&
(eff_stepping <= vrm_models[i].eff_stepping))
return vrm_models[i].vrm_type;
i++;
}

return 0;
}

int vid_which_vrm(void)
u8 vid_which_vrm(void)
{
struct cpuinfo_x86 *c = cpu_data;
u32 eax;
u8 eff_family, eff_model;
int vrm_ret;
u8 eff_family, eff_model, eff_stepping, vrm_ret;

if (c->x86 < 6) /* Any CPU with family lower than 6 */
return 0; /* doesn't have VID and/or CPUID */

eax = cpuid_eax(1);
eff_family = ((eax & 0x00000F00)>>8);
eff_model = ((eax & 0x000000F0)>>4);
eff_stepping = eax & 0xF;
if (eff_family == 0xF) { /* use extended model & family */
eff_family += ((eax & 0x00F00000)>>20);
eff_model += ((eax & 0x000F0000)>>16)<<4;
}
vrm_ret = find_vrm(eff_family,eff_model,c->x86_vendor);
vrm_ret = find_vrm(eff_family, eff_model, eff_stepping, c->x86_vendor);
if (vrm_ret == 0)
printk(KERN_INFO "hwmon-vid: Unknown VRM version of your "
"x86 CPU\n");
return vrm_ret;
}

/* and now something completely different for the non-x86 world */
/* and now for something completely different for the non-x86 world */
#else
int vid_which_vrm(void)
u8 vid_which_vrm(void)
{
printk(KERN_INFO "hwmon-vid: Unknown VRM version of your CPU\n");
return 0;
Expand Down
6 changes: 3 additions & 3 deletions trunk/include/linux/hwmon-vid.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
#ifndef _LINUX_HWMON_VID_H
#define _LINUX_HWMON_VID_H

int vid_from_reg(int val, int vrm);
int vid_which_vrm(void);
int vid_from_reg(int val, u8 vrm);
u8 vid_which_vrm(void);

/* vrm is the VRM/VRD document version multiplied by 10.
val is in mV to avoid floating point in the kernel.
Returned value is the 4-, 5- or 6-bit VID code.
Note that only VRM 9.x is supported for now. */
static inline int vid_to_reg(int val, int vrm)
static inline int vid_to_reg(int val, u8 vrm)
{
switch (vrm) {
case 91: /* VRM 9.1 */
Expand Down

0 comments on commit 5f30ed7

Please sign in to comment.