c271e62f733c1adc19592910ac9477090a1a6203
[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=$(lantiq_board_name)
22
23 case "$board" in
24 # adm6996
25 ARV4510PW)
26 lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
27 wan_mac=$(macaddr_add "$lan_mac" 1)
28 ucidef_add_switch "switch0" \
29 "3:lan:1" "2:lan:2" "1:lan:3" "0:lan:4" "5t@eth0"
30 ;;
31
32 ARV4520PW)
33 ucidef_add_switch "switch0" \
34 "3:lan:1" "2:lan:2" "1:lan:3" "0:lan:4" "5t@eth0"
35 ;;
36
37 ACMP252|GIGASX76X)
38 ucidef_add_switch "switch0" \
39 "4:lan:1" "3:lan:2" "2:lan:3" "1:lan:4" "5t@eth0"
40 ;;
41
42 # ar8316
43 ARV4519PW|ARV7510PW22|ARV7518PW|ARV752DPW22|ARV8539PW22)
44 ucidef_add_switch "switch0" \
45 "0t@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4"
46 ;;
47
48 # rtl8306g
49 ARV7506PW11)
50 lan_mac=$(mtd_get_mac_binary board_config 22)
51 wan_mac=$(macaddr_add "$lan_mac" 2)
52 ucidef_add_switch "switch0" \
53 "4:lan:1" "3:lan:2" "2:lan:3" "1:lan:4" "5t@eth0"
54 ;;
55
56 # rtl8306g
57 ARV7519PW)
58 lan_mac=$(mtd_get_mac_binary board_config 22)
59 wan_mac=$(macaddr_add "$lan_mac" 1)
60 ucidef_add_switch "switch0" \
61 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4t@eth0"
62 ;;
63
64 WBMR)
65 ucidef_add_switch "switch0" \
66 "0t@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4"
67 ;;
68
69 VG3503J)
70 ucidef_set_interface_lan 'eth0'
71 ;;
72
73 ARV4518PWR01*)
74 ucidef_set_interface_lan 'eth0'
75 ;;
76
77 DGN3500*)
78 ucidef_add_switch "switch0" \
79 "3:lan:1" "2:lan:2" "1:lan:3" "0:lan:4" "5t@eth0"
80 ;;
81
82 FRITZ7360SL)
83 ucidef_add_switch "switch0" \
84 "4:lan:1" "2:lan:2" "0:lan:3" "1:lan:4" "6t@eth0"
85 ;;
86
87 H201L)
88 ucidef_add_switch "switch0" \
89 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4t@eth0"
90 ;;
91
92 #rtl8306g
93 P2601HNFX)
94 ucidef_add_switch "switch0" \
95 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "5t@eth0"
96 ;;
97
98 P2812HNUF*)
99 lan_mac=$(mtd_get_mac_ascii uboot-env ethaddr)
100 wan_mac=$(macaddr_add "$lan_mac" 1)
101 ucidef_add_switch "switch0" \
102 "0:lan:1" "1:lan:2" "2:lan:3" "4:lan:4" "5:lan:5" "6t@eth0"
103 ;;
104
105 TDW8970|TDW8980)
106 lan_mac=$(mtd_get_mac_binary boardconfig 61696)
107 wan_mac=$(macaddr_add "$lan_mac" 1)
108 ucidef_add_switch "switch0" \
109 "0:lan:1" "2:lan:2" "4:lan:3" "5:lan:4" "6t@eth0"
110 ;;
111
112 VR200v)
113 lan_mac=$(mtd_get_mac_binary romfile 61696)
114 wan_mac=$(macaddr_add "$lan_mac" 1)
115 ucidef_add_switch "switch0" \
116 "0:lan:1" "2:lan:2" "4:lan:3" "5:lan:4" "6t@eth0"
117 ;;
118
119 ARV7519RW22)
120 lan_mac=$(mtd_get_mac_binary boardconfig 22)
121 wan_mac=$(macaddr_add "$lan_mac" 1)
122 ucidef_add_switch "switch0" \
123 "0:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "5:lan:5" "6t@eth0"
124 ;;
125
126 BTHOMEHUBV2B|BTHOMEHUBV3A)
127 lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
128 wan_mac=$(macaddr_add "$lan_mac" 1)
129 ucidef_set_interface_lan 'eth0'
130 ;;
131
132 BTHOMEHUBV5A)
133 lan_mac=$(mtd_get_mac_binary caldata 4364)
134 wan_mac=$(macaddr_add "$lan_mac" 1)
135 ucidef_add_switch "switch0" \
136 "0:lan:1" "1:lan:2" "2:lan:3" "4:lan:4" "6t@eth0"
137 ;;
138
139 VGV7519)
140 lan_mac=$(mtd_get_mac_binary board_config 22)
141 wan_mac=$(macaddr_add "$lan_mac" 1)
142 ucidef_add_switch "switch0" \
143 "4:lan:1" "2:lan:2" "1:lan:3" "0:lan:4" "6t@eth0"
144 ;;
145
146 VGV7510KW22)
147 lan_mac=$(mtd_get_mac_binary board_config 22)
148 wan_mac=$(macaddr_add "$lan_mac" 1)
149 ucidef_add_switch "switch0" \
150 "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "6t@eth0"
151 ;;
152 *)
153 ucidef_set_interface_lan 'eth0'
154 ;;
155
156 WBMR300)
157 lan_mac=$(mtd_get_mac_ascii ubootconfig ethaddr)
158 wan_mac="$lan_mac"
159 ucidef_add_switch "switch0" \
160 "2:lan:1" "3:lan:2" "5:lan:3" "4:wan:1" "6t@eth0"
161 ;;
162
163 esac
164
165 if [ -n "$(ls /lib/modules/`uname -r`/ltq_atm*)" ]; then
166 ucidef_add_atm_bridge "$vpi" "$vci" "$encaps" "$payload"
167 fi
168
169 if grep -qE "system type.*: (VR9|xRX200)" /proc/cpuinfo; then
170 interface_wan="ptm0"
171 ucidef_add_vdsl_modem "$annex" "av" "ptm"
172 else
173 interface_wan="nas0"
174 ucidef_add_adsl_modem "$annex" "/lib/firmware/adsl.bin"
175 fi
176
177 ucidef_set_interface_wan "$interface_wan" "pppoe"
178
179 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan "$lan_mac"
180 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan "$wan_mac"
181
182 board_config_flush
183
184 exit 0