ath79: add support for EnGenius EWS511AP
[openwrt/openwrt.git] / target / linux / ath79 / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions/system.sh
4 . /lib/functions/uci-defaults.sh
5 . /lib/functions/k2t.sh
6
7 ath79_setup_interfaces()
8 {
9 local board="$1"
10
11 case "$board" in
12 avm,fritz300e|\
13 devolo,dvl1750c|\
14 ocedo,koala|\
15 ocedo,raccoon|\
16 pcs,cap324|\
17 pisen,wmm003n|\
18 pqi,air-pen|\
19 tplink,re450-v2|\
20 tplink,tl-mr10u|\
21 tplink,tl-mr3020-v1|\
22 tplink,tl-mr3040-v2|\
23 tplink,tl-wa901nd-v2|\
24 tplink,tl-wr703n|\
25 ubnt,bullet-m|\
26 ubnt,bullet-m-xw|\
27 ubnt,lap-120|\
28 ubnt,nanostation-ac-loco|\
29 ubnt,rocket-m|\
30 ubnt,unifiac-lite|\
31 ubnt,unifiac-mesh|\
32 ubnt,unifi|\
33 wd,mynet-wifi-rangeextender|\
34 winchannel,wb2000)
35 ucidef_set_interface_lan "eth0"
36 ;;
37 avm,fritz4020|\
38 tplink,archer-c58-v1|\
39 tplink,archer-c59-v1)
40 ucidef_set_interface_wan "eth0"
41 ucidef_add_switch "switch0" \
42 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
43 ;;
44 buffalo,bhr-4grv|\
45 buffalo,wzr-hp-g450h)
46 ucidef_add_switch "switch0" \
47 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
48 ;;
49 buffalo,bhr-4grv2)
50 ucidef_add_switch "switch0" \
51 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth0"
52 ;;
53 buffalo,wzr-hp-ag300h)
54 ucidef_set_interface_wan "eth1"
55 ucidef_add_switch "switch0" \
56 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
57 ;;
58 buffalo,wzr-hp-g302h-a1a0)
59 ucidef_add_switch "switch0" \
60 "0@eth0" "1:lan:1" "3:lan:4" "4:lan:3" "5:lan:2" "2:wan"
61 ;;
62 devolo,dvl1200e)
63 ucidef_set_interface_lan "eth0 eth1"
64 ;;
65 dlink,dir-825-b1)
66 ucidef_set_interface_wan "eth1"
67 ucidef_add_switch "switch0" \
68 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
69 ;;
70 dlink,dir-825-c1|\
71 dlink,dir-835-a1|\
72 iodata,etg3-r|\
73 iodata,wn-ac1167dgr|\
74 iodata,wn-ac1600dgr2|\
75 iodata,wn-ag300dgr|\
76 pcs,cr5000)
77 ucidef_add_switch "switch0" \
78 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
79 ;;
80 elecom,wrc-1750ghbk2-i|\
81 elecom,wrc-300ghbk2-i)
82 ucidef_add_switch "switch0" \
83 "0@eth0" "2:lan:4" "3:lan:3" "4:lan:2" "5:lan:1" "1:wan"
84 ;;
85 embeddedwireless,dorin)
86 ucidef_add_switch "switch0" \
87 "0@eth0" "1:wan" "2:lan:3" "3:lan:2"
88 ;;
89 engenius,ews511ap)
90 ucidef_set_interface_lan "eth0 eth1" "dhcp"
91 ;;
92 etactica,eg200)
93 ucidef_set_interface_lan "eth0" "dhcp"
94 ;;
95 glinet,gl-ar150|\
96 glinet,gl-ar300m-nand|\
97 glinet,gl-ar300m-nor|\
98 glinet,gl-x750|\
99 tplink,tl-wr810n-v1|\
100 tplink,tl-wr810n-v2)
101 ucidef_set_interfaces_lan_wan "eth1" "eth0"
102 ;;
103 glinet,ar750s)
104 ucidef_add_switch "switch0" \
105 "0@eth0" "2:lan:2" "3:lan:1" "1:wan"
106 ;;
107 nec,wg800hp)
108 ucidef_add_switch "switch0" \
109 "0@eth0" "2:lan" "3:lan" "4:lan" "1:wan"
110 ;;
111 netgear,wndr3700|\
112 netgear,wndr3700v2|\
113 netgear,wndr3800)
114 ucidef_set_interfaces_lan_wan "eth0" "eth1"
115 ucidef_add_switch "switch0" \
116 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
117 ucidef_add_switch_attr "switch0" "blinkrate" 2
118 ucidef_add_switch_port_attr "switch0" 1 led 6
119 ucidef_add_switch_port_attr "switch0" 2 led 9
120 ucidef_add_switch_port_attr "switch0" 5 led 2
121 ;;
122 netgear,wnr612-v2|\
123 on,n150r)
124 ucidef_set_interface_wan "eth0"
125 ucidef_add_switch "switch0" \
126 "0@eth1" "1:lan" "2:lan" "3:lan:3" "4:lan:4"
127 ;;
128 pcs,cr3000)
129 ucidef_add_switch "switch0" \
130 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
131 ucidef_set_interface_wan "eth0"
132 ;;
133 phicomm,k2t)
134 ucidef_add_switch "switch0" \
135 "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
136 ;;
137 rosinson,wr818)
138 ucidef_add_switch "switch0" \
139 "0@eth0" "1:lan" "2:lan" "3:wan"
140 ;;
141 tplink,archer-c7-v1|\
142 tplink,archer-c7-v2|\
143 tplink,tl-wdr4900-v2)
144 ucidef_add_switch "switch0" \
145 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
146 ;;
147 buffalo,whr-g301n|\
148 tplink,tl-mr3220-v1|\
149 tplink,tl-mr3420-v1|\
150 tplink,tl-wr841-v7|\
151 ubnt,airrouter)
152 ucidef_set_interface_wan "eth0"
153 ucidef_add_switch "switch0" \
154 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
155 ;;
156 tplink,archer-a7-v5|\
157 tplink,archer-c7-v5|\
158 tplink,tl-wdr3600|\
159 tplink,tl-wdr4300)
160 ucidef_add_switch "switch0" \
161 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
162 ;;
163 tplink,tl-wr1043nd-v1)
164 ucidef_add_switch "switch0" \
165 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
166 ;;
167 tplink,tl-wr1043nd-v2|\
168 tplink,tl-wr1043nd-v3)
169 ucidef_add_switch "switch0" \
170 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
171 ;;
172 dlink,dir-859-a1|\
173 tplink,tl-wr1043nd-v4)
174 ucidef_add_switch "switch0" \
175 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
176 ;;
177 tplink,tl-wr2543-v1)
178 ucidef_add_switch "switch0" \
179 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
180 ;;
181 tplink,tl-wr740n-v1|\
182 tplink,tl-wr740n-v3|\
183 tplink,tl-wr741-v1|\
184 tplink,tl-wr743nd-v1|\
185 tplink,tl-wr841-v5|\
186 tplink,tl-wr941-v4)
187 ucidef_set_interface_wan "eth0"
188 ucidef_add_switch "switch0" \
189 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
190 ;;
191 tplink,tl-wr740nd-v4|\
192 tplink,tl-wr841-v8|\
193 tplink,tl-wr842n-v1|\
194 tplink,tl-wr842n-v2)
195 ucidef_set_interface_wan "eth0"
196 ucidef_add_switch "switch0" \
197 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
198 ;;
199 tplink,tl-wr741nd-v4|\
200 tplink,tl-wr841-v9|\
201 tplink,tl-wr841-v11)
202 ucidef_set_interface_wan "eth0"
203 ucidef_add_switch "switch0" \
204 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
205 ;;
206 tplink,tl-wr941-v2)
207 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
208 ;;
209 ubnt,routerstation)
210 ucidef_set_interfaces_lan_wan "eth1" "eth0"
211 ;;
212 ubnt,routerstation-pro)
213 ucidef_set_interface_wan "eth0"
214 ucidef_add_switch "switch0" \
215 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
216 ;;
217 ubnt,nanostation-ac|\
218 ubnt,unifiac-mesh-pro|\
219 ubnt,unifiac-pro)
220 ucidef_add_switch "switch0" \
221 "0@eth0" "2:lan" "3:wan"
222 ;;
223 *)
224 ucidef_set_interfaces_lan_wan "eth0" "eth1"
225 ;;
226 esac
227 }
228
229 ath79_setup_macs()
230 {
231 local board="$1"
232
233 case "$board" in
234 avm,fritz300e)
235 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
236 ;;
237 avm,fritz4020)
238 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
239 wan_mac=$(fritz_tffs -n macb -i $(find_mtd_part "tffs (1)"))
240 ;;
241 dlink,dir-825-b1)
242 lan_mac=$(mtd_get_mac_text "caldata" 65440)
243 wan_mac=$(mtd_get_mac_text "caldata" 65460)
244 ;;
245 dlink,dir-825-c1|\
246 dlink,dir-835-a1)
247 lan_mac=$(mtd_get_mac_text "mac" 4)
248 wan_mac=$(mtd_get_mac_text "mac" 24)
249 ;;
250 dlink,dir-859-a1)
251 lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
252 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
253 ;;
254 elecom,wrc-1750ghbk2-i|\
255 elecom,wrc-300ghbk2-i)
256 wan_mac=$(macaddr_add "$(mtd_get_mac_binary ART 4098)" -2)
257 ;;
258 engenius,ews511ap)
259 lan_mac=$(mtd_get_mac_text "u-boot-env" 233)
260 eth1_mac=$(macaddr_add "$lan_mac" 1)
261 ucidef_set_interface "eth0" ifname "eth0" protocol "none" macaddr "$lan_mac"
262 ucidef_set_interface "eth1" ifname "eth1" protocol "none" macaddr "$eth1_mac"
263 ;;
264 iodata,etg3-r)
265 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
266 wan_mac=$(macaddr_add "$lan_mac" -1)
267 ;;
268 iodata,wn-ac1167dgr|\
269 iodata,wn-ac1600dgr2|\
270 iodata,wn-ag300dgr)
271 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
272 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
273 ;;
274 nec,wg800hp)
275 lan_mac=$(mtd_get_mac_text board_data 640)
276 wan_mac=$(mtd_get_mac_text board_data 1152)
277 ;;
278 netgear,wndr3700|\
279 netgear,wndr3700v2|\
280 netgear,wndr3800)
281 lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0)")
282 ;;
283 phicomm,k2t)
284 lan_mac=$(k2t_get_mac "lan_mac")
285 wan_mac=$(k2t_get_mac "wan_mac")
286 ;;
287 rosinson,wr818)
288 wan_mac=$(mtd_get_mac_binary factory 0)
289 lan_mac=$(macaddr_setbit_la "$wan_mac")
290 ;;
291 tplink,tl-wr1043nd-v4)
292 base_mac=$(mtd_get_mac_binary product-info 8)
293 wan_mac=$(macaddr_add "$base_mac" 1)
294 ;;
295 tplink,tl-wr941-v2)
296 base_mac=$(mtd_get_mac_binary u-boot 130048)
297 wan_mac=$(macaddr_add "$base_mac" 1)
298 ;;
299 ubnt,routerstation|\
300 ubnt,routerstation-pro)
301 wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n ar7100_esa)
302 lan_mac=$(macaddr_add "$wan_mac" 1)
303 ;;
304 wd,mynet-wifi-rangeextender)
305 lan_mac=$(nvram get et0macaddr)
306 ;;
307 esac
308
309 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
310 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
311 }
312
313 board_config_update
314 board=$(board_name)
315 ath79_setup_interfaces $board
316 ath79_setup_macs $board
317 board_config_flush
318
319 exit 0