ramips: add support for D-Link DAP-1620 B1
[openwrt/staging/wigyori.git] / target / linux / ramips / mt7621 / base-files / etc / hotplug.d / ieee80211 / 10_fix_wifi_mac
index 3390104e8088efd80cba844f5876d104b2793d71..9db115fcae6566325f35f9cf931b3144584c63ca 100644 (file)
@@ -10,16 +10,42 @@ PHYNBR=${DEVPATH##*/phy}
 board=$(board_name)
 
 case "$board" in
-       beeline,smartbox-flash|\
-       mts,wg430223)
-               hw_mac_addr_ra0="$(mtd_get_mac_ascii u-boot-env ra0macaddr)"
-               hw_mac_addr_rax0="$(mtd_get_mac_ascii u-boot-env rax0macaddr)"
-               [ "$PHYNBR" = "0" ] && echo -n $hw_mac_addr_ra0 > /sys${DEVPATH}/macaddress
-               [ "$PHYNBR" = "1" ] && echo -n $hw_mac_addr_rax0 > /sys${DEVPATH}/macaddress
+       arcadyan,we420223-99)
+               if [ "$PHYNBR" = "0" ]; then
+                       mac24=$(macaddr_add "$(get_mac_label)" "0xf00001")
+                       echo -n "$mac24" > /sys${DEVPATH}/macaddress
+               elif [ "$PHYNBR" = "1" ]; then
+                       mac5=$(macaddr_add "$(get_mac_label)" 1)
+                       echo -n "$mac5" > /sys${DEVPATH}/macaddress
+               fi
+               ;;
+       beeline,smartbox-flash)
+               hw_mac_addr=$(macaddr_add $(mtd_get_mac_encrypted_arcadyan "board_data") 1)
+               [ "$PHYNBR" = "0" ] && echo -n "$hw_mac_addr" > /sys${DEVPATH}/macaddress
+               hw_mac_addr=$(macaddr_setbit   $hw_mac_addr 26)
+               hw_mac_addr=$(macaddr_unsetbit $hw_mac_addr 27)
+               hw_mac_addr=$(macaddr_unsetbit $hw_mac_addr 28)
+               [ "$PHYNBR" = "1" ] && macaddr_setbit_la $hw_mac_addr > /sys${DEVPATH}/macaddress
                ;;
        cudy,x6)
+               hw_mac_addr="$(mtd_get_mac_binary bdinfo 0xde00)"
+               [ "$PHYNBR" = "1" ] && \
+               macaddr_setbit_la "$(macaddr_add $hw_mac_addr 0x100000)" > /sys${DEVPATH}/macaddress
+               ;;
+       dlink,dap-1620-b1|\
+       dlink,dir-853-a1)
+               lan_mac_addr="$(mtd_get_mac_binary factory 0xe000)"
+               [ "$PHYNBR" = "0" ] && \
+                       macaddr_add $lan_mac_addr 1 > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && \
+                       macaddr_add $lan_mac_addr 2 > /sys${DEVPATH}/macaddress
+               ;;
+       dlink,dap-x1860-a1)
                hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
-               macaddr_add $hw_mac_addr "$PHYNBR" > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "0" ] && \
+                       macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && \
+                       macaddr_add $hw_mac_addr 4 > /sys${DEVPATH}/macaddress
                ;;
        dlink,dir-853-a3)
                [ "$PHYNBR" = "0" ] && \
@@ -37,6 +63,19 @@ case "$board" in
                [ "$PHYNBR" = "1" ] && \
                        macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1 > /sys${DEVPATH}/macaddress
                ;;
+       h3c,tx1800-plus|\
+       h3c,tx1801-plus|\
+       h3c,tx1806)
+               addr=$(macaddr_setbit $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) 2) 7)
+               [ "$PHYNBR" = "0" ] && echo -n ${addr:0:9}'1'${addr:10:7} > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && echo -n ${addr:0:9}'7'${addr:10:7} > /sys${DEVPATH}/macaddress
+               ;;
+       haier,har-20s2u1|\
+       jcg,y2|\
+       sim,simax1800t)
+               [ "$PHYNBR" = "1" ] && \
+                       macaddr_setbit_la "$(mtd_get_mac_binary factory 0x4)" > /sys${DEVPATH}/macaddress
+               ;;
        hiwifi,hc5962)
                label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
                [ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \
@@ -61,10 +100,6 @@ case "$board" in
                [ "$PHYNBR" = "1" ] && \
                        macaddr_setbit_la "$(mtd_get_mac_binary Factory 0x4)" > /sys${DEVPATH}/macaddress
                ;;
-       jcg,y2)
-               [ "$PHYNBR" = "1" ] && \
-                       macaddr_setbit_la "$(mtd_get_mac_binary factory 0x4)" > /sys${DEVPATH}/macaddress
-               ;;
        linksys,e5600|\
        linksys,ea6350-v4|\
        linksys,ea7300-v1|\
