ar71xx: add support for the OpenMesh OM2P-HS board
[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         alfa-nx)
34                 status_led="alfa:green:led_8"
35                 ;;
36         all0305)
37                 status_led="eap7660d:green:ds4"
38                 ;;
39         ap136)
40                 status_led="ap136:green:status"
41                 ;;
42         ap81)
43                 status_led="ap81:green:status"
44                 ;;
45         ap83)
46                 status_led="ap83:green:power"
47                 ;;
48         ap96)
49                 status_led="ap96:green:led2"
50                 ;;
51         aw-nr580)
52                 status_led="aw-nr580:green:ready"
53                 ;;
54         bullet-m | rocket-m | nano-m | nanostation-m)
55                 status_led="ubnt:green:link4"
56                 ;;
57         db120)
58                 status_led="db120:green:status"
59                 ;;
60         dir-600-a1 |\
61         dir-615-e4)
62                 status_led="d-link:green:power"
63                 ;;
64         dir-615-c1)
65                 status_led="d-link:green:status"
66                 ;;
67         dir-825-b1)
68                 status_led="d-link:orange:power"
69                 ;;
70         eap7660d)
71                 status_led="eap7660d:green:ds4"
72                 ;;
73         hornet-ub)
74                 status_led="alfa:blue:wps"
75                 ;;
76         ja76pf | \
77         ja76pf2)
78                 status_led="jjplus:green:led1"
79                 ;;
80         ls-sr71)
81                 status_led="ubnt:green:d22"
82                 ;;
83         mzk-w04nu | \
84         mzk-w300nh)
85                 status_led="planex:green:status"
86                 ;;
87         nbg460n_550n_550nh)
88                 status_led="nbg460n:green:power"
89                 ;;
90         om2p | \
91         om2p-hs | \
92         om2p-lc)
93                 status_led="om2p:blue:power"
94                 ;;
95         pb44)
96                 status_led="pb44:amber:jump1"
97                 ;;
98         rb-411 | rb-411u | rb-433 | rb-433u | rb-450 | rb-450g | rb-493)
99                 status_led="rb4xx:yellow:user"
100                 ;;
101        rb-750)
102                status_led="rb750:green:act"
103                ;;
104         routerstation | routerstation-pro)
105                 status_led="ubnt:green:rf"
106                 ;;
107         rw2458n)
108                 status_led="rw2458n:green:d3"
109                 ;;
110         tew-632brp)
111                 status_led="tew-632brp:green:status"
112                 ;;
113         tew-673gru)
114                 status_led="trendnet:blue:wps"
115                 ;;
116         tew-712br)
117                 status_led="trendnet:green:power"
118                 ;;
119         tl-mr3020)
120                 status_led="tp-link:green:wps"
121                 ;;
122         tl-mr3220 | \
123         tl-mr3420 | \
124         tl-wa901nd | \
125         tl-wa901nd-v2 | \
126         tl-wr1041n-v2 | \
127         tl-wr1043nd | \
128         tl-wr741nd | \
129         tl-wr741nd-v4 | \
130         tl-wr841n-v1 | \
131         tl-wr841n-v7 | \
132         tl-wr841n-v8 | \
133         tl-wr941nd)
134                 status_led="tp-link:green:system"
135                 ;;
136         tl-wdr4300 | \
137         tl-wr703n)
138                 status_led="tp-link:blue:system"
139                 ;;
140         tl-wr2543n)
141                 status_led="tp-link:green:wps"
142                 ;;
143         unifi)
144                 status_led="ubnt:green:dome"
145                 ;;
146         whr-g301n | \
147         whr-hp-g300n | \
148         whr-hp-gn | \
149         wzr-hp-g300nh)
150                 status_led="buffalo:green:router"
151                 ;;
152         wlae-ag300n)
153                 status_led="buffalo:green:status"
154                 ;;
155         wzr-hp-ag300h | \
156         wzr-hp-g300nh2)
157                 status_led="buffalo:red:diag"
158                 ;;
159         wndr3700)
160                 status_led="wndr3700:green:power"
161                 ;;
162         wnr2000)
163                 status_led="wnr2000:green:power"
164                 ;;
165         wp543)
166                 status_led="wp543:green:diag"
167                 ;;
168         wrt400n)
169                 status_led="wrt400n:blue:wps"
170                 ;;
171         wrt160nl)
172                 status_led="wrt160nl:blue:wps"
173                 ;;
174         zcn-1523h-2 | zcn-1523h-5)
175                 status_led="zcn-1523h:amber:init"
176                 ;;
177         esac;
178 }
179
180 set_state() {
181         get_status_led
182
183         case "$1" in
184         preinit)
185                 insmod leds-gpio
186                 insmod ledtrig-default-on
187                 insmod ledtrig-timer
188                 status_led_set_timer 200 200
189                 ;;
190         failsafe)
191                 status_led_set_timer 50 50
192                 ;;
193         done)
194                 status_led_on
195                 ;;
196         esac
197 }