source: trunk/target/linux/brcm63xx/base-files/etc/diag.sh @ 24187

Last change on this file since 24187 was 24187, checked in by cshore, 5 years ago

bcm63xx: Allow 'colored' power leds.

Since some devices have more than one power led, they might be separated by
their color in the name. To also allow them to be on after leaving preinit,
set any status led starting with 'power' to on instead of only those with
the exact name of 'power'.

Signed-off-by: Jonas Gorski <jonas.gorski+openwrt@…>

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#!/bin/sh
2#
3# Copyright (C) 2007 OpenWrt.org
4#
5#
6
7. /lib/brcm63xx.sh
8
9led_set_attr() {
10        [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2"
11}
12
13status_led_set_timer() {
14        led_set_attr $status_led "trigger" "timer"
15        led_set_attr $status_led "delay_on" "$1"
16        led_set_attr $status_led "delay_off" "$2"
17        [ -n "$status_led2" ] && {
18                led_set_attr $status_led2 "trigger" "timer"
19                led_set_attr $status_led2 "delay_on" "$1"
20                led_set_attr $status_led2 "delay_off" "$2"
21        }
22}
23
24status_led_set_morse() {
25        led_set_attr $status_led "trigger" "morse"
26        led_set_attr $status_led "delay" "$1"
27        led_set_attr $status_led "message" "$2"
28        [ -n "$status_led2" ] && {
29                led_set_attr $status_led2 "trigger" "morse"
30                led_set_attr $status_led2 "delay" "$1"
31                led_set_attr $status_led2 "message" "$2"
32        }
33}
34
35status_led_on() {
36        led_set_attr $status_led "trigger" "none"
37        led_set_attr $status_led "brightness" 255
38        [ -n "$status_led2" ] && {
39                led_set_attr $status_led2 "trigger" "none"
40                led_set_attr $status_led2 "brightness" 255
41        }
42}
43
44status_led_off() {
45        led_set_attr $status_led "trigger" "none"
46        led_set_attr $status_led "brightness" 0
47        [ -n "$status_led2" ] && {
48                led_set_attr $status_led2 "trigger" "none"
49                led_set_attr $status_led2 "brightness" 0
50        }
51}
52
53set_state() {
54        case "$1" in
55        preinit)
56                insmod leds-gpio
57                status_led_on
58                status_led_set_timer 200 200
59                ;;
60        failsafe)
61                status_led_set_timer 50 50
62                ;;
63        done)
64                if [ "${status_led#power}" != "$status_led" ]; then
65                        status_led_on
66                else
67                        status_led_off
68                fi
69                ;;
70        esac
71}
Note: See TracBrowser for help on using the repository browser.