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