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