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