ath79: convert ath10k calibration data to NVMEM (ASCII MAC)
authorShiji Yang <yangshiji66@qq.com>
Thu, 1 Feb 2024 11:39:51 +0000 (19:39 +0800)
committerChristian Marangi <ansuelsmth@gmail.com>
Thu, 1 Feb 2024 16:09:03 +0000 (17:09 +0100)
This patch converts ath10k calibration data to NVMEM format for
wave 1 devices with mtd ASCII MAC address. The "calibration"
NVMEM cell size is 0x844. All unportable MAC address settings
have been moved to '10_fix_wifi_mac' scripts.

Signed-off-by: Shiji Yang <yangshiji66@qq.com>
15 files changed:
target/linux/ath79/dts/ar1022_sitecom_wlr-7100.dts
target/linux/ath79/dts/ar9344_qihoo_c301.dts
target/linux/ath79/dts/qca9531_engenius_ews511ap.dts
target/linux/ath79/dts/qca9557_extreme-networks_ws-ap3805i.dts
target/linux/ath79/dts/qca9557_iodata_wn-ac-dgr.dtsi
target/linux/ath79/dts/qca9557_iodata_wn-ac1600dgr.dts
target/linux/ath79/dts/qca9557_zyxel_nbg6616.dts
target/linux/ath79/dts/qca9558_sitecom_wlr-8100.dts
target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts
target/linux/ath79/dts/qca955x_engenius_ecb1xxx.dtsi
target/linux/ath79/dts/qca9563_nec_wg800hp.dts
target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/11-ath10k-caldata [deleted file]
target/linux/ath79/nand/base-files/etc/hotplug.d/ieee80211/10-fix-wifi-mac

index e2ccef105d6fb6e3815a120f4924f18db0d73042..b45d6bd77f394609a8a92d5a26a8731cc55df943 100644 (file)
@@ -93,6 +93,8 @@
        wifi@0,0 {
                compatible = "qcom,ath10k";
                reg = <0x0000 0 0 0 0>;
+               nvmem-cells = <&cal_art_5000>;
+               nvmem-cell-names = "calibration";
        };
 };
 
                                label = "art";
                                reg = <0x7f0000 0x010000>;
                                read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       cal_art_5000: calibration@5000 {
+                                               reg = <0x5000 0x844>;
+                                       };
+                               };
                        };
                };
        };
index d7e2e242394bac4eaf6f2f1c924c4b84e1188492..8241c21dd07fda3396775e3a8590e1abeaa171ac 100644 (file)
                                label = "radiocfg";
                                reg = <0xff0000 0x10000>;
                                read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       cal_radiocfg_5000: calibration@5000 {
+                                               reg = <0x5000 0x844>;
+                                       };
+                               };
                        };
                };
        };
        wifi@0,0 {
                compatible = "qcom,ath10k";
                reg = <0 0 0 0 0>;
+               nvmem-cells = <&cal_radiocfg_5000>;
+               nvmem-cell-names = "calibration";
        };
 };
 
index 6fd28d5b3637b09f4810b7c8fce61dd2dc3d8024..07b0655e354a9e8ebfcfccce207b48187514d605 100644 (file)
 
 &pcie0 {
        status = "okay";
+
+       wifi@0,0 {
+               compatible = "qcom,ath10k";
+               reg = <0x0000 0 0 0 0>;
+               nvmem-cells = <&cal_art_5000>;
+               nvmem-cell-names = "calibration";
+       };
 };
 
 &spi {
                                label = "art";
                                reg = <0x050000 0x010000>;
                                read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       cal_art_5000: calibration@5000 {
+                                               reg = <0x5000 0x844>;
+                                       };
+                               };
                        };
 
                        partition@60000 {
index 4a68f530751d8f6ac343d70e1ee65858c058faf2..686a4745175f7291a1fe03b59f6c6a5f064d0423 100644 (file)
@@ -78,6 +78,8 @@
        wifi@0,0 {
                compatible = "qcom,ath10k";
                reg = <0x0 0 0 0 0>;
+               nvmem-cells = <&cal_art_5000>;
+               nvmem-cell-names = "calibration";
        };
 };
 
                                label = "art";
                                reg = <0x3fc0000 0x40000>;
                                read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       cal_art_5000: calibration@5000 {
+                                               reg = <0x5000 0x844>;
+                                       };
+                               };
                        };
                };
        };
index 204a63cda8ddcf48ce02791e15bb5c78688dfcd0..76932be64a20552be13a64d6ea7aea392badf060 100644 (file)
                                label = "art";
                                reg = <0xff0000 0x010000>;
                                read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       cal_art_5000: calibration@5000 {
+                                               reg = <0x5000 0x844>;
+                                       };
+                               };
                        };
                };
        };
        wifi@0,0 {
                compatible = "pci168c,003c";
                reg = <0x0000 0 0 0 0>;
+               nvmem-cells = <&cal_art_5000>;
+               nvmem-cell-names = "calibration";
        };
 };
 
