ramips: add support for D-Link DAP-1325-A1
[openwrt/openwrt.git] / target / linux / ramips / mt76x8 / base-files / etc / board.d / 02_network
1
2 . /lib/functions.sh
3 . /lib/functions/uci-defaults.sh
4 . /lib/functions/system.sh
5
6 ramips_setup_interfaces()
7 {
8 local board="$1"
9
10 case $board in
11 alfa-network,awusfree1|\
12 d-team,pbr-d1|\
13 dlink,dap-1325-a1|\
14 glinet,microuter-n300|\
15 glinet,vixmini|\
16 hak5,wifi-pineapple-mk7|\
17 mediatek,linkit-smart-7688|\
18 onion,omega2p|\
19 onion,omega2|\
20 ravpower,rp-wd009|\
21 tama,w06|\
22 tplink,re200-v2|\
23 tplink,re200-v3|\
24 tplink,re200-v4|\
25 tplink,re220-v2|\
26 tplink,re305-v1|\
27 tplink,tl-mr3020-v3|\
28 tplink,tl-wr802n-v4|\
29 tplink,tl-wa801nd-v5|\
30 widora,neo-16m|\
31 widora,neo-32m)
32 ucidef_add_switch "switch0"
33 ucidef_add_switch_attr "switch0" "enable" "false"
34 ucidef_set_interface_lan "eth0"
35 ;;
36 minew,g1-c)
37 ucidef_add_switch "switch0"
38 ucidef_add_switch_attr "switch0" "enable" "false"
39 ucidef_set_interface_lan "eth0" "dhcp"
40 ;;
41 asus,rt-n10p-v3|\
42 asus,rt-n11p-b1|\
43 asus,rt-n12-vp-b1|\
44 hiwifi,hc5661a|\
45 mediatek,mt7628an-eval-board|\
46 mercury,mac1200r-v2|\
47 totolink,lr1200|\
48 wavlink,wl-wn570ha1|\
49 wavlink,wl-wn575a3)
50 ucidef_add_switch "switch0" \
51 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
52 ;;
53 buffalo,wcr-1166ds|\
54 elecom,wrc-1167fs|\
55 wavlink,wl-wn577a2|\
56 wavlink,wl-wn578a2)
57 ucidef_add_switch "switch0" \
58 "3:lan" "4:wan" "6@eth0"
59 ;;
60 cudy,wr1000)
61 ucidef_add_switch "switch0" \
62 "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
63 ;;
64 duzun,dm06)
65 ucidef_add_switch "switch0" \
66 "1:lan" "0:wan" "6@eth0"
67 ;;
68 glinet,gl-mt300n-v2)
69 ucidef_add_switch "switch0" \
70 "1:lan" "0:wan" "6@eth0"
71 ;;
72 hilink,hlk-7628n|\
73 hilink,hlk-7688a|\
74 hiwifi,hc5861b|\
75 skylab,skw92a|\
76 tplink,archer-c20-v4|\
77 tplink,archer-c20-v5|\
78 tplink,archer-c50-v3|\
79 tplink,archer-c50-v4|\
80 tplink,tl-mr3420-v5|\
81 tplink,tl-wr840n-v4|\
82 tplink,tl-wr840n-v5|\
83 tplink,tl-wr841n-v13|\
84 tplink,tl-wr841n-v14|\
85 tplink,tl-wr842n-v5|\
86 tplink,tl-wr850n-v2|\
87 unielec,u7628-01-16m|\
88 wrtnode,wrtnode2p|\
89 wrtnode,wrtnode2r|\
90 zyxel,keenetic-extra-ii)
91 ucidef_add_switch "switch0" \
92 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
93 ;;
94 hiwifi,hc5761a)
95 ucidef_add_switch "switch0" \
96 "0:lan" "1:lan" "4:wan" "6@eth0"
97 ;;
98 iptime,a3|\
99 totolink,a3)
100 ucidef_add_switch "switch0" \
101 "2:lan:2" "3:lan:1" "0:wan" "6@eth0"
102 ;;
103 iptime,a604m)
104 ucidef_add_switch "switch0" \
105 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
106 ;;
107 jotale,js76x8-8m|\
108 jotale,js76x8-16m|\
109 jotale,js76x8-32m)
110 ucidef_add_switch "switch0" \
111 "0:lan" "1:lan" "2:lan" "6@eth0"
112 ;;
113 motorola,mwr03)
114 ucidef_add_switch "switch0" \
115 "1:lan" "2:lan" "3:lan" "0:wan" "6@eth0"
116 ;;
117 netgear,r6020|\
118 netgear,r6080|\
119 netgear,r6120)
120 ucidef_add_switch "switch0" \
121 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
122 ;;
123 rakwireless,rak633)
124 ucidef_add_switch "switch0" \
125 "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
126 ;;
127 tplink,tl-mr6400-v4)
128 ucidef_add_switch "switch0" \
129 "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
130 ;;
131 tplink,tl-mr6400-v5)
132 ucidef_add_switch "switch0" \
133 "0:lan" "1:lan" "2:lan" "3:wan" "6@eth0"
134 ;;
135 tplink,tl-wr902ac-v3)
136 ucidef_add_switch "switch0" \
137 "4:lan" "6@eth0"
138 ;;
139 vocore,vocore2|\
140 vocore,vocore2-lite)
141 ucidef_add_switch "switch0" \
142 "0:lan" "2:lan" "6t@eth0"
143 ;;
144 wiznet,wizfi630s)
145 ucidef_add_switch "switch0" \
146 "0:wan" "3:lan" "4:lan" "6@eth0"
147 ;;
148 xiaomi,mi-router-4a-100m)
149 ucidef_add_switch "switch0" \
150 "4:lan:1" "2:lan:2" "0:wan" "6@eth0"
151 ;;
152 xiaomi,mi-router-4c)
153 ucidef_add_switch "switch0" \
154 "4:lan:1" "2:lan:2" "1:wan" "6@eth0"
155 ;;
156 xiaomi,miwifi-nano)
157 ucidef_add_switch "switch0" \
158 "0:lan:2" "2:lan:1" "4:wan" "6@eth0"
159 ;;
160 zbtlink,zbt-we1226)
161 ucidef_add_switch "switch0" \
162 "0:lan:2" "1:lan:1" "4:wan" "6@eth0"
163 ;;
164 esac
165 }
166
167 ramips_setup_macs()
168 {
169 local board="$1"
170 local lan_mac=""
171 local wan_mac=""
172 local label_mac=""
173
174 case $board in
175 buffalo,wcr-1166ds)
176 local index="$(find_mtd_index "board_data")"
177 wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
178 lan_mac=$wan_mac
179 ;;
180 cudy,wr1000|\
181 hilink,hlk-7628n|\
182 hilink,hlk-7688a|\
183 wavlink,wl-wn577a2|\
184 wavlink,wl-wn578a2)
185 wan_mac=$(mtd_get_mac_binary factory 0x2e)
186 label_mac=$(mtd_get_mac_binary factory 0x4)
187 ;;
188 duzun,dm06|\
189 netgear,r6020|\
190 netgear,r6080|\
191 netgear,r6120|\
192 wrtnode,wrtnode2p|\
193 wrtnode,wrtnode2r|\
194 zyxel,keenetic-extra-ii)
195 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
196 ;;
197 elecom,wrc-1167fs)
198 wan_mac=$(mtd_get_mac_binary factory 0x22)
199 label_mac=$wan_mac
200 ;;
201 hiwifi,hc5661a|\
202 hiwifi,hc5761a|\
203 hiwifi,hc5861b)
204 lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
205 label_mac=$lan_mac
206 [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
207 wan_mac=$(macaddr_add "$lan_mac" 1)
208 ;;
209 iptime,a3|\
210 iptime,a604m|\
211 totolink,a3)
212 wan_mac=$(mtd_get_mac_binary u-boot 0x1fc40)
213 ;;
214 jotale,js76x8-8m|\
215 jotale,js76x8-16m|\
216 jotale,js76x8-32m|\
217 skylab,skw92a|\
218 totolink,lr1200)
219 wan_mac=$(mtd_get_mac_binary factory 0x2e)
220 ;;
221 mercury,mac1200r-v2)
222 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory_info 0xd)" 1)
223 ;;
224 motorola,mwr03)
225 label_mac=$(mtd_get_mac_binary factory 0x4)
226 wan_mac=$(macaddr_add "$label_mac" 2)
227 ;;
228 onion,omega2|\
229 onion,omega2p|\
230 vocore,vocore2|\
231 vocore,vocore2-lite)
232 label_mac=$(mtd_get_mac_binary factory 0x4)
233 ;;
234 rakwireless,rak633|\
235 unielec,u7628-01-16m|\
236 wavlink,wl-wn575a3)
237 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x28)" 1)
238 ;;
239 tplink,archer-c20-v4|\
240 tplink,archer-c50-v3|\
241 tplink,tl-mr3420-v5|\
242 tplink,tl-wr840n-v4|\
243 tplink,tl-wr840n-v5|\
244 tplink,tl-wr841n-v13|\
245 tplink,tl-wr841n-v14|\
246 tplink,tl-wr842n-v5|\
247 tplink,tl-wr850n-v2)
248 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0xf100)" 1)
249 ;;
250 tplink,archer-c20-v5|\
251 tplink,archer-c50-v4)
252 wan_mac=$(macaddr_add "$(mtd_get_mac_binary rom 0xf100)" 1)
253 ;;
254 wavlink,wl-wn570ha1|\
255 zbtlink,zbt-we1226)
256 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x2e)" 1)
257 ;;
258 wiznet,wizfi630s)
259 label_mac=$(mtd_get_mac_binary factory 0x4)
260 wan_mac=$(mtd_get_mac_binary factory 0x28)
261 ;;
262 xiaomi,mi-router-4a-100m|\
263 xiaomi,mi-router-4c)
264 wan_mac=$(mtd_get_mac_binary factory 0x4)
265 ;;
266 esac
267
268 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
269 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
270 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
271 }
272
273 board_config_update
274 board=$(board_name)
275 ramips_setup_interfaces $board
276 ramips_setup_macs $board
277 board_config_flush
278
279 exit 0