ramips: add support for Beeline SmartBox Flash
[openwrt/staging/mkresin.git] / target / linux / ramips / mt7621 / base-files / etc / hotplug.d / ieee80211 / 10_fix_wifi_mac
1 [ "$ACTION" == "add" ] || exit 0
2
3 PHYNBR=${DEVPATH##*/phy}
4
5 [ -n $PHYNBR ] || exit 0
6
7 . /lib/functions.sh
8 . /lib/functions/system.sh
9
10 board=$(board_name)
11
12 case "$board" in
13 beeline,smartbox-flash)
14 hw_mac_addr_ra0="$(mtd_get_mac_ascii u-boot-env ra0macaddr)"
15 hw_mac_addr_rax0="$(mtd_get_mac_ascii u-boot-env rax0macaddr)"
16 [ "$PHYNBR" = "0" ] && echo -n $hw_mac_addr_ra0 > /sys${DEVPATH}/macaddress
17 [ "$PHYNBR" = "1" ] && echo -n $hw_mac_addr_rax0 > /sys${DEVPATH}/macaddress
18 ;;
19 dlink,dir-853-a3)
20 [ "$PHYNBR" = "0" ] && \
21 macaddr_setbit_la "$(mtd_get_mac_binary factory 0xe000)" \
22 > /sys${DEVPATH}/macaddress
23 ;;
24 dlink,dir-853-r1|\
25 phicomm,k2p)
26 if [ "$PHYNBR" = "0" ]; then
27 base_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" -1)
28 macaddr_setbit_la "$base_mac" > /sys${DEVPATH}/macaddress
29 fi
30 ;;
31 glinet,gl-mt1300)
32 [ "$PHYNBR" = "1" ] && \
33 macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1 > /sys${DEVPATH}/macaddress
34 ;;
35 iptime,a3002mesh|\
36 iptime,a3004t)
37 hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
38 [ "$PHYNBR" = "0" ] && \
39 macaddr_setbit_la "$(macaddr_add $hw_mac_addr 3)" > /sys${DEVPATH}/macaddress
40 [ "$PHYNBR" = "1" ] && echo -n "$hw_mac_addr" > /sys${DEVPATH}/macaddress
41 ;;
42 iptime,ax2004m)
43 if [ "$PHYNBR" = "1" ]; then
44 hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
45 macaddr_setbit_la "$(macaddr_add $hw_mac_addr 3)" > /sys${DEVPATH}/macaddress
46 fi
47 ;;
48 jcg,q20)
49 [ "$PHYNBR" = "1" ] && \
50 macaddr_setbit_la "$(mtd_get_mac_binary Factory 0x4)" > /sys${DEVPATH}/macaddress
51 ;;
52 jcg,y2)
53 [ "$PHYNBR" = "1" ] && \
54 macaddr_setbit_la "$(mtd_get_mac_binary factory 0x4)" > /sys${DEVPATH}/macaddress
55 ;;
56 linksys,e5600|\
57 linksys,ea6350-v4|\
58 linksys,ea7300-v1|\
59 linksys,ea7300-v2|\
60 linksys,ea7500-v2|\
61 linksys,ea8100-v1|\
62 linksys,ea8100-v2)
63 hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
64 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
65 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
66 ;;
67 raisecom,msg1500-x-00)
68 [ "$PHYNBR" = "0" ] && \
69 macaddr_setbit_la "$(mtd_get_mac_ascii Config protest_lan_mac)" \
70 > /sys${DEVPATH}/macaddress
71 ;;
72 tenbay,t-mb5eu-v01)
73 hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
74 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr "0x100000" > /sys${DEVPATH}/macaddress
75 ;;
76 esac