Skip to main content

Module thermal

Module thermal 

Source
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)

RegisterDescription
0x78CPU temperature (°C, unsigned)
0x79GPU temperature (°C, unsigned)
0x7ABattery temperature (°C)
0x93Fan control: bit 0 = enable,
bits 1–7 = speed level (0=max)
0x94Fan speed (RPM, 16-bit LE)
0x84EC query: thermal event

Structs§

ThermalState
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.