ramips: add support for Intenso Memory 2 Move USB 3.0
[oweals/openwrt.git] / target / linux / ramips / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults-new.sh
6 . /lib/functions/system.sh
7
8 ramips_setup_rt3x5x_vlans()
9 {
10         if [ ! -x /sbin/swconfig ]; then
11                 # legacy default
12                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
13                 return
14         fi
15         local wanports=""
16         local lanports=""
17         for port in 5 4 3 2 1 0; do
18                 if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
19                         continue
20                 fi
21                 if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
22                         wanports="$port $wanports"
23                 else
24                         lanports="$port $lanports"
25                 fi
26         done
27         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
28         ucidef_add_switch "rt305x" "1" "1"
29         ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"
30         ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t"
31 }
32
33 ramips_setup_interfaces()
34 {
35         local board="$1"
36
37         ucidef_set_interface_loopback
38
39         case $board in
40         a5-v11)
41                 ucidef_set_interface_lan "eth0.1"
42                 ucidef_add_switch "switch0" "1" "1"
43                 ucidef_add_switch_vlan "switch0" "1" "0 6t"
44                 ;;
45
46         3g300m | \
47         w150m | \
48         all0256n | \
49         all5002 | \
50         all5003 | \
51         broadway | \
52         dcs-930| \
53         ht-tm02| \
54         ncs601w | \
55         wnce2001)
56                 ucidef_add_switch "switch0" "1" "0"
57                 ucidef_set_interface_lan "eth0"
58                 ;;
59
60         3g-6200nl | \
61         mlw221)
62                 ucidef_set_interface_lan "eth0.2"
63                 ;;
64         mlwg2)
65                 ucidef_set_interface_lan "eth0.1"
66                 ;;
67
68         m2m)
69                 ucidef_add_switch "switch0" "4"
70                 ucidef_set_interface_lan "eth0"
71                 ;;
72
73         wizard8800 | \
74         wl-330n | \
75         wmr300)
76                 ucidef_set_interface_lan "eth0.1"
77                 ;;
78
79         b2c | \
80         nw718 | \
81         psr-680w | \
82         sl-r7205 | \
83         w502u | \
84         wr6202)
85                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
86                 ;;
87
88         awapn2403)
89                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
90                 ucidef_add_switch "switch0" "1" "1"
91                 ucidef_add_switch_vlan "switch0" "1" "0 6t"
92                 ucidef_add_switch_vlan "switch0" "2" "1 6t"
93                 ;;
94
95         br-6475nd)
96                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
97                 ucidef_add_switch "switch0" "1" "1"
98                 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
99                 ucidef_add_switch_vlan "switch0" "2" "0 9t"
100                 ;;
101
102         asl26555)
103                 ucidef_set_interface_lan "eth0.1"
104                 ucidef_add_switch "switch0" "1" "1"
105                 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
106                 ;;
107
108         cy-swr1100)
109                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
110                 ucidef_add_switch "switch0" "1" "1"
111                 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 9t"
112                 ucidef_add_switch_vlan "switch0" "2" "4 9t"
113                 ;;
114
115         3g-6200n | \
116         ai-br100 | \
117         dir-610-a1 | \
118         dir-300-b7 | \
119         dir-320-b1 | \
120         dir-615-h1 | \
121         hlk-rm04 | \
122         mt7621 | \
123         mt7628 | \
124         mzk-w300nh2 | \
125         mzk-750dhp | \
126         whr-300hp2 | \
127         whr-600d | \
128         wsr-600 | \
129         wsr-1166 | \
130         wt1520 | \
131         y1)
132                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
133                 ucidef_add_switch "switch0" "1" "1"
134                 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
135                 ucidef_add_switch_vlan "switch0" "2" "4 6t"
136                 ;;
137
138         whr-1166d)
139                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
140                 ucidef_add_switch "switch0" "1" "1"
141                 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
142                 ucidef_add_switch_vlan "switch0" "2" "5 6t"
143                 ;;
144
145         awm002-evb | \
146         awm003-evb | \
147         argus-atp52b | \
148         dir-645 | \
149         f5d8235-v1 | \
150         f5d8235-v2 | \
151         hg255d | \
152         rt-n14u | \
153         wrtnode | \
154         wt3020 | \
155         ur-326n4g | \
156         zbt-wa05)
157                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
158                 ucidef_add_switch "switch0" "1" "1"
159                 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
160                 ucidef_add_switch_vlan "switch0" "2" "0 6t"
161                 ;;
162
163         ur-336un)
164                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
165                 ;;
166
167         br6524n | \
168         v11st-fe)
169                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
170                 ucidef_add_switch "switch0" "1" "1"
171                 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
172                 ucidef_add_switch_vlan "switch0" "2" "0 5t"
173                 ;;
174
175         ar670w | \
176         ar725w | \
177         rt-n15 | \
178         wl-351)
179                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
180                 ucidef_add_switch "switch0" "1" "1"
181                 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
182                 ucidef_add_switch_vlan "switch0" "2" "4 5t"
183                 ;;
184
185         rt-n56u)
186                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
187                 ucidef_add_switch "switch0" "1" "1"
188                 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
189                 ucidef_add_switch_vlan "switch0" "2" "4 8t"
190                 ;;
191
192         tew-691gr|\
193         tew-692gr)
194                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
195                 ucidef_add_switch "switch0" "1" "1"
196                 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
197                 ucidef_add_switch_vlan "switch0" "2" "0t 5"
198                 ;;
199
200         vocore)
201                 ucidef_set_interface_lan "eth0.1"
202                 ucidef_add_switch "switch0" "1" "1"
203                 ucidef_add_switch_vlan "switch0" "1" "0 4 6t"
204                 ;;
205
206         wcr-150gn)
207                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
208                 ucidef_add_switch "switch0" "1" "1"
209                 ucidef_add_switch_vlan "switch0" "1" "0 6t"
210                 ucidef_add_switch_vlan "switch0" "2" "6t"
211                 ;;
212
213         wr8305rt)
214                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
215                 ucidef_add_switch "switch0" "1" "1"
216                 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 6t"
217                 ucidef_add_switch_vlan "switch0" "2" "4 6t"
218                 ;;
219
220         y1s)
221                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
222                 ucidef_add_switch "switch0" "1" "1"
223                 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
224                 ucidef_add_switch_vlan "switch0" "2" "0 6t"
225                 ;;
226         d105 | \
227         na930 | \
228         omni-emb-hpm|\
229         wli-tx4-ag300n)
230                 ucidef_set_interface_lan "eth0"
231                 ;;
232
233         e1700 | \
234         mt7620a_mt7530)
235                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
236                 ucidef_add_switch "switch1" "1" "1"
237                 ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 6t"
238                 ucidef_add_switch_vlan "switch1" "2" "4 6t"
239                 ;;
240
241         *)
242                 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
243                 if [ -n "${RT3X5X}" ]; then
244                         ramips_setup_rt3x5x_vlans
245                 else
246                         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
247                 fi
248                 ;;
249         esac
250 }
251
252 ramips_setup_macs()
253 {
254         local board="$1"
255         local lan_mac=""
256         local wan_mac=""
257
258         case $board in
259         br-6475nd)
260                 lan_mac=$(cat /sys/class/net/eth0/address)
261                 wan_mac=$(mtd_get_mac_binary devdata 7)
262                 ;;
263
264         w306r-v20)
265                 lan_mac=$(cat /sys/class/net/eth0/address)
266                 wan_mac=$(macaddr_add "$lan_mac" 5)
267                 ;;
268
269         tew-691gr)
270                 lan_mac=$(cat /sys/class/net/eth0/address)
271                 wan_mac=$(macaddr_add "$lan_mac" 3)
272                 ;;
273
274         tew-692gr)
275                 lan_mac=$(cat /sys/class/net/eth0/address)
276                 wan_mac=$(macaddr_add "$lan_mac" 4)
277                 ;;
278
279         m3 |\
280         m4 |\
281         x5 |\
282         x8)
283                 lan_mac=$(cat /sys/class/net/eth0/address)
284                 lan_mac=$(macaddr_add "$lan_mac" -2)
285                 ;;
286
287         a5-v11 |\
288         bc2 |\
289         broadway |\
290         d105 |\
291         dir-620-a1 |\
292         esr-9753 |\
293         freestation5 |\
294         hlk-rm04 | \
295         mpr-a1 | \
296         mpr-a2 | \
297         dir-300-b7 | \
298         dir-320-b1 | \
299         psr-680w |\
300         sl-r7205 |\
301         y1 |\
302         y1s)
303                 lan_mac=$(cat /sys/class/net/eth0/address)
304                 lan_mac=$(macaddr_setbit_la "$lan_mac")
305                 wan_mac=$(macaddr_add "$lan_mac" 1)
306                 ;;
307
308         ht-tm02)
309                 lan_mac=$(cat /sys/class/net/eth0/address)
310                 ;;
311
312         cy-swr1100 | \
313         dir-645)
314                 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
315                 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
316                 ;;
317
318         e1700)
319                 wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
320                 ;;
321
322         wcr-150gn)
323                 wan_mac=$(mtd_get_mac_binary factory 40)
324                 ;;
325
326         rt-n56u)
327                 lan_mac=$(cat /sys/class/net/eth0/address)
328                 lan_mac=$(macaddr_setbit_la "$lan_mac")
329                 wan_mac=$(mtd_get_mac_binary factory 32772)
330                 ;;
331
332         all0239-3g | \
333         carambola | \
334         freestation5 | \
335         w502u | \
336         wnce2001)
337                 wan_mac=$(mtd_get_mac_binary factory 46)
338                 ;;
339
340         *)
341                 lan_mac=$(cat /sys/class/net/eth0/address)
342                 wan_mac=$(macaddr_add "$lan_mac" 1)
343                 ;;
344
345         esac
346
347         [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
348         [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
349 }
350
351 board_config_update
352 board=$(ramips_board_name)
353 ramips_setup_interfaces $board
354 ramips_setup_macs $board
355 board_config_flush
356
357 exit 0