Skip to content

Commit 003906c

Browse files
committed
Initial implementation (tested on AS604T and AS6204T)
0 parents  commit 003906c

9 files changed

+1796
-0
lines changed

.clang-format

Lines changed: 560 additions & 0 deletions
Large diffs are not rendered by default.

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
TARGET ?= $(shell uname -r)
2+
KERNEL_MODULES := /lib/modules/$(TARGET)
3+
KERNEL_BUILD := $(KERNEL_MODULES)/build
4+
SYSTEM_MAP := /boot/System.map-$(TARGET)
5+
MOD_SUBDIR = drivers/platform/x86
6+
MOD_DEST_DIR = $(KERNEL_MODULES)/kernel/$(MOD_SUBDIR)
7+
DRIVER := asustor
8+
9+
obj-m := $(patsubst %,%.o,$(DRIVER))
10+
obj-ko := $(patsubst %,%.ko,$(DRIVER))
11+
12+
all: modules
13+
14+
modules:
15+
@$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules
16+
17+
install: modules_modules
18+
19+
modules_modules:
20+
/usr/bin/install -m 644 -D $(DRIVER).ko $(MOD_DEST_DIR)/$(DRIVER).ko
21+
depmod -a -F $(SYSTEM_MAP) $(TARGET)
22+
23+
clean:
24+
$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) clean
25+
26+
.PHONY: all modules install modules_install clean

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# asustor-platform-driver
2+
3+
Linux kernel platform driver for ASUSTOR NAS hardware (leds, buttons).
4+
5+
On many systems, ASUSTOR use 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.
6+
7+
**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.**
8+
9+
## Dependencies
10+
11+
**Note:** All dependencies used by this module are part of the mainline linux kernel, if they're not included by your distribution you may need to compile them yourself.
12+
13+
- `gpio-it87` (AS6, AS61, AS62)
14+
- `gpio-ich` (AS6)
15+
16+
### Optional
17+
18+
- `it87` (AS6, AS61, AS62)
19+
- Temperature monitoring (`lm-sensors`)
20+
- Fan speed regulation via `pwm1`
21+
- See [`example/fancontrol`](./example/fancontrol) for an example `/etc/fancontrol` config for a AS62 system
22+
- Front panel LED brightness adjustment via `pwm3`
23+
24+
## Compatibility
25+
26+
- AS6204T
27+
- AS6104T (NOT TESTED!)
28+
- AS604T
29+
30+
## Features
31+
32+
- LEDs
33+
- See [asustor.c](asustor.c).
34+
- Buttons
35+
- USB Copy Button
36+
- Power Button (AS6)
37+
38+
## Installation
39+
40+
```
41+
git clone https://github.com/mafredri/asustor-platform-driver
42+
cd asustor-platform-driver
43+
make
44+
sudo make install
45+
```
46+
47+
## Tips
48+
49+
### `it87` and PWM polarity
50+
51+
You may want to use [`patches/001-ignore-pwm-polarity-it87.patch`](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.
52+
53+
### Misc
54+
55+
- `blue:power` and `red:power` can be turned on simultaneously for a pink-ish tint
56+
- `green:status` and `red:status` can be turned on simultaneously for a orange-ish tint
57+
58+
## Support
59+
60+
If you would like additional hardware to be supported, pull requests are more than welcome. Alternatively, you can install these prerequisites:
61+
62+
```
63+
sudo apt-get install -y gpiod
64+
```
65+
66+
And then open an issue and attach outputs from the following commands:
67+
68+
```
69+
sudo dmesg
70+
sudo dmidecode -s system-manufacturer
71+
sudo dmidecode -s system-product-name
72+
sudo dmidecode -s bios-vendor
73+
sudo dmidecode -s bios-version
74+
sudo dmidecode -s bios-release-date
75+
sudo dmidecode -s bios-revision
76+
sudo gpioinfo
77+
```
78+
79+
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.
80+
81+
## TODO
82+
83+
- Add DKMS support
84+
- Support variable amount of disk LEDs
85+
- ~~Create a new led trigger driver so that we can blink disk LEDs individually, the existing `disk-activity` trigger always blinks all LEDs on activity from any disk~~
86+
- Pray that [[RFC PATCH v3 00/18] Add block device LED trigger](https://lore.kernel.org/linux-leds/20210819025053.222710-1-arequipeno@gmail.com/) by Ian Pilcher lands in the linux kernel
87+
- Release a modified `gpio-it87.c` for figuring out the firmware configuration of IT87 GPIOs (could be useful when adding new devices)

0 commit comments

Comments
 (0)