bced04423436057c0067ee74dad068d82edeeb74
[openwrt/staging/stintel.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 mts,wg430223)
15 hw_mac_addr_ra0="$(mtd_get_mac_ascii u-boot-env ra0macaddr)"
16 hw_mac_addr_rax0="$(mtd_get_mac_ascii u-boot-env rax0macaddr)"
17 [ "$PHYNBR" = "0" ] && echo -n $hw_mac_addr_ra0 > /sys${DEVPATH}/macaddress
18 [ "$PHYNBR" = "1" ] && echo -n $hw_mac_addr_rax0 > /sys${DEVPATH}/macaddress
19 ;;
20 cudy,x6)
21 hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
22 macaddr_add $hw_mac_addr "$PHYNBR" > /sys${DEVPATH}/macaddress
23 ;;
24 dlink,dir-853-a3)
25 [ "$PHYNBR" = "0" ] && \
26 macaddr_setbit_la "$(mtd_get_mac_binary factory 0xe000)" \
27 > /sys${DEVPATH}/macaddress
28 ;;
29 dlink,dir-853-r1|\
30 phicomm,k2p)
31 if [ "$PHYNBR" = "0" ]; then
32 base_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" -1)
33 macaddr_setbit_la "$base_mac" > /sys${DEVPATH}/macaddress
34 fi
35 ;;
36 glinet,gl-mt1300)
37 [ "$PHYNBR" = "1" ] && \
38 macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1 > /sys${DEVPATH}/macaddress
39 ;;
40 hiwifi,hc5962)
41 label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
42 [ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \
43 echo -n "$label_mac" > /sys${DEVPATH}/macaddress
44 [ "$PHYNBR" = "1" ] && [ -n "$label_mac" ] && \
45 macaddr_unsetbit "$label_mac" 6 > /sys${DEVPATH}/macaddress
46 ;;
47 iptime,a3002mesh|\
48 iptime,a3004t)
49 hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
50 [ "$PHYNBR" = "0" ] && \
51 macaddr_setbit_la "$(macaddr_add $hw_mac_addr 3)" > /sys${DEVPATH}/macaddress
52 [ "$PHYNBR" = "1" ] && echo -n "$hw_mac_addr" > /sys${DEVPATH}/macaddress
53 ;;
54 iptime,ax2004m)
55 if [ "$PHYNBR" = "1" ]; then
56 hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
57 macaddr_setbit_la "$(macaddr_add $hw_mac_addr 3)" > /sys${DEVPATH}/macaddress
58 fi
59 ;;
60 jcg,q20)
61 [ "$PHYNBR" = "1" ] && \
62 macaddr_setbit_la "$(mtd_get_mac_binary Factory 0x4)" > /sys${DEVPATH}/macaddress
63 ;;
64 jcg,y2)
65 [ "$PHYNBR" = "1" ] && \
66 macaddr_setbit_la "$(mtd_get_mac_binary factory 0x4)" > /sys${DEVPATH}/macaddress
67 ;;
68 linksys,e5600|\
69 linksys,ea6350-v4|\
70 linksys,ea7300-v1|\
71 linksys,ea7300-v2|\
72 linksys,ea7500-v2|\
73 linksys,ea8100-v1|\
74 linksys,ea8100-v2)
75 hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
76 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
77 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
78 ;;
79 netgear,wax202)
80 hw_mac_addr=$(mtd_get_mac_ascii Config mac)
81 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
82 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress
83 ;;
84 oraybox,x3a)
85 if [ "$PHYNBR" = "1" ]; then
86 hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
87 macaddr_setbit_la "$(macaddr_add $hw_mac_addr 0x100000)" > /sys${DEVPATH}/macaddress
88 fi
89 ;;
90 raisecom,msg1500-x-00)
91 [ "$PHYNBR" = "0" ] && \
92 macaddr_setbit_la "$(mtd_get_mac_ascii Config protest_lan_mac)" \
93 > /sys${DEVPATH}/macaddress
94 ;;
95 tenbay,t-mb5eu-v01)
96 hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
97 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr "0x100000" > /sys${DEVPATH}/macaddress
98 ;;
99 tplink,eap615-wall-v1)
100 hw_mac_addr="$(mtd_get_mac_binary product-info 0x8)"
101 macaddr_add "$hw_mac_addr" "$PHYNBR" > "/sys${DEVPATH}/macaddress"
102 ;;
103 yuncore,ax820)
104 [ "$PHYNBR" = "1" ] && \
105 macaddr_setbit_la "$(mtd_get_mac_binary Factory 0xe000)" > /sys${DEVPATH}/macaddress
106 ;;
107 zyxel,nwa50ax|\
108 zyxel,nwa55axe)
109 hw_mac_addr="$(mtd_get_mac_binary mrd 0x1fff8)"
110 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
111 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
112 ;;
113 esac