Skip to main content

Split Fan Sensor Backlight Driver: Intel Mac SMC Code Undergoes Modernization Overhaul

Hardware support for Intel Macs on the Linux platform is about to receive a low-level upgrade. Developer Atharva Tiwari has submitted 14 RFC patches to the kernel mailing list.

He plans to use the macsmc driver framework developed for Apple Silicon to completely replace the long-serving applesmc driver, giving Intel Macs' SMC support the same level of modularity as M-series chips.

拆分风扇传感器背光驱动 Intel Mac SMC代码迎来现代化重构

The issue with the applesmc driver lies in its outdated architecture. It crams fan control, temperature sensors, light sensors, motion sensors, and keyboard backlighting into a single file, using a unique communication method that makes the code difficult to extend and results in high costs for adapting to new models.

Since the SMC works essentially the same way on Intel Macs and Apple Silicon, with differences only in the communication path with the chip, this provides a foundation for code reuse.

The first step of the patch set is architectural splitting. The macsmc driver is divided into a generic core and backend layers. The RTKit communication code originally prepared for Apple Silicon is moved into a separate backend, while a new ACPI backend designed specifically for Intel Macs is added. This backend supports traditional I/O ports, MMIO, and interrupt-driven completion mechanisms, capabilities that applesmc lacks.

Building on this, the originally bloated monolithic driver has been split into multiple small drivers with single responsibilities, all using standard kernel interfaces.

New additions include an SMC-based watchdog driver that can reset the machine when the system becomes unresponsive; light and acceleration sensor drivers under the IIO framework; and a keyboard backlight LED driver. RTC, power supply, and hwmon have also received dedicated support for Intel Macs.

Power management has also been taken over again. On Intel Macs with macsmc-power enabled, the kernel actively disables acpi-sbs as well as ACPI battery and adapter drivers to avoid duplicate devices from the old and new mechanisms.

The hwmon part also adds data types commonly used on Intel Macs, such as signed fixed-point numbers, solving the problem where the old driver could not read certain SMC key values.

The author has completed testing on several Intel models, including MacBook Pro 16,1, iMac 20,1, MacBook Air 4,2, MacBook Pro 12,1, and MacBook Pro 15,1. Only the motion sensor driver remains unverified due to the lack of corresponding hardware.

Currently, this series is submitted as an RFC (Request for Comments) to first gather feedback from maintainers on the architectural direction. The testing scope will be expanded later, and it will be resubmitted as formal patches.