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