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