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