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