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