[openwrt/openwrt] ath79: calibrate dlink dir-825 c1 and dir-835 a1 with nvmem

LEDE Commits lede-commits at lists.infradead.org
Sat Jan 28 12:30:52 PST 2023


hauke pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/2a20dc717a897efe54f241636ee1566b695dbc7d

commit 2a20dc717a897efe54f241636ee1566b695dbc7d
Author: Edward Chow <equu at openmail.cc>
AuthorDate: Mon Jan 2 19:24:20 2023 +0800

    ath79: calibrate dlink dir-825 c1 and dir-835 a1 with nvmem
    
    Driver for both soc (2.4GHz Wifi) and pci (5 GHz) now pull the calibration
    data from the nvmem subsystem.
    
    This allows us to move the userspace caldata extraction for the pci-e ath9k
    supported wifi into the device-tree definition of the device.
    
    Currently, "mac-address-ascii" cells only works for ethernet and wmac devices,
    so PCI ath9k device uses the old method to calibrate.
    
    Signed-off-by: Edward Chow <equu at openmail.cc>
---
 target/linux/ath79/dts/ar9344_dlink_dir-8x5.dtsi   | 42 +++++++++++++++++++---
 .../generic/base-files/etc/board.d/02_network      |  1 -
 .../etc/hotplug.d/firmware/10-ath9k-eeprom         |  4 +--
 3 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/target/linux/ath79/dts/ar9344_dlink_dir-8x5.dtsi b/target/linux/ath79/dts/ar9344_dlink_dir-8x5.dtsi
index 33c75f4967..8e21b0dd9e 100644
--- a/target/linux/ath79/dts/ar9344_dlink_dir-8x5.dtsi
+++ b/target/linux/ath79/dts/ar9344_dlink_dir-8x5.dtsi
@@ -29,6 +29,9 @@
 	/* default for ar934x, except for 1000M */
 	pll-data = <0x06000000 0x00000101 0x00001616>;
 
+	nvmem-cells = <&macaddr_lan>;
+	nvmem-cell-names = "mac-address-ascii";
+
 	phy-mode = "rgmii";
 	phy-handle = <&phy0>;
 };
@@ -55,7 +58,13 @@
 	ath9k: wifi at 0,0 {
 		compatible = "pci168c,0030";
 		reg = <0x0000 0 0 0 0>;
-		qca,no-eeprom;
+		/* "mac-address-ascii" currently does not work for
+		   ath9k pci devices. these below are retained for future
+		   improvements. */
+		/* nvmem-cells = <&macaddr_wan>, <&cal_art_5000>;
+		   nvmem-cell-names = "mac-address-ascii", "calibration";
+		   mac-address-increment = <1>; */
+		qca,no-eeprom; /* remove this when "mac-address-ascii" works  */
 		gpio-controller;
 		#gpio-cells = <2>;
 	};
@@ -102,16 +111,40 @@
 				read-only;
 			};
 
-			partition at fe0000 {
+			mac: partition at fe0000 {
 				label = "mac";
 				reg = <0xfe0000 0x010000>;
 				read-only;
+
+				compatible = "nvmem-cells";
+				#address-cells = <1>;
+				#size-cells = <1>;
+
+				macaddr_lan: macaddr at 4 {
+					reg = <0x4 0x11>;
+				};
+
+				macaddr_wan: macaddr at 18 {
+					reg = <0x18 0x11>;
+				};
 			};
 
-			partition at ff0000 {
+			art: partition at ff0000 {
 				label = "art";
 				reg = <0xff0000 0x010000>;
 				read-only;
+
+				compatible = "nvmem-cells";
+				#address-cells = <1>;
+				#size-cells = <1>;
+
+				cal_art_1000: cal at 1000 {
+					reg = <0x1000 0x440>;
+				};
+
+				cal_art_5000: cal at 5000 {
+					reg = <0x5000 0x440>;
+				};
 			};
 		};
 	};
@@ -127,5 +160,6 @@
 
 &wmac {
 	status = "okay";
-	qca,no-eeprom;
+	nvmem-cells = <&macaddr_lan>, <&cal_art_1000>;
+	nvmem-cell-names = "mac-address-ascii", "calibration";
 };
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 5db3a2d3c4..3330cd2b0a 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
@@ -639,7 +639,6 @@ ath79_setup_macs()
 		;;
 	dlink,dir-825-c1|\
 	dlink,dir-835-a1)
-		lan_mac=$(mtd_get_mac_text "mac" 0x4)
 		wan_mac=$(mtd_get_mac_text "mac" 0x18)
 		;;
 	dlink,dir-842-c1|\
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 961f5f46aa..14c8eb7d64 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
@@ -23,9 +23,7 @@ case "$FIRMWARE" in
 	avm,fritzdvbc)
 		caldata_extract_reverse "urlader" 0x1541 0x440
 		;;
-	dlink,dir-505|\
-	dlink,dir-825-c1|\
-	dlink,dir-835-a1)
+	dlink,dir-505)
 		caldata_extract "art" 0x1000 0x440
 		ath9k_patch_mac $(mtd_get_mac_text "mac" 0x4)
 		;;




More information about the lede-commits mailing list