Documentation/hwmon/yogafan.rst

Source file repositories/reference/linux-study-clean/Documentation/hwmon/yogafan.rst

File Facts

System
Linux kernel
Corpus path
Documentation/hwmon/yogafan.rst
Extension
.rst
Size
6271 bytes
Lines
139
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

.. SPDX-License-Identifier: GPL-2.0-only

===============================================================================================
Kernel driver yogafan
===============================================================================================

Supported chips:

  * Lenovo Yoga, Legion, IdeaPad, Slim, Flex, and LOQ Embedded Controllers
  * Prefix: 'yogafan'
  * Addresses: ACPI handle (See Database Below)

Author: Sergio Melas <sergiomelas@gmail.com>

Description
-----------

This driver provides fan speed monitoring for modern Lenovo consumer laptops.
Most Lenovo laptops do not provide fan tachometer data through standard
ISA/LPC hardware monitoring chips. Instead, the data is stored in the
Embedded Controller (EC) and exposed via ACPI.

The driver implements a **Rate-Limited Lag (RLLag)** filter to handle
the low-resolution and jittery sampling found in Lenovo EC firmware.

Hardware Identification and Multiplier Logic
--------------------------------------------

The driver supports two distinct EC architectures. Differentiation is handled
deterministically via a DMI Product Family quirk table during the probe phase,
eliminating the need for runtime heuristics.

1. 8-bit EC Architecture (Multiplier: 100)

   - **Families:** Yoga, IdeaPad, Slim, Flex.
   - **Technical Detail:** These models allocate a single 8-bit register for
     tachometer data. Since 8-bit fields are limited to a value of 255, the
     BIOS stores fan speed in units of 100 RPM (e.g., 42 = 4200 RPM).

2. 16-bit EC Architecture (Multiplier: 1)

   - **Families:** Legion, LOQ.
   - **Technical Detail:** High-performance gaming models require greater
     precision for fans exceeding 6000 RPM. These use a 16-bit word (2 bytes)
     storing the raw RPM value directly.

Filter Details
--------------

The RLLag filter is a passive discrete-time first-order lag model that ensures:
  - **Smoothing:** Low-resolution step increments are smoothed into 1-RPM increments.
  - **Slew-Rate Limiting:** Prevents unrealistic readings by capping the change
    to 1500 RPM/s, matching physical fan inertia.
  - **Polling Independence:** The filter math scales based on the time delta
    between userspace reads, ensuring a consistent physical curve regardless
    of polling frequency.

Suspend and Resume
------------------

The driver utilizes the boottime clock (ktime_get_boottime()) to calculate the
sampling delta. This ensures that time spent in system suspend is accounted
for. If the delta exceeds 5 seconds (e.g., after waking the laptop), the
filter automatically resets to the current hardware value to prevent
reporting "ghost" RPM data from before the sleep state.

Usage
-----

The driver exposes standard hwmon sysfs attributes:

Annotation

Implementation Notes