ibm-acpi: extend thermal sensor support for new ThinkPads with 9+ sensors
Subsystems (3)
cover ibm-acpi: extend thermal sensor support for new ThinkPads with 9+ sensors
Hello Borislav,
This patch series extends ibm-acpi thermal support for ThinkPads that support up to 16 sensors in firmware. It also refactors some of the ibm-acpi thermal sensor code to make it easier to extend and read.
The functionality in this patch has been tested by subscribers of the linux-thinkpad mailinglist in different forms for quite a while, now. Many users were using ecdump directly to work around the lack of 16 sensor support in stock ibm-acpi, which is highly suboptimal and not nearly as safe.
One of the patches in the series is already merged in -mm. It is a patch which has been accepted by Pavel Machek (http://lkml.org/lkml/2006/8/2/89)
and Andrew Morton, and it is in 2.6.18-mm1. This patch is used to safely detect a new enough EC firmware through a DMI match. I have included it in the series for ease of testing and merging in linux-acpi.
Please apply.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
PATCH 1/3 ibm-acpi: Use a enum to select the thermal sensor reading strategy
This patch consolidades all decisions regarding the strategy to be used to read thinkpad thermal sensors into a single enum, and refactors the thermal sensor reading code to use a much more readable (and easier to extend) switch() construct.
--- drivers/acpi/ibm_acpi.c | 71 +++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 25 deletions(-)
drivers/acpi/ibm_acpi.c +46 -25
@@ -216,6 +216,12 @@ IBM_HANDLE(sfan, ec, "SFAN", /* 570 */#define IBM_HKEY_HID "IBM0068"#define IBM_PCI_HID "PNP0A03" +enum thermal_access_mode { +IBMACPI_THERMAL_NONE =0 ,/* No thermal support */ +IBMACPI_THERMAL_ACPI_TMP07 ,/* Use ACPI TMP0-7 */ +IBMACPI_THERMAL_ACPI_UPDT ,/* Use ACPI TMP0-7 with UPDT */ +}; +struct ibm_struct {char *name;char param[32 ];
@@ -1272,16 +1278,22 @@ static int acpi_ec_write(int i, u8 v)return 1 ; } -static int thermal_tmp_supported; -static int thermal_updt_supported; +static enum thermal_access_mode thermal_read_mode;static int thermal_init (void ) { -/* temperatures not supported on 570, G4x, R30, R31, R32 */ - thermal_tmp_supported =acpi_evalf (ec_handle,NULL ,"TMP7" ,"qv" ); - -/* 600e/x, 770e, 770x */ - thermal_updt_supported =acpi_evalf (ec_handle,NULL ,"UPDT" ,"qv" ); +if (acpi_evalf (ec_handle,NULL ,"TMP7" ,"qv" )) { +if (acpi_evalf (ec_handle,NULL ,"UPDT" ,"qv" )) { +/* 600e/x, 770e, 770x */ + thermal_read_mode =IBMACPI_THERMAL_ACPI_UPDT ; + }else { +/* Standard ACPI TMPx access, max 8 sensors */ + thermal_read_mode =IBMACPI_THERMAL_ACPI_TMP07 ; + } + }else { +/* temperatures not supported on 570, G4x, R30, R31, R32 */ + thermal_read_mode =IBMACPI_THERMAL_NONE ; + }return 0 ; }
@@ -1289,34 +1301,43 @@ static int thermal_init(void)static int thermal_read (char *p) {int len =0 ; - -if (!thermal_tmp_supported) - len +=sprintf (p + len,"temperatures:\tnot supported\n" ); -else { -int i, t; -char tmpi[] ="TMPi" ; -s8 tmp[8 ]; - -if (thermal_updt_supported) -if (!acpi_evalf (ec_handle,NULL ,"UPDT" ,"v" )) +int i, t; +s8 tmp[8 ]; +char tmpi[] ="TMPi" ; + + len +=sprintf (p + len,"temperatures:\t" ); + +switch (thermal_read_mode) { +case IBMACPI_THERMAL_ACPI_UPDT : +if (!acpi_evalf (ec_handle,NULL ,"UPDT" ,"v" )) +return -EIO ; +for (i =0 ; i <8 ; i++) { + tmpi[3 ] ='0' + i; +if (!acpi_evalf (ec_handle, &t, tmpi,"d" ))return -EIO ; + tmp[i] = (t -2732 +5 ) /10 ; + } +break ; +case IBMACPI_THERMAL_ACPI_TMP07 :for (i =0 ; i <8 ; i++) { tmpi[3 ] ='0' + i;if (!acpi_evalf (ec_handle, &t, tmpi,"d" ))return -EIO ; -if (thermal_updt_supported) - tmp[i] = (t -2732 +5 ) /10 ; -else - tmp[i] = t; + tmp[i] = t; } +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" ); +return len; } +for (i =0 ; i <7 ; i++) + len +=sprintf (p + len,"%d " , tmp[i]); + len +=sprintf (p + len,"%d\n" , tmp[i]); +return len; }
--
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
PATCH 2/3 dmi_scan: this teaches dmi_decode() how to decode and save OEM Strings
In reply to Henrique de Moraes HolschuhThis teaches dmi_decode() how to decode and save OEM Strings (type 11) DMI information, which is currently discarded silently. Existing code using DMI is not affected. Follows the "System Management BIOS (SMBIOS) Specification" (http://www.dmtf.org/standards/smbios), and also the userspace dmidecode.c code.
OEM Strings are the only safe way to identify some hardware, e.g., the ThinkPad embedded controller used by the soon-to-be-submitted tp_smapi driver. This will also let us eliminate the long whitelist in the mainline hdaps driver (in a future patch).
---
This patch is in 2.6.18-mm1.
drivers/firmware/dmi_scan.c | 23 +++++++++++++++++++++++ include/linux/dmi.h | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-)
drivers/firmware/dmi_scan.c renamed from drivers/firmware/dmi_scan.c~dmi-decode-and-save-oem-string-information +23 -0
@@ -123,6 +123,26 @@ static void __init dmi_save_devices(stru dev->type = *d++ &0x7f ; dev->name =dmi_string (dm, *d); dev->device_data =NULL ; +list_add (&dev->list, &dmi_devices); + } +} + +static void __init dmi_save_oem_strings_devices (struct dmi_header *dm) +{ +int i, count = *(u8 *)(dm +1 ); +struct dmi_device *dev; + +for (i =1 ; i <= count; i++) { + dev =dmi_alloc (sizeof (*dev)); +if (!dev) { +printk (KERN_ERR +"dmi_save_oem_strings_devices: out of memory.\n" ); +break ; + } + + dev->type =DMI_DEV_TYPE_OEM_STRING ; + dev->name =dmi_string (dm, i); + dev->device_data =NULL ;list_add (&dev->list, &dmi_devices); }
@@ -181,6 +201,9 @@ static void __init dmi_decode(struct dmicase 10 :/* Onboard Devices Information */ dmi_save_devices (dm);break ; +case 11 :/* OEM Strings */ +dmi_save_oem_strings_devices (dm); +break ;case 38 :/* IPMI Device Information */ dmi_save_ipmi_device (dm); }
include/linux/dmi.h renamed from include/linux/dmi.h~dmi-decode-and-save-oem-string-information +2 -1
@@ -27,7 +27,8 @@ enum dmi_device_type {DMI_DEV_TYPE_ETHERNET ,DMI_DEV_TYPE_TOKENRING ,DMI_DEV_TYPE_SOUND , -DMI_DEV_TYPE_IPMI =-1 +DMI_DEV_TYPE_IPMI =-1 , +DMI_DEV_TYPE_OEM_STRING =-2 }; struct dmi_header {
_
--
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
PATCH 3/3 ibm-acpi: Implement direct-ec-access thermal reading modes for up to 16 sensors
In reply to Henrique de Moraes HolschuhThis patch extends ibm-acpi to support reading thermal sensors directly through ACPI EC register access. It uses a DMI match to detect ThinkPads with a new-style embedded controller, that are known to have forward- compatible register maps and use 0x00 to fill in non-used registers and export thermal sensors at EC offsets 0x78-7F and 0xC0-C7.
Direct ACPI EC register access is implemented for 8-sensor and 16-sensor new-style ThinkPad controller firmwares as an experimental feature. The code does some limited sanity checks on the temperatures read through EC access, and will default to the old ACPI TMP0-7 mode if anything is amiss.
Userspace ABI is not changed for 8 sensors, but /proc/acpi/ibm/thermal is extended for 16 sensors if the firmware supports 16 sensors.
A documentation update is also provided.
---
This patch depends on dmi-decode-and-save-oem-string-information.patch from the 2.6.18-mm1 tree.
The information about the ThinkPad register map was determined by studying ibm-acpi "ecdump" output from various ThinkPad models, submitted by subscribers of the linux-thinkpad mailinglist. Futher information was gathered from the DSDT tables, as they describe the EC register map in recent ThinkPads.
DSDT source shows that TMP0-7 access and direct register access are actually the same thing on these firmwares, but unfortunately IBM never did update their DSDT EC register map to export TMP8-TMP15 for the second range of sensors.
Documentation/ibm-acpi.txt | 55 ++++++++++++++++++++------ drivers/acpi/ibm_acpi.c | 94 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 133 insertions(+), 16 deletions(-)
Documentation/ibm-acpi.txt +43 -12
@@ -430,25 +430,56 @@ Temperature sensors -- /proc/acpi/ibm/th 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 it has experimental support for 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. + +EXPERIMENTAL: The 16-sensors feature is marked EXPERIMENTAL because the +implementation directly accesses hardware registers and may not work as +expected. USE WITH CAUTION! To use this feature, you need to supply the +experimental=1 parameter when loading the module. When EXPERIMENTAL +mode is enabled, reading the first 8 sensors on newer ThinkPads will +also use an new experimental thermal sensor access mode. + +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): +EXPERIMENTAL: 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 +2: (depends on model) +3: (depends on model) 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 +9-15: (depends on model) + +For the R51 (source: Thomas Gruber): +2: Mini-PCI +3: Internal HDD + +For the T43, T43/p (source: Shmidoax/Thinkwiki.org) +http://thinkwiki.org/wiki/Image:T43-thermal-sensors.jpg +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 ------------------------------------------------------------------------
drivers/acpi/ibm_acpi.c +90 -4
155 lines not on this page · raw message
--
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh