ath79: add support for GL.iNet GL-AR750S
[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-300ghbk2-i)
81 ucidef_add_switch "switch0" \
82 "0@eth0" "2:lan:4" "3:lan:3" "4:lan:2" "5:lan:1" "1:wan"
83 ;;
84 embeddedwireless,dorin)
85 ucidef_add_switch "switch0" \
86 "0@eth0" "1:wan" "2:lan:3" "3:lan:2"
87 ;;
88 etactica,eg200)
89 ucidef_set_interface_lan "eth0" "dhcp"
90 ;;
91 glinet,ar150|\
92 glinet,ar300m|\
93 glinet,gl-x750)
94 ucidef_set_interfaces_lan_wan "eth1" "eth0"
95 ;;
96 glinet,ar750s)
97 ucidef_add_switch "switch0" \
98 "0@eth0" "2:lan:2" "3:lan:1" "1:wan"
99 ;;
100 nec,wg800hp)
101 ucidef_add_switch "switch0" \
102 "0@eth0" "2:lan" "3:lan" "4:lan" "1:wan"
103 ;;
104 netgear,wndr3700|\
105 netgear,wndr3700v2|\
106 netgear,wndr3800)
107 ucidef_set_interfaces_lan_wan "eth0" "eth1"
108 ucidef_add_switch "switch0" \
109 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
110 ucidef_add_switch_attr "switch0" "blinkrate" 2
111 ucidef_add_switch_port_attr "switch0" 1 led 6
112 ucidef_add_switch_port_attr "switch0" 2 led 9
113 ucidef_add_switch_port_attr "switch0" 5 led 2
114 ;;
115 netgear,wnr612-v2|\
116 on,n150r)
117 ucidef_set_interface_wan "eth0"
118 ucidef_add_switch "switch0" \
119 "0@eth1" "1:lan" "2:lan" "3:lan:3" "4:lan:4"
120 ;;
121 pcs,cr3000)
122 ucidef_add_switch "switch0" \
123 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
124 ucidef_set_interface_wan "eth0"
125 ;;
126 phicomm,k2t)
127 ucidef_add_switch "switch0" \
128 "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
129 ;;
130 rosinson,wr818)
131 ucidef_add_switch "switch0" \
132 "0@eth0" "1:lan" "2:lan" "3:wan"
133 ;;
134 tplink,archer-c7-v1|\
135 tplink,archer-c7-v2|\
136 tplink,tl-wdr4900-v2)
137 ucidef_add_switch "switch0" \
138 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
139 ;;
140 buffalo,whr-g301n|\
141 tplink,tl-mr3220-v1|\
142 tplink,tl-mr3420-v1|\
143 tplink,tl-wr841-v7|\
144 ubnt,airrouter)
145 ucidef_set_interface_wan "eth0"
146 ucidef_add_switch "switch0" \
147 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
148 ;;
149 tplink,archer-a7-v5|\
150 tplink,archer-c7-v5|\
151 tplink,tl-wdr3600|\
152 tplink,tl-wdr4300)
153 ucidef_add_switch "switch0" \
154 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
155 ;;
156 tplink,tl-wr1043nd-v1)
157 ucidef_add_switch "switch0" \
158 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
159 ;;
160 tplink,tl-wr1043nd-v2|\
161 tplink,tl-wr1043nd-v3)
162 ucidef_add_switch "switch0" \
163 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
164 ;;
165 dlink,dir-859-a1|\
166 tplink,tl-wr1043nd-v4)
167 ucidef_add_switch "switch0" \
168 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
169 ;;
170 tplink,tl-wr2543-v1)
171 ucidef_add_switch "switch0" \
172 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
173 ;;
174 tplink,tl-wr740n-v1|\
175 tplink,tl-wr740n-v3|\
176 tplink,tl-wr741-v1|\
177 tplink,tl-wr743nd-v1|\
178 tplink,tl-wr841-v5|\
179 tplink,tl-wr941-v4)
180 ucidef_set_interface_wan "eth0"
181 ucidef_add_switch "switch0" \
182 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
183 ;;
184 tplink,tl-wr740nd-v4|\
185 tplink,tl-wr842n-v1|\
186 tplink,tl-wr842n-v2)
187 ucidef_set_interface_wan "eth0"
188 ucidef_add_switch "switch0" \
189 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
190 ;;
191 tplink,tl-wr741nd-v4|\
192 tplink,tl-wr841-v9|\
193 tplink,tl-wr841-v11)
194 ucidef_set_interface_wan "eth0"
195 ucidef_add_switch "switch0" \
196 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
197 ;;
198 tplink,tl-wr941-v2)
199 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
200 ;;
201 ubnt,routerstation)
202 ucidef_set_interfaces_lan_wan "eth1" "eth0"
203 ;;
204 ubnt,routerstation-pro)
205 ucidef_set_interface_wan "eth0"
206 ucidef_add_switch "switch0" \
207 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
208 ;;
209 ubnt,nanostation-ac|\
210 ubnt,unifiac-mesh-pro|\
211 ubnt,unifiac-pro)
212 ucidef_add_switch "switch0" \
213 "0@eth0" "2:lan" "3:wan"
214 ;;
215 *)
216 ucidef_set_interfaces_lan_wan "eth0" "eth1"
217 ;;
218 esac
219 }
220
221 ath79_setup_macs()
222 {
223 local board="$1"
224
225 case "$board" in
226 avm,fritz300e)
227 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
228 ;;
229 avm,fritz4020)
230 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
231 wan_mac=$(fritz_tffs -n macb -i $(find_mtd_part "tffs (1)"))
232 ;;
233 dlink,dir-825-b1)
234 lan_mac=$(mtd_get_mac_text "caldata" 65440)
235 wan_mac=$(mtd_get_mac_text "caldata" 65460)
236 ;;
237 dlink,dir-825-c1|\
238 dlink,dir-835-a1)
239 lan_mac=$(mtd_get_mac_text "mac" 4)
240 wan_mac=$(mtd_get_mac_text "mac" 24)
241 ;;
242 dlink,dir-859-a1)
243 lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
244 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
245 ;;
246 elecom,wrc-300ghbk2-i)
247 wan_mac=$(macaddr_add "$(mtd_get_mac_binary ART 4098)" -2)
248 ;;
249 iodata,etg3-r)
250 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
251 wan_mac=$(macaddr_add "$lan_mac" -1)
252 ;;
253 iodata,wn-ac1167dgr|\
254 iodata,wn-ac1600dgr2|\
255 iodata,wn-ag300dgr)
256 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
257 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
258 ;;
259 nec,wg800hp)
260 lan_mac=$(mtd_get_mac_text board_data 640)
261 wan_mac=$(mtd_get_mac_text board_data 1152)
262 ;;
263 netgear,wndr3700|\
264 netgear,wndr3700v2|\
265 netgear,wndr3800)
266 lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0)")
267 ;;
268 phicomm,k2t)
269 lan_mac=$(k2t_get_mac "lan_mac")
270 wan_mac=$(k2t_get_mac "wan_mac")
271 ;;
272 rosinson,wr818)
273 wan_mac=$(mtd_get_mac_binary factory 0)
274 lan_mac=$(macaddr_setbit_la "$wan_mac")
275 ;;
276 tplink,tl-wr1043nd-v4)
277 base_mac=$(mtd_get_mac_binary product-info 8)
278 wan_mac=$(macaddr_add "$base_mac" 1)
279 ;;
280 tplink,tl-wr941-v2)
281 base_mac=$(mtd_get_mac_binary u-boot 130048)
282 wan_mac=$(macaddr_add "$base_mac" 1)
283 ;;
284 ubnt,routerstation|\
285 ubnt,routerstation-pro)
286 wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n ar7100_esa)
287 lan_mac=$(macaddr_add "$wan_mac" 1)
288 ;;
289 wd,mynet-wifi-rangeextender)
290 lan_mac=$(nvram get et0macaddr)
291 ;;
292 esac
293
294 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
295 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
296 }
297
298 board_config_update
299 board=$(board_name)
300 ath79_setup_interfaces $board
301 ath79_setup_macs $board
302 board_config_flush
303
304 exit 0