ipq40xx: add support for MikroTik hAP ac3
[openwrt/openwrt.git] / target / linux / ipq40xx / base-files / etc / board.d / 02_network
1 #
2 # Copyright (c) 2015 The Linux Foundation. All rights reserved.
3 # Copyright (c) 2011-2015 OpenWrt.org
4 #
5
6 . /lib/functions/uci-defaults.sh
7 . /lib/functions/system.sh
8
9 ipq40xx_setup_interfaces()
10 {
11 local board="$1"
12
13 case "$board" in
14 8dev,habanero-dvk|\
15 8dev,jalapeno|\
16 alfa-network,ap120c-ac|\
17 engenius,emr3500|\
18 engenius,ens620ext|\
19 luma,wrtq-329acn|\
20 netgear,wac510|\
21 plasmacloud,pa1200|\
22 plasmacloud,pa2200)
23 ucidef_set_interfaces_lan_wan "eth0" "eth1"
24 ;;
25 aruba,ap-303|\
26 aruba,ap-365|\
27 avm,fritzrepeater-1200|\
28 dlink,dap-2610 |\
29 engenius,eap1300|\
30 engenius,emd1|\
31 meraki,mr33|\
32 mikrotik,sxtsq-5-ac|\
33 netgear,ex6100v2|\
34 netgear,ex6150v2|\
35 zyxel,wre6606)
36 ucidef_set_interface_lan "eth0"
37 ;;
38 aruba,ap-303h)
39 ucidef_set_interfaces_lan_wan "eth0" "eth1"
40 ucidef_add_switch "switch0" \
41 "0u@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "0u@eth1" "5:wan"
42 ;;
43 asus,map-ac2200|\
44 cilab,meshpoint-one|\
45 edgecore,ecw5211|\
46 edgecore,oap100|\
47 openmesh,a42|\
48 openmesh,a62)
49 ucidef_set_interfaces_lan_wan "eth1" "eth0"
50 ;;
51 asus,rt-ac58u|\
52 mikrotik,hap-ac2|\
53 mikrotik,hap-ac3|\
54 p2w,r619ac-64m|\
55 p2w,r619ac-128m|\
56 zyxel,nbg6617)
57 ucidef_set_interfaces_lan_wan "eth0" "eth1"
58 ucidef_add_switch "switch0" \
59 "0u@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
60 ;;
61 avm,fritzbox-4040|\
62 linksys,ea6350v3|\
63 linksys,ea8300|\
64 linksys,mr8300)
65 ucidef_set_interfaces_lan_wan "eth0" "eth1"
66 ucidef_add_switch "switch0" \
67 "0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
68 ;;
69 avm,fritzbox-7530)
70 ucidef_add_switch "switch0" \
71 "0u@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
72 ;;
73 avm,fritzrepeater-3000)
74 ucidef_add_switch "switch0" \
75 "0u@eth0" "4:lan:1" "5:lan:2"
76 ;;
77 compex,wpj419|\
78 compex,wpj428|\
79 engenius,eap2200)
80 ucidef_set_interface_lan "eth0 eth1"
81 ;;
82 buffalo,wtr-m2133hp)
83 ucidef_set_interfaces_lan_wan "eth0" "eth1"
84 ucidef_add_switch "switch0" \
85 "0u@eth0" "2:lan:3" "3:lan:2" "4:lan:1"
86 ;;
87 cellc,rtl30vw)
88 ucidef_set_interface_lan "eth0"
89 ucidef_add_switch "switch0" \
90 "0u@eth0" "3:lan" "4:lan"
91 ;;
92 devolo,magic-2-wifi-next)
93 ucidef_set_interface_lan "eth0 eth1 eth2"
94 ;;
95 ezviz,cs-w3-wd1200g-eup)
96 ucidef_set_interfaces_lan_wan "eth0" "eth1"
97 ucidef_add_switch "switch0" \
98 "0u@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "0u@eth1" "5:wan"
99 ;;
100 glinet,gl-ap1300 |\
101 glinet,gl-b1300 |\
102 glinet,gl-s1300)
103 ucidef_set_interfaces_lan_wan "eth0" "eth1"
104 ucidef_add_switch "switch0" \
105 "0u@eth0" "3:lan" "4:lan"
106 ;;
107 mobipromo,cm520-79f)
108 ucidef_add_switch "switch0" \
109 "0u@eth0" "3:lan:2" "4:lan:1"
110 ucidef_set_interface_wan "eth1"
111 ;;
112 netgear,rbr50|\
113 netgear,rbs50|\
114 netgear,srr60|\
115 netgear,srs60)
116 ucidef_add_switch "switch0" \
117 "0u@eth0" "2:lan" "3:lan" "4:lan"
118 ucidef_set_interface_wan "eth1"
119 ;;
120 qxwlan,e2600ac-c1 |\
121 qxwlan,e2600ac-c2)
122 ucidef_set_interfaces_lan_wan "eth0" "eth1"
123 ucidef_add_switch "switch0" \
124 "0u@eth0" "3:lan" "4:lan" "0u@eth1" "5:wan"
125 ;;
126 unielec,u4019-32m)
127 ucidef_set_interfaces_lan_wan "eth0" "eth1"
128 ucidef_add_switch "switch0" \
129 "0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "0u@eth1" "5:wan"
130 ;;
131 *)
132 echo "Unsupported hardware. Network interfaces not initialized"
133 ;;
134 esac
135 }
136
137 ipq40xx_setup_macs()
138 {
139 local board="$1"
140 local lan_mac=""
141 local wan_mac=""
142 local label_mac=""
143
144 case "$board" in
145 8dev,habanero-dvk)
146 label_mac=$(mtd_get_mac_binary "ART" 0x1006)
147 ;;
148 asus,rt-ac58u)
149 CI_UBIPART=UBI_DEV
150 wan_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
151 lan_mac=$(mtd_get_mac_binary_ubi Factory 0x5006)
152 label_mac=$wan_mac
153 ;;
154 cilab,meshpoint-one)
155 label_mac=$(mtd_get_mac_binary "ART" 0x1006)
156 ;;
157 devolo,magic-2-wifi-next)
158 lan_mac=$(mtd_get_mac_ascii APPSBLENV MacAddress0)
159 label_mac=$lan_mac
160 ;;
161 dlink,dap-2610)
162 lan_mac=$(mtd_get_mac_ascii bdcfg lanmac)
163 label_mac=$lan_mac
164 ;;
165 engenius,eap2200|\
166 engenius,emd1)
167 lan_mac=$(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
168 label_mac=$lan_mac
169 ;;
170 engenius,emr3500)
171 wan_mac=$(mtd_get_mac_ascii 0:APPSBLENV wanaddr)
172 lan_mac=$(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
173 label_mac=$wan_mac
174 ;;
175 engenius,ens620ext)
176 wan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
177 lan_mac=$(macaddr_add "$wan_mac" 1)
178 ;;
179 ezviz,cs-w3-wd1200g-eup)
180 label_mac=$(mtd_get_mac_binary "ART" 0x6)
181 ;;
182 linksys,ea6350v3)
183 wan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
184 lan_mac=$(macaddr_add "$wan_mac" 1)
185 ;;
186 mikrotik,hap-ac2|\
187 mikrotik,hap-ac3)
188 wan_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base)
189 lan_mac=$(macaddr_add $wan_mac 1)
190 label_mac="$wan_mac"
191 ;;
192 mikrotik,sxtsq-5-ac)
193 lan_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base)
194 label_mac="$lan_mac"
195 ;;
196 esac
197
198 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
199 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
200 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
201 }
202
203 board_config_update
204 board=$(board_name)
205 ipq40xx_setup_interfaces $board
206 ipq40xx_setup_macs $board
207 board_config_flush
208
209 exit 0