aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2017-02-13 13:38:33 +0000
committerJohn Crispin <john@phrozen.org>2017-02-17 10:28:52 +0100
commit6d6db65d8294a12265f9ac75dee31d98767946c9 (patch)
tree483a8af7c1afe925640b6f54d9d6a6e11eacf851
parentbd5b5c749a3d5fd7ef4ec8f03330dfef445db218 (diff)
downloadupstream-6d6db65d8294a12265f9ac75dee31d98767946c9.tar.gz
upstream-6d6db65d8294a12265f9ac75dee31d98767946c9.tar.bz2
upstream-6d6db65d8294a12265f9ac75dee31d98767946c9.zip
x86: Enable DIAG LED on Geos
Based on a patch from Chris Blake <chrisrblake93@gmail.com>, except let's do it by using the LED configuration instead of hard-coding it for each board type. And try using /bin/board_detect to do the default behaviour, on the first boot where the config hasn't yet been generated. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
-rwxr-xr-xtarget/linux/x86/base-files/etc/board.d/01_leds2
-rw-r--r--target/linux/x86/base-files/etc/diag.sh78
2 files changed, 79 insertions, 1 deletions
diff --git a/target/linux/x86/base-files/etc/board.d/01_leds b/target/linux/x86/base-files/etc/board.d/01_leds
index 8a1a1e0125..824c652d10 100755
--- a/target/linux/x86/base-files/etc/board.d/01_leds
+++ b/target/linux/x86/base-files/etc/board.d/01_leds
@@ -13,7 +13,7 @@ case "$board" in
traverse-technologies-geos)
ucidef_set_led_netdev "lan" "LAN" "geos:1" "br-lan" "tx rx"
ucidef_set_led_netdev "wlan" "WiFi" "geos:2" "phy0tpt"
- ucidef_set_led_default "diag" "DIAG" "geos:3" "0"
+ ucidef_set_led_default "diag" "DIAG" "geos:3" "1"
;;
esac
board_config_flush
diff --git a/target/linux/x86/base-files/etc/diag.sh b/target/linux/x86/base-files/etc/diag.sh
new file mode 100644
index 0000000000..3af4b23583
--- /dev/null
+++ b/target/linux/x86/base-files/etc/diag.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# Copyright © 2017 OpenWrt.org
+#
+
+. /lib/functions.sh
+. /lib/functions/leds.sh
+. /usr/share/libubox/jshn.sh
+
+preinit_match_diag_led() {
+ local CFG keys key cfg name sysfs default
+
+ CFG=/etc/board.json
+ if [ ! -s $CFG ]; then
+ CFG=/tmp/board.json
+ [ -s /tmp/sysinfo/model ] || return
+ /bin/board_detect $CFG || return
+ fi
+
+ json_init
+ json_load "$(cat $CFG)"
+ json_get_keys keys led
+ json_select led
+ for key in $keys; do
+ json_select "$key"
+ json_get_vars name sysfs default
+
+ if [ "$name" = "DIAG" -a "$default" = "1" ]; then
+ status_led="$sysfs"
+ return
+ fi
+ json_select ..
+ done
+}
+
+match_diag_led() {
+ local name
+ local default
+ local sysfs
+ config_get name "$1" name
+ config_get default "$1" default
+ config_get sysfs "$1" sysfs
+
+ if [ "$name" = "DIAG" -a "$default" = "1" ]; then
+ status_led="$sysfs"
+ fi
+}
+
+get_status_led() {
+ if [ -s /etc/config/system ]; then
+ config_load system
+ config_foreach match_diag_led led
+ else
+ preinit_match_diag_led
+ fi
+}
+
+set_state() {
+ get_status_led
+
+ case "$1" in
+ preinit)
+ status_led_blink_preinit
+ ;;
+
+ failsafe)
+ status_led_blink_failsafe
+ ;;
+
+ preinit_regular)
+ status_led_blink_preinit_regular
+ ;;
+
+ done)
+ status_led_on
+ ;;
+ esac
+}