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