ath79: Port PowerCloud Systems CAP324 support
[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_set_interfaces_lan_wan "eth1.1" "eth0.2"
54 ucidef_add_switch "switch0" \
55 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
56 ;;
57
58 "tplink,tl-mr3020-v1")
59 ucidef_set_interface_lan "eth0.1"
60 ucidef_add_switch "switch0" "0@eth0" "1:lan"
61 ;;
62 "tplink,tl-mr3220-v1"|\
63 "tplink,tl-mr3420-v1"|\
64 "tplink,tl-wr841-v7")
65 ucidef_set_interface_wan "eth0"
66 ucidef_add_switch "switch0" \
67 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
68 ;;
69 "tplink,tl-wdr3600"|\
70 "tplink,tl-wdr4300")
71 ucidef_add_switch "switch0" \
72 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
73 ;;
74
75 "tplink,tl-wr740n-v2")
76 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
77 ucidef_add_switch "switch0" \
78 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
79 ;;
80
81 "tplink,tl-wr741nd-v4"|\
82 "tplink,tl-wr740nd-v4")
83 ucidef_set_interfaces_wan "eth1"
84 ucidef_add_switch "switch0" \
85 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
86 ;;
87
88 "tplink,tl-wr1043nd-v1")
89 ucidef_add_switch "switch0" \
90 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@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-wr1043nd-v2"|\
97 "tplink,tl-wr1043nd-v3")
98 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
99 ucidef_add_switch "switch0" \
100 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
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 "netgear,wndr3800")
107 ucidef_set_interfaces_lan_wan "eth0" "eth1"
108 ucidef_add_switch "switch0" \
109 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
110
111 ucidef_add_switch_attr "switch0" "blinkrate" 2
112 ucidef_add_switch_port_attr "switch0" 1 led 6
113 ucidef_add_switch_port_attr "switch0" 2 led 9
114 ucidef_add_switch_port_attr "switch0" 5 led 2
115 ;;
116 "buffalo,wzr-hp-g450h")
117 ucidef_add_switch "switch0" \
118 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
119 ;;
120 "phicomm,k2t")
121 ucidef_add_switch "switch0" \
122 "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
123 ;;
124 "ubnt,unifiac-mesh-pro"|\
125 "ubnt,unifiac-pro")
126 ucidef_add_switch "switch0" \
127 "0@eth0" "2:lan" "3:wan"
128 ;;
129 *)
130 ucidef_set_interfaces_lan_wan "eth0" "eth1"
131 ;;
132 esac
133 }
134
135 ath79_setup_macs()
136 {
137 local board="$1"
138
139 case "$board" in
140 avm,fritz300e)
141 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
142 ;;
143 phicomm,k2t)
144 lan_mac=$(k2t_get_mac "lan_mac")
145 wan_mac=$(k2t_get_mac "wan_mac")
146 ;;
147 "tplink,tl-wr1043nd-v4")
148 base_mac=$(mtd_get_mac_binary product-info 8)
149 wan_mac=$(macaddr_add "$base_mac" 1)
150 ;;
151 esac
152
153 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
154 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
155 }
156
157 board_config_update
158 board=$(board_name)
159 ath79_setup_interfaces $board
160 ath79_setup_macs $board
161 board_config_flush
162
163 exit 0