ath79: calibrate dlink dir-825 c1 and dir-835 a1 with nvmem
authorEdward Chow <equu@openmail.cc>
Mon, 2 Jan 2023 11:24:20 +0000 (19:24 +0800)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 28 Jan 2023 20:28:25 +0000 (21:28 +0100)
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@openmail.cc>
target/linux/ath79/dts/ar9344_dlink_dir-8x5.dtsi
target/linux/ath79/generic/base-files/etc/board.d/02_network
target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom

index 33c75f49675eb4ea4b598afa7c6c3bc7d6fa3734..8e21b0dd9e8ff83b2ca9c8b99dfd99a9ad395c23 100644 (file)
@@ -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>;
 };
        ath9k: wifi@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>;
        };
                                read-only;
                        };
 
-                       partition@fe0000 {
+                       mac: partition@fe0000 {
                                label = "mac";
                                reg = <0xfe0000 0x010000>;
                                read-only;
+
+                               compatible = "nvmem-cells";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+
+                               macaddr_lan: macaddr@4 {
+                                       reg = <0x4 0x11>;
+                               };
+
+                               macaddr_wan: macaddr@18 {
+                                       reg = <0x18 0x11>;
+                               };
                        };
 
-                       partition@ff0000 {
+                       art: partition@ff0000 {
                                label = "art";
                                reg = <0xff0000 0x010000>;
                                read-only;
+
+                               compatible = "nvmem-cells";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+
+                               cal_art_1000: cal@1000 {
+                                       reg = <0x1000 0x440>;
+                               };
+
+                               cal_art_5000: cal@5000 {
+                                       reg = <0x5000 0x440>;
+                               };
                        };
                };
        };
 
 &wmac {
        status = "okay";
-       qca,no-eeprom;
+       nvmem-cells = <&macaddr_lan>, <&cal_art_1000>;
+       nvmem-cell-names = "mac-address-ascii", "calibration";
 };
index 5db3a2d3c4a3fae84cb8955bfd2da28110cba51a..3330cd2b0ae7b638d14b9ce7930c908e62b48de1 100644 (file)
@@ -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|\
index 961f5f46aa0b721581f158d77776d04a31632356..14c8eb7d642053cdd84a9f69c3b781b8f93527fb 100644 (file)
@@ -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)
                ;;