ar71xx: Buffalo WHR-HP-G300N kernel support
[oweals/openwrt.git] / target / linux / ar71xx / base-files / etc / diag.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2009 OpenWrt.org
4 #
5 #
6
7 . /lib/ar71xx.sh
8
9 status_led=""
10
11 led_set_attr() {
12         [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2"
13 }
14
15 status_led_set_timer() {
16         led_set_attr $status_led "trigger" "timer"
17         led_set_attr $status_led "delay_on" "$1"
18         led_set_attr $status_led "delay_off" "$2"
19 }
20
21 status_led_on() {
22         led_set_attr $status_led "trigger" "none"
23         led_set_attr $status_led "brightness" 255
24 }
25
26 status_led_off() {
27         led_set_attr $status_led "trigger" "none"
28         led_set_attr $status_led "brightness" 0
29 }
30
31 get_status_led() {
32         case $(ar71xx_board_name) in
33         ap81)
34                 status_led="ap81:green:status"
35                 ;;
36         ap83)
37                 status_led="ap83:green:power"
38                 ;;
39         ap96)
40                 status_led="ap96:green:led2"
41                 ;;
42         aw-nr580)
43                 status_led="aw-nr580:green:ready"
44                 ;;
45         bullet-m | rocket-m | nano-m | nanostation-m)
46                 status_led="ubnt:green:link4"
47                 ;;
48         dir-600-a1)
49                 status_led="dir-600-a1:green:power"
50                 ;;
51         dir-615-c1)
52                 status_led="dir-615c1:green:status"
53                 ;;
54         dir-825-b1)
55                 status_led="dir825b1:orange:power"
56                 ;;
57         eap7660d)
58                 status_led="eap7660d:green:ds4"
59                 ;;
60         ja76pf)
61                 status_led="ja76pf:green:led1"
62                 ;;
63         ls-sr71)
64                 status_led="ubnt:green:d22"
65                 ;;
66         mzk-w04nu)
67                 status_led="mzk-w04nu:green:status"
68                 ;;
69         mzk-w300nh)
70                 status_led="mzk-w300nh:green:status"
71                 ;;
72         nbg460n_550n_550nh)
73                 status_led="nbg460n:green:power"
74                 ;;
75         pb44)
76                 status_led="pb44:amber:jump1"
77                 ;;
78         rb-411 | rb-411u | rb-433 | rb-433u | rb-450 | rb-450g | rb-493)
79                 status_led="rb4xx:yellow:user"
80                 ;;
81         routerstation | routerstation-pro)
82                 status_led="ubnt:green:rf"
83                 ;;
84         tew-632brp)
85                 status_led="tew-632brp:green:status"
86                 ;;
87         tl-mr3220 | tl-mr3420)
88                 status_led="tl-mr3x20:green:system"
89                 ;;
90         tl-wa901nd)
91                 status_led="tl-wa901nd:green:system"
92                 ;;
93         tl-wa901nd-v2)
94                 status_led="tl-wa901nd-v2:green:system"
95                 ;;
96         tl-wr1043nd)
97                 status_led="tl-wr1043nd:green:system"
98                 ;;
99         tl-wr703n)
100                 status_led="tl-wr703n:blue:system"
101                 ;;
102         tl-wr741nd)
103                 status_led="tl-wr741nd:green:system"
104                 ;;
105         tl-wr841n-v1)
106                 status_led="tl-wr841n:green:system"
107                 ;;
108         tl-wr941nd)
109                 status_led="tl-wr941nd:green:system"
110                 ;;
111         unifi)
112                 status_led="ubnt:green:dome"
113                 ;;
114         whr-hp-g300n)
115                 status_led="whr-hp-g300n:green:router"
116                 ;;
117         wndr3700 | wndr3700v2)
118                 status_led="wndr3700:green:power"
119                 ;;
120         wnr2000)
121                 status_led="wnr2000:green:power"
122                 ;;
123         wp543)
124                 status_led="wp543:green:diag"
125                 ;;
126         wrt400n)
127                 status_led="wrt400n:green:status"
128                 ;;
129         wrt160nl)
130                 status_led="wrt160nl:blue:wps"
131                 ;;
132         wzr-hp-g300nh)
133                 status_led="wzr-hp-g300nh:green:router"
134                 ;;
135         zcn-1523h-2 | zcn-1523h-5)
136                 status_led="zcn-1523h:amber:init"
137                 ;;
138         esac;
139 }
140
141 set_state() {
142         get_status_led
143
144         case "$1" in
145         preinit)
146                 insmod leds-gpio
147                 status_led_set_timer 200 200
148                 ;;
149         failsafe)
150                 status_led_set_timer 50 50
151                 ;;
152         done)
153                 status_led_on
154                 ;;
155         esac
156 }