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