index 1e7d92db3fe22c0650d4fa2fa4165053d2a2be36..934422f5714e1e33950def67eb023e8d40e92138 100644 (file)
                debounce-interval = <60>;
        };
 };
+
+&pcie1 {
+       wifi@0,0 {
+               /delete-property/ nvmem-cells;
+               /delete-property/ nvmem-cell-names;
+       };
+};
index fff23dcf2ba95e92916319b27a580140ce1defa3..25b36e50be31ea4e9d32e787779b410f9e949bda 100644 (file)
                                label = "art";
                                reg = <0x040000 0x010000>;
                                read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       cal_art_5000: calibration@5000 {
+                                               reg = <0x5000 0x844>;
+                                       };
+                               };
                        };
 
                        partition@50000 {
        wifi@0,0 {
                compatible = "qcom,ath10k";
                reg = <0 0 0 0 0>;
-               qca,no-eeprom;
+               nvmem-cells = <&cal_art_5000>;
+               nvmem-cell-names = "calibration";
        };
 };
index 01a69fce15de0a84bc306a28f2914c3d68b34a86..ba7feeab5a17af7b67dca2938e2d031d4267c862 100644 (file)
                                label = "art";
                                reg = <0xff0000 0x010000>;
                                read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       cal_art_5000: calibration@5000 {
+                                               reg = <0x5000 0x844>;
+                                       };
+                               };
                        };
                };
        };
        wifi@0,0 {
                compatible = "qcom,ath10k";
                reg = <0 0 0 0 0>;
+               nvmem-cells = <&cal_art_5000>;
+               nvmem-cell-names = "calibration";
        };
 };
 
index 20230e684e3a3c4fb56f74fb22ccda5437a59d09..27341a88e67b12b0c92596b54cec51e33c441fb8 100644 (file)
                                label = "art";
                                reg = <0x050000 0x010000>;
                                read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       cal_art_5000: calibration@5000 {
+                                               reg = <0x5000 0x844>;
+                                       };
+                               };
                        };
 
                        partition@60000 {
        wifi@0,0 {
                compatible = "qcom,ath10k";
                reg = <0 0 0 0 0>;
+               nvmem-cells = <&cal_art_5000>;
+               nvmem-cell-names = "calibration";
                qcom,ath10k-calibration-variant = "ZyXEL-NBG6716";
        };
 };
index 66f2e388534bb8f1852ccfb1b6cff524239d14bc..9d591bd6b3638524bde5debede948c760f390610 100644 (file)
                                label = "art";
                                reg = <0xff0000 0x010000>;
                                read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       cal_art_5000: calibration@5000 {
+                                               reg = <0x5000 0x844>;
+                                       };
+                               };
                        };
                };
        };
        wifi@0,0 {
                compatible = "qcom,ath10k";
                reg = <0x0 0 0 0 0>;
-               qca,no-eeprom;
+               nvmem-cells = <&cal_art_5000>;
+               nvmem-cell-names = "calibration";
        };
 };
 
index 1069a63a5e052b6c9be4d96c23b462dbdc1f3b19..a7390573cd642f1758194c92760b4d5626851d2c 100644 (file)
                                label = "board_data";
                                reg = <0x7e0000 0x010000>;
                                read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       macaddr_board_data_880: macaddr@880 {
+                                               compatible = "mac-base";
+                                               reg = <0x880 0x11>;
+                                               #nvmem-cell-cells = <1>;
+                                       };
+                               };
                        };
 
                        art: partition@7f0000 {
                                label = "art";
                                reg = <0x7f0000 0x010000>;
                                read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       cal_art_5000: calibration@5000 {
+                                               reg = <0x5000 0x844>;
+                                       };
+                               };
                        };
                };
        };
 
 &pcie {
        status = "okay";
+
+       wifi@0,0 {
+               compatible = "qcom,ath10k";
+               reg = <0x0000 0 0 0 0>;
+               nvmem-cells = <&cal_art_5000>, <&macaddr_board_data_880 0>;
+               nvmem-cell-names = "calibration", "mac-address";
+       };
 };
 
 &wmac {
index 02cc293a6e831e7dc3452f651ffd7cbf3017f2e7..19b02a5905238a68996d1bd74d7ce64ce9169c5e 100644 (file)
@@ -7,46 +7,6 @@
 board=$(board_name)
 
 case "$FIRMWARE" in
-"ath10k/cal-pci-0000:00:00.0.bin")
-       case $board in
-       engenius,ecb1200|\
-       engenius,ecb1750)
-               caldata_extract "art" 0x5000 0x844
-               ath10k_patch_mac $(mtd_get_mac_ascii u-boot-env athaddr)
-               ;;
-       engenius,ews511ap)
-               caldata_extract "art" 0x5000 0x844
-               ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) 1)
-               ;;
-       extreme-networks,ws-ap3805i)
-               caldata_extract "art" 0x5000 0x844
-               ath10k_patch_mac $(mtd_get_mac_ascii cfg1 RADIOADDR0)
-               ;;
-       iodata,wn-ac1167dgr|\
-       iodata,wn-ac1600dgr2|\
-       sitecom,wlr-7100|\
-       zyxel,nbg6616)
-               caldata_extract "art" 0x5000 0x844
-               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) 1)
-               ;;
-       nec,wg800hp)
-               caldata_extract "art" 0x5000 0x844
-               ath10k_patch_mac $(mtd_get_mac_text board_data 0x880)
-               ;;
-       qihoo,c301)
-               caldata_extract "radiocfg" 0x5000 0x844
-               ath10k_patch_mac $(mtd_get_mac_ascii devdata wlan5mac)
-               ;;
-       esac
-       ;;
-"ath10k/cal-pci-0000:01:00.0.bin")
-       case $board in
-       sitecom,wlr-8100)
-               caldata_extract "art" 0x5000 0x844
-               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) 1)
-               ;;
-       esac
-       ;;
 "ath10k/pre-cal-pci-0000:00:00.0.bin")
        case $board in
        dlink,dir-842-c1|\
