ath79: add WNDR3700 and WNDR3700v2
[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 dlink,dir-825-b1)
34 ucidef_set_interface_wan "eth1"
35 ucidef_add_switch "switch0" \
36 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
37 ;;
38 embeddedwireless,dorin)
39 ucidef_add_switch "switch0" \
40 "0@eth0" "1:wan" "2:lan:3" "3:lan:2"
41 ;;
42 etactica,eg200)
43 ucidef_set_interface_lan "eth0" "dhcp"
44 ;;
45 glinet,ar150|\
46 glinet,ar300m)
47 ucidef_set_interfaces_lan_wan "eth1" "eth0"
48 ;;
49 iodata,wn-ac1600dgr2|\
50 pcs,cr5000)
51 ucidef_add_switch "switch0" \
52 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
53 ;;
54 netgear,wndr3700|\
55 netgear,wndr3700v2|\
56 netgear,wndr3800)
57 ucidef_set_interfaces_lan_wan "eth0" "eth1"
58 ucidef_add_switch "switch0" \
59 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
60 ucidef_add_switch_attr "switch0" "blinkrate" 2
61 ucidef_add_switch_port_attr "switch0" 1 led 6
62 ucidef_add_switch_port_attr "switch0" 2 led 9
63 ucidef_add_switch_port_attr "switch0" 5 led 2
64 ;;
65 netgear,wnr612-v2|\
66 on,n150r)
67 ucidef_set_interface_wan "eth0"
68 ucidef_add_switch "switch0" \
69 "0@eth1" "1:lan" "2:lan" "3:lan:3" "4:lan:4"
70 ;;
71 pcs,cr3000)
72 ucidef_add_switch "switch0" \
73 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
74 ucidef_set_interface_wan "eth0"
75 ;;
76 phicomm,k2t)
77 ucidef_add_switch "switch0" \
78 "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
79 ;;
80 tplink,archer-c7-v2|\
81 tplink,tl-wdr4900-v2)
82 ucidef_add_switch "switch0" \
83 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
84 ;;
85 tplink,tl-mr3220-v1|\
86 tplink,tl-mr3420-v1|\
87 tplink,tl-wr841-v7)
88 ucidef_set_interface_wan "eth0"
89 ucidef_add_switch "switch0" \
90 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
91 ;;
92 tplink,tl-wdr3600|\
93 tplink,tl-wdr4300)
94 ucidef_add_switch "switch0" \
95 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
96 ;;
97 tplink,tl-wr1043nd-v1)
98 ucidef_add_switch "switch0" \
99 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
100 ;;
101 tplink,tl-wr1043nd-v2|\
102 tplink,tl-wr1043nd-v3)
103 ucidef_add_switch "switch0" \
104 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
105 ;;
106 tplink,tl-wr1043nd-v4)
107 ucidef_add_switch "switch0" \
108 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
109 ;;
110 tplink,tl-wr2543-v1)
111 ucidef_add_switch "switch0" \
112 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
113 ;;
114 tplink,tl-wr740n-v1|\
115 tplink,tl-wr740n-v3|\
116 tplink,tl-wr741-v1|\
117 tplink,tl-wr743nd-v1|\
118 tplink,tl-wr841-v5|\
119 tplink,tl-wr941-v4)
120 ucidef_set_interface_wan "eth0"
121 ucidef_add_switch "switch0" \
122 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
123 ;;
124 tplink,tl-wr740nd-v4|\
125 tplink,tl-wr741nd-v4)
126 ucidef_set_interface_wan "eth0"
127 ucidef_add_switch "switch0" \
128 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
129 ;;
130 tplink,tl-wr841n-v9)
131 ucidef_set_interface_wan "eth0"
132 ucidef_add_switch "switch0" \
133 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
134 ;;
135 ubnt,unifiac-mesh-pro|\
136 ubnt,unifiac-pro)
137 ucidef_add_switch "switch0" \
138 "0@eth0" "2:lan" "3:wan"
139 ;;
140 *)
141 ucidef_set_interfaces_lan_wan "eth0" "eth1"
142 ;;
143 esac
144 }
145
146 ath79_setup_macs()
147 {
148 local board="$1"
149
150 case "$board" in
151 avm,fritz300e)
152 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
153 ;;
154 dlink,dir-825-b1)
155 lan_mac=$(mtd_get_mac_text "caldata" 65440)
156 wan_mac=$(mtd_get_mac_text "caldata" 65460)
157 ;;
158 iodata,wn-ac1600dgr2)
159 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
160 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
161 ;;
162 phicomm,k2t)
163 lan_mac=$(k2t_get_mac "lan_mac")
164 wan_mac=$(k2t_get_mac "wan_mac")
165 ;;
166 tplink,tl-wr1043nd-v4)
167 base_mac=$(mtd_get_mac_binary product-info 8)
168 wan_mac=$(macaddr_add "$base_mac" 1)
169 ;;
170 esac
171
172 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
173 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
174 }
175
176 board_config_update
177 board=$(board_name)
178 ath79_setup_interfaces $board
179 ath79_setup_macs $board
180 board_config_flush
181
182 exit 0