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