ar71xx: add support for WHQX E1700AC/E600G/E600GAC v2
[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.sh
5 . /lib/functions/leds.sh
6
7 get_status_led() {
8 local board=$(board_name)
9
10 case $board in
11 a40)
12 status_led="a40:green:status"
13 ;;
14 a60)
15 status_led="a60:green:status"
16 ;;
17 alfa-nx)
18 status_led="alfa:green:led_8"
19 ;;
20 all0305)
21 status_led="eap7660d:green:ds4"
22 ;;
23 antminer-s1|\
24 antminer-s3|\
25 antminer-r1|\
26 e1700ac-v2|\
27 e600gac-v2|\
28 eap120|\
29 minibox-v1|\
30 som9331|\
31 sr3200|\
32 tl-wr802n-v2|\
33 xd3200)
34 status_led="$board:green:system"
35 ;;
36 ap121f)
37 status_led="$board:green:vpn"
38 ;;
39 ap132|\
40 ap531b0|\
41 cpe505n|\
42 db120|\
43 dr342|\
44 dr344|\
45 rut900|\
46 tew-632brp|\
47 tl-wr942n-v1|\
48 wpj344|\
49 zbt-we1526)
50 status_led="$board:green:status"
51 ;;
52 ap136-010|\
53 ap136-020)
54 status_led="ap136:green:status"
55 ;;
56 ap147-010)
57 status_led="ap147:green:status"
58 ;;
59 ap135-020)
60 status_led="ap135:green:status"
61 ;;
62 archer-c25-v1|\
63 archer-c58-v1|\
64 archer-c59-v1|\
65 archer-c60-v1|\
66 archer-c7-v4|\
67 fritz300e|\
68 gl-usb150|\
69 mr12|\
70 mr16|\
71 nbg6616|\
72 sc1750|\
73 sc450|\
74 tl-wpa8630|\
75 tl-wr902ac-v1)
76 status_led="$board:green:power"
77 ;;
78 archer-c5|\
79 archer-c7|\
80 tl-mr10u|\
81 tl-mr12u|\
82 tl-mr13u|\
83 tl-wdr4300|\
84 tl-wdr4900-v2|\
85 tl-wr703n|\
86 tl-wr710n|\
87 tl-wr720n-v3|\
88 tl-wr802n-v1|\
89 tl-wr810n|\
90 tl-wr810n-v2|\
91 tl-wr940n-v4|\
92 tl-wr941nd-v6)
93 status_led="tp-link:blue:system"
94 ;;
95 ap90q|\
96 cpe830|\
97 cpe870|\
98 gl-ar300m|\
99 gl-inet|\
100 gl-mifi)
101 status_led="$board:green:lan"
102 ;;
103 ap91-5g|\
104 n5q)
105 status_led="$board:green:signal4"
106 ;;
107 ap96)
108 status_led="$board:green:led2"
109 ;;
110 aw-nr580)
111 status_led="$board:green:ready"
112 ;;
113 bhr-4grv2|\
114 wzr-hp-ag300h|\
115 wzr-hp-g300nh2)
116 status_led="buffalo:red:diag"
117 ;;
118 bsb)
119 status_led="$board:red:sys"
120 ;;
121 bullet-m|\
122 loco-m-xw|\
123 nano-m|\
124 nanostation-m|\
125 nanostation-m-xw|\
126 rocket-m|\
127 rocket-m-xw)
128 status_led="ubnt:green:link4"
129 ;;
130 bxu2000n-2-a1)
131 status_led="bhu:green:status"
132 ;;
133 cap324)
134 status_led="pcs:green:power"
135 ;;
136 c-55|\
137 c-60)
138 status_led="$board:green:pwr"
139 ;;
140 cap4200ag)
141 status_led="senao:green:pwr"
142 ;;
143 cf-e316n-v2|\
144 cf-e520n|\
145 cf-e530n)
146 status_led="$board:blue:wan"
147 ;;
148 cf-e320n-v2)
149 status_led="$board:blue:wlan"
150 ;;
151 cf-e380ac-v1|\
152 cf-e380ac-v2)
153 status_led="$board:blue:wlan2g"
154 ;;
155 cpe510)
156 status_led="tp-link:green:link4"
157 ;;
158 cr3000|\
159 cr5000)
160 status_led="pcs:amber:power"
161 ;;
162 dgl-5500-a1|\
163 dhp-1565-a1|\
164 dir-505-a1|\
165 dir-600-a1|\
166 dir-615-e1|\
167 dir-615-i1|\
168 dir-615-e4)
169 status_led="d-link:green:power"
170 ;;
171 dir-615-c1)
172 status_led="d-link:green:status"
173 ;;
174 dir-825-b1)
175 status_led="d-link:orange:power"
176 ;;
177 dir-825-c1|\
178 dir-835-a1)
179 status_led="d-link:amber:power"
180 ;;
181 dir-869-a1)
182 status_led="d-link:white:status"
183 ;;
184 dlan-hotspot)
185 status_led="devolo:green:wifi"
186 ;;
187 dlan-pro-500-wp)
188 status_led="devolo:green:wlan-2g"
189 ;;
190 dlan-pro-1200-ac)
191 status_led="devolo:status:wlan"
192 ;;
193 dr531)
194 status_led="$board:green:sig4"
195 ;;
196 dragino2|\
197 oolite)
198 status_led="$board:red:system"
199 ;;
200 dw33d|\
201 r36a)
202 status_led="$board:blue:status"
203 ;;
204 e600g-v2)
205 status_led="$board:blue:system"
206 ;;
207 eap300v2)
208 status_led="engenius:blue:power"
209 ;;
210 ens202ext|\
211 esr900)
212 status_led="engenius:amber:power"
213 ;;
214 eap7660d)
215 status_led="$board:green:ds4"
216 ;;
217 el-m150|\
218 el-mini)
219 status_led="easylink:green:system"
220 ;;
221 ew-balin)
222 status_led="balin:green:status"
223 ;;
224 ew-dorin|\
225 ew-dorin-router)
226 status_led="dorin:green:status"
227 ;;
228 f9k1115v2)
229 status_led="belkin:blue:status"
230 ;;
231 epg5000|\
232 esr1750)
233 status_led="$board:amber:power"
234 ;;
235 gl-ar750|\
236 hiveap-121|\
237 nbg6716)
238 status_led="$board:white:power"
239 ;;
240 hiwifi-hc6361)
241 status_led="hiwifi:blue:system"
242 ;;
243 hornet-ub|\
244 hornet-ub-x2)
245 status_led="alfa:blue:wps"
246 ;;
247 ja76pf|\
248 ja76pf2)
249 status_led="jjplus:green:led1"
250 ;;
251 jwap230)
252 status_led="$board:green:led1"
253 ;;
254 ls-sr71)
255 status_led="ubnt:green:d22"
256 ;;
257 mc-mac1200r)
258 status_led="mercury:green:system"
259 ;;
260 mr18|\
261 z1)
262 status_led="$board:green:tricolor0"
263 ;;
264 mr600)
265 status_led="$board:orange:power"
266 ;;
267 mr600v2)
268 status_led="mr600:blue:power"
269 ;;
270 mr1750|\
271 mr1750v2)
272 status_led="mr1750:blue:power"
273 ;;
274 mr900|\
275 mr900v2)
276 status_led="mr900:blue:power"
277 ;;
278 mynet-n600|\
279 mynet-n750|\
280 mynet-rext)
281 status_led="wd:blue:power"
282 ;;
283 mzk-w04nu|\
284 mzk-w300nh)
285 status_led="planex:green:status"
286 ;;
287 nbg460n_550n_550nh)
288 status_led="nbg460n:green:power"
289 ;;
290 om2p|\
291 om2p-hs|\
292 om2p-hsv2|\
293 om2p-hsv3|\
294 om2p-hsv4|\
295 om2p-lc|\
296 om2pv2|\
297 om2pv4)
298 status_led="om2p:blue:power"
299 ;;
300 om5p|\
301 om5p-an)
302 status_led="om5p:blue:power"
303 ;;
304 om5p-ac|\
305 om5p-acv2)
306 status_led="om5pac:blue:power"
307 ;;
308 omy-g1)
309 status_led="omy:green:wlan"
310 ;;
311 omy-x1)
312 status_led="omy:green:power"
313 ;;
314 onion-omega)
315 status_led="onion:amber:system"
316 ;;
317 pb44)
318 status_led="$board:amber:jump1"
319 ;;
320 r602n)
321 status_led="$board:green:wan"
322 ;;
323 rb-2011il|\
324 rb-2011l|\
325 rb-2011uas|\
326 rb-2011uas-2hnd)
327 status_led="rb:green:usr"
328 ;;
329 rb-411|\
330 rb-411u|\
331 rb-433|\
332 rb-433u|\
333 rb-450|\
334 rb-450g|\
335 rb-493)
336 status_led="rb4xx:yellow:user"
337 ;;
338 rb-750)
339 status_led="rb750:green:act"
340 ;;
341 rb-750-r2|\
342 rb-750p-pbr2|\
343 rb-750up-r2|\
344 rb-911-2hn|\
345 rb-911-5hn|\
346 rb-911g-2hpnd|\
347 rb-911g-5hpacd|\
348 rb-911g-5hpnd|\
349 rb-941-2nd|\
350 rb-951ui-2nd|\
351 rb-952ui-5ac2nd|\
352 rb-962uigs-5hact2hnt|\
353 rb-lhg-5nd|\
354 rb-map-2nd|\
355 rb-mapl-2nd)
356 status_led="rb:green:user"
357 ;;
358 rb-951ui-2hnd)
359 status_led="rb:green:act"
360 ;;
361 rb-912uag-2hpnd|\
362 rb-912uag-5hpnd|\
363 rb-sxt2n|\
364 rb-sxt5n)
365 status_led="rb:green:power"
366 ;;
367 re355|\
368 re450|\
369 sc300m)
370 status_led="$board:blue:power"
371 ;;
372 rocket-m-ti)
373 status_led="ubnt:green:link6"
374 ;;
375 routerstation|\
376 routerstation-pro)
377 status_led="ubnt:green:rf"
378 ;;
379 rw2458n)
380 status_led="$board:green:d3"
381 ;;
382 smart-300)
383 status_led="nc-link:green:system"
384 ;;
385 qihoo-c301)
386 status_led="qihoo:green:status"
387 ;;
388 tellstick-znet-lite)
389 status_led="tellstick:white:system"
390 ;;
391 tew-673gru)
392 status_led="trendnet:blue:wps"
393 ;;
394 tew-712br|\
395 tew-732br|\
396 tew-823dru)
397 status_led="trendnet:green:power"
398 ;;
399 tl-mr3020|\
400 tl-wr2543n)
401 status_led="tp-link:green:wps"
402 ;;
403 tl-wa750re)
404 status_led="tp-link:orange:re"
405 ;;
406 tl-wa850re|\
407 tl-wa850re-v2)
408 status_led="tp-link:blue:re"
409 ;;
410 tl-wa855re-v1|\
411 tl-wa860re)
412 status_led="tp-link:green:power"
413 ;;
414 tl-mr6400)
415 status_led="tp-link:white:power"
416 ;;
417 tl-mr3220|\
418 tl-mr3220-v2|\
419 tl-mr3420|\
420 tl-mr3420-v2|\
421 tl-wa701nd-v2|\
422 tl-wa801nd-v2|\
423 tl-wa801nd-v3|\
424 tl-wa830re-v2|\
425 tl-wa901nd|\
426 tl-wa901nd-v2|\
427 tl-wa901nd-v3|\
428 tl-wa901nd-v4|\
429 tl-wa901nd-v5|\
430 tl-wdr3320-v2|\
431 tl-wdr3500|\
432 tl-wr1041n-v2|\
433 tl-wr1043n-v5|\
434 tl-wr1043nd|\
435 tl-wr1043nd-v2|\
436 tl-wr1043nd-v4|\
437 tl-wr740n-v6|\
438 tl-wr741nd|\
439 tl-wr741nd-v4|\
440 tl-wr840n-v2|\
441 tl-wr840n-v3|\
442 tl-wr841n-v1|\
443 tl-wr841n-v7|\
444 tl-wr841n-v8|\
445 tl-wr841n-v11|\
446 tl-wr842n-v2|\
447 tl-wr842n-v3|\
448 tl-wr941nd|\
449 tl-wr941nd-v5)
450 status_led="tp-link:green:system"
451 ;;
452 tl-wr841n-v9)
453 status_led="tp-link:green:qss"
454 ;;
455 tl-wdr6500-v2)
456 status_led="tp-link:white:system"
457 ;;
458 tube2h)
459 status_led="alfa:green:signal4"
460 ;;
461 unifi)
462 status_led="ubnt:green:dome"
463 ;;
464 uap-pro|\
465 unifiac-lite|\
466 unifiac-pro)
467 status_led="ubnt:white:dome"
468 ;;
469 unifi-outdoor-plus)
470 status_led="ubnt:white:front"
471 ;;
472 airgateway|\
473 airgatewaypro)
474 status_led="ubnt:white:status"
475 ;;
476 wi2a-ac200i)
477 status_led="nokia:green:ctrl"
478 ;;
479 whr-g301n|\
480 whr-hp-g300n|\
481 whr-hp-gn|\
482 wzr-hp-g300nh)
483 status_led="buffalo:green:router"
484 ;;
485 wlae-ag300n)
486 status_led="buffalo:green:status"
487 ;;
488 r6100|\
489 wndap360|\
490 wndr3700|\
491 wndr3700v4|\
492 wndr4300|\
493 wnr2000|\
494 wnr2000-v3|\
495 wnr2200|\
496 wnr612-v2|\
497 wnr1000-v2|\
498 wpn824n)
499 status_led="netgear:green:power"
500 ;;
501 wp543)
502 status_led="$board:green:diag"
503 ;;
504 wpj342|\
505 wpj531|\
506 wpj558)
507 status_led="$board:green:sig3"
508 ;;
509 wpj563)
510 status_led="$board:green:sig1"
511 ;;
512 wrt160nl|\
513 wrt400n)
514 status_led="$board:blue:wps"
515 ;;
516 zcn-1523h-2|\
517 zcn-1523h-5)
518 status_led="zcn-1523h:amber:init"
519 ;;
520 wlr8100)
521 status_led="sitecom:amber:status"
522 ;;
523 esac
524 }
525
526 set_state() {
527 get_status_led
528
529 case "$1" in
530 preinit)
531 status_led_blink_preinit
532 ;;
533 failsafe)
534 status_led_blink_failsafe
535 ;;
536 preinit_regular)
537 status_led_blink_preinit_regular
538 ;;
539 done)
540 status_led_on
541 case $(board_name) in
542 gl-ar300m|\
543 gl-ar750)
544 fw_printenv lc >/dev/null 2>&1 && fw_setenv "bootcount" 0
545 ;;
546 qihoo-c301)
547 local n=$(fw_printenv activeregion | cut -d = -f 2)
548 fw_setenv "image${n}trynum" 0
549 ;;
550 wi2a-ac200i)
551 fw_setenv PKRstCnt 0
552 ;;
553 esac
554 ;;
555 esac
556 }