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