i2c-sensor-vid.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. i2c-sensor-vid.c - Part of lm_sensors, Linux kernel modules for hardware
  3. monitoring
  4. Copyright (c) 2004 Rudolf Marek <r.marek@sh.cvut.cz>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. #include <linux/config.h>
  18. #include <linux/module.h>
  19. #include <linux/kernel.h>
  20. struct vrm_model {
  21. u8 vendor;
  22. u8 eff_family;
  23. u8 eff_model;
  24. int vrm_type;
  25. };
  26. #define ANY 0xFF
  27. #ifdef CONFIG_X86
  28. static struct vrm_model vrm_models[] = {
  29. {X86_VENDOR_AMD, 0x6, ANY, 90}, /* Athlon Duron etc */
  30. {X86_VENDOR_AMD, 0xF, ANY, 24}, /* Athlon 64, Opteron */
  31. {X86_VENDOR_INTEL, 0x6, 0x9, 85}, /* 0.13um too */
  32. {X86_VENDOR_INTEL, 0x6, 0xB, 85}, /* 0xB Tualatin */
  33. {X86_VENDOR_INTEL, 0x6, ANY, 82}, /* any P6 */
  34. {X86_VENDOR_INTEL, 0x7, ANY, 0}, /* Itanium */
  35. {X86_VENDOR_INTEL, 0xF, 0x3, 100}, /* P4 Prescott */
  36. {X86_VENDOR_INTEL, 0xF, ANY, 90}, /* P4 before Prescott */
  37. {X86_VENDOR_INTEL, 0x10,ANY, 0}, /* Itanium 2 */
  38. {X86_VENDOR_UNKNOWN, ANY, ANY, 0} /* stop here */
  39. };
  40. static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor)
  41. {
  42. int i = 0;
  43. while (vrm_models[i].vendor!=X86_VENDOR_UNKNOWN) {
  44. if (vrm_models[i].vendor==vendor)
  45. if ((vrm_models[i].eff_family==eff_family)&& \
  46. ((vrm_models[i].eff_model==eff_model)|| \
  47. (vrm_models[i].eff_model==ANY)))
  48. return vrm_models[i].vrm_type;
  49. i++;
  50. }
  51. return 0;
  52. }
  53. int i2c_which_vrm(void)
  54. {
  55. struct cpuinfo_x86 *c = cpu_data;
  56. u32 eax;
  57. u8 eff_family, eff_model;
  58. int vrm_ret;
  59. if (c->x86 < 6) return 0; /* any CPU with familly lower than 6
  60. dont have VID and/or CPUID */
  61. eax = cpuid_eax(1);
  62. eff_family = ((eax & 0x00000F00)>>8);
  63. eff_model = ((eax & 0x000000F0)>>4);
  64. if (eff_family == 0xF) { /* use extended model & family */
  65. eff_family += ((eax & 0x00F00000)>>20);
  66. eff_model += ((eax & 0x000F0000)>>16)<<4;
  67. }
  68. vrm_ret = find_vrm(eff_family,eff_model,c->x86_vendor);
  69. if (vrm_ret == 0)
  70. printk(KERN_INFO "i2c-sensor.o: Unknown VRM version of your"
  71. " x86 CPU\n");
  72. return vrm_ret;
  73. }
  74. /* and now for something completely different for Non-x86 world*/
  75. #else
  76. int i2c_which_vrm(void)
  77. {
  78. printk(KERN_INFO "i2c-sensor.o: Unknown VRM version of your CPU\n");
  79. return 0;
  80. }
  81. #endif
  82. EXPORT_SYMBOL(i2c_which_vrm);