generic: ar8216: improve ar8xxx_is_possible check
[openwrt/openwrt.git] / target / linux / ar71xx / base-files / etc / diag.sh
1 #!/bin/sh
2 # Copyright (C) 2009-2013 OpenWrt.org
3
4 . /lib/functions/leds.sh
5 . /lib/ar71xx.sh
6
7 get_status_led() {
8 local board=$(ar71xx_board_name)
9
10 case $board in
11 alfa-nx)
12 status_led="alfa:green:led_8"
13 ;;
14 all0305)
15 status_led="eap7660d:green:ds4"
16 ;;
17 antminer-s1|\
18 antminer-s3|\
19 antminer-r1|\
20 minibox-v1|\
21 som9331)
22 status_led="$board:green:system"
23 ;;
24 ap132|\
25 ap81|\
26 db120|\
27 dr344|\
28 tew-632brp|\
29 wpj344|\
30 zbt-we1526)
31 status_led="$board:green:status"
32 ;;
33 ap136-010|\
34 ap136-020)
35 status_led="ap136:green:status"
36 ;;
37 ap147-010)
38 status_led="ap147:green:status"
39 ;;
40 ap135-020)
41 status_led="ap135:green:status"
42 ;;
43 ap83|\
44 mr12|\
45 mr16|\
46 nbg6616)
47 status_led="$board:green:power"
48 ;;
49 ap96)
50 status_led="$board:green:led2"
51 ;;
52 aw-nr580)
53 status_led="$board:green:ready"
54 ;;
55 bsb)
56 status_led="$board:red:sys"
57 ;;
58 bullet-m|\
59 rocket-m|\
60 rocket-m-xw|\
61 nano-m|\
62 nanostation-m|\
63 nanostation-m-xw|\
64 loco-m-xw)
65 status_led="ubnt:green:link4"
66 ;;
67 rocket-m-ti)
68 status_led="ubnt:green:link6"
69 ;;
70 bxu2000n-2-a1)
71 status_led="bhu:green:status"
72 ;;
73 cap324)
74 status_led="pcs:green:power"
75 ;;
76 c-55)
77 status_led="$board:green:pwr"
78 ;;
79 cap4200ag)
80 status_led="senao:green:pwr"
81 ;;
82 cf-e316n-v2)
83 status_led="$board:blue:wan"
84 ;;
85 cpe510)
86 status_led="tp-link:green:link4"
87 ;;
88 cr3000)
89 status_led="pcs:amber:power"
90 ;;
91 cr5000)
92 status_led="pcs:amber:power"
93 ;;
94 dgl-5500-a1|\
95 dhp-1565-a1|\
96 dir-505-a1|\
97 dir-600-a1|\
98 dir-615-e1|\
99 dir-615-i1|\
100 dir-615-e4)
101 status_led="d-link:green:power"
102 ;;
103 dir-615-c1)
104 status_led="d-link:green:status"
105 ;;
106 dir-825-b1)
107 status_led="d-link:orange:power"
108 ;;
109 dir-825-c1|\
110 dir-835-a1)
111 status_led="d-link:amber:power"
112 ;;
113 dir-869-a1)
114 status_led="d-link:white:status"
115 ;;
116 dlan-hotspot)
117 status_led="devolo:green:wifi"
118 ;;
119 dlan-pro-500-wp)
120 status_led="devolo:green:wlan-2g"
121 ;;
122 dlan-pro-1200-ac)
123 status_led="devolo:status:wlan"
124 ;;
125 dr531)
126 status_led="$board:green:sig4"
127 ;;
128 dragino2|\
129 oolite)
130 status_led="$board:red:system"
131 ;;
132 eap300v2)
133 status_led="engenius:blue:power"
134 ;;
135 eap7660d)
136 status_led="$board:green:ds4"
137 ;;
138 el-mini|\
139 el-m150)
140 status_led="easylink:green:system"
141 ;;
142 ew-dorin|\
143 ew-dorin-router)
144 status_led="dorin:green:status"
145 ;;
146 f9k1115v2)
147 status_led="belkin:blue:status"
148 ;;
149 gl-inet)
150 status_led="$board:green:lan"
151 ;;
152 epg5000|\
153 esr1750)
154 status_led="$board:amber:power"
155 ;;
156 esr900)
157 status_led="engenius:amber:power"
158 ;;
159 hiwifi-hc6361)
160 status_led="hiwifi:blue:system"
161 ;;
162 hornet-ub|\
163 hornet-ub-x2)
164 status_led="alfa:blue:wps"
165 ;;
166 ja76pf|\
167 ja76pf2)
168 status_led="jjplus:green:led1"
169 ;;
170 jwap230)
171 status_led="$board:green:led1"
172 ;;
173 ls-sr71)
174 status_led="ubnt:green:d22"
175 ;;
176 mc-mac1200r)
177 status_led="mercury:green:system"
178 ;;
179 mr18|\
180 z1)
181 status_led="$board:green:tricolor0"
182 ;;
183 mr600)
184 status_led="$board:orange:power"
185 ;;
186 mr600v2)
187 status_led="mr600:blue:power"
188 ;;
189 mr1750|\
190 mr1750v2)
191 status_led="mr1750:blue:power"
192 ;;
193 mr900|\
194 mr900v2)
195 status_led="mr900:blue:power"
196 ;;
197 mynet-n600|\
198 mynet-n750)
199 status_led="wd:blue:power"
200 ;;
201 mynet-rext)
202 status_led="wd:blue:power"
203 ;;
204 mzk-w04nu|\
205 mzk-w300nh)
206 status_led="planex:green:status"
207 ;;
208 nbg460n_550n_550nh)
209 status_led="nbg460n:green:power"
210 ;;
211 nbg6716)
212 status_led="$board:white:power"
213 ;;
214 om2p|\
215 om2pv2|\
216 om2p-hs|\
217 om2p-hsv2|\
218 om2p-hsv3|\
219 om2p-lc)
220 status_led="om2p:blue:power"
221 ;;
222 om5p|\
223 om5p-an)
224 status_led="om5p:blue:power"
225 ;;
226 om5p-ac|\
227 om5p-acv2)
228 status_led="om5pac:blue:power"
229 ;;
230 omy-g1)
231 status_led="omy:green:wlan"
232 ;;
233 omy-x1)
234 status_led="omy:green:power"
235 ;;
236 onion-omega)
237 status_led="onion:amber:system"
238 ;;
239 pb44)
240 status_led="$board:amber:jump1"
241 ;;
242 rb-2011l|\
243 rb-2011uas|\
244 rb-2011uas-2hnd)
245 status_led="rb:green:usr"
246 ;;
247 rb-411|\
248 rb-411u|\
249 rb-433|\
250 rb-433u|\
251 rb-450|\
252 rb-450g|\
253 rb-493)
254 status_led="rb4xx:yellow:user"
255 ;;
256 rb-750)
257 status_led="rb750:green:act"
258 ;;
259 rb-911g-2hpnd|\
260 rb-911g-5hpacd|\
261 rb-911g-5hpnd|\
262 rb-912uag-2hpnd|\
263 rb-912uag-5hpnd)
264 status_led="rb:green:user"
265 ;;
266 rb-951ui-2hnd)
267 status_led="rb:green:act"
268 ;;
269 rb-sxt2n|\
270 rb-sxt5n)
271 status_led="rb:green:power"
272 ;;
273 routerstation|\
274 routerstation-pro)
275 status_led="ubnt:green:rf"
276 ;;
277 rw2458n)
278 status_led="$board:green:d3"
279 ;;
280 smart-300)
281 status_led="nc-link:green:system"
282 ;;
283 qihoo-c301)
284 status_led="qihoo:green:status"
285 ;;
286 tellstick-znet-lite)
287 status_led="tellstick:white:system"
288 ;;
289 tew-673gru)
290 status_led="trendnet:blue:wps"
291 ;;
292 tew-712br|\
293 tew-732br|\
294 tew-823dru)
295 status_led="trendnet:green:power"
296 ;;
297 tl-mr3020)
298 status_led="tp-link:green:wps"
299 ;;
300 tl-wa750re)
301 status_led="tp-link:orange:re"
302 ;;
303 tl-wa850re)
304 status_led="tp-link:blue:re"
305 ;;
306 tl-wa860re)
307 status_led="tp-link:green:power"
308 ;;
309 tl-mr3220|\
310 tl-mr3220-v2|\
311 tl-mr3420|\
312 tl-mr3420-v2|\
313 tl-wa701nd-v2|\
314 tl-wa801nd-v2|\
315 tl-wa901nd|\
316 tl-wa901nd-v2|\
317 tl-wa901nd-v3|\
318 tl-wa901nd-v4|\
319 tl-wdr3320-v2|\
320 tl-wdr3500|\
321 tl-wr1041n-v2|\
322 tl-wr1043nd|\
323 tl-wr1043nd-v2|\
324 tl-wr741nd|\
325 tl-wr741nd-v4|\
326 tl-wr841n-v1|\
327 tl-wr841n-v7|\
328 tl-wr841n-v8|\
329 tl-wr841n-v11|\
330 tl-wa830re-v2|\
331 tl-wr842n-v2|\
332 tl-wr842n-v3|\
333 tl-wr941nd|\
334 tl-wr941nd-v5)
335 status_led="tp-link:green:system"
336 ;;
337 archer-c5|\
338 archer-c7|\
339 tl-wdr4900-v2|\
340 tl-mr10u|\
341 tl-mr12u|\
342 tl-mr13u|\
343 tl-wdr4300|\
344 tl-wr703n|\
345 tl-wr710n|\
346 tl-wr720n-v3|\
347 tl-wr810n|\
348 tl-wr941nd-v6)
349 status_led="tp-link:blue:system"
350 ;;
351 tl-wr841n-v9)
352 status_led="tp-link:green:qss"
353 ;;
354 tl-wr2543n)
355 status_led="tp-link:green:wps"
356 ;;
357 tl-wdr6500-v2)
358 status_led="tp-link:white:system"
359 ;;
360 tube2h)
361 status_led="alfa:green:signal4"
362 ;;
363 unifi)
364 status_led="ubnt:green:dome"
365 ;;
366 uap-pro|\
367 unifiac-lite|\
368 unifiac-pro)
369 status_led="ubnt:white:dome"
370 ;;
371 unifi-outdoor-plus)
372 status_led="ubnt:white:front"
373 ;;
374 airgateway|\
375 airgatewaypro)
376 status_led="ubnt:white:status"
377 ;;
378 whr-g301n|\
379 whr-hp-g300n|\
380 whr-hp-gn|\
381 wzr-hp-g300nh)
382 status_led="buffalo:green:router"
383 ;;
384 wlae-ag300n)
385 status_led="buffalo:green:status"
386 ;;
387 wzr-hp-ag300h|\
388 wzr-hp-g300nh2)
389 status_led="buffalo:red:diag"
390 ;;
391 r6100|\
392 wndap360|\
393 wndr3700|\
394 wndr3700v4|\
395 wndr4300|\
396 wnr2000|\
397 wnr2000-v3|\
398 wnr2200|\
399 wnr612-v2|\
400 wnr1000-v2|\
401 wpn824n)
402 status_led="netgear:green:power"
403 ;;
404 wp543)
405 status_led="$board:green:diag"
406 ;;
407 wpj342|\
408 wpj531|\
409 wpj558)
410 status_led="$board:green:sig3"
411 ;;
412 wrt400n|\
413 wrt160nl)
414 status_led="$board:blue:wps"
415 ;;
416 zcn-1523h-2|\
417 zcn-1523h-5)
418 status_led="zcn-1523h:amber:init"
419 ;;
420 wlr8100)
421 status_led="sitecom:amber:status"
422 ;;
423 esac
424 }
425
426 set_state() {
427 get_status_led
428
429 case "$1" in
430 preinit)
431 status_led_blink_preinit
432 ;;
433 failsafe)
434 status_led_blink_failsafe
435 ;;
436 preinit_regular)
437 status_led_blink_preinit_regular
438 ;;
439 done)
440 status_led_on
441 case $(ar71xx_board_name) in
442 gl-ar300m)
443 fw_printenv lc >/dev/null 2>&1 && fw_setenv "bootcount" 0
444 ;;
445 qihoo-c301)
446 local n=$(fw_printenv activeregion | cut -d = -f 2)
447 fw_setenv "image${n}trynum" 0
448 ;;
449 esac
450 ;;
451 esac
452 }