From 8239dd635a45e8b3ca858bd9591f18065e72ab29 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 16 Dec 2024 16:55:55 -0800 Subject: [PATCH] lantiq: use nvmem for bthomehub v5a Userspace handling of both calibration and mac addresses is deprecated. Also fixed calibration size for ath9k. AR9287 uses 3d8 for its size. Signed-off-by: Rosen Penev --- .../boot/dts/lantiq/vr9_bt_homehub-v5a.dts | 46 ++++++++++++++++++- .../xrx200/base-files/etc/board.d/02_network | 4 -- .../etc/hotplug.d/firmware/11-ath10k-caldata | 20 -------- .../etc/hotplug.d/firmware/12-ath9k-eeprom | 4 -- target/linux/lantiq/xrx200/config-6.6 | 1 + 5 files changed, 45 insertions(+), 30 deletions(-) delete mode 100644 target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/11-ath10k-caldata diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_bt_homehub-v5a.dts b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_bt_homehub-v5a.dts index cb6cb74af82..1d7aee8dd8f 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_bt_homehub-v5a.dts +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_bt_homehub-v5a.dts @@ -154,6 +154,8 @@ &gswip { pinctrl-0 = <&mdio_pins>; pinctrl-names = "default"; + nvmem-cells = <&macaddr_caldata_110c 0>; + nvmem-cell-names = "mac-address"; }; &gswip_mdio { @@ -210,6 +212,9 @@ tx-internal-delay-ps = <1500>; rx-internal-delay-ps = <1500>; phy-handle = <&phy5>; + + nvmem-cells = <&macaddr_caldata_110c 1>; + nvmem-cell-names = "mac-address"; }; }; @@ -248,8 +253,35 @@ reg = <0xc0000 0x40000>; }; partition@100000 { + compatible = "linux,ubi"; label = "ubi"; reg = <0x100000 0x7e80000>; + + volumes { + ubi-volume-caldata { + volname = "caldata"; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + cal_caldata_1000: calibration@1000 { + reg = <0x1000 0x3d8>; + }; + + macaddr_caldata_110c: macaddr@110c { + compatible = "mac-base"; + reg = <0x110c 0x6>; + #nvmem-cell-cells = <1>; + }; + + cal_caldata_5000: calibration@5000 { + reg = <0x5000 0x844>; + }; + }; + }; + }; }; /* * last 512 KiB are for the bad block table, not writable @@ -262,14 +294,24 @@ status = "okay"; reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>; - wifi@168c,002d { + wifi@0,0 { compatible = "pci168c,002d"; reg = <0x7000 0 0 0 0>; - qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */ + nvmem-cells = <&cal_caldata_1000>, <&macaddr_caldata_110c 2>; + nvmem-cell-names = "calibration", "mac-address"; ieee80211-freq-limit = <2402000 2482000>; }; }; +&pcie0 { + wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0x7000 0 0 0 0>; + nvmem-cells = <&cal_caldata_5000>, <&macaddr_caldata_110c 3>; + nvmem-cell-names = "calibration", "mac-address"; + }; +}; + &usb_phy0 { status = "okay"; }; diff --git a/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network b/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network index 6c35c7a4deb..8cf64e6ccc1 100644 --- a/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network +++ b/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network @@ -128,10 +128,6 @@ lantiq_setup_macs() lan_mac=$(/usr/bin/fritz_tffs_nand -d $tffsdev -n maca -o) wan_mac=$(/usr/bin/fritz_tffs_nand -d $tffsdev -n macdsl -o) ;; - bt,homehub-v5a) - lan_mac=$(mtd_get_mac_binary_ubi caldata 0x110c) - wan_mac=$(macaddr_add "$lan_mac" 1) - ;; buffalo,wbmr-300hpd) lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr) wan_mac="$lan_mac" diff --git a/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/11-ath10k-caldata deleted file mode 100644 index c555aa2c12c..00000000000 --- a/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -[ -e /lib/firmware/$FIRMWARE ] && exit 0 - -. /lib/functions/caldata.sh - -case "$FIRMWARE" in -"ath10k/cal-pci-0000:02:00.0.bin") - board=$(board_name) - case $board in - bt,homehub-v5a) - caldata_extract_ubi "caldata" 0x5000 0x844 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) 3) - ;; - *) - caldata_die "board $board is not supported yet" - ;; - esac - ;; -esac diff --git a/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom index 164e2d39caa..94be5bf49fe 100644 --- a/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom +++ b/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom @@ -27,10 +27,6 @@ case "$FIRMWARE" in /usr/bin/fritz_cal_extract -i 1 -s 0x1e000 -e 0x207 -l 5120 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader") || \ /usr/bin/fritz_cal_extract -i 1 -s 0x1e800 -e 0x207 -l 5120 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader") ;; - bt,homehub-v5a) - caldata_extract_ubi "caldata" 0x1000 0x1000 - ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) 2) 0x10c - ;; *) caldata_die "board $board is not supported yet" ;; diff --git a/target/linux/lantiq/xrx200/config-6.6 b/target/linux/lantiq/xrx200/config-6.6 index 4819c962c86..861f5b77da2 100644 --- a/target/linux/lantiq/xrx200/config-6.6 +++ b/target/linux/lantiq/xrx200/config-6.6 @@ -46,6 +46,7 @@ CONFIG_MTD_RAW_NAND=y CONFIG_MTD_UBI=y CONFIG_MTD_UBI_BEB_LIMIT=20 CONFIG_MTD_UBI_BLOCK=y +CONFIG_MTD_UBI_NVMEM=y CONFIG_MTD_UBI_WL_THRESHOLD=4096 CONFIG_NEED_SRCU_NMI_SAFE=y CONFIG_NET_DEVLINK=y