diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/i2c/i2c-sensor-vid.c |
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/i2c/i2c-sensor-vid.c')
-rw-r--r-- | drivers/i2c/i2c-sensor-vid.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-sensor-vid.c b/drivers/i2c/i2c-sensor-vid.c new file mode 100644 index 00000000000..922e22f054b --- /dev/null +++ b/drivers/i2c/i2c-sensor-vid.c | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
2 | i2c-sensor-vid.c - Part of lm_sensors, Linux kernel modules for hardware | ||
3 | monitoring | ||
4 | |||
5 | Copyright (c) 2004 Rudolf Marek <r.marek@sh.cvut.cz> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include <linux/config.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/kernel.h> | ||
25 | |||
26 | struct vrm_model { | ||
27 | u8 vendor; | ||
28 | u8 eff_family; | ||
29 | u8 eff_model; | ||
30 | int vrm_type; | ||
31 | }; | ||
32 | |||
33 | #define ANY 0xFF | ||
34 | |||
35 | #ifdef CONFIG_X86 | ||
36 | |||
37 | static struct vrm_model vrm_models[] = { | ||
38 | {X86_VENDOR_AMD, 0x6, ANY, 90}, /* Athlon Duron etc */ | ||
39 | {X86_VENDOR_AMD, 0xF, ANY, 24}, /* Athlon 64, Opteron */ | ||
40 | {X86_VENDOR_INTEL, 0x6, 0x9, 85}, /* 0.13um too */ | ||
41 | {X86_VENDOR_INTEL, 0x6, 0xB, 85}, /* 0xB Tualatin */ | ||
42 | {X86_VENDOR_INTEL, 0x6, ANY, 82}, /* any P6 */ | ||
43 | {X86_VENDOR_INTEL, 0x7, ANY, 0}, /* Itanium */ | ||
44 | {X86_VENDOR_INTEL, 0xF, 0x3, 100}, /* P4 Prescott */ | ||
45 | {X86_VENDOR_INTEL, 0xF, ANY, 90}, /* P4 before Prescott */ | ||
46 | {X86_VENDOR_INTEL, 0x10,ANY, 0}, /* Itanium 2 */ | ||
47 | {X86_VENDOR_UNKNOWN, ANY, ANY, 0} /* stop here */ | ||
48 | }; | ||
49 | |||
50 | static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor) | ||
51 | { | ||
52 | int i = 0; | ||
53 | |||
54 | while (vrm_models[i].vendor!=X86_VENDOR_UNKNOWN) { | ||
55 | if (vrm_models[i].vendor==vendor) | ||
56 | if ((vrm_models[i].eff_family==eff_family)&& \ | ||
57 | ((vrm_models[i].eff_model==eff_model)|| \ | ||
58 | (vrm_models[i].eff_model==ANY))) | ||
59 | return vrm_models[i].vrm_type; | ||
60 | i++; | ||
61 | } | ||
62 | |||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | int i2c_which_vrm(void) | ||
67 | { | ||
68 | struct cpuinfo_x86 *c = cpu_data; | ||
69 | u32 eax; | ||
70 | u8 eff_family, eff_model; | ||
71 | int vrm_ret; | ||
72 | |||
73 | if (c->x86 < 6) return 0; /* any CPU with familly lower than 6 | ||
74 | dont have VID and/or CPUID */ | ||
75 | eax = cpuid_eax(1); | ||
76 | eff_family = ((eax & 0x00000F00)>>8); | ||
77 | eff_model = ((eax & 0x000000F0)>>4); | ||
78 | if (eff_family == 0xF) { /* use extended model & family */ | ||
79 | eff_family += ((eax & 0x00F00000)>>20); | ||
80 | eff_model += ((eax & 0x000F0000)>>16)<<4; | ||
81 | } | ||
82 | vrm_ret = find_vrm(eff_family,eff_model,c->x86_vendor); | ||
83 | if (vrm_ret == 0) | ||
84 | printk(KERN_INFO "i2c-sensor.o: Unknown VRM version of your" | ||
85 | " x86 CPU\n"); | ||
86 | return vrm_ret; | ||
87 | } | ||
88 | |||
89 | /* and now for something completely different for Non-x86 world*/ | ||
90 | #else | ||
91 | int i2c_which_vrm(void) | ||
92 | { | ||
93 | printk(KERN_INFO "i2c-sensor.o: Unknown VRM version of your CPU\n"); | ||
94 | return 0; | ||
95 | } | ||
96 | #endif | ||
97 | |||
98 | EXPORT_SYMBOL(i2c_which_vrm); | ||