ath79: add support for TP-Link Archer C60 v3
[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 aruba,ap-105|\
13 avm,fritz300e|\
14 devolo,dvl1200i|\
15 devolo,dvl1750c|\
16 devolo,dvl1750i|\
17 devolo,dvl1750x|\
18 engenius,ecb1750|\
19 glinet,gl-ar300m-lite|\
20 netgear,ex6400|\
21 netgear,ex7300|\
22 ocedo,koala|\
23 ocedo,raccoon|\
24 pcs,cap324|\
25 pisen,wmm003n|\
26 pqi,air-pen|\
27 tplink,cpe210-v2|\
28 tplink,cpe210-v3|\
29 tplink,re350k-v1|\
30 tplink,re450-v2|\
31 tplink,tl-mr10u|\
32 tplink,tl-mr3020-v1|\
33 tplink,tl-mr3040-v2|\
34 tplink,tl-wa901nd-v2|\
35 tplink,tl-wr703n|\
36 ubnt,bullet-m|\
37 ubnt,bullet-m-xw|\
38 ubnt,lap-120|\
39 ubnt,nanobeam-ac|\
40 ubnt,nanostation-ac-loco|\
41 ubnt,nanostation-loco-m|\
42 ubnt,nanostation-loco-m-xw|\
43 ubnt,picostation-m|\
44 ubnt,rocket-m|\
45 ubnt,unifiac-lite|\
46 ubnt,unifiac-lr|\
47 ubnt,unifiac-mesh|\
48 ubnt,unifi|\
49 wd,mynet-wifi-rangeextender|\
50 winchannel,wb2000)
51 ucidef_set_interface_lan "eth0"
52 ;;
53 avm,fritz4020|\
54 pcs,cr3000|\
55 tplink,archer-c58-v1|\
56 tplink,archer-c59-v1)
57 ucidef_set_interface_wan "eth1"
58 ucidef_add_switch "switch0" \
59 "0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
60 ;;
61 buffalo,bhr-4grv|\
62 buffalo,wzr-hp-g450h)
63 ucidef_add_switch "switch0" \
64 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
65 ;;
66 buffalo,bhr-4grv2)
67 ucidef_add_switch "switch0" \
68 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth0"
69 ;;
70 buffalo,whr-g301n)
71 ucidef_set_interface_wan "eth0"
72 ucidef_add_switch "switch0" \
73 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
74 ;;
75 buffalo,wzr-hp-ag300h|\
76 tplink,archer-c25-v1|\
77 tplink,archer-c60-v1|\
78 tplink,archer-c60-v2|\
79 tplink,archer-c60-v3|\
80 tplink,tl-mr3220-v1|\
81 tplink,tl-mr3420-v1|\
82 tplink,tl-wr841-v7|\
83 tplink,tl-wr841-v9|\
84 tplink,tl-wr841-v10|\
85 tplink,tl-wr841-v11|\
86 tplink,tl-wr841-v12|\
87 tplink,tl-wr842n-v1|\
88 tplink,tl-wr842n-v3|\
89 ubnt,airrouter)
90 ucidef_set_interface_wan "eth1"
91 ucidef_add_switch "switch0" \
92 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
93 ;;
94 buffalo,wzr-hp-g302h-a1a0)
95 ucidef_add_switch "switch0" \
96 "0@eth0" "1:lan:1" "3:lan:4" "4:lan:3" "5:lan:2" "2:wan"
97 ;;
98 comfast,cf-e110n-v2|\
99 comfast,cf-e120a-v3|\
100 tplink,cpe220-v3|\
101 ubnt,nanostation-m|\
102 ubnt,routerstation)
103 ucidef_set_interfaces_lan_wan "eth1" "eth0"
104 ;;
105 devolo,dvl1200e|\
106 devolo,dvl1750e|\
107 ocedo,ursus)
108 ucidef_set_interface_lan "eth0 eth1"
109 ;;
110 dlink,dir-825-b1)
111 ucidef_set_interface_wan "eth1"
112 ucidef_add_switch "switch0" \
113 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
114 ;;
115 dlink,dir-825-c1|\
116 dlink,dir-835-a1|\
117 dlink,dir-859-a1|\
118 engenius,epg5000|\
119 tplink,archer-c2-v3|\
120 tplink,tl-wr1043nd-v4|\
121 tplink,tl-wr1043n-v5)
122 ucidef_add_switch "switch0" \
123 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
124 ;;
125 elecom,wrc-1750ghbk2-i|\
126 elecom,wrc-300ghbk2-i)
127 ucidef_add_switch "switch0" \
128 "0@eth0" "2:lan:4" "3:lan:3" "4:lan:2" "5:lan:1" "1:wan"
129 ;;
130 embeddedwireless,dorin)
131 ucidef_add_switch "switch0" \
132 "0@eth0" "1:wan" "2:lan:3" "3:lan:2"
133 ;;
134 engenius,ews511ap)
135 ucidef_set_interface_lan "eth0 eth1" "dhcp"
136 ;;
137 etactica,eg200)
138 ucidef_set_interface_lan "eth0" "dhcp"
139 ;;
140 glinet,gl-ar750s)
141 ucidef_add_switch "switch0" \
142 "0@eth0" "2:lan:2" "3:lan:1" "1:wan"
143 ;;
144 iodata,etg3-r|\
145 iodata,wn-ac1167dgr|\
146 iodata,wn-ac1600dgr|\
147 iodata,wn-ac1600dgr2|\
148 iodata,wn-ag300dgr|\
149 pcs,cr5000|\
150 wd,mynet-n750)
151 ucidef_add_switch "switch0" \
152 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
153 ;;
154 librerouter,librerouter-v1)
155 ucidef_add_switch "switch0" \
156 "0@eth0" "5:wan" "6@eth1" "4:lan"
157 ;;
158 nec,wg1200cr|\
159 ubnt,nanostation-ac|\
160 ubnt,unifiac-mesh-pro|\
161 ubnt,unifiac-pro|\
162 yuncore,a782|\
163 yuncore,xd4200)
164 ucidef_add_switch "switch0" \
165 "0@eth0" "2:lan" "3:wan"
166 ;;
167 nec,wg800hp)
168 ucidef_add_switch "switch0" \
169 "0@eth0" "2:lan" "3:lan" "4:lan" "1:wan"
170 ;;
171 netgear,wndr3700|\
172 netgear,wndr3700v2|\
173 netgear,wndr3800)
174 ucidef_set_interfaces_lan_wan "eth0" "eth1"
175 ucidef_add_switch "switch0" \
176 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
177 ucidef_add_switch_attr "switch0" "blinkrate" 2
178 ucidef_add_switch_port_attr "switch0" 1 led 6
179 ucidef_add_switch_port_attr "switch0" 2 led 9
180 ucidef_add_switch_port_attr "switch0" 5 led 2
181 ;;
182 netgear,wnr612-v2|\
183 on,n150r|\
184 tplink,tl-wr740n-v1|\
185 tplink,tl-wr740n-v3|\
186 tplink,tl-wr741-v1|\
187 tplink,tl-wr743nd-v1|\
188 tplink,tl-wr841-v5|\
189 tplink,tl-wr941-v4)
190 ucidef_set_interface_wan "eth0"
191 ucidef_add_switch "switch0" \
192 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
193 ;;
194 phicomm,k2t)
195 ucidef_add_switch "switch0" \
196 "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
197 ;;
198 rosinson,wr818)
199 ucidef_add_switch "switch0" \
200 "0@eth0" "1:lan" "2:lan" "3:wan"
201 ;;
202 tplink,archer-a7-v5|\
203 tplink,archer-c6-v2|\
204 tplink,archer-c7-v4|\
205 tplink,archer-c7-v5|\
206 tplink,tl-wdr3600-v1|\
207 tplink,tl-wdr4300-v1|\
208 tplink,tl-wdr4300-v1-il|\
209 tplink,tl-wr941n-v7-cn)
210 ucidef_add_switch "switch0" \
211 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
212 ;;
213 tplink,archer-c5-v1|\
214 tplink,archer-c7-v1|\
215 tplink,archer-c7-v2|\
216 tplink,tl-wdr4900-v2)
217 ucidef_add_switch "switch0" \
218 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
219 ;;
220 tplink,archer-d50-v1)
221 ucidef_add_switch "switch0" \
222 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "1:wan"
223 ;;
224 tplink,tl-wr1043nd-v1)
225 ucidef_add_switch "switch0" \
226 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
227 ;;
228 tplink,tl-wr1043nd-v2|\
229 tplink,tl-wr1043nd-v3)
230 ucidef_add_switch "switch0" \
231 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
232 ;;
233 tplink,tl-wr2543-v1)
234 ucidef_add_switch "switch0" \
235 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
236 ;;
237 tplink,tl-wr740n-v4|\
238 tplink,tl-wr740n-v5|\
239 tplink,tl-wr741nd-v4|\
240 tplink,tl-wr841-v8|\
241 tplink,tl-wr842n-v2)
242 ucidef_set_interface_wan "eth1"
243 ucidef_add_switch "switch0" \
244 "0@eth0" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
245 ;;
246 tplink,tl-wr941-v2)
247 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
248 ;;
249 ubnt,acb-isp)
250 ucidef_set_interface_wan "eth1"
251 ucidef_add_switch "switch0" \
252 "0@eth0" "2:lan:1" "3:lan:3" "4:lan:2"
253 ;;
254 ubnt,routerstation-pro)
255 ucidef_set_interface_wan "eth0"
256 ucidef_add_switch "switch0" \
257 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
258 ;;
259 ubnt,nanostation-m-xw)
260 ucidef_add_switch "switch0" \
261 "0@eth0" "5:lan" "1:wan"
262 ;;
263 zbtlink,zbt-wd323|\
264 xiaomi,mi-router-4q)
265 ucidef_set_interface_wan "eth1"
266 ucidef_add_switch "switch0" \
267 "0@eth0" "3:lan:1" "4:lan:2"
268 ;;
269 *)
270 ucidef_set_interfaces_lan_wan "eth0" "eth1"
271 ;;
272 esac
273 }
274
275 ath79_setup_macs()
276 {
277 local board="$1"
278
279 case "$board" in
280 avm,fritz300e)
281 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
282 ;;
283 avm,fritz4020)
284 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
285 wan_mac=$(fritz_tffs -n macb -i $(find_mtd_part "tffs (1)"))
286 ;;
287 dlink,dir-825-b1)
288 lan_mac=$(mtd_get_mac_text "caldata" 65440)
289 wan_mac=$(mtd_get_mac_text "caldata" 65460)
290 ;;
291 dlink,dir-825-c1|\
292 dlink,dir-835-a1)
293 lan_mac=$(mtd_get_mac_text "mac" 4)
294 wan_mac=$(mtd_get_mac_text "mac" 24)
295 ;;
296 dlink,dir-859-a1|\
297 nec,wg1200cr|\
298 wd,mynet-n750)
299 lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
300 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
301 ;;
302 elecom,wrc-1750ghbk2-i|\
303 elecom,wrc-300ghbk2-i)
304 wan_mac=$(macaddr_add "$(mtd_get_mac_binary art 4098)" -2)
305 ;;
306 engenius,ecb1750)
307 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
308 ;;
309 engenius,epg5000|\
310 iodata,wn-ac1167dgr|\
311 iodata,wn-ac1600dgr|\
312 iodata,wn-ac1600dgr2|\
313 iodata,wn-ag300dgr)
314 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
315 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
316 ;;
317 engenius,ews511ap)
318 lan_mac=$(mtd_get_mac_text "u-boot-env" 233)
319 eth1_mac=$(macaddr_add "$lan_mac" 1)
320 ucidef_set_interface "eth0" ifname "eth0" protocol "none" macaddr "$lan_mac"
321 ucidef_set_interface "eth1" ifname "eth1" protocol "none" macaddr "$eth1_mac"
322 ;;
323 iodata,etg3-r)
324 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
325 wan_mac=$(macaddr_add "$lan_mac" -1)
326 ;;
327 jjplus,ja76pf2)
328 wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n alias/ethaddr)
329 lan_mac=$(macaddr_add "$wan_mac" 1)
330 ;;
331 nec,wg800hp)
332 lan_mac=$(mtd_get_mac_text board_data 640)
333 wan_mac=$(mtd_get_mac_text board_data 1152)
334 ;;
335 netgear,wndr3700|\
336 netgear,wndr3700v2|\
337 netgear,wndr3800)
338 lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0)")
339 ;;
340 phicomm,k2t)
341 lan_mac=$(k2t_get_mac "lan_mac")
342 wan_mac=$(k2t_get_mac "wan_mac")
343 ;;
344 rosinson,wr818)
345 wan_mac=$(mtd_get_mac_binary factory 0)
346 lan_mac=$(macaddr_setbit_la "$wan_mac")
347 ;;
348 tplink,archer-a7-v5|\
349 tplink,archer-c7-v4|\
350 tplink,archer-c7-v5|\
351 tplink,tl-wr1043nd-v4|\
352 tplink,tl-wr1043n-v5)
353 base_mac=$(mtd_get_mac_binary info 8)
354 wan_mac=$(macaddr_add "$base_mac" 1)
355 ;;
356 tplink,tl-wdr3600-v1|\
357 tplink,tl-wdr4300-v1|\
358 tplink,tl-wdr4300-v1-il)
359 base_mac=$(mtd_get_mac_binary u-boot 0x1fc00)
360 wan_mac=$(macaddr_add "$base_mac" 1)
361 ;;
362 tplink,tl-wr941-v2|\
363 tplink,tl-wr941n-v7-cn)
364 base_mac=$(mtd_get_mac_binary u-boot 130048)
365 wan_mac=$(macaddr_add "$base_mac" 1)
366 ;;
367 ubnt,routerstation|\
368 ubnt,routerstation-pro)
369 wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n ar7100_esa)
370 lan_mac=$(macaddr_add "$wan_mac" 1)
371 ;;
372 wd,mynet-wifi-rangeextender)
373 lan_mac=$(nvram get et0macaddr)
374 ;;
375 esac
376
377 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
378 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
379 }
380
381 board_config_update
382 board=$(board_name)
383 ath79_setup_interfaces $board
384 ath79_setup_macs $board
385 board_config_flush
386
387 exit 0