ramips: add user-space support for TEW-691GR
[openwrt.git] / target / linux / ramips / base-files / etc / diag.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2010 OpenWrt.org
4 #
5 #
6
7 . /lib/ramips.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 $(ramips_board_name) in
33         3g-6200n)
34                 status_led="edimax:green:power"
35                 ;;
36         argus-atp52b)
37                 status_led="argus-atp52b:green:run"
38                 ;;
39         dir-300-b1 | dir-600-b1 | dir-600-b2 | dir-615-h1 | dir-620-a1)
40                 status_led="d-link:green:status"
41                 ;;
42         dir-645)
43                 status_led="d-link:green:wps"
44                 ;;
45         dap-1350)
46                 status_led="d-link:blue:power"
47                 ;;
48         esr-9753)
49                 status_led="esr-9753:orange:power"
50                 ;;
51         f5d8235-v2)
52                 status_led="f5d8235v2:blue:router"
53                 ;;
54         fonera20n)
55                 status_led="fonera20n:green:power"
56                 ;;
57         all0239-3g|\
58         hw550-3g)
59                 status_led="hw550-3g:green:status"
60                 ;;
61         mofi3500-3gn)
62                 status_led="mofi3500-3gn:green:status"
63                 ;;
64         nbg-419n)
65                 status_led="nbg-419n:green:power"
66                 ;;
67         nw718)
68                 status_led="nw718:amber:cpu"
69                 ;;
70         omni-emb)
71                 status_led="emb:green:status"
72                 ;;
73         psr-680w)
74                 status_led="psr-680w:red:wan"
75                 ;;
76         pwh2004)
77                 status_led="pwh2004:green:power"
78                 ;;
79         rt-n15)
80                 status_led="rt-n15:blue:power"
81                 ;;
82         rt-n10-plus)
83                 status_led="asus:green:wps"
84                 ;;
85         rt-n56u | wl-330n | wl-330n3g)
86                 status_led="asus:blue:power"
87                 ;;
88         sl-r7205)
89                 status_led="sl-r7205:green:status"
90                 ;;
91         tew-691gr|\
92         tew-692gr)
93                 status_led="trendnet:green:wps"
94                 ;;
95         v11st-fe)
96                 status_led="v11st-fe:green:status"
97                 ;;
98         v22rw-2x2)
99                 status_led="v22rw-2x2:green:security"
100                 ;;
101         w306r-v20)
102                 status_led="w306r-v20:green:sys"
103                 ;;
104         w502u)
105                 status_led="alfa:blue:wps"
106                 ;;
107         wcr-150gn)
108                 status_led="wcr150gn:amber:power"
109                 ;;
110         whr-g300n)
111                 status_led="whr-g300n:green:router"
112                 ;;
113         wli-tx4-ag300n)
114                 status_led="buffalo:blue:power"
115                 ;;
116         wl-351)
117                 status_led="wl-351:amber:power"
118                 ;;
119         wr512-3gn)
120                 status_led="wr512:green:wps"
121                 ;;
122         ur-336un)
123                 status_led="ur336:green:wps"
124                 ;;
125         xdxrn502j)
126                 status_led="xdxrn502j:green:power"
127                 ;;
128         esac
129 }
130
131 set_state() {
132         get_status_led
133
134         case "$1" in
135         preinit)
136                 insmod leds-gpio
137                 status_led_set_timer 200 200
138                 ;;
139         failsafe)
140                 status_led_set_timer 50 50
141                 ;;
142         done)
143                 status_led_on
144                 ;;
145         esac
146 }