From 91966bee336749780317927a633be7e010f69d97 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 15 Jun 2024 14:23:02 -0700 Subject: [PATCH] ath79: nbg6x16: use nvmem Userspace handling is deprecated. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/16291 Signed-off-by: Hauke Mehrtens --- .../linux/ath79/dts/qca9557_zyxel_nbg6616.dts | 10 +++++++-- .../linux/ath79/dts/qca9558_zyxel_nbg6716.dts | 10 +++++++-- .../ath79/dts/qca955x_zyxel_nbg6x16.dtsi | 10 +++++++-- .../generic/base-files/etc/board.d/02_network | 3 --- .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 8 +------ .../base-files/lib/preinit/10_fix_eth_mac.sh | 5 ----- .../etc/hotplug.d/ieee80211/10-fix-wifi-mac | 21 ------------------- .../base-files/lib/preinit/10_fix_eth_mac.sh | 15 ------------- target/linux/ath79/nand/config-default | 1 + 9 files changed, 26 insertions(+), 57 deletions(-) delete mode 100644 target/linux/ath79/nand/base-files/etc/hotplug.d/ieee80211/10-fix-wifi-mac delete mode 100644 target/linux/ath79/nand/base-files/lib/preinit/10_fix_eth_mac.sh diff --git a/target/linux/ath79/dts/qca9557_zyxel_nbg6616.dts b/target/linux/ath79/dts/qca9557_zyxel_nbg6616.dts index 828096f8f6..1c4e9efca0 100644 --- a/target/linux/ath79/dts/qca9557_zyxel_nbg6616.dts +++ b/target/linux/ath79/dts/qca9557_zyxel_nbg6616.dts @@ -9,6 +9,7 @@ model = "Zyxel NBG6616"; aliases { + label-mac-device = &wmac; led-boot = &led_power; led-failsafe = &led_power; led-running = &led_power; @@ -82,8 +83,13 @@ }; partition@30000 { + compatible = "u-boot,env"; label = "u-boot-env"; reg = <0x030000 0x010000>; + + macaddr_uboot_ethaddr: ethaddr { + #nvmem-cell-cells = <1>; + }; }; partition@40000 { @@ -136,7 +142,7 @@ wifi@0,0 { compatible = "qcom,ath10k"; reg = <0 0 0 0 0>; - nvmem-cells = <&cal_art_5000>; - nvmem-cell-names = "calibration"; + nvmem-cells = <&cal_art_5000>, <&macaddr_uboot_ethaddr 1>; + nvmem-cell-names = "calibration", "mac-address"; }; }; diff --git a/target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts b/target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts index 463553fe27..67d2f77d38 100644 --- a/target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts +++ b/target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts @@ -9,6 +9,7 @@ model = "Zyxel NBG6716"; aliases { + label-mac-device = &wmac; led-boot = &led_power; led-failsafe = &led_power; led-running = &led_power; @@ -103,8 +104,13 @@ }; partition@40000 { + compatible = "u-boot,env"; label = "u-boot-env"; reg = <0x040000 0x010000>; + + macaddr_uboot_ethaddr: ethaddr { + #nvmem-cell-cells = <1>; + }; }; partition@50000 { @@ -185,8 +191,8 @@ wifi@0,0 { compatible = "qcom,ath10k"; reg = <0 0 0 0 0>; - nvmem-cells = <&cal_art_5000>; - nvmem-cell-names = "calibration"; + nvmem-cells = <&cal_art_5000>, <&macaddr_uboot_ethaddr 1>; + nvmem-cell-names = "calibration", "mac-address"; qcom,ath10k-calibration-variant = "ZyXEL-NBG6716"; }; }; diff --git a/target/linux/ath79/dts/qca955x_zyxel_nbg6x16.dtsi b/target/linux/ath79/dts/qca955x_zyxel_nbg6x16.dtsi index 3cbb305aad..99f61afbc0 100644 --- a/target/linux/ath79/dts/qca955x_zyxel_nbg6x16.dtsi +++ b/target/linux/ath79/dts/qca955x_zyxel_nbg6x16.dtsi @@ -82,6 +82,9 @@ pll-data = <0xa6000000 0x00000101 0x00001616>; phy-handle = <&phy17>; + nvmem-cells = <&macaddr_uboot_ethaddr 2>; + nvmem-cell-names = "mac-address"; + fixed-link { speed = <1000>; full-duplex; @@ -94,6 +97,9 @@ pll-data = <0x03000101 0x00000101 0x00001616>; phy-handle = <&phy1>; + nvmem-cells = <&macaddr_uboot_ethaddr 3>; + nvmem-cell-names = "mac-address"; + fixed-link { speed = <1000>; full-duplex; @@ -103,8 +109,8 @@ &wmac { status = "okay"; - nvmem-cells = <&cal_art_1000>; - nvmem-cell-names = "calibration"; + nvmem-cells = <&cal_art_1000>, <&macaddr_uboot_ethaddr 0>; + nvmem-cell-names = "calibration", "mac-address"; }; &usb_phy0 { diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index 42910d436e..ad0365a465 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -861,9 +861,6 @@ ath79_setup_macs() xiaomi,aiot-ac2350) lan_mac=$(mtd_get_mac_binary art 0x1002) ;; - zyxel,nbg6616) - label_mac=$(mtd_get_mac_ascii u-boot-env ethaddr) - ;; esac [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index b10599cc15..4dfc67e280 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -75,8 +75,7 @@ case "$board" in iodata,wn-ac1600dgr|\ iodata,wn-ac1600dgr2|\ sitecom,wlr-7100|\ - sitecom,wlr-8100|\ - zyxel,nbg6616) + sitecom,wlr-8100) # There is no eeprom data for 5 GHz wlan in "art" partition # which would allow to patch the macaddress [ "$PHYNBR" -eq 0 ] && \ @@ -121,11 +120,6 @@ case "$board" in [ "$PHYNBR" -eq 0 ] && \ macaddr_add "$(mtd_get_mac_text mac 0x18)" 1 > /sys${DEVPATH}/macaddress ;; - zyxel,nbg6616) - # Set mac address for 2.4g device - [ "$PHYNBR" -eq 1 ] && \ - mtd_get_mac_ascii u-boot-env ethaddr > /sys${DEVPATH}/macaddress - ;; zyxel,nwa1123-ac) [ "$PHYNBR" -eq 0 ] && \ mtd_get_mac_text mib0 0x66 > /sys${DEVPATH}/macaddress diff --git a/target/linux/ath79/generic/base-files/lib/preinit/10_fix_eth_mac.sh b/target/linux/ath79/generic/base-files/lib/preinit/10_fix_eth_mac.sh index 76f4b93a35..41aa43e986 100644 --- a/target/linux/ath79/generic/base-files/lib/preinit/10_fix_eth_mac.sh +++ b/target/linux/ath79/generic/base-files/lib/preinit/10_fix_eth_mac.sh @@ -32,11 +32,6 @@ preinit_set_mac_address() { base_mac=$(mtd_get_mac_encrypted_deco $(find_mtd_part config)) ip link set dev eth0 address $base_mac ;; - zyxel,nbg6616) - ethaddr=$(mtd_get_mac_ascii u-boot-env ethaddr) - ip link set dev eth0 address $(macaddr_add $ethaddr 2) - ip link set dev eth1 address $(macaddr_add $ethaddr 3) - ;; esac } diff --git a/target/linux/ath79/nand/base-files/etc/hotplug.d/ieee80211/10-fix-wifi-mac b/target/linux/ath79/nand/base-files/etc/hotplug.d/ieee80211/10-fix-wifi-mac deleted file mode 100644 index 989791b64f..0000000000 --- a/target/linux/ath79/nand/base-files/etc/hotplug.d/ieee80211/10-fix-wifi-mac +++ /dev/null @@ -1,21 +0,0 @@ -[ "$ACTION" = "add" ] || exit 0 - -PHYNBR=${DEVPATH##*/phy} - -[ -n $PHYNBR ] || exit 0 - -. /lib/functions.sh -. /lib/functions/system.sh - -board=$(board_name) - -case $board in - zyxel,emg2926-q10a|\ - zyxel,nbg6716) - ethaddr=$(mtd_get_mac_ascii u-boot-env ethaddr) - [ "$PHYNBR" -eq 0 ] && \ - macaddr_add $ethaddr 1 > /sys${DEVPATH}/macaddress - [ "$PHYNBR" -eq 1 ] && \ - echo -n $ethaddr > /sys${DEVPATH}/macaddress - ;; -esac diff --git a/target/linux/ath79/nand/base-files/lib/preinit/10_fix_eth_mac.sh b/target/linux/ath79/nand/base-files/lib/preinit/10_fix_eth_mac.sh deleted file mode 100644 index 4e501496be..0000000000 --- a/target/linux/ath79/nand/base-files/lib/preinit/10_fix_eth_mac.sh +++ /dev/null @@ -1,15 +0,0 @@ -. /lib/functions.sh -. /lib/functions/system.sh - -preinit_set_mac_address() { - case $(board_name) in - zyxel,emg2926-q10a|\ - zyxel,nbg6716) - ethaddr=$(mtd_get_mac_ascii u-boot-env ethaddr) - ip link set dev eth0 address $(macaddr_add $ethaddr 2) - ip link set dev eth1 address $(macaddr_add $ethaddr 3) - ;; - esac -} - -boot_hook_add preinit_main preinit_set_mac_address diff --git a/target/linux/ath79/nand/config-default b/target/linux/ath79/nand/config-default index 71ce1caad7..bbe9673d70 100644 --- a/target/linux/ath79/nand/config-default +++ b/target/linux/ath79/nand/config-default @@ -17,6 +17,7 @@ CONFIG_MTD_UBI=y CONFIG_MTD_UBI_BEB_LIMIT=20 CONFIG_MTD_UBI_BLOCK=y CONFIG_MTD_UBI_WL_THRESHOLD=4096 +CONFIG_NVMEM_U_BOOT_ENV=y # CONFIG_PCI_AR71XX is not set CONFIG_POWER_RESET=y CONFIG_POWER_RESET_GPIO_RESTART=y -- 2.30.2