// SPDX-License-Identifier: GPL-2.0-or-later /* * hwmon-vid.c - VID/VRM/VRD voltage conversions * * Copyright (c) 2004 Rudolf Marek <r.marek@assembler.cz> * * Partly imported from i2c-vid.h of the lm_sensors project * Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> * With assistance from Trent Piepho <xyzzy@speakeasy.org>
*/
/* * vrm is the VRM/VRD document version multiplied by 10. * val is the 4-bit or more VID code. * Returned value is in mV to avoid floating point in the kernel. * Some VID have some bits in uV scale, this is rounded to mV.
*/ int vid_from_reg(int val, u8 vrm)
{ int vid;
switch (vrm) {
case100: /* VRD 10.0 */ /* compute in uV, round to mV */
val &= 0x3f; if ((val & 0x1f) == 0x1f) return0; if ((val & 0x1f) <= 0x09 || val == 0x0a)
vid = 1087500 - (val & 0x1f) * 25000; else
vid = 1862500 - (val & 0x1f) * 25000; if (val & 0x20)
vid -= 12500; return (vid + 500) / 1000;
case110: /* Intel Conroe */ /* compute in uV, round to mV */
val &= 0xff; if (val < 0x02 || val > 0xb2) return0; return (1600000 - (val - 2) * 6250 + 500) / 1000;
/* * The stepping_to parameter is highest acceptable stepping for current line. * The model match must be exact for 4-bit values. For model values 0x10 * and above (extended model), all models below the parameter will match.
*/
staticstruct vrm_model vrm_models[] = {
{X86_VENDOR_AMD, 0x6, 0x0, ANY, ANY, 90}, /* Athlon Duron etc */
{X86_VENDOR_AMD, 0xF, 0x0, 0x3F, ANY, 24}, /* Athlon 64, Opteron */ /* * In theory, all NPT family 0Fh processors have 6 VID pins and should * thus use vrm 25, however in practice not all mainboards route the * 6th VID pin because it is never needed. So we use the 5 VID pin * variant (vrm 24) for the models which exist today.
*/
{X86_VENDOR_AMD, 0xF, 0x40, 0x7F, ANY, 24}, /* NPT family 0Fh */
{X86_VENDOR_AMD, 0xF, 0x80, ANY, ANY, 25}, /* future fam. 0Fh */
{X86_VENDOR_AMD, 0x10, 0x0, ANY, ANY, 25}, /* NPT family 10h */
{X86_VENDOR_AMD, 0x11, 0x0, ANY, ANY, 26}, /* family 11h */
{X86_VENDOR_AMD, 0x12, 0x0, ANY, ANY, 26}, /* family 12h */
{X86_VENDOR_AMD, 0x14, 0x0, ANY, ANY, 26}, /* family 14h */
{X86_VENDOR_AMD, 0x15, 0x0, ANY, ANY, 26}, /* family 15h */
/* * Special case for VIA model D: there are two different possible * VID tables, so we have to figure out first, which one must be * used. This resolves temporary drm value 134 to 14 (Intel Core * 7-bit VID), 13 (Pentium M 6-bit VID) or 131 (Pentium M 6-bit VID * + quirk for Eden ULV 500 MHz). * Note: something similar might be needed for model A, I'm not sure.
*/ static u8 get_via_model_d_vrm(void)
{ unsignedint vid, brand, __maybe_unused dummy; staticconstchar *brands[4] = { "C7-M", "C7", "Eden", "C7-D"
};
if (vid > 0x3f) {
pr_info("Using %d-bit VID table for VIA %s CPU\n", 7, brands[brand]); return14;
} else {
pr_info("Using %d-bit VID table for VIA %s CPU\n", 6, brands[brand]); /* Enable quirk for Eden */ return brand == 2 ? 131 : 13;
}
}
for (i = 0; i < ARRAY_SIZE(vrm_models); i++) { if (vendor == vrm_models[i].vendor &&
family == vrm_models[i].family &&
model >= vrm_models[i].model_from &&
model <= vrm_models[i].model_to &&
stepping <= vrm_models[i].stepping_to) return vrm_models[i].vrm_type;
}
if (c->x86 < 6) /* Any CPU with family lower than 6 */ return0; /* doesn't have VID */
vrm_ret = find_vrm(c->x86, c->x86_model, c->x86_stepping, c->x86_vendor); if (vrm_ret == 134)
vrm_ret = get_via_model_d_vrm(); if (vrm_ret == 0)
pr_info("Unknown VRM version of your x86 CPU\n"); return vrm_ret;
}
/* and now for something completely different for the non-x86 world */ #else
u8 vid_which_vrm(void)
{
pr_info("Unknown VRM version of your CPU\n"); return0;
} #endif
EXPORT_SYMBOL(vid_which_vrm);
MODULE_AUTHOR("Rudolf Marek <r.marek@assembler.cz>");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.