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