From db98af34ba599d77fe570d2e9c72fbb04a350066 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 17 Feb 2024 20:58:33 -0800 Subject: [PATCH] ath79: ws-ap3705i: use nvmem Userspace handling is deprecated. Signed-off-by: Rosen Penev --- .../ath79/dts/ar9344_enterasys_ws-ap3705i.dts | 28 +++++++++++++++++-- .../generic/base-files/etc/board.d/02_network | 3 -- .../etc/hotplug.d/firmware/10-ath9k-eeprom | 8 ------ .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 6 ++++ .../base-files/lib/preinit/10_fix_eth_mac.sh | 3 -- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/target/linux/ath79/dts/ar9344_enterasys_ws-ap3705i.dts b/target/linux/ath79/dts/ar9344_enterasys_ws-ap3705i.dts index 0605baa58e7..ad5a3e48c7c 100644 --- a/target/linux/ath79/dts/ar9344_enterasys_ws-ap3705i.dts +++ b/target/linux/ath79/dts/ar9344_enterasys_ws-ap3705i.dts @@ -113,7 +113,9 @@ &wmac { status = "okay"; - qca,no-eeprom; + + nvmem-cells = <&cal_calibrate_1000>; + nvmem-cell-names = "calibration"; }; &spi { @@ -136,9 +138,13 @@ }; partition@80000 { + compatible = "u-boot,env"; label = "u-boot-env0"; reg = <0x80000 0x10000>; read-only; + + macaddr_uboot_ethaddr: ethaddr { + }; }; partition@90000 { @@ -157,6 +163,20 @@ label = "calibrate"; reg = <0x120000 0x10000>; read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + cal_calibrate_1000: calibration@1000 { + reg = <0x1000 0x440>; + }; + + cal_calibrate_5000: calibration@5000 { + reg = <0x5000 0x440>; + }; + }; }; partition@130000 { @@ -196,7 +216,8 @@ ath9k: wifi@0,0 { compatible = "pci168c,0033"; reg = <0x0000 0 0 0 0>; - qca,no-eeprom; + nvmem-cells = <&cal_calibrate_5000>; + nvmem-cell-names = "calibration"; #gpio-cells = <2>; gpio-controller; }; @@ -218,6 +239,9 @@ phy-mode = "rgmii"; phy-handle = <&phy0>; + nvmem-cells = <&macaddr_uboot_ethaddr>; + nvmem-cell-names = "mac-address"; + gmac-config { device = <&gmac>; rgmii-gmac0 = <1>; 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 85debb18775..d46d2663bd9 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 @@ -747,9 +747,6 @@ ath79_setup_macs() ucidef_set_interface "eth0" ifname "eth0" protocol "none" macaddr "$lan_mac" ucidef_set_interface "eth1" ifname "eth1" protocol "none" macaddr "$eth1_mac" ;; - enterasys,ws-ap3705i) - label_mac=$(mtd_get_mac_ascii u-boot-env0 ethaddr) - ;; hak5,lan-turtle|\ hak5,packet-squirrel) label_mac=$(mtd_get_mac_binary u-boot 0x1fc00) diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 95ece068ce0..57f69173e99 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -35,10 +35,6 @@ case "$FIRMWARE" in caldata_extract "art" 0x1000 0x440 ath9k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env athaddr) 1) ;; - enterasys,ws-ap3705i) - caldata_extract "calibrate" 0x1000 0x440 - ath9k_patch_mac $(mtd_get_mac_ascii u-boot-env0 RADIOADDR1) - ;; extreme-networks,ws-ap3805i) caldata_extract "art" 0x1000 0x440 ath9k_patch_mac $(mtd_get_mac_ascii cfg1 RADIOADDR1) @@ -74,10 +70,6 @@ case "$FIRMWARE" in caldata_extract "art" 0x5000 0x440 ath9k_patch_mac $(macaddr_add $(mtd_get_mac_text "mac" 0x18) 1) ;; - enterasys,ws-ap3705i) - caldata_extract "calibrate" 0x5000 0x440 - ath9k_patch_mac $(mtd_get_mac_ascii u-boot-env0 RADIOADDR0) - ;; meraki,mr12) caldata_extract "art" 0x11000 0xeb8 ;; 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 d5cec396649..0a0cfb87ff5 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 @@ -67,6 +67,12 @@ case "$board" in [ "$PHYNBR" -eq 0 ] && \ macaddr_add $(cat /sys/class/net/eth0/address) 1 > /sys${DEVPATH}/macaddress ;; + enterasys,ws-ap3705i) + [ "$PHYNBR" -eq 0 ] && \ + mtd_get_mac_ascii u-boot-env0 RADIOADDR1 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" -eq 1 ] && \ + mtd_get_mac_ascii u-boot-env0 RADIOADDR0 > /sys${DEVPATH}/macaddress + ;; extreme-networks,ws-ap3805i) [ "$PHYNBR" -eq 0 ] && \ mtd_get_mac_ascii cfg1 RADIOADDR0 > /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 41aa43e9869..2d68e02eafd 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 @@ -18,9 +18,6 @@ preinit_set_mac_address() { engenius,esr900) ip link set dev eth0 address $(mtd_get_mac_ascii u-boot-env ethaddr) ;; - enterasys,ws-ap3705i) - ip link set dev eth0 address $(mtd_get_mac_ascii u-boot-env0 ethaddr) - ;; extreme-networks,ws-ap3805i|\ siemens,ws-ap3610) ip link set dev eth0 address $(mtd_get_mac_ascii cfg1 ethaddr)