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