ralink: load mt7530 driver on the 3 buffalo units
[15.05/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         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         mzk-w300nh2 | \
119         mzk-750dhp | \
120         whr-300hp2 | \
121         whr-600d | \
122         whr-1166d | \
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
130         awm002-evb | \
131         awm003-evb | \
132         argus-atp52b | \
133         dir-645 | \
134         f5d8235-v1 | \
135         f5d8235-v2 | \
136         hg255d | \
137         rt-n14u | \
138         wrtnode | \
139         wt3020 | \
140         ur-326n4g | \
141         zbt-wa05)
142                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
143                 ucidef_add_switch "switch0" "1" "1"
144                 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
145                 ucidef_add_switch_vlan "switch0" "2" "0 6t"
146                 ;;
147
148         ur-336un)
149                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
150                 ;;
151
152         br6524n | \
153         v11st-fe)
154                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
155                 ucidef_add_switch "switch0" "1" "1"
156                 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
157                 ucidef_add_switch_vlan "switch0" "2" "0 5t"
158                 ;;
159
160         ar725w | \
161         rt-n15 | \
162         wl-351)
163                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
164                 ucidef_add_switch "switch0" "1" "1"
165                 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
166                 ucidef_add_switch_vlan "switch0" "2" "4 5t"
167                 ;;
168
169         rt-n56u)
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 8t"
173                 ucidef_add_switch_vlan "switch0" "2" "4 8t"
174                 ;;
175
176         tew-691gr|\
177         tew-692gr)
178                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
179                 ucidef_add_switch "switch0" "1" "1"
180                 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
181                 ucidef_add_switch_vlan "switch0" "2" "0t 5"
182                 ;;
183
184         vocore)
185                 ucidef_set_interface_lan "eth0.1"
186                 ucidef_add_switch "switch0" "1" "1"
187                 ucidef_add_switch_vlan "switch0" "1" "0 4 6t"
188                 ;;
189
190         wcr-150gn)
191                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
192                 ucidef_add_switch "switch0" "1" "1"
193                 ucidef_add_switch_vlan "switch0" "1" "0 6t"
194                 ucidef_add_switch_vlan "switch0" "2" "6t"
195                 ;;
196
197         wr8305rt)
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 1 2 3 4 6t"
201                 ucidef_add_switch_vlan "switch0" "2" "4 6t"
202                 ;;
203
204         y1 |\
205         y1s)
206                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
207                 ucidef_add_switch "switch0" "1" "1"
208                 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
209                 ucidef_add_switch_vlan "switch0" "2" "0 6t"
210                 ;;
211         d105 | \
212         na930 | \
213         omni-emb-hpm|\
214         wli-tx4-ag300n)
215                 ucidef_set_interface_lan "eth0"
216                 ;;
217
218         mt7620a_mt7530)
219                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
220                 ucidef_add_switch "switch1" "1" "1"
221                 ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 6t"
222                 ucidef_add_switch_vlan "switch1" "2" "4 6t"
223                 ;;
224
225         *)
226                 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
227                 if [ -n "${RT3X5X}" ]; then
228                         ramips_setup_rt3x5x_vlans
229                 else
230                         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
231                 fi
232                 ;;
233         esac
234 }
235
236 ramips_setup_macs()
237 {
238         local board="$1"
239         local lan_mac=""
240         local wan_mac=""
241
242         case $board in
243         br-6475nd)
244                 lan_mac=$(cat /sys/class/net/eth0/address)
245                 wan_mac=$(mtd_get_mac_binary devdata 7)
246                 ;;
247
248         w306r-v20)
249                 lan_mac=$(cat /sys/class/net/eth0/address)
250                 wan_mac=$(macaddr_add "$lan_mac" 5)
251                 ;;
252
253         tew-691gr)
254                 lan_mac=$(cat /sys/class/net/eth0/address)
255                 wan_mac=$(macaddr_add "$lan_mac" 3)
256                 ;;
257
258         tew-692gr)
259                 lan_mac=$(cat /sys/class/net/eth0/address)
260                 wan_mac=$(macaddr_add "$lan_mac" 4)
261                 ;;
262
263         m3 |\
264         m4 |\
265         x5 |\
266         x8)
267                 lan_mac=$(cat /sys/class/net/eth0/address)
268                 lan_mac=$(macaddr_add "$lan_mac" -2)
269                 ;;
270
271         a5-v11 |\
272         bc2 |\
273         broadway |\
274         d105 |\
275         dir-620-a1 |\
276         esr-9753 |\
277         freestation5 |\
278         hlk-rm04 | \
279         mpr-a1 | \
280         mpr-a2 | \
281         ht-tm02 | \
282         dir-300-b7 | \
283         dir-320-b1 | \
284         psr-680w |\
285         sl-r7205 |\
286         y1 |\
287         y1s)
288                 lan_mac=$(cat /sys/class/net/eth0/address)
289                 lan_mac=$(macaddr_setbit_la "$lan_mac")
290                 wan_mac=$(macaddr_add "$lan_mac" 1)
291                 ;;
292
293         cy-swr1100 | \
294         dir-645)
295                 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
296                 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
297                 ;;
298
299         wcr-150gn)
300                 wan_mac=$(mtd_get_mac_binary factory 40)
301                 ;;
302
303         rt-n56u)
304                 lan_mac=$(cat /sys/class/net/eth0/address)
305                 lan_mac=$(macaddr_setbit_la "$lan_mac")
306                 wan_mac=$(mtd_get_mac_binary factory 32772)
307                 ;;
308
309         all0239-3g | \
310         carambola | \
311         freestation5 | \
312         w502u | \
313         wnce2001)
314                 wan_mac=$(mtd_get_mac_binary factory 46)
315                 ;;
316
317         *)
318                 lan_mac=$(cat /sys/class/net/eth0/address)
319                 wan_mac=$(macaddr_add "$lan_mac" 1)
320                 ;;
321
322         esac
323
324         [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
325         [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
326 }
327
328 board_config_update
329 board=$(ramips_board_name)
330 ramips_setup_interfaces $board
331 ramips_setup_macs $board
332 board_config_flush
333
334 exit 0