ath79: add support for Compex WPJ531 (16M)
[openwrt/staging/dedeckeh.git] / target / linux / ath79 / generic / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions/system.sh
4 . /lib/functions/uci-defaults.sh
5 . /lib/functions/k2t.sh
6
7 ath79_setup_interfaces()
8 {
9 local board="$1"
10
11 case "$board" in
12 adtran,bsap1800-v2|\
13 adtran,bsap1840|\
14 alfa-network,ap121f|\
15 aruba,ap-105|\
16 avm,fritz1750e|\
17 avm,fritz300e|\
18 avm,fritzdvbc|\
19 comfast,cf-wr752ac-v1|\
20 comfast,cf-e130n-v2|\
21 devolo,dvl1200i|\
22 devolo,dvl1750c|\
23 devolo,dvl1750i|\
24 devolo,dvl1750x|\
25 dlink,dir-505|\
26 engenius,ecb1750|\
27 enterasys,ws-ap3705i|\
28 glinet,gl-ar300m-lite|\
29 netgear,ex6400|\
30 netgear,ex7300|\
31 ocedo,koala|\
32 ocedo,raccoon|\
33 pcs,cap324|\
34 pisen,ts-d084|\
35 pisen,wmb001n|\
36 pisen,wmm003n|\
37 siemens,ws-ap3610|\
38 tplink,cpe210-v2|\
39 tplink,cpe210-v3|\
40 tplink,cpe510-v2|\
41 tplink,cpe510-v3|\
42 tplink,cpe610-v1|\
43 tplink,cpe610-v2|\
44 tplink,re350k-v1|\
45 tplink,re355-v1|\
46 tplink,re450-v1|\
47 tplink,re450-v2|\
48 tplink,re450-v3|\
49 tplink,tl-wr902ac-v1|\
50 ubnt,bullet-m-ar7240|\
51 ubnt,bullet-m-ar7241|\
52 ubnt,bullet-m-xw|\
53 ubnt,lap-120|\
54 ubnt,litebeam-ac-gen2|\
55 ubnt,nanobeam-ac|\
56 ubnt,nanobridge-m|\
57 ubnt,nanostation-ac-loco|\
58 ubnt,nanostation-loco-m|\
59 ubnt,nanostation-loco-m-xw|\
60 ubnt,picostation-m|\
61 ubnt,powerbeam-5ac-500|\
62 ubnt,powerbeam-5ac-gen2|\
63 ubnt,rocket-m|\
64 ubnt,unifiac-lite|\
65 ubnt,unifiac-lr|\
66 ubnt,unifiac-mesh|\
67 ubnt,unifi|\
68 wd,mynet-wifi-rangeextender|\
69 winchannel,wb2000)
70 ucidef_set_interface_lan "eth0"
71 ;;
72 avm,fritz4020|\
73 pcs,cr3000|\
74 tplink,archer-c58-v1|\
75 tplink,archer-c59-v1|\
76 tplink,archer-c59-v2)
77 ucidef_set_interface_wan "eth1"
78 ucidef_add_switch "switch0" \
79 "0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
80 ;;
81 buffalo,bhr-4grv|\
82 buffalo,wzr-hp-g450h)
83 ucidef_add_switch "switch0" \
84 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
85 ;;
86 buffalo,bhr-4grv2|\
87 trendnet,tew-823dru)
88 ucidef_add_switch "switch0" \
89 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth0"
90 ;;
91 buffalo,wzr-hp-ag300h|\
92 tplink,archer-c25-v1|\
93 tplink,archer-c60-v1|\
94 tplink,archer-c60-v2|\
95 tplink,archer-c60-v3|\
96 tplink,tl-wdr3500-v1|\
97 tplink,tl-wr842n-v1|\
98 tplink,tl-wr842n-v3|\
99 ubnt,airrouter)
100 ucidef_set_interface_wan "eth1"
101 ucidef_add_switch "switch0" \
102 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
103 ;;
104 buffalo,wzr-hp-g302h-a1a0)
105 ucidef_add_switch "switch0" \
106 "0@eth0" "1:lan:1" "3:lan:4" "4:lan:3" "5:lan:2" "2:wan"
107 ;;
108 comfast,cf-e110n-v2|\
109 comfast,cf-e120a-v3|\
110 comfast,cf-e314n-v2|\
111 compex,wpj531-16m|\
112 tplink,cpe210-v1|\
113 tplink,cpe220-v2|\
114 tplink,cpe220-v3|\
115 tplink,cpe510-v1|\
116 tplink,wbs210-v1|\
117 tplink,wbs210-v2|\
118 tplink,wbs510-v1|\
119 tplink,wbs510-v2|\
120 ubnt,nanostation-m|\
121 ubnt,routerstation)
122 ucidef_set_interfaces_lan_wan "eth1" "eth0"
123 ;;
124 comfast,cf-e560ac)
125 ucidef_set_interface_wan "eth1"
126 ucidef_add_switch "switch0" \
127 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
128 ;;
129 comfast,cf-wr650ac-v1|\
130 comfast,cf-wr650ac-v2)
131 ucidef_add_switch "switch0" \
132 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
133 ;;
134 devolo,dvl1200e|\
135 devolo,dvl1750e|\
136 ocedo,ursus)
137 ucidef_set_interface_lan "eth0 eth1"
138 ;;
139 devolo,magic-2-wifi)
140 ucidef_add_switch "switch0" \
141 "0@eth0" "2:wan" "3:lan" "4:lan"
142 ;;
143 dlink,dap-2695-a1)
144 ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:wan" "6@eth1"
145 ;;
146 dlink,dir-825-b1)
147 ucidef_set_interface_wan "eth1"
148 ucidef_add_switch "switch0" \
149 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
150 ;;
151 dlink,dir-825-c1|\
152 dlink,dir-835-a1|\
153 dlink,dir-842-c1|\
154 dlink,dir-842-c2|\
155 dlink,dir-842-c3|\
156 dlink,dir-859-a1|\
157 engenius,epg5000|\
158 tplink,archer-c2-v3|\
159 tplink,tl-wr1043nd-v4|\
160 tplink,tl-wr1043n-v5)
161 ucidef_add_switch "switch0" \
162 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
163 ;;
164 elecom,wrc-1750ghbk2-i|\
165 elecom,wrc-300ghbk2-i|\
166 sitecom,wlr-8100)
167 ucidef_add_switch "switch0" \
168 "0@eth0" "2:lan:4" "3:lan:3" "4:lan:2" "5:lan:1" "1:wan"
169 ;;
170 embeddedwireless,dorin)
171 ucidef_add_switch "switch0" \
172 "0@eth0" "1:wan" "2:lan:3" "3:lan:2"
173 ;;
174 engenius,ews511ap)
175 ucidef_set_interface_lan "eth0 eth1" "dhcp"
176 ;;
177 etactica,eg200)
178 ucidef_set_interface_lan "eth0" "dhcp"
179 ;;
180 glinet,gl-ar750)
181 ucidef_set_interface_wan "eth1"
182 ucidef_add_switch "switch0" \
183 "0@eth0" "1:lan" "2:lan"
184 ;;
185 iodata,etg3-r|\
186 iodata,wn-ac1167dgr|\
187 iodata,wn-ac1600dgr|\
188 iodata,wn-ac1600dgr2|\
189 iodata,wn-ag300dgr|\
190 pcs,cr5000|\
191 sitecom,wlr-7100|\
192 wd,mynet-n750)
193 ucidef_add_switch "switch0" \
194 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
195 ;;
196 librerouter,librerouter-v1)
197 ucidef_add_switch "switch0" \
198 "0@eth0" "5:wan" "6@eth1" "4:lan"
199 ;;
200 nec,wg1200cr|\
201 ubnt,nanostation-ac|\
202 yuncore,a782|\
203 yuncore,xd4200)
204 ucidef_add_switch "switch0" \
205 "0@eth0" "2:lan" "3:wan"
206 ;;
207 nec,wg800hp)
208 ucidef_add_switch "switch0" \
209 "0@eth0" "2:lan" "3:lan" "4:lan" "1:wan"
210 ;;
211 netgear,wndr3700|\
212 netgear,wndr3700-v2|\
213 netgear,wndr3800|\
214 netgear,wndr3800ch|\
215 netgear,wndrmac-v1|\
216 netgear,wndrmac-v2)
217 ucidef_set_interface_wan "eth1"
218 ucidef_add_switch "switch0" \
219 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
220 ucidef_add_switch_attr "switch0" "blinkrate" 2
221 ucidef_add_switch_port_attr "switch0" 1 led 6
222 ucidef_add_switch_port_attr "switch0" 2 led 9
223 ucidef_add_switch_port_attr "switch0" 5 led 2
224 ;;
225 netgear,wnr2200-8m|\
226 netgear,wnr2200-16m)
227 ucidef_set_interface_wan "eth0"
228 ucidef_add_switch "switch0" \
229 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
230 ;;
231 phicomm,k2t)
232 ucidef_add_switch "switch0" \
233 "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
234 ;;
235 qihoo,c301)
236 ucidef_set_interface_wan "eth1"
237 ucidef_add_switch "switch0" \
238 "0@eth0" "2:lan" "3:lan"
239 ;;
240 rosinson,wr818)
241 ucidef_add_switch "switch0" \
242 "0@eth0" "1:lan" "2:lan" "3:wan"
243 ;;
244 teltonika,rut955|\
245 teltonika,rut955-h7v3c0)
246 ucidef_set_interface_wan "eth1"
247 ucidef_add_switch "switch0" \
248 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1"
249 ;;
250 tplink,archer-a7-v5|\
251 tplink,archer-c6-v2|\
252 tplink,archer-c6-v2-us|\
253 tplink,archer-c7-v4|\
254 tplink,archer-c7-v5|\
255 tplink,tl-wdr3600-v1|\
256 tplink,tl-wdr4300-v1|\
257 tplink,tl-wdr4300-v1-il|\
258 tplink,tl-wdr4310-v1)
259 ucidef_add_switch "switch0" \
260 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
261 ;;
262 tplink,archer-c5-v1|\
263 tplink,archer-c7-v1|\
264 tplink,archer-c7-v2|\
265 tplink,tl-wdr4900-v2)
266 ucidef_add_switch "switch0" \
267 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
268 ;;
269 tplink,archer-d50-v1)
270 ucidef_add_switch "switch0" \
271 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "1:wan"
272 ;;
273 tplink,archer-d7-v1|\
274 tplink,archer-d7b-v1)
275 ucidef_add_switch "switch0" \
276 "0@eth1" "3:lan:3" "4:lan:2" "5:lan:1" "6@eth0" "2:wan:4" "1:wan:5"
277 ;;
278 tplink,tl-mr6400-v1)
279 ucidef_set_interfaces_lan_wan "eth0.1 eth1" "usb0"
280 ucidef_add_switch "switch0" \
281 "0@eth0" "1:lan:1" "2:lan:3" "3:lan:2"
282 ;;
283 tplink,tl-wr842n-v2)
284 ucidef_set_interface_wan "eth1"
285 ucidef_add_switch "switch0" \
286 "0@eth0" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
287 ;;
288 tplink,tl-wr1043nd-v1)
289 ucidef_add_switch "switch0" \
290 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
291 ;;
292 tplink,tl-wr1043nd-v2|\
293 tplink,tl-wr1043nd-v3|\
294 tplink,tl-wr1045nd-v2)
295 ucidef_add_switch "switch0" \
296 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
297 ;;
298 tplink,tl-wr2543-v1)
299 ucidef_add_switch "switch0" \
300 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
301 ;;
302 ubnt,acb-isp)
303 ucidef_set_interface_wan "eth1"
304 ucidef_add_switch "switch0" \
305 "0@eth0" "2:lan:1" "3:lan:3" "4:lan:2"
306 ;;
307 ubnt,edgeswitch-5xp)
308 ucidef_set_interface_wan "eth1"
309 ucidef_add_switch "switch0" \
310 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
311 ;;
312 ubnt,edgeswitch-8xp)
313 ucidef_set_interface_wan "eth1"
314 ucidef_add_switch "switch0" \
315 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:lan:5" "5:lan:6" "6:lan:7" "7:lan:8" "8@eth0"
316 ;;
317 ubnt,routerstation-pro)
318 ucidef_set_interface_wan "eth0"
319 ucidef_add_switch "switch0" \
320 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
321 ;;
322 ubnt,nanostation-m-xw)
323 ucidef_add_switch "switch0" \
324 "0@eth0" "5:lan" "1:wan"
325 ;;
326 ubnt,unifiac-mesh-pro|\
327 ubnt,unifiac-pro)
328 ucidef_add_switch "switch0" \
329 "0@eth0" "2:lan:1" "3:lan:2"
330 ;;
331 zbtlink,zbt-wd323|\
332 xiaomi,mi-router-4q)
333 ucidef_set_interface_wan "eth1"
334 ucidef_add_switch "switch0" \
335 "0@eth0" "3:lan:1" "4:lan:2"
336 ;;
337 *)
338 ucidef_set_interfaces_lan_wan "eth0" "eth1"
339 ;;
340 esac
341 }
342
343 ath79_setup_macs()
344 {
345 local board="$1"
346
347 case "$board" in
348 adtran,bsap1800-v2|\
349 adtran,bsap1840)
350 lan_mac=$(mtd_get_mac_binary "Board data" 2)
351 label_mac=$lan_mac
352 ;;
353 alfa-network,ap121f)
354 label_mac=$(mtd_get_mac_binary art 0x1002)
355 ;;
356 avm,fritz1750e|\
357 avm,fritz450e|\
358 avm,fritzdvbc)
359 label_mac=$(fritz_tffs -n macwlan -i $(find_mtd_part "tffs (1)"))
360 ;;
361 avm,fritz300e)
362 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
363 label_mac=$(fritz_tffs -n macwlan -i $(find_mtd_part "tffs (1)"))
364 ;;
365 avm,fritz4020)
366 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
367 wan_mac=$(fritz_tffs -n macb -i $(find_mtd_part "tffs (1)"))
368 ;;
369 devolo,magic-2-wifi)
370 label_mac=$(macaddr_add "$(mtd_get_mac_binary art 0x1002)" 3)
371 ;;
372 dlink,dap-2695-a1)
373 label_mac=$(mtd_get_mac_ascii bdcfg "wlanmac")
374 ;;
375 dlink,dir-825-b1)
376 lan_mac=$(mtd_get_mac_text "caldata" 0xffa0)
377 wan_mac=$(mtd_get_mac_text "caldata" 0xffb4)
378 ;;
379 dlink,dir-505)
380 lan_mac=$(mtd_get_mac_text "mac" 0x4)
381 ;;
382 dlink,dir-825-c1|\
383 dlink,dir-835-a1)
384 lan_mac=$(mtd_get_mac_text "mac" 0x4)
385 wan_mac=$(mtd_get_mac_text "mac" 0x18)
386 ;;
387 dlink,dir-842-c1|\
388 dlink,dir-842-c2|\
389 dlink,dir-842-c3|\
390 nec,wg1200cr)
391 lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
392 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
393 label_mac=$lan_mac
394 ;;
395 dlink,dir-859-a1|\
396 qihoo,c301|\
397 wd,mynet-n750)
398 lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
399 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
400 ;;
401 elecom,wrc-1750ghbk2-i|\
402 elecom,wrc-300ghbk2-i)
403 wan_mac=$(macaddr_add "$(mtd_get_mac_binary art 0x1002)" -2)
404 ;;
405 engenius,ecb1750)
406 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
407 label_mac=$(mtd_get_mac_ascii u-boot-env athaddr)
408 ;;
409 engenius,epg5000)
410 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
411 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
412 ;;
413 engenius,ews511ap)
414 lan_mac=$(mtd_get_mac_text "u-boot-env" 0xe9)
415 eth1_mac=$(macaddr_add "$lan_mac" 1)
416 ucidef_set_interface "eth0" ifname "eth0" protocol "none" macaddr "$lan_mac"
417 ucidef_set_interface "eth1" ifname "eth1" protocol "none" macaddr "$eth1_mac"
418 ;;
419 enterasys,ws-ap3705i)
420 label_mac=$(mtd_get_mac_ascii u-boot-env0 ethaddr)
421 ;;
422 iodata,etg3-r)
423 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
424 wan_mac=$(macaddr_add "$lan_mac" -1)
425 label_mac=$wan_mac
426 ;;
427 iodata,wn-ac1167dgr|\
428 iodata,wn-ac1600dgr|\
429 iodata,wn-ac1600dgr2|\
430 iodata,wn-ag300dgr)
431 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
432 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
433 label_mac=$wan_mac
434 ;;
435 jjplus,ja76pf2)
436 wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n alias/ethaddr)
437 lan_mac=$(macaddr_add "$wan_mac" 1)
438 ;;
439 nec,wg800hp)
440 lan_mac=$(mtd_get_mac_text board_data 0x280)
441 wan_mac=$(mtd_get_mac_text board_data 0x480)
442 label_mac=$wan_mac
443 ;;
444 netgear,wndr3700|\
445 netgear,wndr3700-v2|\
446 netgear,wndr3800|\
447 netgear,wndrmac-v1|\
448 netgear,wndrmac-v2)
449 lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0x0)")
450 ;;
451 phicomm,k2t)
452 lan_mac=$(k2t_get_mac "lan_mac")
453 wan_mac=$(k2t_get_mac "wan_mac")
454 ;;
455 rosinson,wr818)
456 wan_mac=$(mtd_get_mac_binary factory 0x0)
457 lan_mac=$(macaddr_setbit_la "$wan_mac")
458 ;;
459 sitecom,wlr-7100|\
460 sitecom,wlr-8100)
461 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
462 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
463 label_mac=$lan_mac
464 ;;
465 tplink,archer-a7-v5|\
466 tplink,archer-c7-v4|\
467 tplink,archer-c7-v5|\
468 tplink,tl-wr1043nd-v4|\
469 tplink,tl-wr1043n-v5)
470 base_mac=$(mtd_get_mac_binary info 0x8)
471 wan_mac=$(macaddr_add "$base_mac" 1)
472 ;;
473 tplink,tl-wdr3600-v1|\
474 tplink,tl-wdr4300-v1|\
475 tplink,tl-wdr4300-v1-il)
476 base_mac=$(mtd_get_mac_binary u-boot 0x1fc00)
477 wan_mac=$(macaddr_add "$base_mac" 1)
478 ;;
479 trendnet,tew-823dru)
480 lan_mac=$(mtd_get_mac_text mac 0x4)
481 wan_mac=$(mtd_get_mac_text mac 0x18)
482 label_mac=$wan_mac
483 ;;
484 ubnt,airrouter|\
485 ubnt,bullet-m-ar7240|\
486 ubnt,bullet-m-ar7241|\
487 ubnt,nanobridge-m|\
488 ubnt,nanostation-loco-m|\
489 ubnt,nanostation-m|\
490 ubnt,picostation-m|\
491 ubnt,rocket-m|\
492 ubnt,unifi)
493 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
494 ;;
495 ubnt,litebeam-ac-gen2|\
496 ubnt,powerbeam-5ac-500|\
497 ubnt,powerbeam-5ac-gen2)
498 label_mac=$(mtd_get_mac_binary art 0x5006)
499 ;;
500 ubnt,routerstation|\
501 ubnt,routerstation-pro)
502 wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n ar7100_esa)
503 lan_mac=$(macaddr_add "$wan_mac" 1)
504 ;;
505 wd,mynet-wifi-rangeextender)
506 lan_mac=$(nvram get et0macaddr)
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 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
513 }
514
515 board_config_update
516 board=$(board_name)
517 ath79_setup_interfaces $board
518 ath79_setup_macs $board
519 board_config_flush
520
521 exit 0