mafredri / asustor-platform-driver

Linux kernel platform driver for ASUSTOR NAS hardware (leds, buttons)
GNU General Public License v3.0
62 stars 9 forks source link
asustor button buttons led leds linux linux-kernel-driver linux-kernel-module

asustor-platform-driver

Linux kernel platform driver for ASUSTOR NAS hardware (leds, buttons).

On many systems, ASUSTOR uses a mix of IT87 and CPU GPIOs to control leds and buttons. Adding support for more systems should be fairly trivial, but may require some reverse engineering to figure out which GPIOs are responsible for what.

WARNING: Changing GPIO input/outputs (as done by this module) without knowledge of their effects can be dangerous and lead to instability, corrupted data or a broken system. Use at your own risk.

Dependencies

Note: The following dependencies from the mainline linux kernel are required, if they're not included by your distribution you may need to compile them yourself (note that some modules are only required on specific ASUSTOR models):

Optional

Compatibility

Features

Installation

git clone https://github.com/mafredri/asustor-platform-driver
cd asustor-platform-driver
make
sudo make install

Tips

Control blinking LEDs with it87

Note: This is probably not supported on all devices, only ones that use the IT8625E or IT8720F chips or similar.

Switch off that annoying blinking of the green status LED:

echo 0 | sudo tee /sys/devices/platform/asustor_it87.*/hwmon/hwmon*/gpled1_blink

You can re-enable it with echo 47 | sudo tee ... because the status led is it87_gp47. You can also make other GPIO LEDs blink by using their GP number instead of 47. Note that this could even be done for two LEDs, as gpled2_blink also exists.

If you want the green status LED to be constantly on (without blinking), the following should work, if gpled1_blink is still 47:

echo 11 | sudo tee /sys/devices/platform/asustor_it87.*/hwmon/hwmon*/gpled1_blink_freq

Or, if you set gpled1_blink to 0 (or to another LED), you can switch on the status LED with:

echo 1 | sudo tee /sys/class/leds/green\:status/brightness

You can also configure the blinking frequency to one of 11 supported modes, for example, set mode 3 with:

echo 3 | sudo tee /sys/devices/platform/asustor_it87.*/hwmon/hwmon*/gpled1_blink_freq

The following blinking frequency modes exist on the IT8625:

Other chips also support blinking control, but might support fewer modes. If blink frequency setting is supported at all, mode 11 (always on) should always work, and setting the other modes won't break anything, but might have differing frequencies than described above (and setting modes 8-10 will automatically set mode 0 instead).

Mode 11 for "always on" should always work, at least the bit set there was listed in all datasheets I checked (unfortunately, its function was never described in detail).

Set triggers for LEDs

Linux allows controlling LEDs with "triggers", which means that they will blink on specific events. By default, the trigger is "none" (which means "always on") for most LEDs, but there are others that you may enable (likely in a script that's run after boot), for example:

# make green USB LED blink on USB traffic
echo usb-host > /sys/class/leds/green\:usb/trigger
# make LAN led light up if the first network link is up:
echo r8169-0-200:00:link > /sys/class/leds/blue\:lan

cat /sys/class/leds/green\:usb/trigger will list the available triggers, with the currently used one being marked with square brackes (e.g. [none] kbd-scrolllock kbd-numlock kbd-capslock ...).

it87 and PWM polarity

This project includes a patched version of the it87 module that is part of mainline kernel (asustor-it87). It skips PWM sanity checks for the fan because ASUSTOR firmware correctly initializes fans in active low polarity and can be used straight with fancontrol or similar tools.

Note that it87 conflicts with asustor-it87, you may wish to add it87 to the module blocklist or explicitly load asustor-it87 instead.

You may want to use patches/001-ignore-pwm-polarity-it87.patch for the it87 kernel module if it complains about PWM polarity. In this case, it's possible to use fix_pwm_polarity=1, however, it may reverse the polarity which is unwanted (i.e. high is low, low is high). It works fine when left as configured by the firmware.

Misc

Support

If you would like additional hardware to be supported, pull requests are more than welcome. Alternatively, you can install these prerequisites:

sudo apt-get install -y gpiod

And then open an issue and attach outputs from the following commands:

sudo dmesg
sudo dmidecode -s system-manufacturer
sudo dmidecode -s system-product-name
sudo dmidecode -s bios-vendor
sudo dmidecode -s bios-version
sudo dmidecode -s bios-release-date
sudo dmidecode -s bios-revision
sudo gpioinfo

NOTE: If gpioinfo does not return anything, you may need to figure out which (if any) gpio drivers to load. Also keep in mind that your distribution may not ship with all gpio- drivers, so you may need to compile them yourself.

TODO

DKMS

DKMS installation to enable module auto-build with kernel upgrades.

sudo make dkms