ath79: add support for indicating the boot state using multiple leds

Use diag.sh version used for apm821xx, ipq40xx and ipq806x, which
supports different leds for the different boot states.

The existing led sequences should be the same as before.

Signed-off-by: Dmitry Tunin <hanipouspilot@gmail.com>
[reword commit message]
Signed-off-by: Mathias Kresin <dev@kresin.me>
This commit is contained in:
Dmitry Tunin 2018-08-14 08:54:38 +03:00 committed by Mathias Kresin
parent 37af596593
commit 7a873974f7
33 changed files with 157 additions and 37 deletions

29
target/linux/ath79/base-files/etc/diag.sh Normal file → Executable file
View file

@ -2,21 +2,46 @@
. /lib/functions/leds.sh . /lib/functions/leds.sh
status_led="$(get_dt_led status)" boot="$(get_dt_led boot)"
failsafe="$(get_dt_led failsafe)"
running="$(get_dt_led running)"
upgrade="$(get_dt_led upgrade)"
get_status_led() {
status_led="$boot"
}
set_state() { set_state() {
status_led="$boot"
case "$1" in case "$1" in
preinit) preinit)
status_led_blink_preinit status_led_blink_preinit
;; ;;
failsafe) failsafe)
status_led_off
[ -n "$running" ] && {
status_led="$running"
status_led_off
}
status_led="$failsafe"
status_led_blink_failsafe status_led_blink_failsafe
;; ;;
preinit_regular) preinit_regular)
status_led_blink_preinit_regular status_led_blink_preinit_regular
;; ;;
upgrade)
[ -n "$running" ] && {
status_led="$upgrade"
status_led_blink_preinit_regular
}
;;
done) done)
status_led_on status_led_off
[ -n "$running" ] && {
status_led="$running"
status_led_on
}
;; ;;
esac esac
} }

View file

