diff -urN oldtree/Documentation/ibm-acpi.txt newtree/Documentation/ibm-acpi.txt --- oldtree/Documentation/ibm-acpi.txt 2006-10-05 15:26:55.000000000 -0400 +++ newtree/Documentation/ibm-acpi.txt 2006-10-06 18:13:00.000000000 -0400 @@ -398,25 +398,44 @@ Most ThinkPads include six or more separate temperature sensors but only expose the CPU temperature through the standard ACPI methods. -This feature shows readings from up to eight different sensors. Some -readings may not be valid, e.g. may show large negative values. For -example, on the X40, a typical output may be: +This feature shows readings from up to eight different sensors on older +ThinkPads, and up to sixteen different sensors on newer ThinkPads. +Readings from sensors that are not available return -128. +No commands can be written to this file. + +For example, on the X40, a typical output may be: temperatures: 42 42 45 41 36 -128 33 -128 -Thomas Gruber took his R51 apart and traced all six active sensors in -his laptop (the location of sensors may vary on other models): +On the T43/p, a typical output may be: +temperatures: 48 48 36 52 38 -128 31 -128 48 52 48 -128 -128 -128 -128 -128 + +The mapping of thermal sensors to physical locations varies depending on +system-board model (and thus, on ThinkPad model). + +http://thinkwiki.org/wiki/Thermal_Sensors is a public wiki page that +tries to track down these locations for various models. + +Most (newer?) models seem to follow this pattern: 1: CPU -2: Mini PCI Module -3: HDD 4: GPU -5: Battery -6: N/A -7: Battery -8: N/A +5: Main battery: main sensor +6: Bay battery: main sensor +7: Main battery: secondary sensor +8: Bay battery: secondary sensor + +For the R51 (source: Thomas Gruber): +2: Mini-PCI +3: Internal HDD + +For the T43, T43/p (source: Shmidoax/Thinkwiki.org) +2: System board, left side (near PCMCIA slot), reported as HDAPS temp +3: PCMCIA slot +9: MCH (northbridge) to DRAM Bus +10: ICH (southbridge), under Mini-PCI card, under touchpad +11: Power regulator, underside of system board, below F2 key -No commands can be written to this file. EXPERIMENTAL: Embedded controller reigster dump -- /proc/acpi/ibm/ecdump ------------------------------------------------------------------------ diff -urN oldtree/drivers/acpi/ibm_acpi.c newtree/drivers/acpi/ibm_acpi.c --- oldtree/drivers/acpi/ibm_acpi.c 2006-10-06 18:12:37.000000000 -0400 +++ newtree/drivers/acpi/ibm_acpi.c 2006-10-06 18:13:00.000000000 -0400 @@ -79,6 +79,7 @@ #include #include #include +#include #include #include @@ -218,6 +219,14 @@ #define IBM_HKEY_HID "IBM0068" #define IBM_PCI_HID "PNP0A03" +enum thermal_support_mode { + IBMACPI_THERMAL_NONE = 0, /* No thermal support */ + IBMACPI_THERMAL_ACPI_TMP07, /* Use ACPI functions (older ECs) */ + IBMACPI_THERMAL_TPEC, /* Use EC registers through ACPI EC access */ +}; + +static int ibm_thinkpad_ec_found; + struct ibm_struct { char *name; char param[32]; @@ -1278,16 +1287,25 @@ return 1; } -static int thermal_tmp_supported; +static enum thermal_support_mode thermal_tmp_supported; static int thermal_updt_supported; static int thermal_init(void) { - /* temperatures not supported on 570, G4x, R30, R31, R32 */ - thermal_tmp_supported = acpi_evalf(ec_handle, NULL, "TMP7", "qv"); + if (ibm_thinkpad_ec_found) { + /* Direct EC access mode: faster and max + * 16 sensors in newer models */ + thermal_tmp_supported = IBMACPI_THERMAL_TPEC; + } else if (acpi_evalf(ec_handle, NULL, "TMP7", "qv")) { + /* Standard ACPI TMPx access, max 8 sensors */ + thermal_tmp_supported = IBMACPI_THERMAL_ACPI_TMP07; - /* 600e/x, 770e, 770x */ - thermal_updt_supported = acpi_evalf(ec_handle, NULL, "UPDT", "qv"); + /* 600e/x, 770e, 770x */ + thermal_updt_supported = acpi_evalf(ec_handle, NULL, "UPDT", "qv"); + } else { + /* temperatures not supported on 570, G4x, R30, R31, R32 */ + thermal_tmp_supported = IBMACPI_THERMAL_NONE; + } return 0; } @@ -1295,14 +1313,27 @@ static int thermal_read(char *p) { int len = 0; + int i, t, n; + s8 tmp[16]; + char tmpi[] = "TMPi"; + + len += sprintf(p + len, "temperatures:\t"); + + switch(thermal_tmp_supported) { + case IBMACPI_THERMAL_TPEC: + /* EC thermal registers: 0x78-7F, 0xC0-C7 */ + t = 0; + for (i = 0; i < 8; i++) { + if (!acpi_ec_read(0x78 + i, &tmp[i])) + return -EIO; + if (!acpi_ec_read(0xC0 + i, &tmp[i+8])) + return -EIO; + t |= tmp[i+8]; + } + n = (t != 0) ? 16 : 8; + break; - if (!thermal_tmp_supported) - len += sprintf(p + len, "temperatures:\tnot supported\n"); - else { - int i, t; - char tmpi[] = "TMPi"; - s8 tmp[8]; - + case IBMACPI_THERMAL_ACPI_TMP07: if (thermal_updt_supported) if (!acpi_evalf(ec_handle, NULL, "UPDT", "v")) return -EIO; @@ -1316,12 +1347,21 @@ else tmp[i] = t; } + n = 8; + break; - len += sprintf(p + len, - "temperatures:\t%d %d %d %d %d %d %d %d\n", - tmp[0], tmp[1], tmp[2], tmp[3], - tmp[4], tmp[5], tmp[6], tmp[7]); + case IBMACPI_THERMAL_NONE: + default: + len += sprintf(p + len, "not supported"); + n = 0; + } + + i = 0; + while (n > 0) { + len += sprintf(p + len, "%d ", tmp[i++]); + n--; } + len += sprintf(p + len, "\n"); return len; } @@ -2011,6 +2051,16 @@ remove_proc_entry(IBM_DIR, acpi_root_dir); } +static int __init check_dmi_for_ec(void) +{ + struct dmi_device *dev = NULL; + while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) { + if (strstr(dev->name, "IBM ThinkPad Embedded Controller")) + return 1; + } + return 0; +} + static int __init acpi_ibm_init(void) { int ret, i; @@ -2030,6 +2080,9 @@ return -ENODEV; } + /* Models with newer firmware report the EC in DMI */ + ibm_thinkpad_ec_found = check_dmi_for_ec(); + /* these handles are not required */ IBM_HANDLE_INIT(vid); IBM_HANDLE_INIT(vid2);