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