Expand description
ACPI thermal management : temperature reading and fan control.
On Lenovo ThinkPads (X13, T14, etc.), the Embedded Controller (EC) exposes temperature sensors and fan control registers at known offsets. This driver reads the CPU temperature and controls the fan via the EC.
§ThinkPad EC register map (verified for X13 Gen 1/2)
| Register | Description |
|---|---|
| 0x78 | CPU temperature (°C, unsigned) |
| 0x79 | GPU temperature (°C, unsigned) |
| 0x7A | Battery temperature (°C) |
| 0x93 | Fan control: bit 0 = enable, |
| bits 1–7 = speed level (0=max) | |
| 0x94 | Fan speed (RPM, 16-bit LE) |
| 0x84 | EC query: thermal event |
Structs§
- Thermal
State - Thermal state snapshot, read atomically from EC registers.
Enums§
- FanSpeed
- Fan speed levels for the ThinkPad manual fan control. Level 0 = maximum speed, 7 = off. The EC uses an inverted scale.
Constants§
- EC_
REG_ 🔒FAN_ CTRL - EC register: fan control byte.
- EC_
REG_ 🔒FAN_ SPEED - EC register: fan speed in RPM (16-bit little-endian).
- EC_
REG_ 🔒TEMP_ BAT - EC register: battery temperature in degrees Celsius.
- EC_
REG_ 🔒TEMP_ CPU - EC register: CPU temperature in degrees Celsius.
- EC_
REG_ 🔒TEMP_ GPU - EC register: GPU temperature in degrees Celsius.
- FAN_
MAX_ 🔒THRESHOLD - FAN_
OFF_ 🔒THRESHOLD - FAN_
ON_ 🔒THRESHOLD - Temperature thresholds for fan control (in °C).
Statics§
- AUTO_
FAN_ 🔒CONTROL - Whether automatic fan control is enabled.
- LAST_
CPU_ 🔒TEMP - Last read CPU temperature (for quick non-locking access).
- LAST_
FAN_ 🔒RPM - Last read fan RPM (for quick non-locking access).
- THERMAL_
INITIALIZED 🔒 - Whether thermal management is initialized.
- THERMAL_
STATE 🔒 - Latest thermal snapshot (updated by periodic polling).
Functions§
- auto_
fan_ 🔒control - Automatic fan control logic based on CPU temperature.
- cpu_
temperature - Get the last known CPU temperature (lock-free).
- dump_
status - Dump thermal status to serial console.
- fan_rpm
- Get the last known fan RPM (lock-free).
- init
- Initialize the thermal subsystem.
- poll
- Update the cached thermal state. Call periodically (e.g., from timer tick).
- read_
thermal_ state - Read the current thermal state from EC registers.
- set_
auto_ fan_ control - Enable automatic fan control based on CPU temperature.
- set_
fan_ enabled - Enable or disable the fan entirely.
- set_
fan_ speed - Set the fan to a specific speed level.