ramips: use phytpt trigger for mt76 wireless
[openwrt/openwrt.git] / target / linux / ramips / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/functions/uci-defaults.sh
5 . /lib/functions/system.sh
6
7 ramips_setup_rt3x5x_vlans()
8 {
9 if [ ! -x /sbin/swconfig ]; then
10 # legacy default
11 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
12 return
13 fi
14 local wanports=""
15 local lanports=""
16 for port in 5 4 3 2 1 0; do
17 if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
18 continue
19 fi
20 if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
21 wanports="$port:wan $wanports"
22 else
23 lanports="$port:lan $lanports"
24 fi
25 done
26 ucidef_add_switch "rt305x" $lanports $wanports "6t@eth0"
27 }
28
29 ramips_setup_interfaces()
30 {
31 local board="$1"
32
33 case $board in
34 11acnas|\
35 w2914nsv2|\
36 zbt-we2026)
37 ucidef_add_switch "switch0" \
38 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0"
39 ;;
40 3g150b|\
41 3g300m|\
42 a5-v11|\
43 all0256n-4M|\
44 all0256n-8M|\
45 all5002|\
46 all5003|\
47 bocco|\
48 broadway|\
49 dcs-930|\
50 dcs-930l-b1|\
51 ht-tm02|\
52 linkits7688 | \
53 m2m|\
54 microwrt|\
55 mpr-a2|\
56 ncs601w|\
57 omega2 | \
58 omega2p | \
59 timecloud|\
60 w150m|\
61 widora,neo-16m|\
62 widora,neo-32m|\
63 wnce2001|\
64 zbt-cpe102|\
65 zorlik,zl5900v2|\
66 zte-q7)
67 ucidef_add_switch "switch0"
68 ucidef_add_switch_attr "switch0" "enable" "false"
69 ucidef_set_interface_lan "eth0"
70 ;;
71 mlw221|\
72 mr-102n)
73 ucidef_set_interface_lan "eth0.2"
74 ;;
75 3g-6200n|\
76 ai-br100|\
77 alfa-network,ac1200rm|\
78 mediatek,ap-mt7621a-v60|\
79 d240|\
80 db-wrt01|\
81 dir-300-b7|\
82 dir-320-b1|\
83 dir-610-a1|\
84 dir-615-h1|\
85 dlink,dwr-116-a1|\
86 dlink,dwr-921-c1|\
87 ew1200|\
88 firewrt|\
89 hc5661a|\
90 hc5962|\
91 hlk-rm04|\
92 k2p|\
93 kn|\
94 kn_rc|\
95 mac1200rv2|\
96 miwifi-mini|\
97 miwifi-nano|\
98 mt7621|\
99 mt7628|\
100 mzk-750dhp|\
101 mzk-w300nh2|\
102 d-team,newifi-d2|\
103 nixcore-x1-8M|\
104 nixcore-x1-16M|\
105 oy-0001|\
106 pbr-m1|\
107 psg1208|\
108 psg1218a|\
109 r6220|\
110 rt-n12p|\
111 sap-g3200u3|\
112 sk-wb8|\
113 u7621-06-256M-16M|\
114 vr500|\
115 wf-2881|\
116 whr-g300n|\
117 mqmaker,witi-256m|\
118 mqmaker,witi-512m|\
119 wl-wn575a3|\
120 wndr3700v5|\
121 youku-yk1|\
122 zbt-ape522ii|\
123 zbt-we1326|\
124 zbtlink,zbt-we3526|\
125 zbt-we826-16M|\
126 zbt-we826-32M|\
127 zbt-wg2626|\
128 zbt-wg3526-16M|\
129 zbt-wg3526-32M|\
130 zbt-wr8305rt)
131 ucidef_add_switch "switch0" \
132 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
133 ;;
134 alfa-network,awusfree1|\
135 cs-qr10|\
136 d105|\
137 dlink,dap-1522-a1|\
138 dch-m225|\
139 ex2700|\
140 ex3700|\
141 hpm|\
142 mzk-ex300np|\
143 mzk-ex750np|\
144 na930|\
145 pbr-d1|\
146 ravpower,wd03|\
147 tama,w06|\
148 u25awf-h1|\
149 wli-tx4-ag300n|\
150 wmdr-143n|\
151 wmr-300|\
152 wn3000rpv3|\
153 wrh-300cr)
154 ucidef_set_interface_lan "eth0"
155 ;;
156 mir3g)
157 ucidef_add_switch "switch0" \
158 "2:lan:2" "3:lan:1" "1:wan" "6t@eth0"
159 ;;
160 psg1218b)
161 ucidef_add_switch "switch0" \
162 "0:lan:3" "1:lan:2" "2:lan:1" "3:wan" "6@eth0"
163 ;;
164 whr-300hp2|\
165 whr-600d|\
166 wsr-1166|\
167 wsr-600)
168 ucidef_add_switch "switch0" \
169 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:wan:5" "6@eth0"
170 ;;
171 ar670w|\
172 ar725w|\
173 rt-ac51u)
174 ucidef_add_switch "switch0" \
175 "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
176 ;;
177 rt-n15|\
178 wl-351)
179 ucidef_add_switch "switch0" \
180 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5@eth0"
181 ;;
182 asl26555-8M|\
183 asl26555-16M|\
184 rp-n53)
185 ucidef_add_switch "switch0" \
186 "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
187 ;;
188 atp-52b|\
189 awm002-evb-4M|\
190 awm002-evb-8M|\
191 c20i|\
192 dir-645|\
193 f5d8235-v2|\
194 gl-mt300a|\
195 gl-mt300n|\
196 gl-mt750|\
197 hg255d|\
198 jhr-n805r|\
199 jhr-n825r|\
200 jhr-n926r|\
201 mzk-wdpr|\
202 rb750gr3|\
203 rt-n14u|\
204 tplink,c20-v4|\
205 tplink,c50-v3|\
206 tplink,tl-mr3420-v5|\
207 tl-wr840n-v4|\
208 tl-wr840n-v5|\
209 tl-wr841n-v13|\
210 u7628-01-128M-16M|\
211 ubnt-erx|\
212 ubnt-erx-sfp|\
213 ur-326n4g|\
214 wrtnode|\
215 wrtnode2p | \
216 wrtnode2r | \
217 youhua,wr1200js|\
218 zbt-wa05)
219 ucidef_add_switch "switch0" \
220 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
221 ;;
222 c50|\
223 tplink,c20-v1)
224 ucidef_add_switch "switch0" \
225 "1:lan:3" "2:lan:4" "3:lan:1" "4:lan:2" "0:wan" "6@eth0"
226 ;;
227 dir-860l-b1)
228 ucidef_add_switch "switch0" \
229 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
230 ;;
231 gnubee,gb-pc1|\
232 gnubee,gb-pc2)
233 ucidef_add_switch "switch0" \
234 "0:lan" "4:lan" "6@eth0"
235 ;;
236 gl-mt300n-v2)
237 ucidef_add_switch "switch0" \
238 "1:lan" "0:wan" "6@eth0"
239 ;;
240 awapn2403)
241 ucidef_add_switch "switch0" \
242 "0:lan" "1:wan" "6@eth0"
243 ;;
244 b2c|\
245 nw718|\
246 psr-680w|\
247 sl-r7205|\
248 ur-336un|\
249 w502u|\
250 wr6202)
251 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
252 ;;
253 br-6475nd)
254 ucidef_add_switch "switch0" \
255 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
256 ;;
257 c108|\
258 cf-wr800n)
259 ucidef_add_switch "switch0" \
260 "4:lan" "6t@eth0"
261 ;;
262 cy-swr1100)
263 ucidef_add_switch "switch0" \
264 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "9@eth0"
265 ;;
266 duzun-dm06)
267 ucidef_add_switch "switch0" \
268 "1:lan" "0:wan" "6@eth0"
269 ;;
270 e1700|\
271 mt7620a_mt7530)
272 ucidef_add_switch "switch1" \
273 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
274 ;;
275 hc5*61|\
276 y1s)
277 ucidef_add_switch "switch0" \
278 "1:lan" "2:lan" "3:lan" "4:lan" "5:lan" "0:wan" "6@eth0"
279 ;;
280 kn_rf)
281 ucidef_add_switch "switch0" \
282 "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6@eth0"
283 ;;
284 kng_rc)
285 ucidef_add_switch "switch1" \
286 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "7t@eth0"
287 ;;
288 mlwg2|\
289 wizard8800|\
290 wl-330n)
291 ucidef_set_interface_lan "eth0.1"
292 ;;
293 mr200)
294 ucidef_add_switch "switch0" \
295 "0:lan" "1:lan" "2:lan" "3:lan" "6t@eth0"
296 ucidef_set_interface_wan "usb0"
297 ;;
298 mzk-dp150n|\
299 vocore-8M|\
300 vocore-16M)
301 ucidef_add_switch "switch0" \
302 "0:lan" "4:lan" "6t@eth0"
303 ;;
304 newifi-d1)
305 ucidef_add_switch "switch0" \
306 "1:lan:2" "2:lan:1" "4:wan" "6@eth0"
307 ;;
308 re350-v1)
309 ucidef_add_switch "switch0" \
310 "0:lan" "6@eth0"
311 ;;
312 re6500)
313 ucidef_add_switch "switch0" \
314 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "6@eth0"
315 ;;
316 rt-n56u)
317 ucidef_add_switch "switch0" \
318 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "8@eth0"
319 ;;
320 tew-638apb-v2)
321 ucidef_add_switch "switch0" \
322 "4:lan" "6@eth0"
323 ;;
324 tew-691gr|\
325 tew-692gr|\
326 wlr-6000)
327 ucidef_add_switch "switch0" \
328 "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0"
329 ;;
330 tplink,tl-wr902ac-v3)
331 ucidef_add_switch "switch0" \
332 "4:lan" "6@eth0"
333 ;;
334 vonets,var11n-300|\
335 wt1520-4M|\
336 wt1520-8M)
337 ucidef_add_switch "switch0" \
338 "0:lan" "4:wan" "6@eth0"
339 ;;
340 vocore2|\
341 vocore2lite)
342 ucidef_add_switch "switch0" \
343 "0:lan" "2:lan" "6t@eth0"
344 ;;
345 f5d8235-v1|\
346 tew-714tru|\
347 v11st-fe|\
348 wzr-agl300nh)
349 ucidef_add_switch "switch0" \
350 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
351 ;;
352 wcr-1166ds)
353 ucidef_add_switch "switch0" \
354 "3:lan" "4:wan" "6@eth0"
355 ;;
356 wcr-150gn|\
357 we1026-5g-16m)
358 ucidef_add_switch "switch0" \
359 "0:lan" "6t@eth0"
360 ;;
361 whr-1166d)
362 ucidef_add_switch "switch0" \
363 "0:lan" "1:lan" "2:lan" "3:lan" "5:wan" "6@eth0"
364 ;;
365 wizfi630a)
366 ucidef_add_switch "switch0" \
367 "1:lan" "2:lan" "0:wan" "6@eth0"
368 ;;
369 wt3020-4M|\
370 wt3020-8M)
371 ucidef_add_switch "switch0" \
372 "4:lan" "0:wan" "6@eth0"
373 ;;
374 zbtlink,zbt-we1226|\
375 y1)
376 ucidef_add_switch "switch0" \
377 "0:lan:2" "1:lan:1" "4:wan" "6@eth0"
378 ;;
379 *)
380 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
381 if [ -n "${RT3X5X}" ]; then
382 ramips_setup_rt3x5x_vlans
383 else
384 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
385 fi
386 ;;
387 esac
388 }
389
390 ramips_setup_macs()
391 {
392 local board="$1"
393 local lan_mac=""
394 local wan_mac=""
395
396 case $board in
397 a5-v11|\
398 ht-tm02|\
399 wmdr-143n)
400 lan_mac=$(cat /sys/class/net/eth0/address)
401 ;;
402 all0239-3g|\
403 carambola|\
404 freestation5|\
405 w502u|\
406 wnce2001)
407 wan_mac=$(mtd_get_mac_binary factory 46)
408 ;;
409 bc2|\
410 broadway|\
411 d105|\
412 dir-300-b7|\
413 dir-320-b1|\
414 dir-620-a1|\
415 esr-9753|\
416 freestation5|\
417 hlk-rm04|\
418 mpr-a1|\
419 psr-680w|\
420 sl-r7205|\
421 y1|\
422 y1s)
423 lan_mac=$(cat /sys/class/net/eth0/address)
424 lan_mac=$(macaddr_setbit_la "$lan_mac")
425 wan_mac=$(macaddr_add "$lan_mac" 1)
426 ;;
427 br-6475nd)
428 lan_mac=$(cat /sys/class/net/eth0/address)
429 wan_mac=$(mtd_get_mac_binary devdata 7)
430 ;;
431 cy-swr1100|\
432 dch-m225)
433 lan_mac=$(mtd_get_mac_ascii factory lanmac)
434 ;;
435 dir-645)
436 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
437 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
438 ;;
439 dir-860l-b1)
440 lan_mac=$(mtd_get_mac_ascii factory lanmac)
441 wan_mac=$(mtd_get_mac_ascii factory wanmac)
442 ;;
443 dlink,dwr-116-a1|\
444 dlink,dwr-921-c1)
445 wan_mac=$(jboot_config_read -m -i $(find_mtd_part "config") -o 0xE000)
446 lan_mac=$(macaddr_add "$wan_mac" 1)
447 ;;
448 e1700)
449 wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
450 ;;
451 gl-mt300n-v2|\
452 whr-g300n)
453 wan_mac=$(mtd_get_mac_binary factory 4)
454 ;;
455 hc5*61|\
456 hc5661a|\
457 hc5962)
458 lan_mac=`mtd_get_mac_ascii bdinfo "Vfac_mac "`
459 [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
460 wan_mac=$(macaddr_add "$lan_mac" 1)
461 ;;
462 kn_rc|\
463 kn_rf|\
464 kng_rc)
465 wan_mac=$(mtd_get_mac_binary factory 40)
466 ;;
467 linkits7688)
468 wan_mac=$(mtd_get_mac_binary factory 4)
469 lan_mac=$(mtd_get_mac_binary factory 46)
470 ;;
471 mac1200rv2)
472 lan_mac=$(mtd_get_mac_binary factory_info 13)
473 wan_mac=$(macaddr_add "$lan_mac" 1)
474 ;;
475 mir3g)
476 lan_mac=$(mtd_get_mac_binary Factory 0xe006)
477 ;;
478 miwifi-mini)
479 wan_mac=$(cat /sys/class/net/eth0/address)
480 lan_mac=$(macaddr_setbit_la "$wan_mac")
481 ;;
482 m3|\
483 m4-4M|\
484 m4-8M|\
485 x5|\
486 x8)
487 lan_mac=$(cat /sys/class/net/eth0/address)
488 lan_mac=$(macaddr_add "$lan_mac" -2)
489 ;;
490 newifi-d1)
491 lan_mac=$(cat /sys/class/net/eth0/address)
492 lan_mac=$(macaddr_add "$lan_mac" 2)
493 ;;
494 omega2|\
495 omega2p)
496 wan_mac=$(mtd_get_mac_binary factory 4)
497 lan_mac=$(mtd_get_mac_binary factory 46)
498 ;;
499 oy-0001)
500 lan_mac=$(mtd_get_mac_binary factory 40)
501 wan_mac=$(mtd_get_mac_binary factory 46)
502 ;;
503 r6220)
504 wan_mac=$(mtd_get_mac_binary factory 4)
505 lan_mac=$(macaddr_add "$wan_mac" 1)
506 ;;
507 rt-n56u)
508 lan_mac=$(cat /sys/class/net/eth0/address)
509 lan_mac=$(macaddr_setbit_la "$lan_mac")
510 wan_mac=$(mtd_get_mac_binary factory 32772)
511 ;;
512 sk-wb8)
513 wan_mac=$(mtd_get_mac_binary factory 57350)
514 ;;
515 tew-691gr)
516 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 4)" 3)
517 ;;
518 tew-692gr)
519 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 4)" 1)
520 ;;
521 tiny-ac)
522 lan_mac=$(mtd_get_mac_ascii u-boot-env LAN_MAC_ADDR)
523 wan_mac=$(mtd_get_mac_ascii u-boot-env WAN_MAC_ADDR)
524 ;;
525 vr500)
526 lan_mac=$(mtd_get_mac_binary factory 57344)
527 wan_mac=$(mtd_get_mac_binary factory 57350)
528 ;;
529 w306r-v20)
530 lan_mac=$(cat /sys/class/net/eth0/address)
531 wan_mac=$(macaddr_add "$lan_mac" 5)
532 ;;
533 wcr-1166ds|\
534 wsr-1166)
535 local index="$(find_mtd_index "board_data")"
536 wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
537 lan_mac=$wan_mac
538 ;;
539 wcr-150gn)
540 wan_mac=$(mtd_get_mac_binary factory 40)
541 ;;
542 whr-1166d|\
543 whr-300hp2|\
544 whr-600d|\
545 wsr-600)
546 wan_mac=$(mtd_get_mac_binary factory 4)
547 lan_mac=$wan_mac
548 ;;
549 wizfi630a)
550 lan_mac=$(mtd_get_mac_binary factory 4)
551 wan_mac=$(mtd_get_mac_binary factory 40)
552 ;;
553 wlr-6000)
554 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 32772)" 2)
555 ;;
556 *)
557 lan_mac=$(cat /sys/class/net/eth0/address)
558 wan_mac=$(macaddr_add "$lan_mac" 1)
559 ;;
560 esac
561
562 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
563 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
564 }
565
566 board_config_update
567 board=$(board_name)
568 ramips_setup_interfaces $board
569 ramips_setup_macs $board
570 board_config_flush
571
572 exit 0