ramips: introduce DTS for ALL5003
[openwrt/openwrt.git] / target / linux / ramips / base-files / etc / uci-defaults / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults.sh
6
7 ramips_setup_rt3x5x_vlans()
8 {
9 if [ ! -x /sbin/swconfig ]; then
10 # legacy default
11 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
12 return
13 fi
14 local wanports=""
15 local lanports=""
16 swconfig dev rt305x set reset 1
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 wnce2001)
47 ucidef_add_switch "switch0" "1" "0"
48 ucidef_set_interface_lan "eth0"
49 ;;
50
51 3g-6200nl | \
52 wl-330n)
53 ucidef_set_interface_lan "eth0.1"
54 ;;
55
56 3g-6200n | \
57 argus-atp52b | \
58 b2c | \
59 nw718 | \
60 psr-680w | \
61 sl-r7205 | \
62 w502u | \
63 wr6202)
64 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
65 ;;
66
67 asl26555)
68 ucidef_set_interface_lan "eth0.1"
69 ucidef_add_switch "switch0" "1" "1"
70 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
71 ;;
72
73 dir-645)
74 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
75 ucidef_add_switch "switch0" "1" "1"
76 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
77 ucidef_add_switch_vlan "switch0" "2" "0 6t"
78 ;;
79
80 dir-615-h1 | \
81 mzk-w300nh2)
82 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
83 ucidef_add_switch "switch0" "1" "1"
84 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
85 ucidef_add_switch_vlan "switch0" "2" "4 6t"
86 ;;
87
88 f5d8235-v1 | \
89 f5d8235-v2 | \
90 ur-326n4g)
91 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
92 ucidef_add_switch "switch0" "1" "1"
93 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
94 ucidef_add_switch_vlan "switch0" "2" "0 6t"
95 ;;
96
97 ur-336un)
98 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
99 ;;
100
101 br6524n | \
102 v11st-fe)
103 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
104 ucidef_add_switch "switch0" "1" "1"
105 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
106 ucidef_add_switch_vlan "switch0" "2" "0 5t"
107 ;;
108
109 rt-n15 | \
110 wl-351)
111 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
112 ucidef_add_switch "switch0" "1" "1"
113 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
114 ucidef_add_switch_vlan "switch0" "2" "4 5t"
115 ;;
116
117 rt-n56u)
118 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
119 ucidef_add_switch "switch0" "1" "1"
120 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
121 ucidef_add_switch_vlan "switch0" "2" "4 8t"
122 ;;
123
124 tew-691gr|\
125 tew-692gr)
126 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
127 ucidef_add_switch "switch0" "1" "1"
128 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
129 ucidef_add_switch_vlan "switch0" "2" "0t 5"
130 ;;
131
132 freestation5 | \
133 wcr-150gn)
134 ucidef_set_interfaces_lan_wan "eth0.2" "eth0.1"
135 ;;
136
137 d105 | \
138 omni-emb-hpm|\
139 wli-tx4-ag300n)
140 ucidef_set_interface_lan "eth0"
141 ;;
142
143 *)
144 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
145 if [ -n "${RT3X5X}" ]; then
146 ramips_setup_rt3x5x_vlans
147 else
148 ucidef_set_interfaces_lan_wan "eth0" "eth1"
149 fi
150 ;;
151 esac
152 }
153
154 ramips_setup_macs()
155 {
156 local board="$1"
157 local lan_mac=""
158 local wan_mac=""
159
160 case $board in
161 all0256n | \
162 all5002 | \
163 dir-615-h1)
164 lan_mac=$(mtd_get_mac_binary factory 40)
165 ;;
166 3g-6200n | \
167 3g300m | \
168 w150m | \
169 air3gii | \
170 argus-atp52b | \
171 bc2 | \
172 br6425 | \
173 broadway | \
174 dir-620-d1 | \
175 f5d8235-v1 | \
176 mzk-w300nh2 | \
177 nw718 | \
178 psr-680w | \
179 rt-n15 | \
180 sl-r7205 | \
181 wl-351)
182 lan_mac=$(mtd_get_mac_binary factory 4)
183 wan_mac=$(macaddr_add "$lan_mac" 1)
184 ;;
185
186 asl26555)
187 lan_mac=$(mtd_get_mac_binary devdata 16388)
188 ;;
189
190 w306r-v20)
191 lan_mac=$(mtd_get_mac_binary factory 4)
192 wan_mac=$(macaddr_add "$lan_mac" 5)
193 ;;
194
195 rt-n13u | \
196 fonera20n)
197 lan_mac=$(mtd_get_mac_binary factory 40)
198 wan_mac=$(macaddr_add "$lan_mac" 1)
199 ;;
200
201 dir-300-b1 |\
202 dir-300-b2 |\
203 dir-600-b1)
204 lan_mac=$(mtd_get_mac_binary devdata 16388)
205 wan_mac=$(macaddr_add "$lan_mac" 1)
206 ;;
207
208 dir-620-a1)
209 lan_mac=$(mtd_get_mac_binary factory 4)
210 lan_mac=$(macaddr_setbit_la "$lan_mac")
211 wan_mac=$(macaddr_add "$lan_mac" 1)
212 ;;
213
214 dir-645)
215 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
216 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
217 ;;
218
219 esr-9753 | \
220 ur-326n4g | \
221 ur-336un)
222 lan_mac=$(mtd_get_mac_binary devdata 16388)
223 wan_mac=$(macaddr_add "$lan_mac" 1)
224 ;;
225
226 nbg-419n | \
227 wcr-150gn)
228 lan_mac=$(mtd_get_mac_binary factory 4)
229 wan_mac=$(mtd_get_mac_binary factory 40)
230 ;;
231
232 omni-emb-hpm)
233 lan_mac=$(mtd_get_mac_binary factory 40)
234 ;;
235
236 f5d8235-v2)
237 lan_mac=$(mtd_get_mac_binary "u-boot" 262148)
238 wan_mac=$(macaddr_add "$lan_mac" 1)
239 ;;
240
241 rt-n56u)
242 lan_mac=$(mtd_get_mac_binary factory 4)
243 wan_mac=$(mtd_get_mac_binary factory 32772)
244 ;;
245
246 tew-691gr)
247 lan_mac=$(mtd_get_mac_binary factory 40)
248 wan_mac=$(macaddr_add "$lan_mac" 3)
249 ;;
250
251 tew-692gr)
252 lan_mac=$(mtd_get_mac_binary factory 40)
253 wan_mac=$(macaddr_add "$lan_mac" 4)
254 ;;
255
256 all0239-3g | \
257 carambola | \
258 w502u | \
259 wnce2001)
260 lan_mac=$(mtd_get_mac_binary factory 40)
261 wan_mac=$(mtd_get_mac_binary factory 46)
262 ;;
263
264 wl341v3)
265 lan_mac=$(mtd_get_mac_binary board-nvram 65440)
266 wan_mac=$(macaddr_add "$lan_mac" 1)
267 ;;
268
269 d105 | \
270 wli-tx4-ag300n)
271 lan_mac=$(mtd_get_mac_binary factory 4)
272 ;;
273
274 esac
275
276 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
277 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
278 }
279
280 [ -e /etc/config/network ] && exit 0
281
282 touch /etc/config/network
283
284 board=$(ramips_board_name)
285
286 ramips_setup_interfaces $board
287 ramips_setup_macs $board
288
289 uci commit network
290
291 exit 0