ath79: add support for TP-Link Archer C6 v2
[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-c6-v2|\
158 tplink,archer-c7-v5|\
159 tplink,tl-wdr3600|\
160 tplink,tl-wdr4300)
161 ucidef_add_switch "switch0" \
162 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
163 ;;
164 tplink,tl-wr1043nd-v1)
165 ucidef_add_switch "switch0" \
166 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
167 ;;
168 tplink,tl-wr1043nd-v2|\
169 tplink,tl-wr1043nd-v3)
170 ucidef_add_switch "switch0" \
171 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
172 ;;
173 dlink,dir-859-a1|\
174 tplink,tl-wr1043nd-v4)
175 ucidef_add_switch "switch0" \
176 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
177 ;;
178 tplink,tl-wr2543-v1)
179 ucidef_add_switch "switch0" \
180 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
181 ;;
182 tplink,tl-wr740n-v1|\
183 tplink,tl-wr740n-v3|\
184 tplink,tl-wr741-v1|\
185 tplink,tl-wr743nd-v1|\
186 tplink,tl-wr841-v5|\
187 tplink,tl-wr941-v4)
188 ucidef_set_interface_wan "eth0"
189 ucidef_add_switch "switch0" \
190 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
191 ;;
192 tplink,tl-wr740nd-v4|\
193 tplink,tl-wr841-v8|\
194 tplink,tl-wr842n-v1|\
195 tplink,tl-wr842n-v2)
196 ucidef_set_interface_wan "eth0"
197 ucidef_add_switch "switch0" \
198 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
199 ;;
200 tplink,tl-wr741nd-v4|\
201 tplink,tl-wr841-v9|\
202 tplink,tl-wr841-v11)
203 ucidef_set_interface_wan "eth0"
204 ucidef_add_switch "switch0" \
205 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
206 ;;
207 tplink,tl-wr941-v2)
208 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
209 ;;
210 ubnt,routerstation)
211 ucidef_set_interfaces_lan_wan "eth1" "eth0"
212 ;;
213 ubnt,routerstation-pro)
214 ucidef_set_interface_wan "eth0"
215 ucidef_add_switch "switch0" \
216 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
217 ;;
218 ubnt,nanostation-ac|\
219 ubnt,unifiac-mesh-pro|\
220 ubnt,unifiac-pro)
221 ucidef_add_switch "switch0" \
222 "0@eth0" "2:lan" "3:wan"
223 ;;
224 *)
225 ucidef_set_interfaces_lan_wan "eth0" "eth1"
226 ;;
227 esac
228 }
229
230 ath79_setup_macs()
231 {
232 local board="$1"
233
234 case "$board" in
235 avm,fritz300e)
236 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
237 ;;
238 avm,fritz4020)
239 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
240 wan_mac=$(fritz_tffs -n macb -i $(find_mtd_part "tffs (1)"))
241 ;;
242 dlink,dir-825-b1)
243 lan_mac=$(mtd_get_mac_text "caldata" 65440)
244 wan_mac=$(mtd_get_mac_text "caldata" 65460)
245 ;;
246 dlink,dir-825-c1|\
247 dlink,dir-835-a1)
248 lan_mac=$(mtd_get_mac_text "mac" 4)
249 wan_mac=$(mtd_get_mac_text "mac" 24)
250 ;;
251 dlink,dir-859-a1)
252 lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
253 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
254 ;;
255 elecom,wrc-1750ghbk2-i|\
256 elecom,wrc-300ghbk2-i)
257 wan_mac=$(macaddr_add "$(mtd_get_mac_binary ART 4098)" -2)
258 ;;
259 engenius,ews511ap)
260 lan_mac=$(mtd_get_mac_text "u-boot-env" 233)
261 eth1_mac=$(macaddr_add "$lan_mac" 1)
262 ucidef_set_interface "eth0" ifname "eth0" protocol "none" macaddr "$lan_mac"
263 ucidef_set_interface "eth1" ifname "eth1" protocol "none" macaddr "$eth1_mac"
264 ;;
265 iodata,etg3-r)
266 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
267 wan_mac=$(macaddr_add "$lan_mac" -1)
268 ;;
269 iodata,wn-ac1167dgr|\
270 iodata,wn-ac1600dgr2|\
271 iodata,wn-ag300dgr)
272 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
273 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
274 ;;
275 nec,wg800hp)
276 lan_mac=$(mtd_get_mac_text board_data 640)
277 wan_mac=$(mtd_get_mac_text board_data 1152)
278 ;;
279 netgear,wndr3700|\
280 netgear,wndr3700v2|\
281 netgear,wndr3800)
282 lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0)")
283 ;;
284 phicomm,k2t)
285 lan_mac=$(k2t_get_mac "lan_mac")
286 wan_mac=$(k2t_get_mac "wan_mac")
287 ;;
288 rosinson,wr818)
289 wan_mac=$(mtd_get_mac_binary factory 0)
290 lan_mac=$(macaddr_setbit_la "$wan_mac")
291 ;;
292 tplink,tl-wr1043nd-v4)
293 base_mac=$(mtd_get_mac_binary product-info 8)
294 wan_mac=$(macaddr_add "$base_mac" 1)
295 ;;
296 tplink,tl-wr941-v2)
297 base_mac=$(mtd_get_mac_binary u-boot 130048)
298 wan_mac=$(macaddr_add "$base_mac" 1)
299 ;;
300 ubnt,routerstation|\
301 ubnt,routerstation-pro)
302 wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n ar7100_esa)
303 lan_mac=$(macaddr_add "$wan_mac" 1)
304 ;;
305 wd,mynet-wifi-rangeextender)
306 lan_mac=$(nvram get et0macaddr)
307 ;;
308 esac
309
310 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
311 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
312 }
313
314 board_config_update
315 board=$(board_name)
316 ath79_setup_interfaces $board
317 ath79_setup_macs $board
318 board_config_flush
319
320 exit 0