ath79: add support for Senao Engenius EAP300 v2
[openwrt/openwrt.git] / target / linux / ramips / mt76x8 / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/functions/uci-defaults.sh
5 . /lib/functions/system.sh
6
7 ramips_setup_interfaces()
8 {
9 local board="$1"
10
11 case $board in
12 alfa-network,awusfree1|\
13 d-team,pbr-d1|\
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 asus,rt-n10p-v3|\
37 asus,rt-n11p-b1|\
38 asus,rt-n12-vp-b1|\
39 hiwifi,hc5661a|\
40 mediatek,mt7628an-eval-board|\
41 mercury,mac1200r-v2|\
42 totolink,lr1200|\
43 wavlink,wl-wn570ha1|\
44 wavlink,wl-wn575a3)
45 ucidef_add_switch "switch0" \
46 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
47 ;;
48 buffalo,wcr-1166ds|\
49 wavlink,wl-wn577a2)
50 ucidef_add_switch "switch0" \
51 "3:lan" "4:wan" "6@eth0"
52 ;;
53 cudy,wr1000)
54 ucidef_add_switch "switch0" \
55 "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
56 ;;
57 duzun,dm06)
58 ucidef_add_switch "switch0" \
59 "1:lan" "0:wan" "6@eth0"
60 ;;
61 glinet,gl-mt300n-v2)
62 ucidef_add_switch "switch0" \
63 "1:lan" "0:wan" "6@eth0"
64 ;;
65 hilink,hlk-7628n|\
66 hiwifi,hc5861b|\
67 skylab,skw92a|\
68 tplink,archer-c20-v4|\
69 tplink,archer-c20-v5|\
70 tplink,archer-c50-v3|\
71 tplink,archer-c50-v4|\
72 tplink,tl-mr3420-v5|\
73 tplink,tl-wr840n-v4|\
74 tplink,tl-wr840n-v5|\
75 tplink,tl-wr841n-v13|\
76 tplink,tl-wr841n-v14|\
77 tplink,tl-wr842n-v5|\
78 tplink,tl-wr850n-v2|\
79 unielec,u7628-01-16m|\
80 wrtnode,wrtnode2p|\
81 wrtnode,wrtnode2r|\
82 zyxel,keenetic-extra-ii)
83 ucidef_add_switch "switch0" \
84 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
85 ;;
86 hiwifi,hc5761a)
87 ucidef_add_switch "switch0" \
88 "0:lan" "1:lan" "4:wan" "6@eth0"
89 ;;
90 iptime,a3|\
91 totolink,a3)
92 ucidef_add_switch "switch0" \
93 "2:lan:2" "3:lan:1" "0:wan" "6@eth0"
94 ;;
95 iptime,a604m)
96 ucidef_add_switch "switch0" \
97 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
98 ;;
99 jotale,js76x8-8m|\
100 jotale,js76x8-16m|\
101 jotale,js76x8-32m)
102 ucidef_add_switch "switch0" \
103 "0:lan" "1:lan" "2:lan" "6@eth0"
104 ;;
105 netgear,r6020|\
106 netgear,r6080|\
107 netgear,r6120)
108 ucidef_add_switch "switch0" \
109 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
110 ;;
111 rakwireless,rak633)
112 ucidef_add_switch "switch0" \
113 "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
114 ;;
115 tplink,tl-mr6400-v4)
116 ucidef_add_switch "switch0" \
117 "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
118 ;;
119 tplink,tl-wr902ac-v3)
120 ucidef_add_switch "switch0" \
121 "4:lan" "6@eth0"
122 ;;
123 vocore,vocore2|\
124 vocore,vocore2-lite)
125 ucidef_add_switch "switch0" \
126 "0:lan" "2:lan" "6t@eth0"
127 ;;
128 wiznet,wizfi630s)
129 ucidef_add_switch "switch0" \
130 "0:wan" "3:lan" "4:lan" "6@eth0"
131 ;;
132 xiaomi,mir4a-100m)
133 ucidef_add_switch "switch0" \
134 "4:lan:1" "2:lan:2" "0:wan" "6@eth0"
135 ;;
136 xiaomi,miwifi-nano)
137 ucidef_add_switch "switch0" \
138 "0:lan:2" "2:lan:1" "4:wan" "6@eth0"
139 ;;
140 zbtlink,zbt-we1226)
141 ucidef_add_switch "switch0" \
142 "0:lan:2" "1:lan:1" "4:wan" "6@eth0"
143 ;;
144 esac
145 }
146
147 ramips_setup_macs()
148 {
149 local board="$1"
150 local lan_mac=""
151 local wan_mac=""
152 local label_mac=""
153
154 case $board in
155 buffalo,wcr-1166ds)
156 local index="$(find_mtd_index "board_data")"
157 wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
158 lan_mac=$wan_mac
159 ;;
160 cudy,wr1000|\
161 wavlink,wl-wn577a2)
162 wan_mac=$(mtd_get_mac_binary factory 0x2e)
163 label_mac=$(mtd_get_mac_binary factory 0x4)
164 ;;
165 duzun,dm06|\
166 netgear,r6020|\
167 netgear,r6080|\
168 netgear,r6120|\
169 wrtnode,wrtnode2p|\
170 wrtnode,wrtnode2r|\
171 zyxel,keenetic-extra-ii)
172 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
173 ;;
174 hilink,hlk-7628n)
175 lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
176 wan_mac=$(macaddr_add "$lan_mac" 1)
177 ;;
178 hiwifi,hc5661a|\
179 hiwifi,hc5761a|\
180 hiwifi,hc5861b)
181 lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
182 label_mac=$lan_mac
183 [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
184 wan_mac=$(macaddr_add "$lan_mac" 1)
185 ;;
186 iptime,a3|\
187 iptime,a604m|\
188 totolink,a3)
189 wan_mac=$(mtd_get_mac_binary u-boot 0x1fc40)
190 ;;
191 jotale,js76x8-8m|\
192 jotale,js76x8-16m|\
193 jotale,js76x8-32m|\
194 skylab,skw92a|\
195 totolink,lr1200)
196 wan_mac=$(mtd_get_mac_binary factory 0x2e)
197 ;;
198 mercury,mac1200r-v2)
199 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory_info 0xd)" 1)
200 ;;
201 rakwireless,rak633|\
202 unielec,u7628-01-16m|\
203 wavlink,wl-wn575a3)
204 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x28)" 1)
205 ;;
206 tplink,archer-c20-v4|\
207 tplink,archer-c50-v3|\
208 tplink,tl-mr3420-v5|\
209 tplink,tl-wr840n-v4|\
210 tplink,tl-wr840n-v5|\
211 tplink,tl-wr841n-v13|\
212 tplink,tl-wr841n-v14|\
213 tplink,tl-wr842n-v5|\
214 tplink,tl-wr850n-v2)
215 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0xf100)" 1)
216 ;;
217 tplink,archer-c20-v5|\
218 tplink,archer-c50-v4)
219 wan_mac=$(macaddr_add "$(mtd_get_mac_binary rom 0xf100)" 1)
220 ;;
221 vocore,vocore2|\
222 vocore,vocore2-lite)
223 label_mac=$(mtd_get_mac_binary factory 0x4)
224 ;;
225 wavlink,wl-wn570ha1|\
226 zbtlink,zbt-we1226)
227 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x2e)" 1)
228 ;;
229 wiznet,wizfi630s)
230 label_mac=$(mtd_get_mac_binary factory 0x4)
231 wan_mac=$(mtd_get_mac_binary factory 0x28)
232 ;;
233 xiaomi,mir4a-100m)
234 wan_mac=$(mtd_get_mac_binary factory 0x4)
235 ;;
236 esac
237
238 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
239 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
240 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
241 }
242
243 board_config_update
244 board=$(board_name)
245 ramips_setup_interfaces $board
246 ramips_setup_macs $board
247 board_config_flush
248
249 exit 0