v3: CC : ar71xx: Backport Support for the Bitmain Antminer S3
[15.05/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         case $(ar71xx_board_name) in
9         alfa-nx)
10                 status_led="alfa:green:led_8"
11                 ;;
12         all0305)
13                 status_led="eap7660d:green:ds4"
14                 ;;
15         antminer-s1|\
16         antminer-s3)
17                 status_led="bitmain:green:system"
18                 ;;
19         ap132)
20                 status_led="ap132:green:status"
21                 ;;
22         ap136-010|\
23         ap136-020)
24                 status_led="ap136:green:status"
25                 ;;
26         ap135-020)
27                 status_led="ap135:green:status"
28                 ;;
29         ap81)
30                 status_led="ap81:green:status"
31                 ;;
32         ap83)
33                 status_led="ap83:green:power"
34                 ;;
35         ap96)
36                 status_led="ap96:green:led2"
37                 ;;
38         aw-nr580)
39                 status_led="aw-nr580:green:ready"
40                 ;;
41         bullet-m | rocket-m | rocket-m-xw | nano-m | nanostation-m | nanostation-m-xw | loco-m-xw)
42                 status_led="ubnt:green:link4"
43                 ;;
44         bxu2000n-2-a1)
45                 status_led="bhu:green:status"
46                 ;;
47         cap4200ag)
48                 status_led="senao:green:pwr"
49                 ;;
50         cpe510)
51                 status_led="tp-link:green:link4"
52                 ;;
53         db120)
54                 status_led="db120:green:status"
55                 ;;
56         dgl-5500-a1 |\
57         dhp-1565-a1|\
58         dir-505-a1 |\
59         dir-600-a1 |\
60         dir-615-e1 |\
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         dir-825-c1 |\
71         dir-835-a1)
72                 status_led="d-link:amber:power"
73                 ;;
74         dlan-pro-500-wp)
75                 status_led="devolo:green:wlan-2g"
76                 ;;
77         dlan-pro-1200-ac)
78                 status_led="devolo:status:wlan"
79                 ;;
80         dragino2)
81                 status_led="dragino2:red:system"
82                 ;;
83         eap300v2)
84                 status_led="engenius:blue:power"
85                 ;;
86         eap7660d)
87                 status_led="eap7660d:green:ds4"
88                 ;;
89         el-mini | \
90         el-m150)
91                 status_led="easylink:green:system"
92                 ;;
93         ew-dorin | ew-dorin-router)
94                 status_led="dorin:green:status"
95                 ;;
96         f9k1115v2)
97                 status_led="belkin:blue:status"
98                 ;;
99         gl-inet)
100                 status_led="gl-connect:green:lan"
101                 ;;
102         esr1750)
103                 status_led="esr1750:amber:power"
104                 ;;
105         esr900)
106                 status_led="engenius:amber:power"
107                 ;;
108         hiwifi-hc6361)
109                 status_led="hiwifi:blue:system"
110                 ;;
111         hornet-ub | \
112         hornet-ub-x2)
113                 status_led="alfa:blue:wps"
114                 ;;
115         ja76pf | \
116         ja76pf2)
117                 status_led="jjplus:green:led1"
118                 ;;
119         ls-sr71)
120                 status_led="ubnt:green:d22"
121                 ;;
122         mc-mac1200r)
123                 status_led="mercury:green:system"
124                 ;;
125         mr12)
126                 status_led="mr12:green:power"
127                 ;;
128         mr16)
129                 status_led="mr16:green:power"
130                 ;;
131         mr600)
132                 status_led="mr600:orange:power"
133                 ;;
134         mr600v2)
135                 status_led="mr600:blue:power"
136                 ;;
137         mr900 | \
138         mr900v2)
139                 status_led="mr900:blue:power"
140                 ;;
141         mynet-n600 | \
142         mynet-n750)
143                 status_led="wd:blue:power"
144                 ;;
145         mynet-rext)
146                 status_led="wd:blue:power"
147                 ;;
148         mzk-w04nu | \
149         mzk-w300nh)
150                 status_led="planex:green:status"
151                 ;;
152         nbg460n_550n_550nh)
153                 status_led="nbg460n:green:power"
154                 ;;
155         nbg6716)
156                 status_led="zyxel:white:power"
157                 ;;
158         om2p | \
159         om2pv2 | \
160         om2p-hs | \
161         om2p-hsv2 | \
162         om2p-lc)
163                 status_led="om2p:blue:power"
164                 ;;
165         om5p | \
166         om5p-an)
167                 status_led="om5p:blue:power"
168                 ;;
169         pb44)
170                 status_led="pb44:amber:jump1"
171                 ;;
172         rb-2011l|\
173         rb-2011uas|\
174         rb-2011uas-2hnd)
175                 status_led="rb:green:usr"
176                 ;;
177         rb-411 | rb-411u | rb-433 | rb-433u | rb-450 | rb-450g | rb-493)
178                 status_led="rb4xx:yellow:user"
179                 ;;
180         rb-750)
181                 status_led="rb750:green:act"
182                 ;;
183         rb-911g-2hpnd|\
184         rb-911g-5hpacd|\
185         rb-911g-5hpnd|\
186         rb-912uag-2hpnd|\
187         rb-912uag-5hpnd)
188                 status_led="rb:green:user"
189                 ;;
190         rb-951ui-2hnd)
191                 status_led="rb:green:act"
192                 ;;
193         rb-sxt2n|\
194         rb-sxt5n)
195                 status_led="rb:green:power"
196                 ;;
197         routerstation | routerstation-pro)
198                 status_led="ubnt:green:rf"
199                 ;;
200         rw2458n)
201                 status_led="rw2458n:green:d3"
202                 ;;
203         smart-300)
204                 status_led="nc-link:green:system"
205                 ;;
206         oolite)
207                 status_led="oolite:red:system"
208                 ;;
209         qihoo-c301)
210                 status_led="qihoo:green:status"
211                 ;;
212         tew-632brp)
213                 status_led="tew-632brp:green:status"
214                 ;;
215         tew-673gru)
216                 status_led="trendnet:blue:wps"
217                 ;;
218         tew-712br|\
219         tew-732br)
220                 status_led="trendnet:green:power"
221                 ;;
222         tl-mr3020)
223                 status_led="tp-link:green:wps"
224                 ;;
225         tl-wa750re)
226                 status_led="tp-link:orange:re"
227                 ;;
228         tl-wa850re)
229                 status_led="tp-link:blue:re"
230                 ;;
231         tl-wa860re)
232                 status_led="tp-link:green:power"
233                 ;;
234         tl-mr3220 | \
235         tl-mr3220-v2 | \
236         tl-mr3420 | \
237         tl-mr3420-v2 | \
238         tl-wa701nd-v2 | \
239         tl-wa801nd-v2 | \
240         tl-wa901nd | \
241         tl-wa901nd-v2 | \
242         tl-wa901nd-v3 | \
243         tl-wdr3500 | \
244         tl-wr1041n-v2 | \
245         tl-wr1043nd | \
246         tl-wr1043nd-v2 | \
247         tl-wr741nd | \
248         tl-wr741nd-v4 | \
249         tl-wr841n-v1 | \
250         tl-wr841n-v7 | \
251         tl-wr841n-v8 | \
252         tl-wa830re-v2 | \
253         tl-wr842n-v2 | \
254         tl-wr941nd | \
255         tl-wr941nd-v5)
256                 status_led="tp-link:green:system"
257                 ;;
258         archer-c5 | \
259         archer-c7 | \
260         tl-wdr4900-v2 | \
261         tl-mr10u | \
262         tl-mr12u | \
263         tl-mr13u | \
264         tl-wdr4300 | \
265         tl-wr703n | \
266         tl-wr710n | \
267         tl-wr720n-v3)
268                 status_led="tp-link:blue:system"
269                 ;;
270         tl-wr841n-v9)
271                 status_led="tp-link:green:qss"
272                 ;;
273         tl-wr2543n)
274                 status_led="tp-link:green:wps"
275                 ;;
276         tube2h)
277                 status_led="alfa:green:signal4"
278                 ;;
279         unifi)
280                 status_led="ubnt:green:dome"
281                 ;;
282         uap-pro)
283                 status_led="ubnt:white:dome"
284                 ;;
285         unifi-outdoor-plus)
286                 status_led="ubnt:white:front"
287                 ;;
288         airgateway)
289                 status_led="ubnt:white:status"
290                 ;;
291         whr-g301n | \
292         whr-hp-g300n | \
293         whr-hp-gn | \
294         wzr-hp-g300nh)
295                 status_led="buffalo:green:router"
296                 ;;
297         wlae-ag300n)
298                 status_led="buffalo:green:status"
299                 ;;
300         wzr-hp-ag300h | \
301         wzr-hp-g300nh2)
302                 status_led="buffalo:red:diag"
303                 ;;
304         r6100 | \
305         wndap360 | \
306         wndr3700 | \
307         wndr3700v4 | \
308         wndr4300 | \
309         wnr2000 | \
310         wnr2200 |\
311         wnr612-v2 |\
312         wnr1000-v2)
313                 status_led="netgear:green:power"
314                 ;;
315         wp543)
316                 status_led="wp543:green:diag"
317                 ;;
318         wpj344)
319                 status_led="wpj344:green:status"
320                 ;;
321         wpj531)
322                 status_led="wpj531:green:sig3"
323                 ;;
324         wpj558)
325                 status_led="wpj558:green:sig3"
326                 ;;
327         wrt400n)
328                 status_led="wrt400n:blue:wps"
329                 ;;
330         wrt160nl)
331                 status_led="wrt160nl:blue:wps"
332                 ;;
333         zcn-1523h-2 | zcn-1523h-5)
334                 status_led="zcn-1523h:amber:init"
335                 ;;
336         wlr8100)
337                 status_led="sitecom:amber:status"
338                 ;;
339         esac
340 }
341
342 set_state() {
343         get_status_led
344
345         case "$1" in
346         preinit)
347                 status_led_blink_preinit
348                 ;;
349         failsafe)
350                 status_led_blink_failsafe
351                 ;;
352         preinit_regular)
353                 status_led_blink_preinit_regular
354                 ;;
355         done)
356                 status_led_on
357                 case $(ar71xx_board_name) in
358                 qihoo-c301)
359                         local n=$(fw_printenv activeregion | cut -d = -f 2)
360                         fw_setenv "image${n}trynum" 0
361                         ;;
362                 esac
363                 ;;
364         esac
365 }