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