I'm porting OpenWRT onto a custom device. I wrote a .dts
file, but can't get LEDs working. echo "default-on" > /sys/class/leds/device:*/trigger
and echo 1 > /sys/class/leds/device:*/brightness
commands have no effect. echo 5xx > /sys/class/gpio/export
returns an error ash: write error: Resource busy
.
The leds_gpio
kernel module is loaded, and here is /sys/kernel/debug/gpio
file contents:
gpiochip0: GPIOs 512-543, parent: platform/1e000600.gpio, 1e000600.gpio-bank0:
gpio-515 ( |i2c_ctrl ) out hi
gpio-516 ( |i2c_ctrl ) out hi
gpio-525 ( |device:green:lan3 ) out hi ACTIVE LOW
gpio-526 ( |device:green:wan ) out hi ACTIVE LOW
gpio-527 ( |device:green:lan2 ) out hi ACTIVE LOW
gpio-528 ( |device:green:lan1 ) out hi ACTIVE LOW
gpio-529 ( |device:green:lan4 ) out hi ACTIVE LOW
gpio-530 ( |wps ) in hi ACTIVE LOW
gpio-531 ( |reset ) out hi ACTIVE LOW
gpio-534 ( |usb-pwr ) out hi
gpio-538 ( |device:red:power-r ) out hi ACTIVE LOW
gpio-539 ( |device:blue:power-b ) out hi ACTIVE LOW
gpio-540 ( |device:green:wlan1 ) out hi ACTIVE LOW
gpio-543 ( |device:green:power-g ) out hi ACTIVE LOW
gpiochip1: GPIOs 544-575, parent: platform/1e000600.gpio, 1e000600.gpio-bank1:
gpio-545 ( |device:green:wlan0 ) out hi ACTIVE LOW
gpiochip2: GPIOs 576-607, parent: platform/1e000600.gpio, 1e000600.gpio-bank2:
Below is the list of additions I made.
Part of the .dts
file (unrelated parts removed):
/ {
leds {
compatible = "gpio-leds";
led_power_r: power-r {
label = "device:red:power-r";
function = LED_FUNCTION_INDICATOR;
gpios = <&gpio 26 GPIO_ACTIVE_LOW>;
};
led_power_g: power-g {
label = "device:green:power-g";
function = LED_FUNCTION_POWER;
gpios = <&gpio 31 GPIO_ACTIVE_LOW>;
};
led_power_b: power-b {
label = "device:blue:power-b";
function = LED_FUNCTION_STATUS;
gpios = <&gpio 27 GPIO_ACTIVE_LOW>;
};
wan {
// Port 3
label = "device:green:wan";
function = LED_FUNCTION_WAN;
gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
};
lan1 {
// Port 0
label = "device:green:lan1";
function = LED_FUNCTION_LAN;
gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
};
wlan0 {
// WiFi 2.4G Activity
label = "device:green:wlan0";
function = LED_FUNCTION_WLAN_2GHZ;
gpios = <&gpio 33 GPIO_ACTIVE_LOW>;
};
wlan1 {
// WiFi 5G Activity
label = "device:green:wlan1";
function = LED_FUNCTION_WLAN_5GHZ;
gpios = <&gpio 28 GPIO_ACTIVE_LOW>;
};
};
};
&gpio {
status = "okay";
};
&state_default {
gpio {
ralink,group = "wdt", "rgmii2", "jtag", "mdio", "uart3";
ralink,function = "gpio";
};
};
The list of packages required by the device:
DEVICE_PACKAGES := kmod-mt7621 kmod-mt76x2 \
kmod-usb2 kmod-usb3 kmod-usb-storage-extras \
swconfig xl2tpd kmod-l2tp-eth kmod-l2tp-ip \
kmod-leds-gpio kmod-ledtrig-default-on \
kmod-ledtrig-gpio kmod-ledtrig-heartbeat \
kmod-ledtrig-netdev kmod-ledtrig-oneshot \
kmod-ledtrig-timer kmod-ledtrig-transient \
automount kmod-mtd-rw
What am I missing?