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