Skip to content

Commit

Permalink
Add led, gpio and wifi mac fix for z8102ax
Browse files Browse the repository at this point in the history
  • Loading branch information
Ysurac committed Feb 7, 2024
1 parent 8479dde commit c1b58b3
Show file tree
Hide file tree
Showing 6 changed files with 326 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ xiaomi,redmi-router-ax6000-stock|\
xiaomi,redmi-router-ax6000-ubootmod)
ucidef_set_led_netdev "wan" "wan" "rgb:network" "wan"
;;
z8102axx)
ucidef_set_led_netdev "4g" "4g" "4g:status" "wwan0"
ucidef_set_led_netdev "4g2" "4g2" "4g2:status" "wwan1"
z8102ax-128m|\
z8102ax-64m)
ucidef_set_led_netdev "modem1" "modem1" "modem1:status" "wwan0"
ucidef_set_led_netdev "modem2" "modem2" "modem2:status" "wwan1"
;;
esac

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
. /lib/functions/uci-defaults.sh

board_config_update

board=$(board_name)

case "$board" in
zbtlink,zbt-z8102ax)
ucidef_add_gpio_switch "5g1" "Power 1st modem" "5g1" "1"
ucidef_add_gpio_switch "5g2" "Power 2nd modem" "5g2" "1"
ucidef_add_gpio_switch "pcie" "Power PCIe port" "pcie" "1"
ucidef_add_gpio_switch "sim1" "SIM 1" "sim1" "1"
ucidef_add_gpio_switch "sim2" "SIM 2" "sim2" "1"
;;
z8102ax-64m|\
z8102ax-128m)
ucidef_add_gpio_switch "modem1" "Power 1st modem" "modem1" "1"
ucidef_add_gpio_switch "modem2" "Power 2nd modem" "modem2" "1"
ucidef_add_gpio_switch "pcie" "Power PCIe port" "pcie" "1"
ucidef_add_gpio_switch "sim1" "SIM 1" "sim1" "1"
ucidef_add_gpio_switch "sim2" "SIM 2" "sim2" "1"
;;
esac

board_config_flush

exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
[ "$ACTION" == "add" ] || exit 0

