ipq40xx: utilize nvmem-cells for openmesh,a62
authorSven Eckelmann <sven@narfation.org>
Tue, 25 Oct 2022 07:12:16 +0000 (09:12 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 12 Nov 2022 17:15:55 +0000 (18:15 +0100)
The calibration data and mac addresses on this device are stored in the
0:ART partition. It is therefore possible to move the code to handle them
directly to the devicetree instead of the various scripts.

But the actual relevant information about the partition layout is provided
by the bootloader via bootargs (mtdparts) and not via the devicetree
itself. Instead of using a fixed-partition template, the mtd dynamic
partitions support from the upstream kernel is used.

Reported-by: Robert Marko <robert.marko@sartura.hr>
Reviewed-by: Robert Marko <robimarko@gmail.com>
Tested-by: Michaƫl BILCOT <michael.bilcot@gmail.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
target/linux/ipq40xx/base-files/etc/board.d/02_network
target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh
target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-a62.dts

index 46e6a3f9bdc38ced829680e68de491c669895fa5..e682a0fb15700362e6972749e67d3287d12fbfd6 100644 (file)
@@ -163,9 +163,6 @@ ipq40xx_setup_macs()
        pakedge,wr-1)
                wan_mac=$(macaddr_add $(get_mac_label) 1)
                ;;
-       openmesh,a62)
-               label_mac="$(mtd_get_mac_binary "0:ART" 0x0)"
-               ;;
        esac
 
        [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
index 559aacea1ebef21eeb78112b6cc61c637fd4bd33..9cdbaa3d4e7f6882b0e362eed6680667e4fbde0b 100644 (file)
@@ -34,7 +34,6 @@ case "$FIRMWARE" in
                /usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
                /usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1")
                ;;
-       openmesh,a62 |\
        plasmacloud,pa2200)
                caldata_extract "0:ART" 0x9000 0x2f20
                ;;
@@ -77,7 +76,6 @@ case "$FIRMWARE" in
                /usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1")
                ;;
        cellc,rtl30vw |\
-       openmesh,a62 |\
        plasmacloud,pa1200 |\
        plasmacloud,pa2200)
                caldata_extract "0:ART" 0x1000 0x2f20
@@ -173,7 +171,6 @@ case "$FIRMWARE" in
                /usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1")
                ;;
        cellc,rtl30vw |\
-       openmesh,a62 |\
        plasmacloud,pa1200 |\
        plasmacloud,pa2200)
                caldata_extract "0:ART" 0x5000 0x2f20
index 81d22686a3d18dcb3b15a46ed5299e84cb9b61c8..ddfef1ab2d42b8d858efff17e50625742f840e49 100644 (file)
@@ -29,10 +29,6 @@ preinit_set_mac_address() {
                ip link set dev lan1 address $(macaddr_add "$base_mac" 1)
                ip link set dev eth0 address $(macaddr_setbit "$base_mac" 7)
                ;;
-       openmesh,a62)
-               ip link set dev ethernet1 address $(mtd_get_mac_binary "0:ART" 0x0)
-               ip link set dev ethernet2 address $(mtd_get_mac_binary "0:ART" 0x6)
-               ;;
        mikrotik,wap-ac)
                base_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base)
                ip link set dev sw-eth1 address "$base_mac"
index 11d27ab339f2dfc45bbacfe06e7395443dd59415..d3481011101454efd6befc52023084003b658f80 100644 (file)
@@ -71,6 +71,7 @@
                led-failsafe = &led_status_green;
                led-running = &led_status_green;
                led-upgrade = &led_status_green;
+               label-mac-device = &swport4;
        };
 
        leds {
                compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <24000000>;
+
                /* partitions are passed via bootloader */
+               partitions {
+                       partition-art {
+                               compatible = "nvmem-cells";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+                               label = "0:ART";
+
+                               precal_art_1000: precal@1000 {
+                                       reg = <0x1000 0x2f20>;
+                               };
+
+                               precal_art_5000: precal@5000 {
+                                       reg = <0x5000 0x2f20>;
+                               };
+
+                               precal_art_9000: precal@9000 {
+                                       reg = <0x9000 0x2f20>;
+                               };
+
+                               macaddr_gmac0: macaddr@0 {
+                                       reg = <0x0 0x6>;
+                               };
+
+                               macaddr_gmac1: macaddr@6 {
+                                       reg = <0x6 0x6>;
+                               };
+                       };
+               };
        };
 };
 
                        reg = <0x00010000 0 0 0 0>;
                        qcom,ath10k-calibration-variant = "OM-A62";
                        ieee80211-freq-limit = <5170000 5350000>;
+
+                       nvmem-cell-names = "pre-calibration";
+                       nvmem-cells = <&precal_art_9000>;
                };
        };
 };
 &swport4 {
        status = "okay";
        label = "ethernet1";
+
+       nvmem-cell-names = "mac-address";
+       nvmem-cells = <&macaddr_gmac0>;
 };
 
 &swport5 {
        status = "okay";
        label = "ethernet2";
+
+       nvmem-cell-names = "mac-address";
+       nvmem-cells = <&macaddr_gmac1>;
 };
 
 &wifi0 {
        status = "okay";
        qcom,ath10k-calibration-variant = "OM-A62";
+
+       nvmem-cell-names = "pre-calibration";
+       nvmem-cells = <&precal_art_1000>;
 };
 
 &wifi1 {
        status = "okay";
        qcom,ath10k-calibration-variant = "OM-A62";
        ieee80211-freq-limit = <5470000 5875000>;
+
+       nvmem-cell-names = "pre-calibration";
+       nvmem-cells = <&precal_art_5000>;
 };