mediatek: filogic: asus-tuf-ax4200: use NVMEM-on-UBI
authorDaniel Golle <daniel@makrotopia.org>
Mon, 19 Feb 2024 03:18:47 +0000 (03:18 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Fri, 23 Feb 2024 14:35:00 +0000 (14:35 +0000)
Use newly added support for NVMEM-on-UBI instead of extracting MAC
address and WiFi EEPROM data in userspace.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
target/linux/mediatek/dts/mt7986a-asus-tuf-ax4200.dts
target/linux/mediatek/filogic/base-files/etc/board.d/02_network
target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata

index e9c8edc3dcee710334d69cded439d0e444c6f6e1..22530df9bb9d0574cb0d0b9b6183cda8f89408a5 100644 (file)
@@ -13,6 +13,7 @@
 
        aliases {
                serial0 = &uart0;
+               label-mac-device = &gmac0;
                led-boot = &led_system;
                led-failsafe = &led_system;
                led-running = &led_system;
@@ -21,7 +22,7 @@
 
        chosen {
                stdout-path = "serial0:115200n8";
-               bootargs-override = "ubi.mtd=UBI_DEV";
+               bootargs-override = "";
        };
 
        memory {
                /* LAN */
                compatible = "mediatek,eth-mac";
                reg = <0>;
+               nvmem-cells = <&macaddr_factory_4>;
+               nvmem-cell-names = "mac-address";
                phy-mode = "2500base-x";
 
                fixed-link {
                spi-tx-bus-width = <4>;
                spi-rx-bus-width = <4>;
 
-               partitions: partitions {
+               /*
+                * ASUS bootloader tries to replace the partitions defined in
+                * Device Tree and by that also deletes all additional properties
+                * needed for UBI and NVMEM-on-UBI.
+                * Prevent this from happening by tricking the loader to delete and
+                * replace a bait node instead.
+                */
+               partitions: dummy {
+                       compatible = "u-boot-dummy-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               reg = <0x0 0x0>;
+                               label = "remove_me";
+                       };
+               };
+
+               partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                        #size-cells = <1>;
 
                        partition@0 {
-                               label = "bootloader";
                                reg = <0x0 0x400000>;
+                               label = "bootloader";
                                read-only;
                        };
 
                        partition@400000 {
-                               label = "UBI_DEV";
+                               compatible = "linux,ubi";
                                reg = <0x400000 0xfc00000>;
+                               label = "UBI_DEV";
+
+                               volumes {
+                                       ubi_factory: ubi-volume-factory {
+                                               volname = "Factory";
+                                       };
+                               };
                        };
                };
        };
 };
 
+&ubi_factory {
+       nvmem-layout {
+               compatible = "fixed-layout";
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               eeprom_factory_0: eeprom@0 {
+                       reg = <0x0 0x1000>;
+               };
+
+               macaddr_factory_4: macaddr@4 {
+                       reg = <0x4 0x6>;
+               };
+       };
+};
+
 &switch {
        ports {
                #address-cells = <1>;
 };
 
 &wifi {
-       status = "okay";
-       pinctrl-names = "default", "dbdc";
+       nvmem-cells = <&eeprom_factory_0>;
+       nvmem-cell-names = "eeprom";
        pinctrl-0 = <&wf_2g_5g_pins>;
        pinctrl-1 = <&wf_dbdc_pins>;
+       pinctrl-names = "default", "dbdc";
+       status = "okay";
 };
 
 &trng {
index a639f3df16a886f0a53758feaa86a1173869e5d1..9f9544dec052fdc39d8626abfbefc5f754ffd11e 100644 (file)
@@ -109,7 +109,6 @@ mediatek_setup_macs()
        local label_mac=""
 
        case $board in
-       asus,tuf-ax4200|\
        asus,tuf-ax6000)
                CI_UBIPART="UBI_DEV"
                addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
index 9f9084732dfd4702a24c98c2f46627c84198f38f..bb81444b01b75b441ccb126320f1ae1e0c9092e0 100644 (file)
@@ -57,14 +57,6 @@ case "$FIRMWARE" in
                ;;
        esac
        ;;
-"mediatek/mt7986_eeprom_mt7976_dbdc.bin")
-       case "$board" in
-       asus,tuf-ax4200)
-               CI_UBIPART="UBI_DEV"
-               caldata_extract_ubi "Factory" 0x0 0x1000
-               ;;
-       esac
-       ;;
 "mediatek/mt7986_eeprom_mt7976_dual.bin")
        case "$board" in
        asus,tuf-ax6000)