Skip to content

Add LenovoYogaEC module - #117

Open
dragosbas wants to merge 1 commit into
namazso:mainfrom
dragosbas:lenovo-yoga-ec
Open

dragosbas wants to merge 1 commit into
namazso:mainfrom
dragosbas:lenovo-yoga-ec

Conversation

@dragosbas

Copy link
Copy Markdown

Adds a module for Lenovo Yoga laptops that expose the EC fan mailbox at IO ports 0x5C0/0x5C4.

Hardware

Verified on a Yoga Pro 9 16IMH9 (83DN), BIOS NKCN35WW, Core Ultra 9 185H.

The mailbox is declared in the DSDT:

OperationRegion(CMDA, SystemIO, 0x05C0, 0x05)
  X5C0 = data, X5C4 = command/status
Method MBEY(cmd, sub, arg) - write X5C4/X5C0, wait IBE/OBE/OBF, read X5C0
cmd sub arg effect
0xEF 0x61 / 0x62 0-100 set fan 1 / fan 2
0xEF 0x63 0x01 / 0x02 read fan 1 / fan 2
0xEF 0x63 0x03 restore EC automatic mode

Reply is 0xAC on success, 0xFA if unsupported. Probing sub 0x63 with args 0x00-0x13 shows only 0x01-0x03 are implemented; there are no temperature sensors behind this mailbox.

Why this is needed

LENOVO_FAN_METHOD and LENOVO_GAMEZONE_DATA exist in the MOF on these machines but have no instances - Lenovo ships the Legion MOF on Yoga without implementing the ACPI methods - so LenovoLegionToolkit and similar tools do not work here. The mailbox is the only interface available.

Existing Yoga fan control tools drive it through WinRing0, which is what this module is meant to replace.

The firmware fan curve is the practical motivation: under an all-core load it holds the fans at 26% with the package at 78-81 C. Forcing 45% drops the package about 4 C and the hottest core about 8 C within 20 seconds.

Scope

Command is fixed at 0xEF and both ports are hardcoded, so no general purpose port IO is exposed. Subcommand and argument are validated. The whole handshake runs inside the module, which also keeps the user mode side to a single ioctl per operation instead of roughly ten port accesses.

Compiles clean with pawncc LenovoYogaEC.p -iinclude -C64 -;+ -(+ -p.

Note on testing

The ioctl path could not be exercised end to end, because the official signed driver only loads modules signed by the project. The protocol itself is the one in use on this machine through WinRing0, byte for byte, and is confirmed working there.

🤖 Generated with Claude Code

https://claude.ai/code/session_014hPSWGJHRXbqXYFhoWe5Et

Fan control for Lenovo Yoga laptops that expose the EC mailbox at IO
0x5C0/0x5C4 (DSDT method MBEY). Verified on a Yoga Pro 9 16IMH9 (83DN),
BIOS NKCN35WW.

The Lenovo WMI classes (LENOVO_FAN_METHOD, LENOVO_GAMEZONE_DATA) are
present in the MOF on these machines but have no instances, so the
mailbox is the only interface available. Replaces WinRing0 usage in
existing Yoga fan control tools.

Only command 0xEF is accepted and both ports are fixed, so no general
purpose port IO is exposed. The full mailbox handshake runs in the
module, which keeps the user mode side to one ioctl per operation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014hPSWGJHRXbqXYFhoWe5Et
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant