ramips: add support for H3C TX1800 Plus / TX1801 Plus / TX1806
[openwrt/openwrt.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 h3c,tx1800-plus|\
41 h3c,tx1801-plus|\
42 h3c,tx1806)
43 addr=$(macaddr_setbit $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) 2) 7)
44 [ "$PHYNBR" = "0" ] && echo -n ${addr:0:9}'1'${addr:10:7} > /sys${DEVPATH}/macaddress
45 [ "$PHYNBR" = "1" ] && echo -n ${addr:0:9}'7'${addr:10:7} > /sys${DEVPATH}/macaddress
46 ;;
47 hiwifi,hc5962)
48 label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
49 [ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \
50 echo -n "$label_mac" > /sys${DEVPATH}/macaddress
51 [ "$PHYNBR" = "1" ] && [ -n "$label_mac" ] && \
52 macaddr_unsetbit "$label_mac" 6 > /sys${DEVPATH}/macaddress
53 ;;
54 iptime,a3002mesh|\
55 iptime,a3004t)
56 hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
57 [ "$PHYNBR" = "0" ] && \
58 macaddr_setbit_la "$(macaddr_add $hw_mac_addr 3)" > /sys${DEVPATH}/macaddress
59 [ "$PHYNBR" = "1" ] && echo -n "$hw_mac_addr" > /sys${DEVPATH}/macaddress
60 ;;
61 iptime,ax2004m)
62 if [ "$PHYNBR" = "1" ]; then
63 hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
64 macaddr_setbit_la "$(macaddr_add $hw_mac_addr 3)" > /sys${DEVPATH}/macaddress
65 fi
66 ;;
67 jcg,q20)
68 [ "$PHYNBR" = "1" ] && \
69 macaddr_setbit_la "$(mtd_get_mac_binary Factory 0x4)" > /sys${DEVPATH}/macaddress
70 ;;
71 jcg,y2)
72 [ "$PHYNBR" = "1" ] && \
73 macaddr_setbit_la "$(mtd_get_mac_binary factory 0x4)" > /sys${DEVPATH}/macaddress
74 ;;
75 linksys,e5600|\
76 linksys,ea6350-v4|\
77 linksys,ea7300-v1|\
78 linksys,ea7300-v2|\
79 linksys,ea7500-v2|\
80 linksys,ea8100-v1|\
81 linksys,ea8100-v2)
82 hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
83 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
84 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
85 ;;
86 netgear,wax202)
87 hw_mac_addr=$(mtd_get_mac_ascii Config mac)
88 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
89 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress
90 ;;
91 oraybox,x3a)
92 if [ "$PHYNBR" = "1" ]; then
93 hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
94 macaddr_setbit_la "$(macaddr_add $hw_mac_addr 0x100000)" > /sys${DEVPATH}/macaddress
95 fi
96 ;;
97 raisecom,msg1500-x-00)
98 [ "$PHYNBR" = "0" ] && \
99 macaddr_setbit_la "$(mtd_get_mac_ascii Config protest_lan_mac)" \
100 > /sys${DEVPATH}/macaddress
101 ;;
102 tenbay,t-mb5eu-v01)
103 hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
104 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr "0x100000" > /sys${DEVPATH}/macaddress
105 ;;
106 tplink,eap615-wall-v1)
107 hw_mac_addr="$(mtd_get_mac_binary product-info 0x8)"
108 macaddr_add "$hw_mac_addr" "$PHYNBR" > "/sys${DEVPATH}/macaddress"
109 ;;
110 yuncore,ax820)
111 [ "$PHYNBR" = "1" ] && \
112 macaddr_setbit_la "$(mtd_get_mac_binary Factory 0xe000)" > /sys${DEVPATH}/macaddress
113 ;;
114 zyxel,nwa50ax|\
115 zyxel,nwa55axe)
116 hw_mac_addr="$(mtd_get_mac_binary mrd 0x1fff8)"
117 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
118 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
119 ;;
120 esac