|
| 1 | +.. SPDX-License-Identifier: GPL-2.0-only |
| 2 | +=============================================================================================== |
| 3 | +Kernel driver yogafan |
| 4 | +=============================================================================================== |
| 5 | + |
| 6 | +Supported chips: |
| 7 | + |
| 8 | + * Lenovo Yoga, Legion, IdeaPad, Slim, Flex, and LOQ Embedded Controllers |
| 9 | + Prefix: 'yogafan' |
| 10 | + Addresses: ACPI handle (See Database Below) |
| 11 | + |
| 12 | +Author: Sergio Melas <sergiomelas@gmail.com> |
| 13 | + |
| 14 | +Description |
| 15 | +----------- |
| 16 | + |
| 17 | +This driver provides fan speed monitoring for modern Lenovo consumer laptops. |
| 18 | +Most Lenovo laptops do not provide fan tachometer data through standard |
| 19 | +ISA/LPC hardware monitoring chips. Instead, the data is stored in the |
| 20 | +Embedded Controller (EC) and exposed via ACPI. |
| 21 | + |
| 22 | +The driver implements a **Rate-Limited Lag (RLLag)** filter to handle |
| 23 | +the low-resolution and jittery sampling found in Lenovo EC firmware. |
| 24 | + |
| 25 | +Hardware Identification and Multiplier Logic |
| 26 | +-------------------------------------------- |
| 27 | + |
| 28 | +The driver supports two distinct EC architectures. Differentiation is handled |
| 29 | +deterministically via a DMI Product Family quirk table during the probe phase, |
| 30 | +eliminating the need for runtime heuristics. |
| 31 | + |
| 32 | +1. 8-bit EC Architecture (Multiplier: 100) |
| 33 | + - **Families:** Yoga, IdeaPad, Slim, Flex. |
| 34 | + - **Technical Detail:** These models allocate a single 8-bit register for |
| 35 | + tachometer data. Since 8-bit fields are limited to a value of 255, the |
| 36 | + BIOS stores fan speed in units of 100 RPM (e.g., 42 = 4200 RPM). |
| 37 | + |
| 38 | +2. 16-bit EC Architecture (Multiplier: 1) |
| 39 | + - **Families:** Legion, LOQ. |
| 40 | + - **Technical Detail:** High-performance gaming models require greater |
| 41 | + precision for fans exceeding 6000 RPM. These use a 16-bit word (2 bytes) |
| 42 | + storing the raw RPM value directly. |
| 43 | + |
| 44 | +Filter Details: |
| 45 | +--------------- |
| 46 | + |
| 47 | +The RLLag filter is a passive discrete-time first-order lag model that ensures: |
| 48 | + - **Smoothing:** Low-resolution step increments are smoothed into 1-RPM increments. |
| 49 | + - **Slew-Rate Limiting:** Prevents unrealistic readings by capping the change |
| 50 | + to 1500 RPM/s, matching physical fan inertia. |
| 51 | + - **Polling Independence:** The filter math scales based on the time delta |
| 52 | + between userspace reads, ensuring a consistent physical curve regardless |
| 53 | + of polling frequency. |
| 54 | + |
| 55 | +Suspend and Resume |
| 56 | +------------------ |
| 57 | + |
| 58 | +The driver utilizes the boottime clock (ktime_get_boottime()) to calculate the |
| 59 | +sampling delta. This ensures that time spent in system suspend is accounted |
| 60 | +for. If the delta exceeds 5 seconds (e.g., after waking the laptop), the |
| 61 | +filter automatically resets to the current hardware value to prevent |
| 62 | +reporting "ghost" RPM data from before the sleep state. |
| 63 | + |
| 64 | +Usage |
| 65 | +----- |
| 66 | + |
| 67 | +The driver exposes standard hwmon sysfs attributes: |
| 68 | +Attribute Description |
| 69 | +fanX_input Filtered fan speed in RPM. |
| 70 | + |
| 71 | + |
| 72 | +Note: If the hardware reports 0 RPM, the filter is bypassed and 0 is reported |
| 73 | +immediately to ensure the user knows the fan has stopped. |
| 74 | + |
| 75 | + |
| 76 | +==================================================================================================== |
| 77 | + LENOVO FAN CONTROLLER: MASTER REFERENCE DATABASE (2026) |
| 78 | +==================================================================================================== |
| 79 | + |
| 80 | +MODEL (DMI PN) | FAMILY / SERIES | EC OFFSET | FULL ACPI OBJECT PATH | WIDTH | MULTiplier |
| 81 | +---------------------------------------------------------------------------------------------------- |
| 82 | +82N7 | Yoga 14cACN | 0x06 | \_SB.PCI0.LPC0.EC0.FANS | 8-bit | 100 |
| 83 | +80V2 / 81C3 | Yoga 710/720 | 0x06 | \_SB.PCI0.LPC0.EC0.FAN0 | 8-bit | 100 |
| 84 | +83E2 / 83DN | Yoga Pro 7/9 | 0xFE | \_SB.PCI0.LPC0.EC0.FANS | 8-bit | 100 |
| 85 | +82A2 / 82A3 | Yoga Slim 7 | 0x06 | \_SB.PCI0.LPC0.EC0.FANS | 8-bit | 100 |
| 86 | +81YM / 82FG | IdeaPad 5 | 0x06 | \_SB.PCI0.LPC0.EC0.FAN0 | 8-bit | 100 |
| 87 | +82JW / 82JU | Legion 5 (AMD) | 0xFE/0xFF | \_SB.PCI0.LPC0.EC0.FANS (Fan1) | 16-bit | 1 |
| 88 | +82JW / 82JU | Legion 5 (AMD) | 0xFE/0xFF | \_SB.PCI0.LPC0.EC0.FA2S (Fan2) | 16-bit | 1 |
| 89 | +82WQ | Legion 7i (Int) | 0xFE/0xFF | \_SB.PCI0.LPC0.EC0.FANS (Fan1) | 16-bit | 1 |
| 90 | +82WQ | Legion 7i (Int) | 0xFE/0xFF | \_SB.PCI0.LPC0.EC0.FA2S (Fan2) | 16-bit | 1 |
| 91 | +82XV / 83DV | LOQ 15/16 | 0xFE/0xFF | \_SB.PCI0.LPC0.EC0.FANS /FA2S | 16-bit | 1 |
| 92 | +83AK | ThinkBook G6 | 0x06 | \_SB.PCI0.LPC0.EC0.FAN0 | 8-bit | 100 |
| 93 | +81X1 | Flex 5 | 0x06 | \_SB.PCI0.LPC0.EC0.FAN0 | 8-bit | 100 |
| 94 | +*Legacy* | Pre-2020 Models | 0x06 | \_SB.PCI0.LPC.EC.FAN0 | 8-bit | 100 |
| 95 | +---------------------------------------------------------------------------------------------------- |
| 96 | + |
| 97 | +METHODOLOGY & IDENTIFICATION: |
| 98 | + |
| 99 | +1. DSDT ANALYSIS (THE PATH): |
| 100 | + BIOS ACPI tables were analyzed using 'iasl' and cross-referenced with |
| 101 | + public dumps. Internal labels (FANS, FAN0, FA2S) are mapped to |
| 102 | + EmbeddedControl OperationRegion offsets. |
| 103 | + |
| 104 | +2. EC MEMORY MAPPING (THE OFFSET): |
| 105 | + Validated by matching NBFC (NoteBook FanControl) XML logic with DSDT Field |
| 106 | + definitions found in BIOS firmware. |
| 107 | + |
| 108 | +3. DATA-WIDTH ANALYSIS (THE MULTIPLIER): |
| 109 | + - 8-bit (Multiplier 100): Standard for Yoga/IdeaPad. Raw values (0-255). |
| 110 | + - 16-bit (Multiplier 1): Standard for Legion/LOQ. Two registers (0xFE/0xFF). |
| 111 | + |
| 112 | + |
| 113 | +References |
| 114 | +---------- |
| 115 | + |
| 116 | +1. **ACPI Specification (Field Objects):** Documentation on how 8-bit vs 16-bit |
| 117 | + fields are accessed in OperationRegions. |
| 118 | + https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#field-objects |
| 119 | + |
| 120 | +2. **NBFC Projects:** Community-driven reverse engineering |
| 121 | + of Lenovo Legion/LOQ EC memory maps (16-bit raw registers). |
| 122 | + https://github.com/hirschmann/nbfc/tree/master/Configs |
| 123 | + |
| 124 | +3. **Linux Kernel Timekeeping API:** Documentation for ktime_get_boottime() and |
| 125 | + handling deltas across suspend states. |
| 126 | + https://www.kernel.org/doc/html/latest/core-api/timekeeping.html |
| 127 | + |
| 128 | +4. **Lenovo IdeaPad Laptop Driver:** Reference for DMI-based hardware |
| 129 | + feature gating in Lenovo laptops. |
| 130 | + https://github.com/torvalds/linux/blob/master/drivers/platform/x86/ideapad-laptop.c |
0 commit comments