index d3392aa61e71507a5a8fa645ebb611ebdaaf19ff..1a845a4ed717fb539724621fa2a9984178c0b93c 100644 (file)
@@ -41,13 +41,31 @@ case "$board" in
                [ "$PHYNBR" -eq 1 ] && \
                        mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
                ;;
+       engenius,ecb1200|\
+       engenius,ecb1750)
+               [ "$PHYNBR" -eq 0 ] && \
+               mtd_get_mac_ascii u-boot-env ethaddr > /sys${DEVPATH}/macaddress
+               ;;
        engenius,epg5000|\
        engenius,esr1200|\
        engenius,esr1750|\
        engenius,esr900)
                macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" "$PHYNBR" > /sys${DEVPATH}/macaddress
                ;;
-       iodata,wn-ac1600dgr)
+       engenius,ews511ap)
+               [ "$PHYNBR" -eq 0 ] && \
+               macaddr_add $(cat /sys/class/net/eth0/address) 1 > /sys${DEVPATH}/macaddress
+               ;;
+       extreme-networks,ws-ap3805i)
+               [ "$PHYNBR" -eq 0 ] && \
+               mtd_get_mac_ascii cfg1 RADIOADDR0 > /sys${DEVPATH}/macaddress
+               ;;
+       iodata,wn-ac1167dgr|\
+       iodata,wn-ac1600dgr|\
+       iodata,wn-ac1600dgr2|\
+       sitecom,wlr-7100|\
+       sitecom,wlr-8100|\
+       zyxel,nbg6616)
                # There is no eeprom data for 5 GHz wlan in "art" partition
                # which would allow to patch the macaddress
                [ "$PHYNBR" -eq 0 ] && \
@@ -60,7 +78,8 @@ case "$board" in
                        macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
                ;;
        nec,wf1200cr|\
-       nec,wg1200cr)
+       nec,wg1200cr|\
+       qihoo,c301)
                [ "$PHYNBR" -eq 0 ] && \
                        mtd_get_mac_ascii devdata wlan5mac > /sys${DEVPATH}/macaddress
                ;;
diff --git a/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
deleted file mode 100644 (file)
index c85a134..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-[ -e /lib/firmware/$FIRMWARE ] && exit 0
-
-. /lib/functions/caldata.sh
-
-board=$(board_name)
-
-case "$FIRMWARE" in
-"ath10k/cal-pci-0000:00:00.0.bin")
-       case $board in
-       zyxel,emg2926-q10a|\
-       zyxel,nbg6716)
-               caldata_extract "art" 0x5000 0x844
-               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) 1)
-               ;;
-       esac
-       ;;
-*)
-       exit 1
-       ;;
-esac
index 20974248c16743aa614d1384a05ed6d701abb303..5a933df501a7abad9528ce3ff775ef85944d82af 100644 (file)
@@ -17,8 +17,10 @@ case $board in
                ;;
        zyxel,emg2926-q10a|\
        zyxel,nbg6716)
-               # Set mac address for 2.4g device
+               ethaddr=$(mtd_get_mac_ascii u-boot-env ethaddr)
+               [ "$PHYNBR" -eq 0 ] && \
+                       macaddr_add $ethaddr 1 > /sys${DEVPATH}/macaddress
                [ "$PHYNBR" -eq 1 ] && \
-                       mtd_get_mac_ascii u-boot-env ethaddr > /sys${DEVPATH}/macaddress
+                       echo -n $ethaddr > /sys${DEVPATH}/macaddress
                ;;
 esac