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