@ -11,7 +11,10 @@
model = "D-Link DIR825B1"; model = "D-Link DIR825B1";
aliases { aliases {
led-status = &orange_power; led-boot = &orange_power;
led-failsafe = &orange_power;
led-running = &orange_power;
led-upgrade = &orange_power;
}; };
chosen { chosen {

View file

@ -8,7 +8,10 @@
/ { / {
aliases { aliases {
led-status = &power_green; led-boot = &power_green;
led-failsafe = &power_green;
led-running = &power_green;
led-upgrade = &power_green;
}; };
chosen { chosen {

View file

@ -11,7 +11,10 @@
model = "Netgear WNR612 V2"; model = "Netgear WNR612 V2";
aliases { aliases {
led-status = &led_power; led-boot = &power;
led-failsafe = &power;
led-running = &power;
led-upgrade = &power;
}; };
gpio-keys-polled { gpio-keys-polled {
@ -28,7 +31,7 @@
gpio-leds { gpio-leds {
compatible = "gpio-leds"; compatible = "gpio-leds";
led_power: power { power: power {
label = "netgear:green:power"; label = "netgear:green:power";
gpios = <&gpio 11 GPIO_ACTIVE_LOW>; gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
}; };

View file

@ -7,7 +7,10 @@
/ { / {
aliases { aliases {
led-status = &led_system; led-boot = &led_system;
led-failsafe = &led_system;
led-running = &led_system;
led-upgrade = &led_system;
}; };
gpio-keys-polled { gpio-keys-polled {

View file

@ -7,7 +7,10 @@
/ { / {
aliases { aliases {
led-status = &led_system; led-boot = &led_system;
led-failsafe = &led_system;
led-running = &led_system;
led-upgrade = &led_system;
}; };
gpio-keys-polled { gpio-keys-polled {

View file

@ -11,7 +11,10 @@
model = "Ubiquiti UniFi AP"; model = "Ubiquiti UniFi AP";
aliases { aliases {
led-status = &dome_green; led-boot = &dome_green;
led-failsafe = &dome_green;
led-running = &dome_green;
led-upgrade = &dome_green;
}; };
extosc: ref { extosc: ref {

View file

@ -11,7 +11,10 @@
model = "AVM FRITZ!WLAN Repeater 300E"; model = "AVM FRITZ!WLAN Repeater 300E";
aliases { aliases {
led-status = &power; led-boot = &power;
led-failsafe = &power;
led-running = &power;
led-upgrade = &power;
}; };
gpio-keys { gpio-keys {

View file

@ -11,7 +11,10 @@
model = "TP-LINK TL-WR2543N/ND"; model = "TP-LINK TL-WR2543N/ND";
aliases { aliases {
led-status = &system; led-boot = &system;
led-failsafe = &system;
led-running = &system;
led-upgrade = &system;
}; };
chosen { chosen {

View file

@ -11,7 +11,10 @@
model = "TP-Link TL-WR1043ND Version 1"; model = "TP-Link TL-WR1043ND Version 1";
aliases { aliases {
led-status = &system; led-boot = &system;
led-failsafe = &system;
led-running = &system;
led-upgrade = &system;
}; };
extosc: ref { extosc: ref {

View file

@ -11,7 +11,10 @@
model = "TP-Link TL-WR941N/ND v2/v3"; model = "TP-Link TL-WR941N/ND v2/v3";
aliases { aliases {
led-status = &led_system; led-boot = &led_system;
led-failsafe = &led_system;
led-running = &led_system;
led-upgrade = &led_system;
}; };
keys { keys {

View file

@ -12,7 +12,9 @@
aliases { aliases {
serial0 = &uart; serial0 = &uart;
led-status = &wlan; led-boot = &wlan;
led-failsafe = &wlan;
led-upgrade = &wlan;
}; };
leds { leds {

View file

@ -11,7 +11,10 @@
compatible = "embeddedwireless,dorin", "qca,ar9331"; compatible = "embeddedwireless,dorin", "qca,ar9331";
aliases { aliases {
led-status = &status; led-boot = &status;
led-failsafe = &status;
led-running = &status;
led-upgrade = &status;
serial0 = &uart; serial0 = &uart;
}; };

View file

@ -12,7 +12,10 @@
aliases { aliases {
serial0 = &uart; serial0 = &uart;
led-status = &led_system; led-boot = &led_system;
led-failsafe = &led_system;
led-running = &led_system;
led-upgrade = &led_system;
}; };
gpio-keys-polled { gpio-keys-polled {

View file

@ -12,7 +12,10 @@
aliases { aliases {
serial0 = &uart; serial0 = &uart;
led-status = &system; led-boot = &system;
led-failsafe = &system;
led-running = &system;
led-upgrade = &system;
}; };
leds { leds {

View file

@ -9,7 +9,10 @@
/ { / {
aliases { aliases {
serial0 = &uart; serial0 = &uart;
led-status = &led_system; led-boot = &system;
led-failsafe = &system;
led-running = &system;
led-upgrade = &system;
}; };
gpio-keys-polled { gpio-keys-polled {
@ -27,7 +30,7 @@
gpio-leds { gpio-leds {
compatible = "gpio-leds"; compatible = "gpio-leds";
led_system: system { system: system {
label = "tl-wr703n:blue:system"; label = "tl-wr703n:blue:system";
gpios = <&gpio 27 GPIO_ACTIVE_LOW>; gpios = <&gpio 27 GPIO_ACTIVE_LOW>;
}; };

View file

@ -12,7 +12,10 @@
aliases { aliases {
serial0 = &uart; serial0 = &uart;
led-status = &led_system; led-boot = &system;
led-failsafe = &system;
led-running = &system;
led-upgrade = &system;
}; };
gpio-keys-polled { gpio-keys-polled {
@ -64,7 +67,7 @@
gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; gpios = <&gpio 1 GPIO_ACTIVE_HIGH>;
}; };
led_system: system { system: system {
label = "tp-link:green:system"; label = "tp-link:green:system";
gpios = <&gpio 27 GPIO_ACTIVE_HIGH>; gpios = <&gpio 27 GPIO_ACTIVE_HIGH>;
}; };

View file

@ -12,7 +12,10 @@
aliases { aliases {
serial0 = &uart; serial0 = &uart;
led-status = &status; led-boot = &status;
led-failsafe = &status;
led-running = &status;
led-upgrade = &status;
}; };
keys { keys {

View file

@ -15,7 +15,10 @@
}; };
aliases { aliases {
led-status = &system; led-boot = &system;
led-failsafe = &system;
led-running = &system;
led-upgrade = &system;
}; };
leds { leds {

View file

@ -12,7 +12,10 @@
aliases { aliases {
serial0 = &uart; serial0 = &uart;
led-status = &status; led-boot = &status;
led-failsafe = &status;
led-running = &status;
led-upgrade = &status;
}; };
keys { keys {

View file

@ -12,7 +12,10 @@
aliases { aliases {
serial0 = &uart; serial0 = &uart;
led-status = &status; led-boot = &status;
led-failsafe = &status;
led-running = &status;
led-upgrade = &status;
}; };
keys { keys {

View file

@ -10,7 +10,10 @@
compatible = "tplink,tl-wdr4300"; compatible = "tplink,tl-wdr4300";
aliases { aliases {
led-status = &system; led-boot = &system;
led-failsafe = &system;
led-running = &system;
led-upgrade = &system;
}; };
leds { leds {

View file

@ -11,7 +11,10 @@
model = "TP-Link TL-WR841N/ND Version 11"; model = "TP-Link TL-WR841N/ND Version 11";
aliases { aliases {
led-status = &system_led; led-boot = &system_led;
led-failsafe = &system_led;
led-running = &system_led;
led-upgrade = &system_led;
}; };
}; };

View file

@ -11,6 +11,9 @@
model = "TP-Link TL-WR841N/ND Version 9"; model = "TP-Link TL-WR841N/ND Version 9";
aliases { aliases {
led-status = &qss_led; led-boot = &qss_led;
led-failsafe = &qss_led;
led-running = &qss_led;
led-upgrade = &qss_led;
}; };
}; };

View file

@ -11,7 +11,10 @@
model = "I-O DATA WN-AC1600DGR2"; model = "I-O DATA WN-AC1600DGR2";
aliases { aliases {
led-status = &power; led-boot = &power;
led-failsafe = &power;
led-running = &power;
led-upgrade = &power;
}; };
chosen { chosen {

View file

@ -11,7 +11,10 @@
model = "Buffalo BHR-4GRV2"; model = "Buffalo BHR-4GRV2";
aliases { aliases {
led-status = &power; led-boot = &power;
led-failsafe = &power;
led-running = &power;
led-upgrade = &power;
}; };
chosen { chosen {

View file

@ -15,7 +15,10 @@
}; };
aliases { aliases {
led-status = &system; led-boot = &system;
led-failsafe = &system;
led-running = &system;
led-upgrade = &system;
}; };
leds { leds {

View file

@ -12,7 +12,10 @@
}; };
aliases { aliases {
led-status = &system; led-boot = &system;
led-failsafe = &system;
led-running = &system;
led-upgrade = &system;
}; };
gpio_leds: leds { gpio_leds: leds {

View file

@ -15,7 +15,10 @@
}; };
aliases { aliases {
led-status = &led_system; led-boot = &led_system;
led-failsafe = &led_system;
led-running = &led_system;
led-upgrade = &led_system;
}; };
gpio_leds: leds { gpio_leds: leds {

View file

@ -12,7 +12,10 @@
}; };
aliases { aliases {
led-status = &system; led-boot = &system;
led-failsafe = &system;
led-running = &system;
led-upgrade = &system;
}; };
leds { leds {

View file

@ -11,7 +11,10 @@
compatible = "phicomm,k2t"; compatible = "phicomm,k2t";
aliases { aliases {
led-status = &status_red; led-boot = &status_red;
led-failsafe = &status_red;
led-running = &status_red;
led-upgrade = &status_red;
}; };
chosen { chosen {

View file

@ -15,7 +15,10 @@
}; };
aliases { aliases {
led-status = &system; led-boot = &system;
led-failsafe = &system;
led-running = &system;
led-upgrade = &system;
mdio-gpio0 = &mdio2; mdio-gpio0 = &mdio2;
}; };

View file

@ -12,7 +12,10 @@
}; };
aliases { aliases {
led-status = &system; led-boot = &system;
led-failsafe = &system;
led-running = &system;
led-upgrade = &system;
}; };
gpio_leds: leds { gpio_leds: leds {