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