PHYNBR=${DEVPATH##*/phy}

[ -n $PHYNBR ] || exit 0

. /lib/functions.sh
. /lib/functions/system.sh

board=$(board_name)

case "$board" in
acer,predator-w6)
key_path="/var/qcidata/data"
[ "$PHYNBR" = "0" ] && cat $key_path/2gMAC > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && cat $key_path/6gMAC > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "2" ] && cat $key_path/5gMAC > /sys${DEVPATH}/macaddress
;;
asus,rt-ax59u)
CI_UBIPART="UBI_DEV"
addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
# Originally, phy1 is phy0 mac with LA and 28th bits set. However, this would conflict
# addresses on multiple VIFs with the other radio when bit 28 is already set.
# Set LA and 28 bits and increment mac-address instead.
[ "$PHYNBR" = "1" ] && \
macaddr_setbit_la $(macaddr_setbit $(macaddr_add $addr 1) 28) > \
/sys${DEVPATH}/macaddress
;;
asus,tuf-ax4200|\
asus,tuf-ax6000)
CI_UBIPART="UBI_DEV"
addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
# Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
# addresses on multiple VIFs with the other radio. Set LA bit and increment
# mac-address instead.
[ "$PHYNBR" = "0" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
;;
bananapi,bpi-r3)
addr=$(cat /sys/class/net/eth0/address)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
;;
cetron,ct3003)
addr=$(mtd_get_mac_binary "art" 0)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 2) > /sys${DEVPATH}/macaddress
;;
cmcc,rax3000m)
case "$(cmdline_get_var root)" in
/dev/mmc*)
addr=$(mmc_get_mac_binary factory 0xa)
;;
*)
addr=$(mtd_get_mac_binary factory 0xa)
;;
esac
[ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
;;
cudy,wr3000-v1)
addr=$(mtd_get_mac_binary bdinfo 0xde00)
# Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
# addresses on multiple VIFs with the other radio. Set LA bit and increment
# mac-address instead.
[ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
;;
glinet,gl-mt6000)
addr=$(mmc_get_mac_binary factory 0x04)
[ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
;;
h3c,magic-nx30-pro)
addr=$(mtd_get_mac_ascii pdt_data_1 ethaddr)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
;;
jcg,q30-pro)
# Originally, phy1 is phy0 mac with LA bit set. However, this would conflict
# addresses on multiple VIFs with the other radio. Use label mac to set LA bit.
[ "$PHYNBR" = "1" ] && macaddr_setbit_la $(get_mac_label) > /sys${DEVPATH}/macaddress
;;
mercusys,mr90x-v1)
addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0)
[ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr -1 > /sys${DEVPATH}/macaddress
;;
netgear,wax220)
hw_mac_addr=$(mtd_get_mac_ascii u-boot-env mac)
[ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress
;;
qihoo,360t7)
addr=$(mtd_get_mac_ascii factory lanMac)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
;;
smartrg,sdg-8612|\
smartrg,sdg-8614|\
smartrg,sdg-8622|\
smartrg,sdg-8632)
addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "2" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress
;;
tplink,tl-xdr4288|\
tplink,tl-xdr6086|\
tplink,tl-xdr6088)
[ "$PHYNBR" = "0" ] && get_mac_label > /sys${DEVPATH}/macaddress
;;
ubnt,unifi-6-plus)
addr=$(mtd_get_mac_binary EEPROM 0x6)
[ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
;;
routerich,ax3000|\
zbtlink,zbt-z8102ax|\
z8102ax-128m|\
z8102ax-64m|\
zbtlink,zbt-z8103ax|\
zyxel,ex5601-t0|\
zyxel,ex5601-t0-ubootmod)
addr=$(mtd_get_mac_binary "Factory" 0x4)
[ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
;;
zyxel,nwa50ax-pro)
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
;;
esac
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ xiaomi,redmi-router-ax6000-stock|\
xiaomi,redmi-router-ax6000-ubootmod)
ucidef_set_led_netdev "wan" "wan" "rgb:network" "wan"
;;
z8102axx)
ucidef_set_led_netdev "4g" "4g" "4g:status" "wwan0"
ucidef_set_led_netdev "4g2" "4g2" "4g2:status" "wwan1"
z8102ax-128m|\
z8102ax-64m)
ucidef_set_led_netdev "modem1" "modem1" "modem1:status" "wwan0"
ucidef_set_led_netdev "modem2" "modem2" "modem2:status" "wwan1"
;;
esac

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
. /lib/functions/uci-defaults.sh

board_config_update

board=$(board_name)

case "$board" in
zbtlink,zbt-z8102ax)
ucidef_add_gpio_switch "5g1" "Power 1st modem" "5g1" "1"
ucidef_add_gpio_switch "5g2" "Power 2nd modem" "5g2" "1"
ucidef_add_gpio_switch "pcie" "Power PCIe port" "pcie" "1"
ucidef_add_gpio_switch "sim1" "SIM 1" "sim1" "1"
ucidef_add_gpio_switch "sim2" "SIM 2" "sim2" "1"
;;
z8102ax-64m|\
z8102ax-128m)
ucidef_add_gpio_switch "modem1" "Power 1st modem" "modem1" "1"
ucidef_add_gpio_switch "modem2" "Power 2nd modem" "modem2" "1"
ucidef_add_gpio_switch "pcie" "Power PCIe port" "pcie" "1"
ucidef_add_gpio_switch "sim1" "SIM 1" "sim1" "1"
ucidef_add_gpio_switch "sim2" "SIM 2" "sim2" "1"
;;
esac

board_config_flush

exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
[ "$ACTION" == "add" ] || exit 0

