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