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