brcm47xx: fix switch handling
[openwrt/openwrt.git] / target / linux / brcm47xx / base-files / lib / preinit / 05_init_interfaces_brcm
1 #!/bin/sh
2
3 set_preinit_iface() {
4 ifname=eth0
5
6 # hardware specific overrides
7 case "$(cat /proc/diag/model)" in
8 "Linksys WAP54G V1") ifname=eth1;;
9 "ASUS WL-HDD") ifname=eth1;;
10 "ASUS WL-300g") ifname=eth1;;
11 "ASUS (unknown, BCM4702)") ifname=eth1;;
12 "Sitecom WL-105b") ifname=eth1;;
13 esac
14
15 # The interface has to be up to configure the switch
16 ifconfig $ifname 0.0.0.0 up
17 [ -f /lib/modules/`uname -r`/switch-robo.ko ] && {
18 rmmod switch-robo
19 insmod switch-robo
20 }
21 [ -f /lib/modules/`uname -r`/switch-adm.ko ] && {
22 rmmod switch-adm
23 insmod switch-adm
24 }
25 }
26
27 init_iface() {
28 [ -d /proc/switch/eth0 ] && [ "$ifname" = "eth0" ] && {
29 case "$(cat /proc/switch/eth0/cpuport)" in
30 "5") cpu_port="5u*";;
31 "8") cpu_port="8u*";;
32 esac
33 }
34 }
35
36 boot_hook_add preinit_main set_preinit_iface
37 boot_hook_add preinit_main init_iface