This is a Linux kernel HWMON driver for the Lunar 2-in-1 Mini PC, providing:
- Fan speed monitoring and control
- LED control for keyboard indicators (L1 and L2)
make clean
make
sudo make installTo install:
sudo make dkmsTo remove:
sudo make dkms_clean- The module does not provide a real version number, so
git describe --longis used to create one. This means that anything that changes the git state will change the version.make dkms_cleanshould be run before making a commit or an update withgit pullas the Makefile is currently unable to track the last installed version to replace it. If this doesn't happen, the old version will need to be manually removed from dkms, before installing the updated module. Something likedkms remove -m lunar -v <old version> --all, followed byrm -rf /usr/src/lunar-<old version>, should do.dkms status -m lunarcan be used to list the installed versions.
- Read fan RPM via EC register values
- Control fan speed in automatic/manual modes
- Expose fan control and telemetry via
hwmoninterface - LED brightness control for keyboard indicators through
ledssubsystem
The driver communicates with the EC using LPC IO ports:
- Configuration addresses at
0x4E(address) and0x4F(data) - Addressing EC RAM using custom protocols via
D2ADR/D2DATIO ports
Handles low-level read/write to EC RAM using mutex-protected access:
ec_ram_read(uint16_t address)ec_ram_write(uint16_t address, uint8_t data)
-
Data exposed via
hwmonandthermal_cooling_deviceAPIs -
PWM values scaled between EC range (0-184) and hwmon (0-200)
-
Supports three modes:
- Off
- Manual (user-defined PWM)
- Auto (firmware-controlled)
- Two LEDs (L1 and L2) controlled by writing to EC
- State maintained in memory due to lack of readable EC brightness register
Exposes the following attributes:
-
/sys/class/hwmon/hwmonX/fan1_input– current fan speed (RPM) -
/sys/class/hwmon/hwmonX/pwm1– fan speed setting (0-255) -
/sys/class/hwmon/hwmonX/pwm1_enable– fan mode:- 0 = Off (control off, speed 100%)
- 1 = Manual
- 2 = Automatic
Exposes standard LED class entries:
/sys/class/leds/L1/brightness- (0 off, 1-255 on)/sys/class/leds/L2/brightness- (0 off, 1-255 on)
Ensures driver only loads on supported hardware:
static const struct dmi_system_id lunar_dmi_table[] __initconst = {
LUNAR_DMI_MATCH_VND("SU", "ARB33P"),
{ }
};| Register | Address (hex) | Description |
|---|---|---|
| PNPCFG_ADDR | 0x4E | EC address port |
| PNPCFG_DATA | 0x4F | EC data port |
| D2ADR | 0x2E | EC indirect address register |
| D2DAT | 0x2F | EC indirect data register |
| I2EC_ADDR_L | 0x10 | EC RAM address low byte |
| I2EC_ADDR_H | 0x11 | EC RAM address high byte |
| I2EC_DATA | 0x12 | EC RAM data access |
| FAN_TACHO_ADDR_H | 0x0218 | Fan speed high byte |
| FAN_TACHO_ADDR_L | 0x0219 | Fan speed low byte |
| FAN_PWM_ADDR | 0x1809 | PWM duty cycle |
| FAN_MODE_ADDR | 0x0F02 | Fan control mode |
| L1 LED Address | 0x04A0 | L1 keyboard LED control |
| L2 LED Address | 0x04A1 | L2 keyboard LED control |
GPL-2.0-or-later
Rafal Goslawski rafal.goslawski@gmail.com