@@ -76,6 +111,30 @@ case "$board" in
                [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
                [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
                ;;
+       belkin,rt1800|\
+       linksys,e7350)
+               hw_mac_addr=$(mtd_get_mac_ascii Config wan_hwaddr)
+               [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
+               ;;
+       netgear,wax202)
+               hw_mac_addr=$(mtd_get_mac_ascii Config mac)
+               [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress
+               ;;
+       mercusys,mr70x-v1|\
+       tplink,archer-ax23-v1)
+               hw_mac_addr="$(mtd_get_mac_binary config 0x8)"
+               [ "$PHYNBR" = "1" ] &&  macaddr_add "$hw_mac_addr" -1 > "/sys${DEVPATH}/macaddress"
+               ;;
+       mts,wg430223)
+               hw_mac_addr=$(macaddr_add $(mtd_get_mac_encrypted_arcadyan "board_data") 1)
+               [ "$PHYNBR" = "0" ] && echo -n "$hw_mac_addr" > /sys${DEVPATH}/macaddress
+               hw_mac_addr=$(macaddr_unsetbit $hw_mac_addr 26)
+               hw_mac_addr=$(macaddr_setbit   $hw_mac_addr 27)
+               hw_mac_addr=$(macaddr_unsetbit $hw_mac_addr 28)
+               [ "$PHYNBR" = "1" ] && macaddr_setbit_la $hw_mac_addr > /sys${DEVPATH}/macaddress
+               ;;
        oraybox,x3a)
                if [ "$PHYNBR" = "1" ]; then
                        hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
@@ -84,19 +143,48 @@ case "$board" in
                ;;
        raisecom,msg1500-x-00)
                [ "$PHYNBR" = "0" ] && \
-                       macaddr_setbit_la "$(mtd_get_mac_ascii Config protest_lan_mac)" \
-                               > /sys${DEVPATH}/macaddress
+                       macaddr_setbit_la "$(get_mac_label)" > /sys${DEVPATH}/macaddress
+               ;;
+       snr,snr-cpe-me2-sfp)
+               hw_mac_addr="$(mtd_get_mac_binary factory 0x8004)"
+               [ "$PHYNBR" = "1" ] &&  echo -n "$hw_mac_addr" > /sys${DEVPATH}/macaddress
                ;;
        tenbay,t-mb5eu-v01)
                hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
                [ "$PHYNBR" = "1" ] &&  macaddr_add $hw_mac_addr "0x100000" > /sys${DEVPATH}/macaddress
                ;;
+       totolink,x5000r)
+               hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
+               [ "$PHYNBR" = "1" ] &&  macaddr_add $hw_mac_addr 4 > /sys${DEVPATH}/macaddress
+               ;;
        tplink,eap615-wall-v1)
                hw_mac_addr="$(mtd_get_mac_binary product-info 0x8)"
                macaddr_add "$hw_mac_addr" "$PHYNBR" > "/sys${DEVPATH}/macaddress"
                ;;
+       tplink,ec330-g5u-v1)
+               hw_mac_addr="$(mtd_get_mac_text factory 0x165)"
+               [ "$PHYNBR" = "0" ] && echo -n $hw_mac_addr > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
+               ;;
        yuncore,ax820)
                [ "$PHYNBR" = "1" ] && \
                        macaddr_setbit_la "$(mtd_get_mac_binary Factory 0xe000)" > /sys${DEVPATH}/macaddress
                ;;
+       yuncore,fap640|\
+       yuncore,fap690)
+               hw_mac_addr="$(mtd_get_mac_binary Factory 0x4)"
+               [ "$PHYNBR" = "0" ] && macaddr_setbit_la "$hw_mac_addr" > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && echo -n "$hw_mac_addr" > /sys${DEVPATH}/macaddress
+               ;;
+       zyxel,nwa50ax|\
+       zyxel,nwa55axe)
+               hw_mac_addr="$(mtd_get_mac_binary mrd 0x1fff8)"
+               [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
+               ;;
+       zyxel,wsm20)
+               hw_mac_addr="$(mtd_get_mac_binary Factory 0x1fdfa)"
+               [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
+               ;;
 esac