diff options
author | Andrii Pientsov <andrii.pientsov@globallogic.com> | 2021-01-28 11:26:05 +0200 |
---|---|---|
committer | Andrii Pientsov <andrii.pientsov@globallogic.com> | 2021-01-28 13:58:55 +0200 |
commit | 81f0751c9d15d969ebb568c67b7903d2d5e49a0d (patch) | |
tree | 4ddcc04c315469111787908f643ac421973ea37b /recipes-bsp | |
parent | 80ea39818fb8a55028d115720ead3ad6d241dc29 (diff) | |
download | meta-multitech-atmel-81f0751c9d15d969ebb568c67b7903d2d5e49a0d.tar.gz meta-multitech-atmel-81f0751c9d15d969ebb568c67b7903d2d5e49a0d.tar.bz2 meta-multitech-atmel-81f0751c9d15d969ebb568c67b7903d2d5e49a0d.zip |
MTRE: Add mtre-leds recipe
Diffstat (limited to 'recipes-bsp')
-rw-r--r-- | recipes-bsp/multitech/mtre-leds.bb | 30 | ||||
-rwxr-xr-x | recipes-bsp/multitech/mtre-leds/mtre-leds-device-ready.init | 7 | ||||
-rwxr-xr-x | recipes-bsp/multitech/mtre-leds/mtre-leds-monitor.sh | 23 | ||||
-rw-r--r-- | recipes-bsp/multitech/mtre-leds/mtre-leds.init | 21 | ||||
-rwxr-xr-x | recipes-bsp/multitech/mtre-leds/mtre-leds.sh | 160 |
5 files changed, 241 insertions, 0 deletions
diff --git a/recipes-bsp/multitech/mtre-leds.bb b/recipes-bsp/multitech/mtre-leds.bb new file mode 100644 index 0000000..59660b4 --- /dev/null +++ b/recipes-bsp/multitech/mtre-leds.bb @@ -0,0 +1,30 @@ +DESCRIPTION = "MTRE led setup facilities" +HOMEPAGE = "http://www.multitech.com/" +LICENSE = "Proprietary" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Proprietary;md5=0557f9d92cf58f2ccdd50f62f8ac0b28" +RDEPENDS_${PN} += "bash" + +PR = "r2" + +SRC_URI = " file://mtre-leds.init \ + file://mtre-leds.sh \ + file://mtre-leds-monitor.sh \ + file://mtre-leds-device-ready.init \ +" +inherit update-rc.d + +INITSCRIPT_NAME = "mtre-leds" +INITSCRIPT_PARAMS = "start 45 S . stop 30 6 ." + +do_install() { + install -d ${D}/etc/init.d + install -m 0755 ${WORKDIR}/mtre-leds.init ${D}/etc/init.d/mtre-leds + install -d ${D}/sbin + install -m 0744 ${WORKDIR}/mtre-leds.sh ${D}/sbin/mtre-leds + install -m 0744 ${WORKDIR}/mtre-leds-monitor.sh ${D}/sbin/mtre-leds-monitor + + # Install mtre device ready hook which turns on ENABLED LED after Web Access is allowed + install -d ${D}${sysconfdir}/rc5.d + install -m 0755 ${WORKDIR}/mtre-leds-device-ready.init ${D}/etc/init.d/mtre-leds-device-ready + ln -s /etc/init.d/mtre-leds-device-ready ${D}${sysconfdir}/rc5.d/S76mtre-leds-device-ready +} diff --git a/recipes-bsp/multitech/mtre-leds/mtre-leds-device-ready.init b/recipes-bsp/multitech/mtre-leds/mtre-leds-device-ready.init new file mode 100755 index 0000000..250f592 --- /dev/null +++ b/recipes-bsp/multitech/mtre-leds/mtre-leds-device-ready.init @@ -0,0 +1,7 @@ +#!/bin/bash + +# +# Notify LEDs engine that the device is now accessible. +# + +mtre-leds device_ready diff --git a/recipes-bsp/multitech/mtre-leds/mtre-leds-monitor.sh b/recipes-bsp/multitech/mtre-leds/mtre-leds-monitor.sh new file mode 100755 index 0000000..087d8f3 --- /dev/null +++ b/recipes-bsp/multitech/mtre-leds/mtre-leds-monitor.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +gpio=/sys/devices/platform/mts-io/reset +#gpio=/tmp/pb + +status="0" + +while : +do + usleep 150000 + if [[ -r "$gpio" ]]; then + read -n 1 val < $gpio + if [[ ! -z "$val" && "$val" != "$status" ]]; then + if [[ "$val" == "1" ]]; then + mtre-leds start-test + status=$val + elif [[ "$val" == "0" ]]; then + mtre-leds stop-test + status=$val + fi + fi + fi +done diff --git a/recipes-bsp/multitech/mtre-leds/mtre-leds.init b/recipes-bsp/multitech/mtre-leds/mtre-leds.init new file mode 100644 index 0000000..686fba8 --- /dev/null +++ b/recipes-bsp/multitech/mtre-leds/mtre-leds.init @@ -0,0 +1,21 @@ +#!/bin/bash + +case $1 in + start) + echo "Setting up leds" + # setup leds and triggers + mtre-leds start + # set to no-alarm initially + mtre-leds alarm-off + ;; + + stop) + # turn leds off, disable triggers + mtre-leds stop + ;; + + *) + echo "Usage: $0 {start|stop}" + exit 2 + ;; +esac
\ No newline at end of file diff --git a/recipes-bsp/multitech/mtre-leds/mtre-leds.sh b/recipes-bsp/multitech/mtre-leds/mtre-leds.sh new file mode 100755 index 0000000..773e331 --- /dev/null +++ b/recipes-bsp/multitech/mtre-leds/mtre-leds.sh @@ -0,0 +1,160 @@ +#!/bin/bash + +# +# LED to trigger map +# +declare -A triggers + +################################################################## +# # # # +# LED name # Trigger # Description # +# /sys/class/leds # # # +################################################################## +triggers[pca955x:0]="led-no-alarm" # ENABLE +triggers[pca955x:1]="led-alarm" # ALARM +triggers[pca955x:2]="none" # 10/100MBPS (HW controlled) +triggers[pca955x:3]="none" # LNK/ACT (HW controlled) +triggers[pca955x:4]="vizzini1-tx" # TX (serial) +triggers[pca955x:5]="vizzini1-rx" # RX (serial) +triggers[pca955x:6]="led-sig4" # LINK Quality Green +triggers[pca955x:7]="led-sig3" # LINK Quality Green +triggers[pca955x:8]="led-sig2" # LINK Quality Yellow +triggers[pca955x:9]="led-sig1" # LINK Quality Red +triggers[pca955x:10]="led-cd" # Celullar connectivity +triggers[pca955x:11]="netdev" # Cellular activity + +debug() { + [[ "$DEBUG" ]] && builtin echo $@ +} + +leds_enable() { + cd /sys/class/leds + for led in "${!triggers[@]}" + do + echo ${triggers[$led]} > $led/trigger + debug "LEDS: $led trigger enabled" + done +} + +leds_disable() { + cd /sys/class/leds + for led in "${!triggers[@]}" + do + echo "none" > $led/trigger + done +} + +led_set_alarm() { + local cmd="$1" + + [ x"$cmd" == x"on" ] && mts-io-sysfs store alarm 1 + [ x"$cmd" == x"off" ] && mts-io-sysfs store alarm 0 + [ x"$cmd" == x"minor" ] && mts-io-sysfs store alarm 2 + [ x"$cmd" == x"update" ] && mts-io-sysfs store alarm 100 + debug "LEDS: alarm set to $1" +} + +led_set_device_ready() { + local cmd="$1" + + [ x"$cmd" == x"on" ] && mts-io-sysfs store device-ready 1 + [ x"$cmd" == x"off" ] && mts-io-sysfs store device-ready 0 + debug "LEDS: device_ready set to $1" +} + +led_set_ppp_act() { + cd /sys/class/leds + for led in "${!triggers[@]}" + do + if [[ x"${triggers[$led]}" == x"netdev" ]]; then + echo "ppp0" > $led/device_name + echo "1" > $led/rx + echo "1" > $led/tx + debug "LEDS: ppp activity trigger is set" + fi + done +} + +leds_set_brightness() { + cd /sys/class/leds + for led in "${!triggers[@]}" + do + local cmd="$1" + + if [[ x"$cmd" == x"on" ]]; then + brightness="255" + elif [[ x"$cmd" == x"off" ]]; then + brightness="0" + fi + + if [[ x"${triggers[$led]}" == x"led-alarm" ]]; then + # + # led alarm is inverted + # + if [[ x"$cmd" == x"on" ]]; then + brightness="0" + elif [[ x"$cmd" == x"off" ]]; then + brightness="255" + fi + fi + + echo $brightness > $led/brightness + + debug "LEDS: $led brightness set to $cmd" + done +} + +case $1 in + start) + leds_disable # disable all triggers + leds_set_brightness off # set all leds to off + leds_enable # enable all triggers + led_set_alarm update # update alarm leds with current alarm status + led_set_ppp_act # setup ppp activity led + mtre-leds-monitor & # start push-button monitor + ;; + + stop) + killall -q mtre-leds-monitor + leds_disable # disable all led triggers + leds_set_brightness off # set all leds to off + ;; + + alarm-on) + led_set_alarm on # store alarm + ;; + + alarm-off) + led_set_alarm off # set no alarm + ;; + + alarm-minor) + led_set_alarm minor # blink oneshot on minor alarm + ;; + + device_ready) + led_set_device_ready on # indicate device readyness + ;; + + device_not_ready) + led_set_device_ready off # indicate device readyness + ;; + + start-test) + leds_disable # disable all triggers + leds_set_brightness on # set all leds to on + ;; + + stop-test) + leds_disable # disable all led triggers + leds_set_brightness off # set all leds to off + leds_enable # enable all triggers + led_set_alarm update # update alarm leds with current alarm status + led_set_ppp_act # restore ppp activity settings + ;; + + *) + echo "Usage: $0 <start|stop|alarm-on|alarm-off|alarm-minor|device_ready|device_not_ready|start-test|stop-test>" + exit 2 + ;; +esac |