ramips: add support for TP-Link Archer C20 v5
[openwrt/staging/dedeckeh.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 tama,w06|\
15 tplink,tl-mr3020-v3|\
16 tplink,tl-wr802n-v4)
17 ucidef_set_interface_lan "eth0"
18 ;;
19 buffalo,wcr-1166ds)
20 ucidef_add_switch "switch0" \
21 "3:lan" "4:wan" "6@eth0"
22 ;;
23 cudy,wr1000)
24 ucidef_add_switch "switch0" \
25 "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
26 ;;
27 duzun,dm06)
28 ucidef_add_switch "switch0" \
29 "1:lan" "0:wan" "6@eth0"
30 ;;
31 glinet,gl-mt300n-v2)
32 ucidef_add_switch "switch0" \
33 "1:lan" "0:wan" "6@eth0"
34 ;;
35 glinet,vixmini)
36 ucidef_add_switch "switch0" \
37 "0:lan" "6@eth0"
38 ;;
39 hilink,hlk-7628n|\
40 hiwifi,hc5861b|\
41 skylab,skw92a|\
42 tplink,archer-c20-v4|\
43 tplink,archer-c20-v5|\
44 tplink,archer-c50-v3|\
45 tplink,archer-c50-v4|\
46 tplink,tl-mr3420-v5|\
47 tplink,tl-wr840n-v4|\
48 tplink,tl-wr840n-v5|\
49 tplink,tl-wr841n-v13|\
50 tplink,tl-wr841n-v14|\
51 tplink,tl-wr842n-v5|\
52 unielec,u7628-01-16m|\
53 wrtnode,wrtnode2p|\
54 wrtnode,wrtnode2r|\
55 zyxel,keenetic-extra-ii)
56 ucidef_add_switch "switch0" \
57 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
58 ;;
59 hiwifi,hc5661a|\
60 hiwifi,hc5761a|\
61 mediatek,mt7628an-eval-board|\
62 mercury,mac1200r-v2|\
63 totolink,lr1200|\
64 wavlink,wl-wn570ha1|\
65 wavlink,wl-wn575a3)
66 ucidef_add_switch "switch0" \
67 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
68 ;;
69 iptime,a3)
70 ucidef_add_switch "switch0" \
71 "2:lan:2" "3:lan:1" "0:wan" "6@eth0"
72 ;;
73 iptime,a604m)
74 ucidef_add_switch "switch0" \
75 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
76 ;;
77 mediatek,linkit-smart-7688|\
78 onion,omega2p|\
79 onion,omega2|\
80 tplink,tl-wa801nd-v5|\
81 widora,neo-16m|\
82 widora,neo-32m)
83 ucidef_add_switch "switch0"
84 ucidef_add_switch_attr "switch0" "enable" "false"
85 ucidef_set_interface_lan "eth0"
86 ;;
87 netgear,r6120)
88 ucidef_add_switch "switch0" \
89 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
90 ;;
91 rakwireless,rak633)
92 ucidef_add_switch "switch0" \
93 "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
94 ;;
95 tplink,tl-wr902ac-v3)
96 ucidef_add_switch "switch0" \
97 "4:lan" "6@eth0"
98 ;;
99 vocore,vocore2|\
100 vocore,vocore2-lite)
101 ucidef_add_switch "switch0" \
102 "0:lan" "2:lan" "6t@eth0"
103 ;;
104 wiznet,wizfi630s)
105 ucidef_add_switch "switch0" \
106 "0:wan" "3:lan" "4:lan" "6@eth0"
107 ;;
108 xiaomi,mir4a-100m)
109 ucidef_add_switch "switch0" \
110 "4:lan:1" "2:lan:2" "0:wan" "6@eth0"
111 ;;
112 xiaomi,miwifi-nano)
113 ucidef_add_switch "switch0" \
114 "0:lan:2" "2:lan:1" "4:wan" "6@eth0"
115 ;;
116 zbtlink,zbt-we1226)
117 ucidef_add_switch "switch0" \
118 "0:lan:2" "1:lan:1" "4:wan" "6@eth0"
119 ;;
120 *)
121 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
122 ;;
123 esac
124 }
125
126 ramips_setup_macs()
127 {
128 local board="$1"
129 local lan_mac=""
130 local wan_mac=""
131 local label_mac=""
132
133 case $board in
134 buffalo,wcr-1166ds)
135 local index="$(find_mtd_index "board_data")"
136 wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
137 lan_mac=$wan_mac
138 ;;
139 cudy,wr1000)
140 wan_mac=$(mtd_get_mac_binary factory 0x2e)
141 label_mac=$(mtd_get_mac_binary factory 0x4)
142 ;;
143 duzun,dm06|\
144 netgear,r6120|\
145 wrtnode,wrtnode2p|\
146 wrtnode,wrtnode2r|\
147 zyxel,keenetic-extra-ii)
148 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
149 ;;
150 hilink,hlk-7628n)
151 lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
152 wan_mac=$(macaddr_add "$lan_mac" 1)
153 ;;
154 hiwifi,hc5661a|\
155 hiwifi,hc5761a|\
156 hiwifi,hc5861b)
157 lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
158 label_mac=$lan_mac
159 [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
160 wan_mac=$(macaddr_add "$lan_mac" 1)
161 ;;
162 iptime,a3|\
163 iptime,a604m)
164 wan_mac=$(mtd_get_mac_binary u-boot 0x1fc40)
165 ;;
166 mediatek,linkit-smart-7688|\
167 onion,omega2|\
168 onion,omega2p)
169 wan_mac=$(mtd_get_mac_binary factory 0x4)
170 lan_mac=$(mtd_get_mac_binary factory 0x2e)
171 ;;
172 mercury,mac1200r-v2)
173 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory_info 0xd)" 1)
174 ;;
175 rakwireless,rak633|\
176 unielec,u7628-01-16m|\
177 wavlink,wl-wn575a3|\
178 wiznet,wizfi630s)
179 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x28)" 1)
180 ;;
181 skylab,skw92a|\
182 totolink,lr1200)
183 wan_mac=$(mtd_get_mac_binary factory 0x2e)
184 ;;
185 tplink,archer-c20-v4|\
186 tplink,archer-c50-v3|\
187 tplink,tl-mr3420-v5|\
188 tplink,tl-wr840n-v4|\
189 tplink,tl-wr840n-v5|\
190 tplink,tl-wr841n-v13|\
191 tplink,tl-wr841n-v14|\
192 tplink,tl-wr842n-v5)
193 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0xf100)" 1)
194 ;;
195 tplink,archer-c20-v5|\
196 tplink,archer-c50-v4)
197 wan_mac=$(macaddr_add "$(mtd_get_mac_binary rom 0xf100)" 1)
198 ;;
199 vocore,vocore2|\
200 vocore,vocore2-lite)
201 label_mac=$(mtd_get_mac_binary factory 0x4)
202 ;;
203 wavlink,wl-wn570ha1|\
204 zbtlink,zbt-we1226)
205 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x2e)" 1)
206 ;;
207 xiaomi,mir4a-100m)
208 wan_mac=$(mtd_get_mac_binary factory 0x4)
209 ;;
210 esac
211
212 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
213 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
214 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
215 }
216
217 board_config_update
218 board=$(board_name)
219 ramips_setup_interfaces $board
220 ramips_setup_macs $board
221 board_config_flush
222
223 exit 0