ath79: Fix support for TP-LINK Archer C7 v2
[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 "etactica,eg200")
13 ucidef_set_interface_lan "eth0" "dhcp"
14 ;;
15 "avm,fritz300e"|\
16 "ocedo,raccoon"|\
17 "pcs,cap324"|\
18 "tplink,re450-v2"|\
19 "tplink,tl-mr10u"|\
20 "tplink,tl-wr703n"|\
21 "ubnt,unifiac-lite"|\
22 "ubnt,unifiac-mesh"|\
23 "ubnt,unifi")
24 ucidef_set_interface_lan "eth0"
25 ;;
26
27 "embeddedwireless,dorin")
28 ucidef_add_switch "switch0" \
29 "0@eth0" "1:wan" "2:lan:3" "3:lan:2"
30 ;;
31
32 "glinet,ar150")
33 ucidef_set_interfaces_lan_wan "eth1" "eth0"
34 ;;
35
36 "glinet,ar300m")
37 ucidef_set_interfaces_lan_wan "eth1" "eth0"
38 ;;
39
40 "netgear,wnr612-v2"|\
41 "on,n150r")
42 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
43 ucidef_add_switch "switch0" \
44 "0@eth1" "1:lan" "2:lan" "3:lan:3" "4:lan:4"
45 ;;
46
47 "pcs,cr5000")
48 ucidef_add_switch "switch0" \
49 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
50 ;;
51
52 "tplink,tl-archer-c7-v2")
53 ucidef_add_switch "switch0" \
54 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
55 ;;
56
57 "tplink,tl-mr3020-v1")
58 ucidef_set_interface_lan "eth0.1"
59 ucidef_add_switch "switch0" "0@eth0" "1:lan"
60 ;;
61 "tplink,tl-mr3220-v1"|\
62 "tplink,tl-mr3420-v1"|\
63 "tplink,tl-wr841-v7")
64 ucidef_set_interface_wan "eth0"
65 ucidef_add_switch "switch0" \
66 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
67 ;;
68 "tplink,tl-wdr3600"|\
69 "tplink,tl-wdr4300")
70 ucidef_add_switch "switch0" \
71 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
72 ;;
73
74 "tplink,tl-wr740n-v2")
75 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
76 ucidef_add_switch "switch0" \
77 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
78 ;;
79
80 "tplink,tl-wr741nd-v4"|\
81 "tplink,tl-wr740nd-v4")
82 ucidef_set_interfaces_wan "eth1"
83 ucidef_add_switch "switch0" \
84 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
85 ;;
86
87 "tplink,tl-wr1043nd-v1")
88 ucidef_add_switch "switch0" \
89 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
90 ;;
91 "tplink,tl-wr1043nd-v4")
92 ucidef_add_switch "switch0" \
93 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
94 ;;
95 "tplink,tl-wr1043nd-v2"|\
96 "tplink,tl-wr1043nd-v3")
97 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
98 ucidef_add_switch "switch0" \
99 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
100 ;;
101 "tplink,tl-wr2543-v1")
102 ucidef_add_switch "switch0" \
103 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
104 ;;
105 "netgear,wndr3800")
106 ucidef_set_interfaces_lan_wan "eth0" "eth1"
107 ucidef_add_switch "switch0" \
108 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
109
110 ucidef_add_switch_attr "switch0" "blinkrate" 2
111 ucidef_add_switch_port_attr "switch0" 1 led 6
112 ucidef_add_switch_port_attr "switch0" 2 led 9
113 ucidef_add_switch_port_attr "switch0" 5 led 2
114 ;;
115 "buffalo,wzr-hp-g450h")
116 ucidef_add_switch "switch0" \
117 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
118 ;;
119 "phicomm,k2t")
120 ucidef_add_switch "switch0" \
121 "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
122 ;;
123 "ubnt,unifiac-mesh-pro"|\
124 "ubnt,unifiac-pro")
125 ucidef_add_switch "switch0" \
126 "0@eth0" "2:lan" "3:wan"
127 ;;
128 *)
129 ucidef_set_interfaces_lan_wan "eth0" "eth1"
130 ;;
131 esac
132 }
133
134 ath79_setup_macs()
135 {
136 local board="$1"
137
138 case "$board" in
139 avm,fritz300e)
140 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
141 ;;
142 phicomm,k2t)
143 lan_mac=$(k2t_get_mac "lan_mac")
144 wan_mac=$(k2t_get_mac "wan_mac")
145 ;;
146 "tplink,tl-wr1043nd-v4")
147 base_mac=$(mtd_get_mac_binary product-info 8)
148 wan_mac=$(macaddr_add "$base_mac" 1)
149 ;;
150 esac
151
152 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
153 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
154 }
155
156 board_config_update
157 board=$(board_name)
158 ath79_setup_interfaces $board
159 ath79_setup_macs $board
160 board_config_flush
161
162 exit 0