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