Add support for alix2 leds.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 30 Apr 2010 15:03:15 +0000 (17:03 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 30 Apr 2010 15:03:15 +0000 (17:03 +0200)
This script enables led 2 and 3 of the alix boards and
they will show traffic on the red device.

lfs/initscripts
src/initscripts/init.d/leds [new file with mode: 0644]

index 56c42222573f726f631a59e5d9c545315f75841d..38870b84a35c4ab665075d6c26e348dcd911e605 100644 (file)
@@ -147,6 +147,9 @@ $(TARGET) :
        ln -sf  ../init.d/cyrus-sasl /etc/rc.d/rc0.d/K49cyrus-sasl
        ln -sf  ../init.d/cyrus-sasl /etc/rc.d/rc3.d/S24cyrus-sasl
        ln -sf  ../init.d/cyrus-sasl /etc/rc.d/rc6.d/K49cyrus-sasl
+       ln -sf ../init.d/leds        /etc/rc.d/rc0.d/K79leds
+       ln -sf ../init.d/leds        /etc/rc.d/rc3.d/S21leds
+       ln -sf ../init.d/leds        /etc/rc.d/rc6.d/K79leds
        ln -sf ../init.d/mountkernfs /etc/rc.d/rcsysinit.d/S00mountkernfs
        ln -sf ../init.d/modules     /etc/rc.d/rcsysinit.d/S05modules
        ln -sf ../init.d/udev        /etc/rc.d/rcsysinit.d/S10udev
diff --git a/src/initscripts/init.d/leds b/src/initscripts/init.d/leds
new file mode 100644 (file)
index 0000000..4927b63
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/sh
+########################################################################
+# Begin $rc_base/init.d/leds
+#
+# Description : Script to setup leds at boot.
+#
+########################################################################
+
+. /etc/sysconfig/rc
+. ${rc_functions}
+
+# Load ethernet settings
+eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
+
+setup_red_modem() {
+       local led1=${1}
+       local led2=${2}
+
+       modprobe ledtrig-netdev
+
+       local i
+       for i in ${led1} ${led2}; do
+               echo "netdev" > ${i}/trigger
+               echo "${RED_DEV}" > ${i}/device_name
+       done
+
+       echo "rx" > ${led1}/mode
+       echo "tx" > ${led2}/mode
+}
+
+reset_trigger() {
+       [ -d "${1}" ] || return 0
+       echo "none" > ${1}/trigger
+}
+
+start_alix2() {
+       modprobe -q leds-alix2
+
+       local i
+       for i in 1 2 3; do
+               if [ ! -d "/sys/class/leds/alix:${i}" ]; then
+                       return 1
+               fi
+       done
+
+       setup_red_modem /sys/class/leds/alix:2 /sys/class/leds/alix:3
+}
+
+stop_alix2() {
+       local i
+       for i in 1 2 3; do
+               reset_trigger /sys/class/leds/alix:${i}
+       done
+}
+
+case "${1}" in
+       start|stop)
+               for i in alix2; do
+                 ${1}_${i}
+               done
+               ;;
+
+       *)
+               echo "Usage: ${0} {start|stop}"
+               exit 1
+               ;;
+esac
+
+# End $rc_base/init.d/leds