ar71xx: add support for RB750UPr2
[openwrt/staging/yousong.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-750up-r2|\
140 rb-951ui-2hnd|\
141 rb-951ui-2nd|\
142 routerstation|\
143 tl-wr710n|\
144 tl-wr720n-v3|\
145 tl-wr810n|\
146 wpe72|\
147 wrtnode2q)
148 ucidef_set_interfaces_lan_wan "eth1" "eth0"
149 ;;
150 all0258n|\
151 all0315n|\
152 dlan-hotspot|\
153 dlan-pro-500-wp|\
154 dr344|\
155 ja76pf2|\
156 rocket-m-ti|\
157 ubnt-unifi-outdoor)
158 ucidef_set_interface_lan "eth0 eth1"
159 ;;
160 wzr-hp-g300nh2)
161 ucidef_add_switch "switch0" \
162 "0@eth0" "1:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "2:wan"
163 ;;
164 ap132|\
165 ap136|\
166 ap152|\
167 rb-750gl|\
168 rb-751g|\
169 rb-951g-2hnd|\
170 wlr8100|\
171 wzr-hp-g450h)
172 ucidef_add_switch "switch0" \
173 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
174 ;;
175 ap135-020|\
176 ap136-020|\
177 bhr-4grv2|\
178 tew-823dru|\
179 tl-wr1043nd-v2|\
180 wzr-450hp2)
181 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
182 ucidef_add_switch "switch0" \
183 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
184 ;;
185 ap136-010|\
186 ap147-010|\
187 nbg6616|\
188 nbg6716)
189 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
190 ucidef_add_switch "switch0" \
191 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
192 ;;
193 ap143|\
194 rb-433|\
195 rb-433u)
196 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
197 ucidef_add_switch "switch0" \
198 "1:lan" "2:lan" "5@eth1"
199 ;;
200 archer-c5|\
201 archer-c7|\
202 tl-wdr4900-v2)
203 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
204 ucidef_add_switch "switch0" \
205 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
206 ;;
207 archer-c59-v1|\
208 archer-c60-v1)
209 ucidef_add_switch "switch0" \
210 "0@eth0" "2:lan:4" "3:lan:3" "4:lan:2" "5:lan:1" "1:wan"
211 ;;
212 arduino-yun|\
213 dir-505-a1|\
214 tl-wa801nd-v3)
215 ucidef_set_interface_lan "eth1"
216 ;;
217 bsb)
218 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
219 ucidef_add_switch "switch0" \
220 "0@eth1" "1:lan" "3:lan"
221 ;;
222 c-60)
223 ucidef_add_switch "switch0" \
224 "0@eth0" "3:wan" "4:lan"
225 ;;
226 cap324)
227 ucidef_set_interface_lan "eth0" "dhcp"
228 ;;
229 cpe210|\
230 cpe510|\
231 wbs210|\
232 wbs510)
233 ucidef_add_switch "switch0" \
234 "0@eth0" "5:lan" "4:wan"
235 ;;
236 cr3000)
237 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
238 ucidef_add_switch "switch0" \
239 "0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
240 ;;
241 cr5000|\
242 dgl-5500-a1|\
243 dhp-1565-a1|\
244 dir-825-c1|\
245 dir-835-a1|\
246 esr900|\
247 mynet-n750|\
248 sr3200|\
249 wndr3700v4|\
250 wndr4300)
251 ucidef_add_switch "switch0" \
252 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
253 ;;
254 dap-2695-a1)
255 ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:wan" "6@eth1"
256 ;;
257 rb-941-2nd)
258 ucidef_add_switch "switch0" \
259 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:wan:1"
260 ;;
261 db120|\
262 rb-2011l|\
263 rb-2011uas|\
264 rb-2011uas-2hnd|\
265 rb-2011uias|\
266 rb-2011uias-2hnd)
267 case "$board" in
268 rb-2011uas*|\
269 rb-2011uias|\
270 rb-2011uias-2hnd)
271 ucidef_add_switch "switch0" \
272 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan" "6:sfp"
273 ;;
274 *)
275 ucidef_add_switch "switch0" \
276 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
277 ;;
278 esac
279
280 ucidef_add_switch "switch1" \
281 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
282 ;;
283 dir-615-i1|\
284 omy-g1|\
285 r6100|\
286 smart-300|\
287 tl-mr3420-v2|\
288 tl-wdr6500-v2|\
289 tl-wr841n-v8|\
290 tl-wr940n-v4|\
291 tl-wr941nd-v5|\
292 tl-wr941nd-v6|\
293 wnr1000-v2|\
294 wnr2000-v4|\
295 wnr2200|\
296 wnr612-v2|\
297 wpn824n)
298 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
299 ucidef_add_switch "switch0" \
300 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth1"
301 ;;
302 dir-825-b1|\
303 nbg460n_550n_550nh|\
304 tew-673gru|\
305 wzr-hp-g300nh)
306 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
307 ucidef_add_switch "switch0" \
308 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
309 ;;
310 dlan-pro-1200-ac)
311 ucidef_set_interface_lan "eth0"
312 ucidef_add_switch "switch0" \
313 "0u@eth0" "2:lan" "3:lan" "4:lan"
314 ucidef_add_switch_attr "switch0" "enable" "false"
315 ;;
316 ebr-2310-c1)
317 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
318 ucidef_add_switch "switch0" \
319 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
320 ;;
321 el-m150)
322 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
323 ucidef_add_switch "switch0" \
324 "0:lan" "1:lan" "3@eth1"
325 ;;
326 dir-869-a1|\
327 epg5000|\
328 esr1750|\
329 tl-wr1043nd-v4)
330 ucidef_add_switch "switch0" \
331 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
332 ;;
333 ew-dorin)
334 ucidef_add_switch "switch0" \
335 "0@eth0" "1:lan" "2:lan" "3:wan"
336 ;;
337 ew-dorin-router)
338 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
339 ucidef_add_switch "switch0" \
340 "0@eth0" "2:lan" "3:lan"
341 ;;
342 dw33d|\
343 f9k1115v2)
344 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
345 ucidef_add_switch "switch0" \
346 "2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "0@eth0" "1:wan"
347 ;;
348 gl-ar300|\
349 wnr2000-v3)
350 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
351 ucidef_add_switch "switch0" \
352 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
353 ;;
354 jwap230)
355 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
356 ucidef_add_switch "switch0" \
357 "0@eth0" "1:lan" "5:wan" "6@eth1"
358 ;;
359 nanostation-m-xw)
360 ucidef_add_switch "switch0" \
361 "0@eth0" "5:lan" "1:wan"
362 ;;
363 onion-omega)
364 ucidef_set_interface_lan "wlan0"
365 ;;
366 rb-435g)
367 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
368 ucidef_add_switch "switch0" \
369 "0@eth1" "1:lan" "2:lan"
370 ;;
371 rb-450)
372 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
373 ucidef_add_switch "switch0" \
374 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth1"
375 ;;
376 rb-450g)
377 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
378 ucidef_add_switch "switch0" \
379 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
380 ;;
381 routerstation-pro)
382 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
383 ucidef_add_switch "switch0" \
384 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
385 ;;
386 rb-493g)
387 ucidef_set_interfaces_lan_wan "eth0.1 eth1.1" "eth1.2"
388 ucidef_add_switch "switch0" \
389 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
390 ucidef_add_switch "switch1" \
391 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
392 ;;
393 tellstick-znet-lite)
394 ucidef_set_interface_wan "eth0"
395 ucidef_set_interface_raw "wlan" "wlan0" "dhcp"
396 ;;
397 tl-wdr4300|\
398 tl-wr1041n-v2)
399 ucidef_add_switch "switch0" \
400 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
401 ;;
402 tl-wpa8630)
403 ucidef_add_switch "switch0" \
404 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "5:lan:4"
405 ;;
406 tl-wr1043nd)
407 ucidef_add_switch "switch0" \
408 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
409 ;;
410 tl-wr2543n)
411 ucidef_add_switch "switch0" \
412 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
413 ;;
414 tl-wr841n-v1|\
415 tl-wr941nd)
416 ucidef_set_interface_raw "eth" "eth0"
417 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
418 ;;
419 tl-wr841n-v7)
420 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
421 ucidef_add_switch "switch0" \
422 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
423 ;;
424 tl-wr842n-v2)
425 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
426 ucidef_add_switch "switch0" \
427 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
428 ;;
429 uap-pro|\
430 wpj342)
431 ucidef_add_switch "switch0" \
432 "0@eth0" "1:lan" "2:wan"
433 ;;
434 unifiac-pro|\
435 xd3200)
436 ucidef_add_switch "switch0" \
437 "0@eth0" "2:lan" "3:wan"
438 ;;
439 wndr3700|\
440 wndr3700v2|\
441 wndr3800|\
442 wndr3800ch)
443 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
444 ucidef_add_switch "switch0" \
445 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth0"
446
447 ucidef_add_switch_attr "switch0" "blinkrate" 2
448 ucidef_add_switch_port_attr "switch0" 1 led 6
449 ucidef_add_switch_port_attr "switch0" 2 led 9
450 ucidef_add_switch_port_attr "switch0" 5 led 2
451 ;;
452 wpj344)
453 ucidef_add_switch "switch0" \
454 "0@eth0" "3:lan" "2:wan"
455 ;;
456 wpj558)
457 ucidef_add_switch "switch0" \
458 "5:lan" "1:wan" "6@eth0"
459 ;;
460 wrt160nl)
461 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
462 ucidef_add_switch "switch0" \
463 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth0"
464 ;;
465 wzr-hp-g450h)
466 ucidef_add_switch "switch0" \
467 "0@eth0" "2:lan:1 3:lan:2 4:lan:3 5:lan:4" "1:wan"
468 ;;
469 z1)
470 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
471 ucidef_add_switch "switch0" \
472 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "5:wan"
473 ;;
474 *)
475 ucidef_set_interfaces_lan_wan "eth0" "eth1"
476 ;;
477 esac
478 }
479
480 ar71xx_setup_macs()
481 {
482 local board="$1"
483 local lan_mac=""
484 local wan_mac=""
485
486 case $board in
487 dgl-5500-a1|\
488 dir-825-c1)
489 wan_mac=$(mtd_get_mac_ascii nvram "wan_mac")
490 ;;
491 dhp-1565-a1|\
492 dir-835-a1|\
493 wndr3700v4|\
494 wndr4300)
495 lan_mac=$(mtd_get_mac_binary caldata 0)
496 wan_mac=$(mtd_get_mac_binary caldata 6)
497 ;;
498 tl-wr1043nd-v4)
499 wan_mac=$(mtd_get_mac_binary config 0x1017c)
500 ;;
501 esr900)
502 wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
503 ;;
504 dir-869-a1|\
505 mynet-n750)
506 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
507 ;;
508 esac
509
510 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
511 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
512 }
513
514 board_config_update
515 board=$(ar71xx_board_name)
516 ar71xx_setup_interfaces $board
517 ar71xx_setup_macs $board
518 board_config_flush
519
520 exit 0