ath79: add support for TP-Link Archer C7 v1
[openwrt/staging/wigyori.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-v1|\
84 tplink,archer-c7-v2|\
85 tplink,tl-wdr4900-v2)
86 ucidef_add_switch "switch0" \
87 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
88 ;;
89 buffalo,whr-g301n|\
90 tplink,tl-mr3220-v1|\
91 tplink,tl-mr3420-v1|\
92 tplink,tl-wr841-v7)
93 ucidef_set_interface_wan "eth0"
94 ucidef_add_switch "switch0" \
95 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
96 ;;
97 tplink,tl-wdr3600|\
98 tplink,tl-wdr4300)
99 ucidef_add_switch "switch0" \
100 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
101 ;;
102 tplink,tl-wr1043nd-v1)
103 ucidef_add_switch "switch0" \
104 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
105 ;;
106 tplink,tl-wr1043nd-v2|\
107 tplink,tl-wr1043nd-v3)
108 ucidef_add_switch "switch0" \
109 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
110 ;;
111 tplink,tl-wr1043nd-v4)
112 ucidef_add_switch "switch0" \
113 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
114 ;;
115 tplink,tl-wr2543-v1)
116 ucidef_add_switch "switch0" \
117 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
118 ;;
119 tplink,tl-wr740n-v1|\
120 tplink,tl-wr740n-v3|\
121 tplink,tl-wr741-v1|\
122 tplink,tl-wr743nd-v1|\
123 tplink,tl-wr841-v5|\
124 tplink,tl-wr941-v4)
125 ucidef_set_interface_wan "eth0"
126 ucidef_add_switch "switch0" \
127 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
128 ;;
129 tplink,tl-wr740nd-v4|\
130 tplink,tl-wr741nd-v4|\
131 tplink,tl-wr841-v9|\
132 tplink,tl-wr841-v11)
133 ucidef_set_interface_wan "eth0"
134 ucidef_add_switch "switch0" \
135 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
136 ;;
137 tplink,tl-wr941-v2)
138 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
139 ;;
140 ubnt,unifiac-mesh-pro|\
141 ubnt,unifiac-pro)
142 ucidef_add_switch "switch0" \
143 "0@eth0" "2:lan" "3:wan"
144 ;;
145 *)
146 ucidef_set_interfaces_lan_wan "eth0" "eth1"
147 ;;
148 esac
149 }
150
151 ath79_setup_macs()
152 {
153 local board="$1"
154
155 case "$board" in
156 avm,fritz300e)
157 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
158 ;;
159 dlink,dir-825-b1)
160 lan_mac=$(mtd_get_mac_text "caldata" 65440)
161 wan_mac=$(mtd_get_mac_text "caldata" 65460)
162 ;;
163 iodata,wn-ac1167dgr|\
164 iodata,wn-ac1600dgr2)
165 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
166 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
167 ;;
168 netgear,wndr3700|\
169 netgear,wndr3700v2|\
170 netgear,wndr3800)
171 lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0)")
172 ;;
173 phicomm,k2t)
174 lan_mac=$(k2t_get_mac "lan_mac")
175 wan_mac=$(k2t_get_mac "wan_mac")
176 ;;
177 tplink,tl-wr1043nd-v4)
178 base_mac=$(mtd_get_mac_binary product-info 8)
179 wan_mac=$(macaddr_add "$base_mac" 1)
180 ;;
181 tplink,tl-wr941-v2)
182 base_mac=$(mtd_get_mac_binary u-boot 130048)
183 wan_mac=$(macaddr_add "$base_mac" 1)
184 ;;
185 esac
186
187 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
188 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
189 }
190
191 board_config_update
192 board=$(board_name)
193 ath79_setup_interfaces $board
194 ath79_setup_macs $board
195 board_config_flush
196
197 exit 0