ath79: add support for OCEDO Koala
[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 ucidef_add_switch "switch0" \
74 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
75 ;;
76 tplink,tl-mr3220-v1|\
77 tplink,tl-mr3420-v1|\
78 tplink,tl-wr841-v7)
79 ucidef_set_interface_wan "eth0"
80 ucidef_add_switch "switch0" \
81 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
82 ;;
83 tplink,tl-wdr3600|\
84 tplink,tl-wdr4300)
85 ucidef_add_switch "switch0" \
86 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
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-v2|\
93 tplink,tl-wr1043nd-v3)
94 ucidef_add_switch "switch0" \
95 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
96 ;;
97 tplink,tl-wr1043nd-v4)
98 ucidef_add_switch "switch0" \
99 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
100 ;;
101 tplink,tl-wr2543-v1)
102 ucidef_add_switch "switch0" \
103 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
104 ;;
105 tplink,tl-wr740n-v1|\
106 tplink,tl-wr740n-v3|\
107 tplink,tl-wr741-v1|\
108 tplink,tl-wr743nd-v1|\
109 tplink,tl-wr841-v5|\
110 tplink,tl-wr941-v4)
111 ucidef_set_interface_wan "eth0"
112 ucidef_add_switch "switch0" \
113 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
114 ;;
115 tplink,tl-wr740nd-v4|\
116 tplink,tl-wr741nd-v4)
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 tplink,tl-wr841n-v9)
122 ucidef_set_interface_wan "eth0"
123 ucidef_add_switch "switch0" \
124 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
125 ;;
126 ubnt,unifiac-mesh-pro|\
127 ubnt,unifiac-pro)
128 ucidef_add_switch "switch0" \
129 "0@eth0" "2:lan" "3:wan"
130 ;;
131 *)
132 ucidef_set_interfaces_lan_wan "eth0" "eth1"
133 ;;
134 esac
135 }
136
137 ath79_setup_macs()
138 {
139 local board="$1"
140
141 case "$board" in
142 avm,fritz300e)
143 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
144 ;;
145 phicomm,k2t)
146 lan_mac=$(k2t_get_mac "lan_mac")
147 wan_mac=$(k2t_get_mac "wan_mac")
148 ;;
149 tplink,tl-wr1043nd-v4)
150 base_mac=$(mtd_get_mac_binary product-info 8)
151 wan_mac=$(macaddr_add "$base_mac" 1)
152 ;;
153 esac
154
155 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
156 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
157 }
158
159 board_config_update
160 board=$(board_name)
161 ath79_setup_interfaces $board
162 ath79_setup_macs $board
163 board_config_flush
164
165 exit 0