ar71xx: add support for TP-Link WR802N v1
[openwrt/openwrt.git] / target / linux / ar71xx / base-files / etc / board.d / 02_network
1 #!/bin/sh
2 #
3 # Copyright (C) 2011-2015 OpenWrt.org
4 #
5
6 . /lib/functions/system.sh
7 . /lib/functions/uci-defaults.sh
8 . /lib/ar71xx.sh
9
10 ar71xx_setup_interfaces()
11 {
12 local board="$1"
13
14 case "$board" in
15 airgatewaypro)
16 ucidef_add_switch "switch0" \
17 "0@eth0" "4:lan" "5:wan"
18 ;;
19 airrouter|\
20 ap121|\
21 ap121-mini|\
22 ap96|\
23 dir-600-a1|\
24 dir-615-c1|\
25 dir-615-e1|\
26 dir-615-e4|\
27 hiwifi-hc6361|\
28 ja76pf|\
29 mc-mac1200r|\
30 minibox-v1|\
31 mynet-n600|\
32 oolite|\
33 qihoo-c301|\
34 rb-750|\
35 rb-751|\
36 som9331|\
37 tew-632brp|\
38 tew-712br|\
39 tew-732br|\
40 tl-mr3220|\
41 tl-mr3220-v2|\
42 tl-mr3420|\
43 tl-wdr3320-v2|\
44 tl-wdr3500|\
45 tl-wr741nd|\
46 tl-wr741nd-v4|\
47 tl-wr841n-v11|\
48 tl-wr841n-v7|\
49 tl-wr841n-v9|\
50 tl-wr842n-v3|\
51 whr-g301n|\
52 whr-hp-g300n|\
53 whr-hp-gn|\
54 wzr-hp-ag300h|\
55 zbt-we1526)
56 ucidef_set_interfaces_lan_wan "eth0" "eth1"
57 ucidef_add_switch "switch0" \
58 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
59 ;;
60 alfa-ap120c|\
61 all0305|\
62 antminer-s1|\
63 antminer-s3|\
64 antrouter-r1|\
65 aw-nr580|\
66 bullet-m|\
67 c-55|\
68 cap4200ag|\
69 eap120|\
70 eap300v2|\
71 eap7660d|\
72 el-mini|\
73 loco-m-xw|\
74 mr1750|\
75 mr1750v2|\
76 mr18|\
77 mr600|\
78 mr600v2|\
79 mr900|\
80 mr900v2|\
81 mynet-rext|\
82 rb-411|\
83 rb-911g-2hpnd|\
84 rb-911g-5hpacd|\
85 rb-911g-5hpnd|\
86 rb-912uag-2hpnd|\
87 rb-912uag-5hpnd|\
88 rb-sxt2n|\
89 rb-sxt5n|\
90 rocket-m-xw|\
91 tl-mr10u|\
92 tl-mr11u|\
93 tl-mr12u|\
94 tl-mr13u|\
95 tl-mr3020|\
96 tl-mr3040|\
97 tl-mr3040-v2|\
98 tl-wa701nd-v2|\
99 tl-wa7210n-v2|\
100 tl-wa750re|\
101 tl-wa801nd-v2|\
102 tl-wa830re-v2|\
103 tl-wa850re|\
104 tl-wa901nd|\
105 tl-wa901nd-v2|\
106 tl-wa901nd-v3|\
107 tl-wa901nd-v4|\
108 tl-wr703n|\
109 tl-wr802n-v1|\
110 tube2h|\
111 unifiac-lite|\
112 wndap360|\
113 wp543)
114 ucidef_set_interface_lan "eth0"
115 ;;
116 alfa-ap96|\
117 alfa-nx|\
118 ap83|\
119 gl-ar150|\
120 gl-ar300m|\
121 gl-domino|\
122 gl-inet|\
123 gl-mifi|\
124 jwap003|\
125 pb42|\
126 pb44|\
127 rb-951ui-2hnd|\
128 routerstation|\
129 tl-wr710n|\
130 tl-wr720n-v3|\
131 tl-wr810n|\
132 wpe72|\
133 wrtnode2q)
134 ucidef_set_interfaces_lan_wan "eth1" "eth0"
135 ;;
136 all0258n|\
137 all0315n|\
138 dlan-hotspot|\
139 dlan-pro-500-wp|\
140 dr344|\
141 ja76pf2|\
142 rocket-m-ti|\
143 ubnt-unifi-outdoor)
144 ucidef_set_interface_lan "eth0 eth1"
145 ;;
146 ap113|\
147 pb92|\
148 wzr-hp-g300nh2)
149 ucidef_add_switch "switch0" \
150 "0@eth0" "1:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "2:wan"
151 ;;
152 ap132|\
153 ap136|\
154 ap152|\
155 rb-750gl|\
156 rb-751g|\
157 rb-951g-2hnd|\
158 wlr8100|\
159 wzr-hp-g450h)
160 ucidef_add_switch "switch0" \
161 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
162 ;;
163 ap135-020|\
164 ap136-020|\
165 tew-823dru|\
166 tl-wr1043nd-v2|\
167 wzr-450hp2)
168 ucidef_set_interfaces_lan_wan "eth1" "eth0"
169 ucidef_add_switch "switch0" \
170 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
171 ;;
172 ap136-010|\
173 ap147-010|\
174 nbg6616|\
175 nbg6716)
176 ucidef_set_interfaces_lan_wan "eth0" "eth1"
177 ucidef_add_switch "switch0" \
178 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
179 ;;
180 ap143|\
181 rb-433|\
182 rb-433u)
183 ucidef_set_interfaces_lan_wan "eth1" "eth0"
184 ucidef_add_switch "switch0" \
185 "1:lan" "2:lan" "5@eth1"
186 ;;
187 archer-c5|\
188 archer-c7|\
189 tl-wdr4900-v2)
190 ucidef_set_interfaces_lan_wan "eth1" "eth0"
191 ucidef_add_switch "switch0" \
192 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
193 ;;
194 arduino-yun|\
195 dir-505-a1|\
196 tl-wa801nd-v3)
197 ucidef_set_interface_lan "eth1"
198 ;;
199 bsb)
200 ucidef_set_interfaces_lan_wan "eth1" "eth0"
201 ucidef_add_switch "switch0" \
202 "0@eth1" "1:lan" "3:lan"
203 ;;
204 c-60)
205 ucidef_add_switch "switch0" \
206 "0@eth0" "3:wan" "4:lan"
207 ;;
208 cap324)
209 ucidef_set_interface_lan "eth0" "dhcp"
210 ;;
211 cpe210|\
212 cpe510)
213 ucidef_add_switch "switch0" \
214 "0@eth0" "5:lan" "4:wan"
215 ;;
216 cr3000)
217 ucidef_set_interfaces_lan_wan "eth0" "eth1"
218 ucidef_add_switch "switch0" \
219 "0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
220 ;;
221 cr5000|\
222 dgl-5500-a1|\
223 dhp-1565-a1|\
224 dir-825-c1|\
225 dir-835-a1|\
226 esr900|\
227 mynet-n750|\
228 wndr3700v4|\
229 wndr4300)
230 ucidef_add_switch "switch0" \
231 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
232 ;;
233 db120|\
234 rb-2011l|\
235 rb-2011uas|\
236 rb-2011uas-2hnd|\
237 rb-2011uias|\
238 rb-2011uias-2hnd)
239 case "$board" in
240 rb-2011uas*|\
241 rb-2011uias|\
242 rb-2011uias-2hnd)
243 ucidef_add_switch "switch0" \
244 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan" "6:sfp"
245 ;;
246 *)
247 ucidef_add_switch "switch0" \
248 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
249 ;;
250 esac
251
252 ucidef_add_switch "switch1" \
253 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
254 ;;
255 dir-615-i1|\
256 omy-g1|\
257 r6100|\
258 smart-300|\
259 tl-mr3420-v2|\
260 tl-wdr6500-v2|\
261 tl-wr841n-v8|\
262 tl-wr842n-v2|\
263 tl-wr941nd-v5|\
264 tl-wr941nd-v6|\
265 wnr1000-v2|\
266 wnr2000-v3|\
267 wnr2000-v4|\
268 wnr2200|\
269 wnr612-v2|\
270 wpn824n)
271 ucidef_set_interfaces_lan_wan "eth1" "eth0"
272 ucidef_add_switch "switch0" \
273 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth1"
274 ;;
275 dir-825-b1|\
276 nbg460n_550n_550nh|\
277 tew-673gru|\
278 wzr-hp-g300nh)
279 ucidef_set_interfaces_lan_wan "eth0" "eth1"
280 ucidef_add_switch "switch0" \
281 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
282 ;;
283 dlan-pro-1200-ac)
284 ucidef_set_interface_lan "eth0"
285 ucidef_add_switch "switch0" \
286 "0@eth0" "2:lan" "3:lan" "4:lan"
287 ucidef_add_switch_attr "switch0" "enable" "false"
288 ;;
289 el-m150)
290 ucidef_set_interfaces_lan_wan "eth1" "eth0"
291 ucidef_add_switch "switch0" \
292 "0:lan" "1:lan" "3@eth1"
293 ;;
294 dir-869-a1|\
295 epg5000|\
296 esr1750)
297 ucidef_add_switch "switch0" \
298 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
299 ;;
300 ew-dorin)
301 ucidef_add_switch "switch0" \
302 "0@eth0" "1:lan" "2:lan" "3:wan"
303 ;;
304 ew-dorin-router)
305 ucidef_set_interfaces_lan_wan "eth0" "eth1"
306 ucidef_add_switch "switch0" \
307 "0@eth0" "2:lan" "3:lan"
308 ;;
309 dw33d|\
310 f9k1115v2)
311 ucidef_set_interfaces_lan_wan "eth1" "eth0"
312 ucidef_add_switch "switch0" \
313 "2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "0@eth0" "1:wan"
314 ;;
315 gl-ar300)
316 ucidef_set_interfaces_lan_wan "eth1" "eth0"
317 ucidef_add_switch "switch0" \
318 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
319 ;;
320 jwap230)
321 ucidef_set_interfaces_lan_wan "eth0" "eth1"
322 ucidef_add_switch "switch0" \
323 "0@eth0" "1:lan" "5:wan" "6@eth1"
324 ;;
325 nanostation-m-xw)
326 ucidef_add_switch "switch0" \
327 "0@eth0" "5:lan" "1:wan"
328 ;;
329 onion-omega)
330 ucidef_set_interface_lan "wlan0"
331 ;;
332 rb-435g)
333 ucidef_set_interfaces_lan_wan "eth1" "eth0"
334 ucidef_add_switch "switch0" \
335 "0@eth1" "1:lan" "2:lan"
336 ;;
337 rb-450)
338 ucidef_set_interfaces_lan_wan "eth1" "eth0"
339 ucidef_add_switch "switch0" \
340 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth1"
341 ;;
342 rb-450g|\
343 routerstation-pro)
344 ucidef_set_interfaces_lan_wan "eth1" "eth0"
345 ucidef_add_switch "switch0" \
346 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
347 ;;
348 rb-493g)
349 ucidef_set_interfaces_lan_wan "eth0 eth1.1" "eth1.2"
350 ucidef_add_switch "switch0" \
351 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
352 ucidef_add_switch "switch1" \
353 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
354 ;;
355 tellstick-znet-lite)
356 ucidef_set_interface_wan "eth0"
357 ucidef_set_interface_raw "wlan" "wlan0" "dhcp"
358 ;;
359 tl-wdr4300|\
360 tl-wr1041n-v2)
361 ucidef_add_switch "switch0" \
362 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
363 ;;
364 tl-wr1043nd)
365 ucidef_add_switch "switch0" \
366 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
367 ;;
368 tl-wr2543n)
369 ucidef_add_switch "switch0" \
370 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
371 ;;
372 tl-wr841n-v1|\
373 tl-wr941nd)
374 ucidef_set_interface_raw "eth" "eth0"
375 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
376 ;;
377 uap-pro|\
378 wpj342)
379 ucidef_add_switch "switch0" \
380 "0@eth0" "1:lan" "2:wan"
381 ;;
382 unifiac-pro)
383 ucidef_add_switch "switch0" \
384 "0@eth0" "2:lan" "3:wan"
385 ;;
386 wndr3700)
387 ucidef_set_interfaces_lan_wan "eth0" "eth1"
388 ucidef_add_switch "switch0" \
389 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
390
391 ucidef_add_switch_attr "switch0" "blinkrate" 2
392 ucidef_add_switch_port_attr "switch0" 1 led 6
393 ucidef_add_switch_port_attr "switch0" 2 led 9
394 ucidef_add_switch_port_attr "switch0" 5 led 2
395 ;;
396 wpj344)
397 ucidef_add_switch "switch0" \
398 "0@eth0" "3:lan" "2:wan"
399 ;;
400 wpj558)
401 ucidef_add_switch "switch0" \
402 "5:lan" "1:wan" "6@eth0"
403 ;;
404 wrt160nl)
405 ucidef_set_interfaces_lan_wan "eth0" "eth1"
406 ucidef_add_switch "switch0" \
407 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth0"
408 ;;
409 wzr-hp-g450h)
410 ucidef_add_switch "switch0" \
411 "0@eth0" "2:lan:1 3:lan:2 4:lan:3 5:lan:4" "1:wan"
412 ;;
413 z1)
414 ucidef_set_interfaces_lan_wan "eth0" "eth1"
415 ucidef_add_switch "switch0" \
416 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "5:wan"
417 ;;
418 *)
419 ucidef_set_interfaces_lan_wan "eth0" "eth1"
420 ;;
421 esac
422 }
423
424 ar71xx_setup_macs()
425 {
426 local board="$1"
427 local lan_mac=""
428 local wan_mac=""
429
430 case $board in
431 dgl-5500-a1|\
432 dir-825-c1)
433 wan_mac=$(mtd_get_mac_ascii nvram "wan_mac")
434 ;;
435 dhp-1565-a1|\
436 dir-835-a1|\
437 wndr3700v4|\
438 wndr4300)
439 lan_mac=$(mtd_get_mac_binary caldata 0)
440 wan_mac=$(mtd_get_mac_binary caldata 6)
441 ;;
442 esr900)
443 wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
444 ;;
445 dir-869-a1|\
446 mynet-n750)
447 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
448 ;;
449 esac
450
451 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
452 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
453 }
454
455 board_config_update
456 board=$(ar71xx_board_name)
457 ar71xx_setup_interfaces $board
458 ar71xx_setup_macs $board
459 board_config_flush
460
461 exit 0