55498b9f596963e0ea23d8a023676ea33b0bde8d
[openwrt/openwrt.git] / target / linux / lantiq / base-files / etc / board.d / 02_network
1 #!/bin/sh
2 #
3 # Copyright (C) 2011-2015 OpenWrt.org
4 #
5
6 . /lib/functions/uci-defaults.sh
7 . /lib/functions/system.sh
8 . /lib/functions/lantiq.sh
9
10 board_config_update
11
12 vpi=1
13 vci=32
14 annex="a"
15 encaps="llc"
16 payload="bridged"
17 lan_mac=""
18 wan_mac=""
19 interface_wan=""
20
21 board=$(board_name)
22
23 case "$board" in
24 ACMP252|GIGASX76X)
25 ucidef_add_switch "switch0" \
26 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5t@eth0"
27 ;;
28
29 ALL0333CJ)
30 annex="b"
31 lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
32 wan_mac=$(macaddr_add "$lan_mac" 1)
33 ucidef_set_interface_lan 'eth0'
34 ;;
35
36 ARV4510PW)
37 lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
38 wan_mac=$(macaddr_add "$lan_mac" 1)
39 ucidef_add_switch "switch0" \
40 "0:lan:4" "2:lan:2" "1:lan:3" "3:lan:1" "5t@eth0"
41 ;;
42
43 ARV4519PW|ARV7510PW22|ARV7518PW|ARV752DPW22|ARV8539PW22)
44 ucidef_add_switch "switch0" \
45 "0t@eth0" "2:lan" "3:lan" "4:lan" "5:lan"
46 ;;
47
48 ARV4520PW)
49 ucidef_add_switch "switch0" \
50 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5t@eth0"
51 ;;
52
53 ARV7506PW11)
54 wan_mac=$(macaddr_add "$(mtd_get_mac_binary board_config 22)" 2)
55 ucidef_add_switch "switch0" \
56 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5t@eth0"
57 ;;
58
59 ARV7519PW)
60 wan_mac=$(macaddr_add "$(mtd_get_mac_binary board_config 22)" 1)
61 ucidef_add_switch "switch0" \
62 "0:lan" "1:lan" "2:lan" "3:lan" "4t@eth0"
63 ;;
64
65 ARV7519RW22)
66 wan_mac=$(macaddr_add "$(mtd_get_mac_binary boardconfig 22)" 1)
67 ucidef_add_switch "switch0" \
68 "0:lan:5" "2:lan:3" "3:lan:4" "4:lan:1" "5:lan:2" "6t@eth0"
69 ;;
70
71 ASL56026)
72 lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
73 wan_mac=$(mtd_get_mac_ascii uboot_env wanmac)
74 ucidef_add_switch "switch0"\
75 "2:lan" "3:lan" "6t@eth0"
76 ;;
77
78 BTHOMEHUBV2B)
79 lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
80 wan_mac=$(macaddr_add "$lan_mac" 1)
81 ucidef_add_switch "switch0" \
82 "1:lan" "2:lan" "3:lan" "4:lan" "5t@eth0"
83 ;;
84
85 BTHOMEHUBV3A)
86 lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
87 wan_mac=$(macaddr_add "$lan_mac" 1)
88 ucidef_set_interface_lan 'eth0'
89 ;;
90
91 BTHOMEHUBV5A)
92 lan_mac=$(mtd_get_mac_binary_ubi caldata 4364)
93 wan_mac=$(macaddr_add "$lan_mac" 1)
94 ucidef_add_switch "switch0" \
95 "0:lan:3" "1:lan:4" "2:lan:2" "4:lan:1" "5:wan:5" "6t@eth0"
96 ;;
97
98 DGN3500*)
99 ucidef_add_switch "switch0" \
100 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5t@eth0"
101 ;;
102
103 EASY80920NAND|EASY80920NOR)
104 lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
105 wan_mac=$(macaddr_add "$lan_mac" 1)
106 ucidef_add_switch "switch0" \
107 "0:lan:4" "1:lan:3" "2:lan:2" "4:lan:1" "5:wan:5" "6t@eth0"
108 ;;
109
110 FRITZ3370)
111 wan_mac=$(macaddr_add "$(mtd_get_mac_binary urlader 2439)" 1)
112 ;;
113
114 FRITZ7320)
115 wan_mac=$(macaddr_add "$(mtd_get_mac_binary urlader 2705)" 1)
116 ;;
117
118 FRITZ7360SL)
119 wan_mac=$(macaddr_add "$(mtd_get_mac_binary urlader 2705)" 1)
120 ucidef_add_switch "switch0" \
121 "0:lan:3" "1:lan:4" "2:lan:2" "4:lan:1" "6t@eth0"
122 ;;
123
124 H201L)
125 ucidef_add_switch "switch0" \
126 "0:lan" "1:lan" "2:lan" "3:lan" "4t@eth0"
127 ;;
128
129 P2601HNFX)
130 ucidef_add_switch "switch0" \
131 "0:lan" "1:lan" "2:lan" "3:lan" "5t@eth0"
132 ;;
133
134 P2812HNUF*)
135 lan_mac=$(mtd_get_mac_ascii uboot-env ethaddr)
136 wan_mac=$(macaddr_add "$lan_mac" 1)
137 ucidef_add_switch "switch0" \
138 "0:lan" "1:lan" "2:lan" "4:lan" "5:wan" "6t@eth0"
139 ;;
140
141 TDW8970|TDW8980)
142 wan_mac=$(macaddr_add "$(mtd_get_mac_binary boardconfig 61696)" 1)
143 ucidef_add_switch "switch0" \
144 "0:lan:2" "2:lan:3" "4:lan:4" "5:lan:1" "6t@eth0"
145 ;;
146
147 VG3503J)
148 lan_mac=$(mtd_get_mac_ascii uboot-env ethaddr)
149 wan_mac=$(macaddr_add "$lan_mac" 1)
150 ucidef_add_switch "switch0" \
151 "2:lan:1" "4:lan:2" "6t@eth0"
152 ;;
153
154 VR200v)
155 wan_mac=$(macaddr_add "$(mtd_get_mac_binary romfile 61696)" 1)
156 ucidef_add_switch "switch0" \
157 "0:lan" "2:lan" "4:lan" "5:lan" "6t@eth0"
158 ;;
159
160 VGV7510KW22*)
161 wan_mac=$(macaddr_add "$(mtd_get_mac_binary board_config 22)" 2)
162 ucidef_add_switch "switch0" \
163 "2:lan:2" "3:lan:1" "4:lan:4" "5:lan:3" "0:wan:5" "6t@eth0"
164 ;;
165
166 VGV7519*)
167 wan_mac=$(mtd_get_mac_binary board_config 22)
168 ucidef_add_switch "switch0" \
169 "0:lan:4" "1:lan:3" "2:lan:2" "4:lan:1" "5:wan:5" "6t@eth0"
170 ;;
171
172 WBMR)
173 ucidef_add_switch "switch0" \
174 "0t@eth0" "2:lan" "3:lan" "4:lan" "5:lan"
175 ;;
176
177 WBMR300)
178 lan_mac=$(mtd_get_mac_ascii ubootconfig ethaddr)
179 wan_mac="$lan_mac"
180 ucidef_add_switch "switch0" \
181 "5:lan:2" "2:lan:3" "3:lan:4" "4:wan:1" "6t@eth0"
182 ;;
183
184 *)
185 ucidef_set_interface_lan 'eth0'
186 ;;
187
188 esac
189
190 ls /lib/modules/$(uname -r)/ltq_atm* 1> /dev/null 2>&1 && \
191 ucidef_add_atm_bridge "$vpi" "$vci" "$encaps" "$payload"
192
193 if lantiq_is_vdsl_system; then
194 interface_wan="ptm0"
195 ucidef_add_vdsl_modem "$annex" "av" "ptm"
196 else
197 interface_wan="nas0"
198 ucidef_add_adsl_modem "$annex" "/lib/firmware/adsl.bin"
199 fi
200
201 ucidef_set_interface_wan "$interface_wan" "pppoe"
202
203 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
204 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac"
205
206 board_config_flush
207
208 exit 0
209