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