066f3bdb404a0b954380bfdc842f270439ee21b5
[openwrt.git] / target / linux / ramips / base-files / lib / ramips.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2010-2013 OpenWrt.org
4 #
5
6 RAMIPS_BOARD_NAME=
7 RAMIPS_MODEL=
8
9 ramips_board_detect() {
10         local machine
11         local name
12
13         machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
14
15         case "$machine" in
16         *"8devices Carambola")
17                 name="carambola"
18                 ;;
19         *"Edimax 3g-6200n")
20                 name="3g-6200n"
21                 ;;
22         *"Edimax 3g-6200nl")
23                 name="3g-6200nl"
24                 ;;
25         *"AirLive Air3GII")
26                 name="air3gii"
27                 ;;
28         *"Edimax BR-6425")
29                 name="br6425"
30                 ;;
31         *"Allnet ALL0239-3G")
32                 name="all0239-3g"
33                 ;;
34         *"Allnet ALL0256N")
35                 name="all0256n"
36                 ;;
37         *"Allnet ALL5002")
38                 name="all5002"
39                 ;;
40         *"Allnet ALL5003")
41                 name="all5003"
42                 ;;
43         *"ARC FreeStation5")
44                 name="freestation5"
45                 ;;
46         *"Argus ATP-52B")
47                 name="argus-atp52b"
48                 ;;
49         *"AsiaRF AWM002-EVB")
50                 name="awm002-evb"
51                 ;;
52         *"BR6524N")
53                 name="br6524n"
54                 ;;
55         *"Asus WL-330N")
56                 name="wl-330n"
57                 ;;
58         *"Asus WL-330N3G")
59                 name="wl-330n3g"
60                 ;;
61         *"Alpha ASL26555")
62                 name="asl26555"
63                 ;;
64         *"Aztech HW550-3G")
65                 name="hw550-3g"
66                 ;;
67         *"DIR-300 B1")
68                 name="dir-300-b1"
69                 ;;
70         *"DIR-600 B1")
71                 name="dir-600-b1"
72                 ;;
73         *"DIR-600 B2")
74                 name="dir-600-b2"
75                 ;;
76         *"DIR-610 A1")
77                 name="dir-610-a1"
78                 ;;
79         *"DIR-620 A1")
80                 name="dir-620-a1"
81                 ;;
82         *"DIR-620 D1")
83                 name="dir-620-d1"
84                 ;;
85         *"DIR-615 H1")
86                 name="dir-615-h1"
87                 ;;
88         *"DIR-615 D")
89                 name="dir-615-d"
90                 ;;
91         *"DIR-645")
92                 name="dir-645"
93                 ;;
94         *"DIR-810L")
95                 name="dir-810l"
96                 ;;
97         *"DAP-1350")
98                 name="dap-1350"
99                 ;;
100         *"ESR-9753")
101                 name="esr-9753"
102                 ;;
103         *"F7C027")
104                 name="f7c027"
105                 ;;
106         *"F5D8235 v1")
107                 name="f5d8235-v1"
108                 ;;
109         *"F5D8235 v2")
110                 name="f5d8235-v2"
111                 ;;
112         *"Hauppauge Broadway")
113                 name="broadway"
114                 ;;
115         *"Huawei D105")
116                 name="d105"
117                 ;;
118         *"La Fonera 2.0N")
119                 name="fonera20n"
120                 ;;
121         *"Asus RT-N13U")
122                 name="rt-n13u"
123                 ;;
124         *"MoFi Network MOFI3500-3GN")
125                 name="mofi3500-3gn"
126                 ;;
127         *"HAME MPR-A1")
128                 name="mpr-a1"
129                 ;;
130         *"HAME MPR-A2")
131                 name="mpr-a2"
132                 ;;
133         *"NBG-419N")
134                 name="nbg-419n"
135                 ;;
136         *"Netgear WNCE2001")
137                 name="wnce2001"
138                 ;;
139         *"NexAira BC2")
140                 name="bc2"
141                 ;;
142         *"NW718")
143                 name="nw718"
144                 ;;
145         *"Omnima EMB HPM")
146                 name="omni-emb-hpm"
147                 ;;
148         *"Omnima MiniEMBWiFi")
149                 name="omni-emb"
150                 ;;
151         *"Petatel PSR-680W"*)
152                 name="psr-680w"
153                 ;;
154         *"Planex MZK-W300NH2"*)
155                 name="mzk-w300nh2"
156                 ;;
157         *"Poray IP2202")
158                 name="ip2202"
159                 ;;
160         *"Poray M3")
161                 name="m3"
162                 ;;
163         *"Poray M4")
164                 name="m4"
165                 ;;
166         *"Poray X5")
167                 name="x5"
168                 ;;
169         *"Poray X8")
170                 name="x8"
171                 ;;
172         *"PWH2004")
173                 name="pwh2004"
174                 ;;
175         *"Asus RP-N53")
176                 name="rp-n53"
177                 ;;
178         *"RT-G32 B1")
179                 name="rt-g32-b1"
180                 ;;
181         *"RT-N10+")
182                 name="rt-n10-plus"
183                 ;;
184         *"RT-N15")
185                 name="rt-n15"
186                 ;;
187         *"RT-N56U")
188                 name="rt-n56u"
189                 ;;
190         *"Skyline SL-R7205"*)
191                 name="sl-r7205"
192                 ;;
193         *"Sparklan WCR-150GN")
194                 name="wcr-150gn"
195                 ;;
196         *"V22RW-2X2")
197                 name="v22rw-2x2"
198                 ;;
199         *"W502U")
200                 name="w502u"
201                 ;;
202         *"WHR-G300N")
203                 name="whr-g300n"
204                 ;;
205         *"Sitecom WL-341 v3")
206                 name="wl341v3"
207                 ;;
208         *"Sitecom WL-351 v1 002")
209                 name="wl-351"
210                 ;;
211         *"Tenda 3G300M")
212                 name="3g300m"
213                 ;;
214         *"Tenda W306R V2.0")
215                 name="w306r-v20"
216                 ;;
217         *"Tenda W150M")
218                 name="w150m"
219                 ;;
220         *"TEW-691GR")
221                 name="tew-691gr"
222                 ;;
223         *"TEW-692GR")
224                 name="tew-692gr"
225                 ;;
226         *"Ralink V11ST-FE")
227                 name="v11st-fe"
228                 ;;
229         *"WLI-TX4-AG300N")
230                 name="wli-tx4-ag300n"
231                 ;;
232         *"WZR-AGL300NH")
233                 name="wzr-agl300nh"
234                 ;;
235         *"WR512-3GN-like router")
236                 name="wr512-3gn"
237                 ;;
238         *"UR-326N4G Wireless N router")
239                 name="ur-326n4g"
240                 ;;
241         *"UR-336UN Wireless N router")
242                 name="ur-336un"
243                 ;;
244         *"AWB WR6202")
245                 name="wr6202"
246                 ;;
247         *"XDX RN502J")
248                 name="xdxrn502j"
249                 ;;
250         *"HG255D")
251                 name="hg255d"
252                 ;;
253         *)
254                 name="generic"
255                 ;;
256         esac
257
258         [ -z "$RAMIPS_BOARD_NAME" ] && RAMIPS_BOARD_NAME="$name"
259         [ -z "$RAMIPS_MODEL" ] && RAMIPS_MODEL="$machine"
260
261         [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
262
263         echo "$RAMIPS_BOARD_NAME" > /tmp/sysinfo/board_name
264         echo "$RAMIPS_MODEL" > /tmp/sysinfo/model
265 }
266
267 ramips_board_name() {
268         local name
269
270         [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
271         [ -z "$name" ] && name="unknown"
272
273         echo "$name"
274 }