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