PHYNBR=${DEVPATH##*/phy}

[ -n $PHYNBR ] || exit 0

. /lib/functions.sh
. /lib/functions/system.sh

board=$(board_name)

case "$board" in
acer,predator-w6)
key_path="/var/qcidata/data"
[ "$PHYNBR" = "0" ] && cat $key_path/2gMAC > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && cat $key_path/6gMAC > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "2" ] && cat $key_path/5gMAC > /sys${DEVPATH}/macaddress
;;
asus,rt-ax59u)
CI_UBIPART="UBI_DEV"
addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
# Originally, phy1 is phy0 mac with LA and 28th bits set. However, this would conflict
# addresses on multiple VIFs with the other radio when bit 28 is already set.
# Set LA and 28 bits and increment mac-address instead.
[ "$PHYNBR" = "1" ] && \
macaddr_setbit_la $(macaddr_setbit $(macaddr_add $addr 1) 28) > \
/sys${DEVPATH}/macaddress
;;
asus,tuf-ax4200|\
asus,tuf-ax6000)
CI_UBIPART="UBI_DEV"
addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
# Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
# addresses on multiple VIFs with the other radio. Set LA bit and increment
# mac-address instead.
[ "$PHYNBR" = "0" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
;;
bananapi,bpi-r3)
addr=$(cat /sys/class/net/eth0/address)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
;;
cetron,ct3003)
addr=$(mtd_get_mac_binary "art" 0)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 2) > /sys${DEVPATH}/macaddress
;;
cmcc,rax3000m)
case "$(cmdline_get_var root)" in
/dev/mmc*)
addr=$(mmc_get_mac_binary factory 0xa)
;;
*)
addr=$(mtd_get_mac_binary factory 0xa)
;;
esac
[ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
;;
cudy,wr3000-v1)
addr=$(mtd_get_mac_binary bdinfo 0xde00)
# Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
# addresses on multiple VIFs with the other radio. Set LA bit and increment
# mac-address instead.
[ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
;;
glinet,gl-mt6000)
addr=$(mmc_get_mac_binary factory 0x04)
[ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
;;
h3c,magic-nx30-pro)
addr=$(mtd_get_mac_ascii pdt_data_1 ethaddr)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
;;
jcg,q30-pro)
# Originally, phy1 is phy0 mac with LA bit set. However, this would conflict
# addresses on multiple VIFs with the other radio. Use label mac to set LA bit.
[ "$PHYNBR" = "1" ] && macaddr_setbit_la $(get_mac_label) > /sys${DEVPATH}/macaddress
;;
mercusys,mr90x-v1)
addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0)
[ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr -1 > /sys${DEVPATH}/macaddress
;;
netgear,wax220)
hw_mac_addr=$(mtd_get_mac_ascii u-boot-env mac)
[ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress
;;
qihoo,360t7)
addr=$(mtd_get_mac_ascii factory lanMac)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
;;
smartrg,sdg-8612|\
smartrg,sdg-8614|\
smartrg,sdg-8622|\
smartrg,sdg-8632)
addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "2" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress
;;
tplink,tl-xdr4288|\
tplink,tl-xdr6086|\
tplink,tl-xdr6088)
[ "$PHYNBR" = "0" ] && get_mac_label > /sys${DEVPATH}/macaddress
;;
ubnt,unifi-6-plus)
addr=$(mtd_get_mac_binary EEPROM 0x6)
[ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
;;
routerich,ax3000|\
zbtlink,zbt-z8102ax|\
z8102ax-128m|\
z8102ax-64m|\
zbtlink,zbt-z8103ax|\
zyxel,ex5601-t0|\
zyxel,ex5601-t0-ubootmod)
addr=$(mtd_get_mac_binary "Factory" 0x4)
[ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
;;
zyxel,nwa50ax-pro)
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
;;
esac

0 comments on commit c1b58b3

Please sign in to comment.