ar71xx: add support for TP-Link TL-WR940N v6
[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
9 ar71xx_setup_interfaces()
10 {
11 local board="$1"
12
13 case "$board" in
14 airgatewaypro)
15 ucidef_add_switch "switch0" \
16 "0@eth0" "4:lan" "5:wan"
17 ;;
18 airrouter|\
19 ap121|\
20 ap121-mini|\
21 ap96|\
22 dir-600-a1|\
23 dir-615-c1|\
24 dir-615-e1|\
25 dir-615-e4|\
26 hiwifi-hc6361|\
27 ja76pf|\
28 mc-mac1200r|\
29 minibox-v1|\
30 mynet-n600|\
31 oolite-v1|\
32 oolite-v5.2|\
33 oolite-v5.2-dev|\
34 qihoo-c301|\
35 r602n|\
36 rb-750|\
37 rb-751|\
38 som9331|\
39 t830|\
40 tew-632brp|\
41 tew-712br|\
42 tew-732br|\
43 tl-mr3220|\
44 tl-mr3220-v2|\
45 tl-mr3420|\
46 tl-wdr3320-v2|\
47 tl-wdr3500|\
48 tl-wr740n-v6|\
49 tl-wr741nd-v4|\
50 tl-wr840n-v2|\
51 tl-wr840n-v3|\
52 tl-wr841n-v11|\
53 tl-wr841n-v9|\
54 tl-wr842n-v3|\
55 whr-g301n|\
56 whr-hp-g300n|\
57 whr-hp-gn|\
58 wzr-hp-ag300h|\
59 zbt-we1526)
60 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
61 ucidef_add_switch "switch0" \
62 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
63 ;;
64 alfa-ap120c|\
65 all0305|\
66 antminer-s1|\
67 antminer-s3|\
68 antrouter-r1|\
69 ap121f|\
70 ap91-5g|\
71 aw-nr580|\
72 bullet-m|\
73 c-55|\
74 cap4200ag|\
75 cf-e380ac-v1|\
76 cf-e380ac-v2|\
77 dr342|\
78 eap120|\
79 eap300v2|\
80 eap7660d|\
81 el-mini|\
82 fritz300e|\
83 gl-usb150|\
84 hiveap-121|\
85 lbe-m5|\
86 loco-m-xw|\
87 mr12|\
88 mr16|\
89 mr1750|\
90 mr1750v2|\
91 mr18|\
92 mr600|\
93 mr600v2|\
94 mr900|\
95 mr900v2|\
96 mynet-rext|\
97 pqi-air-pen|\
98 rb-411|\
99 rb-411u|\
100 rb-911-2hn|\
101 rb-911-5hn|\
102 rb-911g-2hpnd|\
103 rb-911g-5hpacd|\
104 rb-911g-5hpnd|\
105 rb-912uag-2hpnd|\
106 rb-912uag-5hpnd|\
107 rb-921gs-5hpacd-r2|\
108 rb-lhg-5nd|\
109 rb-mapl-2nd|\
110 rb-sxt2n|\
111 rb-sxt5n|\
112 rb-wap-2nd|\
113 rb-wapg-5hact2hnd|\
114 re355|\
115 re450|\
116 rocket-m-xw|\
117 sc300m |\
118 tl-mr10u|\
119 tl-mr11u|\
120 tl-mr12u|\
121 tl-mr13u|\
122 tl-mr3020|\
123 tl-mr3040|\
124 tl-mr3040-v2|\
125 tl-wa701nd-v2|\
126 tl-wa7210n-v2|\
127 tl-wa750re|\
128 tl-wa801nd-v2|\
129 tl-wa830re-v2|\
130 tl-wa850re|\
131 tl-wa850re-v2|\
132 tl-wa855re-v1|\
133 tl-wa901nd|\
134 tl-wa901nd-v2|\
135 tl-wa901nd-v3|\
136 tl-wa901nd-v4|\
137 tl-wa901nd-v5|\
138 tl-wr703n|\
139 tl-wr802n-v1|\
140 tl-wr802n-v2|\
141 tl-wr902ac-v1|\
142 tube2h|\
143 unifi|\
144 unifiac-lite|\
145 wi2a-ac200i|\
146 wifi-pineapple-nano|\
147 wndap360|\
148 wp543)
149 ucidef_set_interface_lan "eth0"
150 ;;
151 a40|\
152 a60|\
153 alfa-ap96|\
154 alfa-nx|\
155 archer-c25-v1|\
156 dr344|\
157 gl-ar150|\
158 gl-ar300m|\
159 gl-domino|\
160 gl-inet|\
161 gl-mifi|\
162 jwap003|\
163 om2p-hsv4|\
164 om2pv4|\
165 pb42|\
166 pb44|\
167 rb-951ui-2hnd|\
168 rb-952ui-5ac2nd|\
169 routerstation|\
170 tl-wr710n|\
171 tl-wr720n-v3|\
172 tl-wr810n|\
173 tl-wr810n-v2|\
174 wpe72|\
175 wrtnode2q)
176 ucidef_set_interfaces_lan_wan "eth1" "eth0"
177 ;;
178 rb-750-r2|\
179 rb-750p-pbr2|\
180 rb-750up-r2|\
181 rb-951ui-2nd)
182 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
183 ucidef_add_switch "switch0" \
184 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
185 ;;
186 all0258n|\
187 all0315n|\
188 dlan-hotspot|\
189 dlan-pro-500-wp|\
190 ens202ext|\
191 ja76pf2|\
192 rocket-m-ti|\
193 ubnt-unifi-outdoor)
194 ucidef_set_interface_lan "eth0 eth1"
195 ;;
196 wzr-hp-g300nh2)
197 ucidef_add_switch "switch0" \
198 "0@eth0" "1:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "2:wan"
199 ;;
200 ap132|\
201 ap136|\
202 ap152|\
203 rb-750gl|\
204 rb-751g|\
205 rb-951g-2hnd|\
206 rb-962uigs-5hact2hnt|\
207 wlr8100|\
208 wzr-hp-g450h)
209 ucidef_add_switch "switch0" \
210 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
211 ;;
212 ap135-020|\
213 ap136-020|\
214 bhr-4grv2|\
215 tew-823dru|\
216 tl-wr1043nd-v2|\
217 wzr-450hp2)
218 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
219 ucidef_add_switch "switch0" \
220 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
221 ;;
222 ap136-010|\
223 ap147-010|\
224 nbg6616|\
225 nbg6716)
226 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
227 ucidef_add_switch "switch0" \
228 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
229 ;;
230 ap143|\
231 rb-433|\
232 rb-433u)
233 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
234 ucidef_add_switch "switch0" \
235 "1:lan" "2:lan" "5@eth1"
236 ;;
237 archer-c5|\
238 archer-c7|\
239 tl-wdr4900-v2)
240 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
241 ucidef_add_switch "switch0" \
242 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
243 ;;
244 archer-c58-v1|\
245 archer-c59-v1|\
246 rb-450g)
247 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
248 ucidef_add_switch "switch0" \
249 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
250 ;;
251 archer-c60-v1)
252 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
253 ucidef_add_switch "switch0" \
254 "0@eth1" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
255 ;;
256 arduino-yun|\
257 dir-505-a1|\
258 tl-wa801nd-v3)
259 ucidef_set_interface_lan "eth1"
260 ;;
261 bsb)
262 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
263 ucidef_add_switch "switch0" \
264 "0@eth1" "1:lan" "3:lan"
265 ;;
266 c-60)
267 ucidef_add_switch "switch0" \
268 "0@eth0" "3:wan" "4:lan"
269 ;;
270 cap324|\
271 rme-eg200)
272 ucidef_set_interface_lan "eth0" "dhcp"
273 ;;
274 cf-e375ac|\
275 rb-map-2nd)
276 ucidef_add_switch "switch0" \
277 "0@eth0" "1:wan" "2:lan"
278 ;;
279 cf-e385ac)
280 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
281 ucidef_add_switch "switch0" \
282 "0@eth0" "2:lan" "1:wan" "6@eth1"
283 ;;
284 cpe210|\
285 cpe510|\
286 wbs210|\
287 wbs510)
288 ucidef_add_switch "switch0" \
289 "0@eth0" "5:lan" "4:wan"
290 ;;
291 cr3000)
292 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
293 ucidef_add_switch "switch0" \
294 "0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
295 ;;
296 cr5000|\
297 dgl-5500-a1|\
298 dhp-1565-a1|\
299 dir-825-c1|\
300 dir-835-a1|\
301 esr900|\
302 mynet-n750|\
303 sr3200|\
304 tl-wr1043n-v5)
305 ucidef_add_switch "switch0" \
306 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
307 ;;
308 dap-2695-a1)
309 ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:wan" "6@eth1"
310 ;;
311 rb-941-2nd)
312 ucidef_add_switch "switch0" \
313 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:wan:1"
314 ;;
315 db120|\
316 rb-2011il|\
317 rb-2011l|\
318 rb-2011uas|\
319 rb-2011uas-2hnd|\
320 rb-2011uias|\
321 rb-2011uias-2hnd)
322 case "$board" in
323 rb-2011uas*|\
324 rb-2011uias|\
325 rb-2011uias-2hnd)
326 ucidef_add_switch "switch0" \
327 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan" "6:sfp"
328 ;;
329 *)
330 ucidef_add_switch "switch0" \
331 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
332 ;;
333 esac
334
335 ucidef_add_switch "switch1" \
336 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
337 ;;
338 dir-615-i1|\
339 omy-g1|\
340 r6100|\
341 smart-300|\
342 tl-wdr6500-v2|\
343 tl-wr940n-v4|\
344 tl-wr940n-v6|\
345 tl-wr941nd-v6|\
346 wnr1000-v2|\
347 wnr2000-v4|\
348 wnr2200|\
349 wnr612-v2|\
350 wpn824n)
351 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
352 ucidef_add_switch "switch0" \
353 "0@eth1" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
354 ;;
355 tl-mr6400)
356 ucidef_set_interfaces_lan_wan "eth0.1 eth1" "usb0"
357 ucidef_add_switch "switch0" \
358 "0@eth0" "1:lan" "2:lan" "3:lan"
359 ;;
360 dir-825-b1|\
361 nbg460n_550n_550nh|\
362 tew-673gru|\
363 wzr-hp-g300nh)
364 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
365 ucidef_add_switch "switch0" \
366 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
367 ;;
368 dlan-pro-1200-ac)
369 ucidef_set_interface_lan "eth0"
370 ucidef_add_switch "switch0" \
371 "0u@eth0" "2:lan" "3:lan" "4:lan"
372 ucidef_add_switch_attr "switch0" "enable" "false"
373 ;;
374 e1700ac-v2|\
375 unifiac-pro|\
376 xd3200)
377 ucidef_add_switch "switch0" \
378 "0@eth0" "2:lan" "3:wan"
379 ;;
380 ebr-2310-c1)
381 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
382 ucidef_add_switch "switch0" \
383 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
384 ;;
385 el-m150)
386 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
387 ucidef_add_switch "switch0" \
388 "0:lan" "1:lan" "3@eth1"
389 ;;
390 dir-869-a1|\
391 epg5000|\
392 esr1750|\
393 tl-wr1043nd-v4|\
394 wndr3700v4|\
395 wndr4300)
396 ucidef_add_switch "switch0" \
397 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
398 ;;
399 ew-balin)
400 ucidef_set_interface_raw "usb2" "usb0" "static"
401 ucidef_add_switch "switch0" \
402 "0@eth0" "5:lan:4" "4:lan:5" "3:wan"
403 ;;
404 ew-dorin)
405 ucidef_add_switch "switch0" \
406 "0@eth0" "1:lan" "2:lan" "3:wan"
407 ;;
408 ew-dorin-router)
409 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
410 ucidef_add_switch "switch0" \
411 "0@eth0" "2:lan" "3:lan"
412 ;;
413 dw33d|\
414 f9k1115v2)
415 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
416 ucidef_add_switch "switch0" \
417 "2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "0@eth0" "1:wan"
418 ;;
419 gl-ar300|\
420 wnr2000-v3)
421 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
422 ucidef_add_switch "switch0" \
423 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
424 ;;
425 gl-ar750|\
426 rb-435g)
427 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
428 ucidef_add_switch "switch0" \
429 "0@eth1" "1:lan" "2:lan"
430 ;;
431 jwap230)
432 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
433 ucidef_add_switch "switch0" \
434 "0@eth0" "1:lan" "5:wan" "6@eth1"
435 ;;
436 nanostation-m-xw)
437 ucidef_add_switch "switch0" \
438 "0@eth0" "5:lan" "1:wan"
439 ;;
440 onion-omega)
441 ucidef_set_interface_lan "wlan0"
442 ;;
443 rb-450)
444 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
445 ucidef_add_switch "switch0" \
446 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth1"
447 ;;
448 routerstation-pro)
449 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
450 ucidef_add_switch "switch0" \
451 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
452 ;;
453 rb-493g)
454 ucidef_set_interfaces_lan_wan "eth0.1 eth1.1" "eth1.2"
455 ucidef_add_switch "switch0" \
456 "0@eth0" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
457 ucidef_add_switch "switch1" \
458 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:3" "4:lan:2" "5:wan"
459 ;;
460 rut900)
461 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
462 ucidef_add_switch "switch0" \
463 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1"
464 ;;
465 tellstick-znet-lite)
466 ucidef_set_interface_wan "eth0"
467 ucidef_set_interface_raw "wlan" "wlan0" "dhcp"
468 ;;
469 tl-mr3420-v2|\
470 tl-wr841n-v8|\
471 tl-wr842n-v2|\
472 tl-wr941nd-v5|\
473 tl-wr942n-v1)
474 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
475 ucidef_add_switch "switch0" \
476 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
477 ;;
478 archer-c7-v4|\
479 tl-wdr4300|\
480 tl-wr1041n-v2)
481 ucidef_add_switch "switch0" \
482 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
483 ;;
484 tl-wpa8630)
485 ucidef_add_switch "switch0" \
486 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "5:lan:4"
487 ;;
488 tl-wr1043nd)
489 ucidef_add_switch "switch0" \
490 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
491 ;;
492 tl-wr2543n)
493 ucidef_add_switch "switch0" \
494 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
495 ;;
496 tl-wr841n-v1|\
497 tl-wr941nd)
498 ucidef_set_interface_raw "eth" "eth0"
499 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
500 ;;
501 tl-wr741nd|\
502 tl-wr841n-v7)
503 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
504 ucidef_add_switch "switch0" \
505 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
506 ;;
507 uap-pro|\
508 wpj342)
509 ucidef_add_switch "switch0" \
510 "0@eth0" "1:lan" "2:wan"
511 ;;
512 wndr3700|\
513 wndr3700v2|\
514 wndr3800|\
515 wndr3800ch)
516 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
517 ucidef_add_switch "switch0" \
518 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth0"
519
520 ucidef_add_switch_attr "switch0" "blinkrate" 2
521 ucidef_add_switch_port_attr "switch0" 1 led 6
522 ucidef_add_switch_port_attr "switch0" 2 led 9
523 ucidef_add_switch_port_attr "switch0" 5 led 2
524 ;;
525 wpj344)
526 ucidef_add_switch "switch0" \
527 "0@eth0" "3:lan" "2:wan"
528 ;;
529 wpj558)
530 ucidef_add_switch "switch0" \
531 "5:lan" "1:wan" "6@eth0"
532 ;;
533 wpj563)
534 ucidef_add_switch "switch0" \
535 "0@eth0" "2:lan" "3:wan"
536 ;;
537 wrt160nl)
538 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
539 ucidef_add_switch "switch0" \
540 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth0"
541 ;;
542 wzr-hp-g450h)
543 ucidef_add_switch "switch0" \
544 "0@eth0" "2:lan:1 3:lan:2 4:lan:3 5:lan:4" "1:wan"
545 ;;
546 z1)
547 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
548 ucidef_add_switch "switch0" \
549 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "5:wan"
550 ;;
551 *)
552 ucidef_set_interfaces_lan_wan "eth0" "eth1"
553 ;;
554 esac
555 }
556
557 ar71xx_setup_macs()
558 {
559 local board="$1"
560 local lan_mac=""
561 local wan_mac=""
562
563 case $board in
564 dgl-5500-a1|\
565 dir-825-c1)
566 wan_mac=$(mtd_get_mac_ascii nvram "wan_mac")
567 ;;
568 dhp-1565-a1|\
569 dir-835-a1|\
570 wndr3700v4|\
571 wndr4300)
572 lan_mac=$(mtd_get_mac_binary caldata 0)
573 wan_mac=$(mtd_get_mac_binary caldata 6)
574 ;;
575 fritz300e)
576 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
577 ;;
578 tl-wr1043n-v5|\
579 tl-wr1043nd-v4)
580 lan_mac=$(mtd_get_mac_binary product-info 8)
581 wan_mac=$(macaddr_add "$lan_mac" 1)
582 ;;
583 esr900)
584 wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
585 ;;
586 dir-869-a1|\
587 mynet-n750)
588 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
589 ;;
590 wlr8100)
591 lan_mac=$(mtd_get_mac_ascii u-boot-env "ethaddr")
592 wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
593 ;;
594 wpj344|\
595 wpj558)
596 wan_mac=$(mtd_get_mac_binary u-boot 0x2e018)
597 ;;
598 esac
599
600 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
601 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
602 }
603
604 board_config_update
605 board=$(board_name)
606 ar71xx_setup_interfaces $board
607 ar71xx_setup_macs $board
608 board_config_flush
609
610 exit 0