ramips: W306R V2.0 - GPIO and Network fixes
[openwrt.git] / target / linux / ramips / base-files / etc / uci-defaults / network
1 #!/bin/sh
2
3 . /etc/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults.sh
6
7 if [ ! -x /usr/sbin/maccalc ]; then
8         echo "$0: maccalc not found!"
9         return
10 fi
11
12 ramips_setup_interfaces()
13 {
14         local board="$1"
15
16         ucidef_set_interface_loopback
17
18         case $board in
19         all0256n | \
20         wl-330n)
21                 ucidef_set_interface_lan "eth0.1"
22                 ;;
23
24         argus-atp52b | \
25         b2c | \
26         nw718 | \
27         sl-r7205 | \
28         w502u | \
29         wr6202)
30                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
31                 ;;
32
33         f5d8235-v1 | \
34         f5d8235-v2 | \
35         ur-336un)
36                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
37                 ;;
38
39         v11st-fe)
40                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
41                 ucidef_add_switch "switch0" "1" "1"
42                 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
43                 ucidef_add_switch_vlan "switch0" "2" "0 5t"
44                 ;;
45
46         rt-n15 | \
47         wl-351)
48                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
49                 ucidef_add_switch "switch0" "1" "1"
50                 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
51                 ucidef_add_switch_vlan "switch0" "2" "4 5t"
52                 ;;
53
54         rt-n56u)
55                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
56                 ucidef_add_switch "switch0" "1" "1"
57                 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
58                 ucidef_add_switch_vlan "switch0" "2" "4 8t"
59                 ;;
60
61         freestation5 | \
62         wcr-150gn)
63                 ucidef_set_interfaces_lan_wan "eth0.2" "eth0.1"
64                 ;;
65
66         wli-tx4-ag300n)
67                 ucidef_set_interface_lan "eth0"
68                 ;;
69
70         *)
71                 RT3X5X=`cat /proc/cpuinfo | grep RT3.5`
72                 if [ -n "${RT3X5X}" ]; then
73                         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
74                 else
75                         ucidef_set_interfaces_lan_wan "eth0" "eth1"
76                 fi
77                 ;;
78         esac
79 }
80
81 ramips_setup_macs()
82 {
83         local board="$1"
84         local lan_mac=""
85         local wan_mac=""
86
87         case $board in
88         all0256n)
89                 lan_mac=$(ramips_get_mac_binary factory 40)
90                 ;;
91
92         argus-atp52b | \
93         b2c | \
94         f5d8235-v1 | \
95         nw718 | \
96         rt-n15 | \
97         sl-r7205 | \
98         wl-351)
99                 lan_mac=$(ramips_get_mac_binary factory 4)
100                 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
101                 ;;
102
103         w306r-v20)
104                 lan_mac=$(ramips_get_mac_binary factory 4)
105                 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 5)
106                 ;;
107
108         dir-300-b1 |\
109         dir-300-b2 |\
110         dir-600-b1)
111                 lan_mac=$(ramips_get_mac_binary devdata 16388)
112                 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
113                 ;;
114
115         esr-9753 | \
116         ur-336un)
117                 lan_mac=$(ramips_get_mac_binary devdata 16388)
118                 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
119                 ;;
120
121         nbg-419n | \
122         wcr-150gn)
123                 lan_mac=$(ramips_get_mac_binary factory 4)
124                 wan_mac=$(ramips_get_mac_binary factory 40)
125                 ;;
126
127         f5d8235-v2)
128                 lan_mac=$(ramips_get_mac_binary "u-boot" 262148)
129                 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
130                 ;;
131
132         rt-n56u)
133                 lan_mac=$(ramips_get_mac_binary factory 4)
134                 wan_mac=$(ramips_get_mac_binary factory 32772)
135                 ;;
136
137         w502u)
138                 lan_mac=$(ramips_get_mac_binary factory 40)
139                 wan_mac=$(ramips_get_mac_binary factory 46)
140                 ;;
141
142         wl341v3)
143                 lan_mac=$(ramips_get_mac_binary board-nvram 65440)
144                 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
145                 ;;
146
147         wli-tx4-ag300n)
148                 lan_mac=$(ramips_get_mac_binary factory 4)
149                 ;;
150
151         esac
152
153         [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
154         [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
155 }
156
157 [ -e /etc/config/network ] && exit 0
158
159 touch /etc/config/network
160
161 board=$(ramips_board_name)
162
163 ramips_setup_interfaces $board
164 ramips_setup_macs $board
165
166 uci commit network
167
168 exit 0