ath79: add support for I-O DATA WN-AC1167DGR
[openwrt/openwrt.git] / target / linux / ath79 / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions/system.sh
4 . /lib/functions/uci-defaults.sh
5 . /lib/functions/k2t.sh
6
7 ath79_setup_interfaces()
8 {
9 local board="$1"
10
11 case "$board" in
12 avm,fritz300e|\
13 ocedo,koala|\
14 ocedo,raccoon|\
15 pcs,cap324|\
16 pisen,wmm003n|\
17 tplink,re450-v2|\
18 tplink,tl-mr10u|\
19 tplink,tl-mr3020-v1|\
20 tplink,tl-mr3040-v2|\
21 tplink,tl-wr703n|\
22 ubnt,unifiac-lite|\
23 ubnt,unifiac-mesh|\
24 ubnt,unifi)
25 ucidef_set_interface_lan "eth0"
26 ;;
27 buffalo,wzr-hp-g450h)
28 ucidef_add_switch "switch0" \
29 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
30 ;;
31 buffalo,bhr-4grv2)
32 ucidef_add_switch "switch0" \
33 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth0"
34 ;;
35 dlink,dir-825-b1)
36 ucidef_set_interface_wan "eth1"
37 ucidef_add_switch "switch0" \
38 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
39 ;;
40 embeddedwireless,dorin)
41 ucidef_add_switch "switch0" \
42 "0@eth0" "1:wan" "2:lan:3" "3:lan:2"
43 ;;
44 etactica,eg200)
45 ucidef_set_interface_lan "eth0" "dhcp"
46 ;;
47 glinet,ar150|\
48 glinet,ar300m)
49 ucidef_set_interfaces_lan_wan "eth1" "eth0"
50 ;;
51 iodata,wn-ac1167dgr|\
52 iodata,wn-ac1600dgr2|\
53 pcs,cr5000)
54 ucidef_add_switch "switch0" \
55 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
56 ;;
57 netgear,wndr3700|\
58 netgear,wndr3700v2|\
59 netgear,wndr3800)
60 ucidef_set_interfaces_lan_wan "eth0" "eth1"
61 ucidef_add_switch "switch0" \
62 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
63 ucidef_add_switch_attr "switch0" "blinkrate" 2
64 ucidef_add_switch_port_attr "switch0" 1 led 6
65 ucidef_add_switch_port_attr "switch0" 2 led 9
66 ucidef_add_switch_port_attr "switch0" 5 led 2
67 ;;
68 netgear,wnr612-v2|\
69 on,n150r)
70 ucidef_set_interface_wan "eth0"
71 ucidef_add_switch "switch0" \
72 "0@eth1" "1:lan" "2:lan" "3:lan:3" "4:lan:4"
73 ;;
74 pcs,cr3000)
75 ucidef_add_switch "switch0" \
76 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
77 ucidef_set_interface_wan "eth0"
78 ;;
79 phicomm,k2t)
80 ucidef_add_switch "switch0" \
81 "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
82 ;;
83 tplink,archer-c7-v2|\
84 tplink,tl-wdr4900-v2)
85 ucidef_add_switch "switch0" \
86 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
87 ;;
88 buffalo,whr-g301n|\
89 tplink,tl-mr3220-v1|\
90 tplink,tl-mr3420-v1|\
91 tplink,tl-wr841-v7)
92 ucidef_set_interface_wan "eth0"
93 ucidef_add_switch "switch0" \
94 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
95 ;;
96 tplink,tl-wdr3600|\
97 tplink,tl-wdr4300)
98 ucidef_add_switch "switch0" \
99 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
100 ;;
101 tplink,tl-wr1043nd-v1)
102 ucidef_add_switch "switch0" \
103 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
104 ;;
105 tplink,tl-wr1043nd-v2|\
106 tplink,tl-wr1043nd-v3)
107 ucidef_add_switch "switch0" \
108 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
109 ;;
110 tplink,tl-wr1043nd-v4)
111 ucidef_add_switch "switch0" \
112 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
113 ;;
114 tplink,tl-wr2543-v1)
115 ucidef_add_switch "switch0" \
116 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
117 ;;
118 tplink,tl-wr740n-v1|\
119 tplink,tl-wr740n-v3|\
120 tplink,tl-wr741-v1|\
121 tplink,tl-wr743nd-v1|\
122 tplink,tl-wr841-v5|\
123 tplink,tl-wr941-v4)
124 ucidef_set_interface_wan "eth0"
125 ucidef_add_switch "switch0" \
126 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
127 ;;
128 tplink,tl-wr740nd-v4|\
129 tplink,tl-wr741nd-v4|\
130 tplink,tl-wr841-v9|\
131 tplink,tl-wr841-v11)
132 ucidef_set_interface_wan "eth0"
133 ucidef_add_switch "switch0" \
134 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
135 ;;
136 tplink,tl-wr941-v2)
137 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
138 ;;
139 ubnt,unifiac-mesh-pro|\
140 ubnt,unifiac-pro)
141 ucidef_add_switch "switch0" \
142 "0@eth0" "2:lan" "3:wan"
143 ;;
144 *)
145 ucidef_set_interfaces_lan_wan "eth0" "eth1"
146 ;;
147 esac
148 }
149
150 ath79_setup_macs()
151 {
152 local board="$1"
153
154 case "$board" in
155 avm,fritz300e)
156 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
157 ;;
158 dlink,dir-825-b1)
159 lan_mac=$(mtd_get_mac_text "caldata" 65440)
160 wan_mac=$(mtd_get_mac_text "caldata" 65460)
161 ;;
162 iodata,wn-ac1167dgr|\
163 iodata,wn-ac1600dgr2)
164 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
165 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
166 ;;
167 netgear,wndr3700|\
168 netgear,wndr3700v2|\
169 netgear,wndr3800)
170 lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0)")
171 ;;
172 phicomm,k2t)
173 lan_mac=$(k2t_get_mac "lan_mac")
174 wan_mac=$(k2t_get_mac "wan_mac")
175 ;;
176 tplink,tl-wr1043nd-v4)
177 base_mac=$(mtd_get_mac_binary product-info 8)
178 wan_mac=$(macaddr_add "$base_mac" 1)
179 ;;
180 tplink,tl-wr941-v2)
181 base_mac=$(mtd_get_mac_binary u-boot 130048)
182 wan_mac=$(macaddr_add "$base_mac" 1)
183 ;;
184 esac
185
186 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
187 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
188 }
189
190 board_config_update
191 board=$(board_name)
192 ath79_setup_interfaces $board
193 ath79_setup_macs $board
194 board_config_flush
195
196 exit 0