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