瀏覽代碼

ramips: convert most mtd-mac-address cases in DTSI to nvmem

Convert most of the cases from mtd-mac-address to nvmem where
MAC addresses are set in the DTSI, but the partitions are only
located in the device DTS. This posed some problems earlier, since
in these cases we are using partitions before they are defined,
and the nvmem system did not seem to like that.

There have been a few different resolution approaches, based on
the different tradeoffs of deduplication vs. maintainability:

 1. In many cases, the partition tables were identical except for
    the firmware partition size, and the firmware partition was
    the last in the table.
    In these cases, the partition table has been moved to the
    DTSI, and only the firmware partition's "reg" property has
    been kept in the DTS files. So, the updated nvmem definition
    could stay in the DTSI files as well.

 2. For all other cases, splitting up the partition table would
    have introduced additional complexity. Thus, the nodes to be
    converted to nvmem have been moved to the DTS files where the
    partitioning was defined.

 3. For Netgear EX2700 and WN3000RP v3, the remaining DTSI file
    was completely dissolved, as it was quite small and the name
    was not really nice either.

 4. The D-Link DIR-853 A3 was converted to nvmem as well, though
    it is just a plain DTS file not taken care of in the first
    wave.

In addition, some minor rearrangements have been made for tidyness.

Not covered (yet) by this patch are:

 * Various unielec devices
 * The D-Link DIR-8xx family

Signed-off-by: Adrian Schmutzler <[email protected]>
Adrian Schmutzler 4 年之前
父節點
當前提交
ba3d92c5a0
共有 47 個文件被更改,包括 938 次插入1021 次删除
  1. 88 18
      target/linux/ramips/dts/mt7620a_netgear_ex2700.dts
  2. 0 58
      target/linux/ramips/dts/mt7620a_netgear_ex2700_wn3000rp-v3.dtsi
  3. 88 18
      target/linux/ramips/dts/mt7620a_netgear_wn3000rp-v3.dts
  4. 2 38
      target/linux/ramips/dts/mt7620a_zbtlink_zbt-we826-16m.dts
  5. 2 38
      target/linux/ramips/dts/mt7620a_zbtlink_zbt-we826-32m.dts
  6. 2 38
      target/linux/ramips/dts/mt7620a_zbtlink_zbt-we826-e.dts
  7. 52 1
      target/linux/ramips/dts/mt7620a_zbtlink_zbt-we826.dtsi
  8. 2 38
      target/linux/ramips/dts/mt7620n_nexx_wt3020-4m.dts
  9. 4 40
      target/linux/ramips/dts/mt7620n_nexx_wt3020-8m.dts
  10. 52 1
      target/linux/ramips/dts/mt7620n_nexx_wt3020.dtsi
  11. 24 3
      target/linux/ramips/dts/mt7621_dlink_dir-853-a3.dts
  12. 25 0
      target/linux/ramips/dts/mt7621_netgear_r6220.dts
  13. 1 8
      target/linux/ramips/dts/mt7621_netgear_sercomm_ayx.dtsi
  14. 25 0
      target/linux/ramips/dts/mt7621_netgear_wndr3700-v5.dts
  15. 8 0
      target/linux/ramips/dts/mt7621_ubnt_unifi-6-lite.dts
  16. 19 0
      target/linux/ramips/dts/mt7621_ubnt_unifi-nanohd.dts
  17. 0 5
      target/linux/ramips/dts/mt7621_ubnt_unifi.dtsi
  18. 2 38
      target/linux/ramips/dts/mt7628an_vocore_vocore2-lite.dts
  19. 2 38
      target/linux/ramips/dts/mt7628an_vocore_vocore2.dts
  20. 52 1
      target/linux/ramips/dts/mt7628an_vocore_vocore2.dtsi
  21. 2 48
      target/linux/ramips/dts/mt7628an_widora_neo-16m.dts
  22. 2 48
      target/linux/ramips/dts/mt7628an_widora_neo-32m.dts
  23. 62 1
      target/linux/ramips/dts/mt7628an_widora_neo.dtsi
  24. 2 38
      target/linux/ramips/dts/rt3050_allnet_all0256n-4m.dts
  25. 2 38
      target/linux/ramips/dts/rt3050_allnet_all0256n-8m.dts
  26. 52 1
      target/linux/ramips/dts/rt3050_allnet_all0256n.dtsi
  27. 15 0
      target/linux/ramips/dts/rt3050_alphanetworks_asl26555-16m.dts
  28. 15 0
      target/linux/ramips/dts/rt3050_alphanetworks_asl26555-8m.dts
  29. 0 4
      target/linux/ramips/dts/rt3050_alphanetworks_asl26555.dtsi
  30. 2 38
      target/linux/ramips/dts/rt5350_7links_px-4885-4m.dts
  31. 2 38
      target/linux/ramips/dts/rt5350_7links_px-4885-8m.dts
  32. 52 1
      target/linux/ramips/dts/rt5350_7links_px-4885.dtsi
  33. 2 38
      target/linux/ramips/dts/rt5350_asiarf_awm002-evb-4m.dts
  34. 2 38
      target/linux/ramips/dts/rt5350_asiarf_awm002-evb-8m.dts
  35. 52 1
      target/linux/ramips/dts/rt5350_asiarf_awm002-evb.dtsi
  36. 2 38
      target/linux/ramips/dts/rt5350_nexx_wt1520-4m.dts
  37. 2 38
      target/linux/ramips/dts/rt5350_nexx_wt1520-8m.dts
  38. 52 1
      target/linux/ramips/dts/rt5350_nexx_wt1520.dtsi
  39. 2 38
      target/linux/ramips/dts/rt5350_nixcore_x1-16m.dts
  40. 2 38
      target/linux/ramips/dts/rt5350_nixcore_x1-8m.dts
  41. 52 1
      target/linux/ramips/dts/rt5350_nixcore_x1.dtsi
  42. 2 38
      target/linux/ramips/dts/rt5350_poray_m4-4m.dts
  43. 2 38
      target/linux/ramips/dts/rt5350_poray_m4-8m.dts
  44. 52 1
      target/linux/ramips/dts/rt5350_poray_m4.dtsi
  45. 2 38
      target/linux/ramips/dts/rt5350_vocore_vocore-16m.dts
  46. 2 38
      target/linux/ramips/dts/rt5350_vocore_vocore-8m.dts
  47. 52 1
      target/linux/ramips/dts/rt5350_vocore_vocore.dtsi

+ 88 - 18
target/linux/ramips/dts/mt7620a_netgear_ex2700.dts

@@ -3,7 +3,10 @@
  * Copyright (C) 2016 Joseph C. Lehner <[email protected]>
  */
 
-#include "mt7620a_netgear_ex2700_wn3000rp-v3.dtsi"
+#include "mt7620a.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
 
 / {
 	compatible = "netgear,ex2700", "ralink,mt7620a-soc";
@@ -16,6 +19,22 @@
 		led-upgrade = &led_power_green;
 	};
 
+	keys {
+		compatible = "gpio-keys";
+
+		reset {
+			label = "reset";
+			gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_RESTART>;
+		};
+
+		wps {
+			label = "wps";
+			gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_WPS_BUTTON>;
+		};
+	};
+
 	leds {
 		compatible = "gpio-leds";
 
@@ -57,28 +76,79 @@
 	};
 };
 
-&partitions {
-	partition@0 {
-		label = "u-boot";
-		reg = <0x0 0x30000>;
-		read-only;
+&gpio1 {
+	status = "okay";
+};
+
+&spi0 {
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition@30000 {
+				label = "u-boot-env";
+				reg = <0x30000 0x10000>;
+				read-only;
+			};
+
+			partition@40000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				reg = <0x40000 0x3b0000>;
+			};
+
+			art: partition@3f0000 {
+				label = "art";
+				reg = <0x3f0000 0x10000>;
+				read-only;
+			};
+		};
 	};
+};
+
+&ethernet {
+	nvmem-cells = <&macaddr_art_0>;
+	nvmem-cell-names = "mac-address";
+};
+
+&wmac {
+	ralink,mtd-eeprom = <&art 0x1000>;
+
+	nvmem-cells = <&macaddr_art_6>;
+	nvmem-cell-names = "mac-address";
+};
 
-	partition@30000 {
-		label = "u-boot-env";
-		reg = <0x30000 0x10000>;
-		read-only;
+&state_default {
+	default {
+		groups = "i2c", "uartf", "spi refclk";
+		function = "gpio";
 	};
+};
+
+&art {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
 
-	partition@40000 {
-		compatible = "denx,uimage";
-		label = "firmware";
-		reg = <0x40000 0x3b0000>;
+	macaddr_art_0: macaddr@0 {
+		reg = <0x0 0x6>;
 	};
 
-	art: partition@3f0000 {
-		label = "art";
-		reg = <0x3f0000 0x10000>;
-		read-only;
+	macaddr_art_6: macaddr@6 {
+		reg = <0x6 0x6>;
 	};
 };

+ 0 - 58
target/linux/ramips/dts/mt7620a_netgear_ex2700_wn3000rp-v3.dtsi

@@ -1,58 +0,0 @@
-#include "mt7620a.dtsi"
-
-#include <dt-bindings/gpio/gpio.h>
-#include <dt-bindings/input/input.h>
-
-/ {
-	keys {
-		compatible = "gpio-keys";
-
-		reset {
-			label = "reset";
-			gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
-			linux,code = <KEY_RESTART>;
-		};
-
-		wps {
-			label = "wps";
-			gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
-			linux,code = <KEY_WPS_BUTTON>;
-		};
-	};
-};
-
-&gpio1 {
-	status = "okay";
-};
-
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions: partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-		};
-	};
-};
-
-&ethernet {
-	mtd-mac-address = <&art 0x0>;
-};
-
-&wmac {
-	ralink,mtd-eeprom = <&art 0x1000>;
-	mtd-mac-address = <&art 0x6>;
-};
-
-&state_default {
-	default {
-		groups = "i2c", "uartf", "spi refclk";
-		function = "gpio";
-	};
-};

+ 88 - 18
target/linux/ramips/dts/mt7620a_netgear_wn3000rp-v3.dts

@@ -1,6 +1,9 @@
 /* This file is released into the public domain */
 
-#include "mt7620a_netgear_ex2700_wn3000rp-v3.dtsi"
+#include "mt7620a.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
 
 / {
 	compatible = "netgear,wn3000rp-v3", "ralink,mt7620a-soc";
@@ -13,6 +16,22 @@
 		led-upgrade = &led_power_green;
 	};
 
+	keys {
+		compatible = "gpio-keys";
+
+		reset {
+			label = "reset";
+			gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_RESTART>;
+		};
+
+		wps {
+			label = "wps";
+			gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_WPS_BUTTON>;
+		};
+	};
+
 	leds {
 		compatible = "gpio-leds";
 
@@ -64,28 +83,79 @@
 	};
 };
 
-&partitions {
-	partition@0 {
-		label = "u-boot";
-		reg = <0x0 0x30000>;
-		read-only;
+&gpio1 {
+	status = "okay";
+};
+
+&spi0 {
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition@30000 {
+				label = "u-boot-env";
+				reg = <0x30000 0x10000>;
+				read-only;
+			};
+
+			partition@40000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				reg = <0x40000 0x7b0000>;
+			};
+
+			art: partition@7f0000 {
+				label = "art";
+				reg = <0x7f0000 0x10000>;
+				read-only;
+			};
+		};
 	};
+};
+
+&ethernet {
+	nvmem-cells = <&macaddr_art_0>;
+	nvmem-cell-names = "mac-address";
+};
+
+&wmac {
+	ralink,mtd-eeprom = <&art 0x1000>;
 
-	partition@30000 {
-		label = "u-boot-env";
-		reg = <0x30000 0x10000>;
-		read-only;
+	nvmem-cells = <&macaddr_art_6>;
+	nvmem-cell-names = "mac-address";
+};
+
+&state_default {
+	default {
+		groups = "i2c", "uartf", "spi refclk";
+		function = "gpio";
 	};
+};
+
+&art {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
 
-	partition@40000 {
-		compatible = "denx,uimage";
-		label = "firmware";
-		reg = <0x40000 0x7b0000>;
+	macaddr_art_0: macaddr@0 {
+		reg = <0x0 0x6>;
 	};
 
-	art: partition@7f0000 {
-		label = "art";
-		reg = <0x7f0000 0x10000>;
-		read-only;
+	macaddr_art_6: macaddr@6 {
+		reg = <0x6 0x6>;
 	};
 };

+ 2 - 38
target/linux/ramips/dts/mt7620a_zbtlink_zbt-we826-16m.dts

@@ -5,42 +5,6 @@
 	model = "Zbtlink ZBT-WE826 (16M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			firmware: partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0xfb0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0xfb0000>;
 };

+ 2 - 38
target/linux/ramips/dts/mt7620a_zbtlink_zbt-we826-32m.dts

@@ -5,42 +5,6 @@
 	model = "Zbtlink ZBT-WE826 (32M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			firmware: partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x1fb0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x1fb0000>;
 };

+ 2 - 38
target/linux/ramips/dts/mt7620a_zbtlink_zbt-we826-e.dts

@@ -33,44 +33,8 @@
 	};
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			firmware: partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x1fb0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x1fb0000>;
 };
 
 &state_default {

+ 52 - 1
target/linux/ramips/dts/mt7620a_zbtlink_zbt-we826.dtsi

@@ -49,6 +49,46 @@
 	};
 };
 
+&spi0 {
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition@30000 {
+				label = "u-boot-env";
+				reg = <0x30000 0x10000>;
+				read-only;
+			};
+
+			factory: partition@40000 {
+				label = "factory";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			firmware: partition@50000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				/* reg property is set based on flash size in DTS files */
+			};
+		};
+	};
+};
+
 &gpio1 {
 	status = "okay";
 };
@@ -70,7 +110,8 @@
 };
 
 &ethernet {
-	mtd-mac-address = <&factory 0x4>;
+	nvmem-cells = <&macaddr_factory_4>;
+	nvmem-cell-names = "mac-address";
 
 	mediatek,portmap = "llllw";
 };
@@ -89,3 +130,13 @@
 &pcie {
 	status = "okay";
 };
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_4: macaddr@4 {
+		reg = <0x4 0x6>;
+	};
+};

+ 2 - 38
target/linux/ramips/dts/mt7620n_nexx_wt3020-4m.dts

@@ -5,42 +5,6 @@
 	model = "Nexx WT3020 (4M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x3b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x3b0000>;
 };

+ 4 - 40
target/linux/ramips/dts/mt7620n_nexx_wt3020-8m.dts

@@ -5,50 +5,14 @@
 	model = "Nexx WT3020 (8M)";
 };
 
-&ehci {
-	status = "okay";
+&firmware {
+	reg = <0x50000 0x7b0000>;
 };
 
-&ohci {
+&ehci {
 	status = "okay";
 };
 
-&spi0 {
+&ohci {
 	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x7b0000>;
-			};
-		};
-	};
 };

+ 52 - 1
target/linux/ramips/dts/mt7620n_nexx_wt3020.dtsi

@@ -34,12 +34,53 @@
 	};
 };
 
+&spi0 {
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition@30000 {
+				label = "u-boot-env";
+				reg = <0x30000 0x10000>;
+				read-only;
+			};
+
+			factory: partition@40000 {
+				label = "factory";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			firmware: partition@50000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				/* reg property is set based on flash size in DTS files */
+			};
+		};
+	};
+};
+
 &gpio3 {
 	status = "okay";
 };
 
 &ethernet {
-	mtd-mac-address = <&factory 0x4>;
+	nvmem-cells = <&macaddr_factory_4>;
+	nvmem-cell-names = "mac-address";
 
 	mediatek,portmap = "wllll";
 };
@@ -54,3 +95,13 @@
 		function = "gpio";
 	};
 };
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_4: macaddr@4 {
+		reg = <0x4 0x6>;
+	};
+};

+ 24 - 3
target/linux/ramips/dts/mt7621_dlink_dir-853-a3.dts

@@ -158,12 +158,14 @@
 		mediatek,mtd-eeprom = <&factory 0x0>;
 		/* 5 GHz (phy1) does not take the address from calibration data,
 		   but setting it manually here works */
-		mtd-mac-address = <&factory 0x4>;
+		nvmem-cells = <&macaddr_factory_4>;
+		nvmem-cell-names = "mac-address";
 	};
 };
 
 &gmac0 {
-	mtd-mac-address = <&factory 0xe000>;
+	nvmem-cells = <&macaddr_factory_e000>;
+	nvmem-cell-names = "mac-address";
 };
 
 &switch0 {
@@ -191,7 +193,8 @@
 		port@4 {
 			status = "okay";
 			label = "wan";
-			mtd-mac-address = <&factory 0xe006>;
+			nvmem-cells = <&macaddr_factory_e006>;
+			nvmem-cell-names = "mac-address";
 		};
 	};
 };
@@ -202,3 +205,21 @@
 		function = "gpio";
 	};
 };
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_4: macaddr@4 {
+		reg = <0x4 0x6>;
+	};
+
+	macaddr_factory_e000: macaddr@e000 {
+		reg = <0xe000 0x6>;
+	};
+
+	macaddr_factory_e006: macaddr@e006 {
+		reg = <0xe006 0x6>;
+	};
+};

+ 25 - 0
target/linux/ramips/dts/mt7621_netgear_r6220.dts

@@ -5,6 +5,10 @@
 / {
 	compatible = "netgear,r6220", "mediatek,mt7621-soc";
 	model = "Netgear R6220";
+
+	aliases {
+		label-mac-device = &gmac0;
+	};
 };
 
 &nand {
@@ -50,3 +54,24 @@
 		};
 	};
 };
+
+&gmac0 {
+	nvmem-cells = <&macaddr_factory_4>;
+	nvmem-cell-names = "mac-address";
+};
+
+&wan {
+	nvmem-cells = <&macaddr_factory_4>;
+	nvmem-cell-names = "mac-address";
+	mac-address-increment = <1>;
+};
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_4: macaddr@4 {
+		reg = <0x4 0x6>;
+	};
+};

+ 1 - 8
target/linux/ramips/dts/mt7621_netgear_sercomm_ayx.dtsi

@@ -13,7 +13,6 @@
 		led-failsafe = &led_power;
 		led-running = &led_power;
 		led-upgrade = &led_power;
-		label-mac-device = &gmac0;
 	};
 
 	keys {
@@ -106,10 +105,6 @@
 	};
 };
 
-&gmac0 {
-	mtd-mac-address = <&factory 0x4>;
-};
-
 &switch0 {
 	ports {
 		port@0 {
@@ -132,11 +127,9 @@
 			label = "lan1";
 		};
 
-		port@4 {
+		wan: port@4 {
 			status = "okay";
 			label = "wan";
-			mtd-mac-address = <&factory 0x4>;
-			mac-address-increment = <1>;
 		};
 	};
 };

+ 25 - 0
target/linux/ramips/dts/mt7621_netgear_wndr3700-v5.dts

@@ -5,6 +5,10 @@
 / {
 	compatible = "netgear,wndr3700-v5", "mediatek,mt7621-soc";
 	model = "Netgear WNDR3700 v5";
+
+	aliases {
+		label-mac-device = &gmac0;
+	};
 };
 
 &spi0 {
@@ -46,3 +50,24 @@
 		};
 	};
 };
+
+&gmac0 {
+	nvmem-cells = <&macaddr_factory_4>;
+	nvmem-cell-names = "mac-address";
+};
+
+&wan {
+	nvmem-cells = <&macaddr_factory_4>;
+	nvmem-cell-names = "mac-address";
+	mac-address-increment = <1>;
+};
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_4: macaddr@4 {
+		reg = <0x4 0x6>;
+	};
+};

+ 8 - 0
target/linux/ramips/dts/mt7621_ubnt_unifi-6-lite.dts

@@ -73,13 +73,21 @@
 	};
 };
 
+&gmac0 {
+	nvmem-cells = <&macaddr_eeprom_0>;
+	nvmem-cell-names = "mac-address";
+};
+
 &wlan_2g {
+	mediatek,mtd-eeprom = <&factory 0x0>;
+
 	nvmem-cells = <&macaddr_eeprom_0>;
 	nvmem-cell-names = "mac-address";
 };
 
 &wlan_5g {
 	mediatek,mtd-eeprom = <&factory 0x20000>;
+
 	nvmem-cells = <&macaddr_eeprom_6>;
 	nvmem-cell-names = "mac-address";
 	ieee80211-freq-limit = <5000000 6000000>;

+ 19 - 0
target/linux/ramips/dts/mt7621_ubnt_unifi-nanohd.dts

@@ -70,6 +70,25 @@
 	};
 };
 
+&gmac0 {
+	nvmem-cells = <&macaddr_eeprom_0>;
+	nvmem-cell-names = "mac-address";
+};
+
+&wlan_2g {
+	mediatek,mtd-eeprom = <&factory 0x0>;
+};
+
 &wlan_5g {
 	mediatek,mtd-eeprom = <&factory 0x8000>;
 };
+
+&eeprom {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_eeprom_0: macaddr@0 {
+		reg = <0x0 0x6>;
+	};
+};

+ 0 - 5
target/linux/ramips/dts/mt7621_ubnt_unifi.dtsi

@@ -50,7 +50,6 @@
 &pcie0 {
 	wlan_2g: wifi@0,0 {
 		reg = <0x0 0 0 0 0>;
-		mediatek,mtd-eeprom = <&factory 0x0>;
 	};
 };
 
@@ -60,10 +59,6 @@
 	};
 };
 
-&gmac0 {
-	mtd-mac-address = <&eeprom 0x0>;
-};
-
 &switch0 {
 	ports {
 		port@0 {

+ 2 - 38
target/linux/ramips/dts/mt7628an_vocore_vocore2-lite.dts

@@ -21,42 +21,6 @@
 	};
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x7b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x7b0000>;
 };

+ 2 - 38
target/linux/ramips/dts/mt7628an_vocore_vocore2.dts

@@ -21,42 +21,6 @@
 	};
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0xfb0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0xfb0000>;
 };

+ 52 - 1
target/linux/ramips/dts/mt7628an_vocore_vocore2.dtsi

@@ -14,6 +14,46 @@
 	};
 };
 
+&spi0 {
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition@30000 {
+				label = "u-boot-env";
+				reg = <0x30000 0x10000>;
+				read-only;
+			};
+
+			factory: partition@40000 {
+				label = "factory";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			firmware: partition@50000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				/* reg property is set based on flash size in DTS files */
+			};
+		};
+	};
+};
+
 &state_default {
 	gpio {
 		groups = "wled_an", "refclk", "wdt";
@@ -28,7 +68,8 @@
 };
 
 &ethernet {
-	mtd-mac-address = <&factory 0x28>;
+	nvmem-cells = <&macaddr_factory_28>;
+	nvmem-cell-names = "mac-address";
 };
 
 &esw {
@@ -55,3 +96,13 @@
 &uart2 {
 	status = "okay";
 };
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_28: macaddr@28 {
+		reg = <0x28 0x6>;
+	};
+};

+ 2 - 48
target/linux/ramips/dts/mt7628an_widora_neo-16m.dts

@@ -5,52 +5,6 @@
 	model = "Widora-NEO (16M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	pinctrl-names = "default";
-	pinctrl-0 = <&spi_pins>, <&spi_cs1_pins>;
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <40000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x0fb0000>;
-			};
-		};
-	};
-
-	spidev@1 {
-		#address-cells = <1>;
-		#size-cells = <1>;
-		compatible = "linux,spidev";
-		reg = <1>;
-		spi-max-frequency = <40000000>;
-	};
+&firmware {
+	reg = <0x50000 0xfb0000>;
 };

+ 2 - 48
target/linux/ramips/dts/mt7628an_widora_neo-32m.dts

@@ -5,52 +5,6 @@
 	model = "Widora-NEO (32M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	pinctrl-names = "default";
-	pinctrl-0 = <&spi_pins>, <&spi_cs1_pins>;
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <40000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x1fb0000>;
-			};
-		};
-	};
-
-	spidev@1 {
-		#address-cells = <1>;
-		#size-cells = <1>;
-		compatible = "linux,spidev";
-		reg = <1>;
-		spi-max-frequency = <40000000>;
-	};
+&firmware {
+	reg = <0x50000 0x1fb0000>;
 };

+ 62 - 1
target/linux/ramips/dts/mt7628an_widora_neo.dtsi

@@ -46,6 +46,56 @@
 	};
 };
 
+&spi0 {
+	status = "okay";
+
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi_pins>, <&spi_cs1_pins>;
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <40000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition@30000 {
+				label = "u-boot-env";
+				reg = <0x30000 0x10000>;
+			};
+
+			factory: partition@40000 {
+				label = "factory";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			firmware: partition@50000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				/* reg property is set based on flash size in DTS files */
+			};
+		};
+	};
+
+	spidev@1 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "linux,spidev";
+		reg = <1>;
+		spi-max-frequency = <40000000>;
+	};
+};
+
 &state_default {
 	gpio {
 		groups = "gpio";
@@ -105,7 +155,8 @@
 };
 
 &ethernet {
-	mtd-mac-address = <&factory 0x28>;
+	nvmem-cells = <&macaddr_factory_28>;
+	nvmem-cell-names = "mac-address";
 };
 
 &sdhci {
@@ -118,3 +169,13 @@
 
 	mediatek,mtd-eeprom = <&factory 0x0>;
 };
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_28: macaddr@28 {
+		reg = <0x28 0x6>;
+	};
+};

+ 2 - 38
target/linux/ramips/dts/rt3050_allnet_all0256n-4m.dts

@@ -5,42 +5,6 @@
 	model = "Allnet ALL0256N (4M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x3b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x3b0000>;
 };

+ 2 - 38
target/linux/ramips/dts/rt3050_allnet_all0256n-8m.dts

@@ -5,42 +5,6 @@
 	model = "Allnet ALL0256N (8M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x7b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x7b0000>;
 };

+ 52 - 1
target/linux/ramips/dts/rt3050_allnet_all0256n.dtsi

@@ -37,6 +37,46 @@
 	};
 };
 
+&spi0 {
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition@30000 {
+				label = "u-boot-env";
+				reg = <0x30000 0x10000>;
+				read-only;
+			};
+
+			factory: partition@40000 {
+				label = "factory";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			firmware: partition@50000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				/* reg property is set based on flash size in DTS files */
+			};
+		};
+	};
+};
+
 &state_default {
 	gpio {
 		groups = "i2c", "jtag", "rgmii", "mdio", "uartf";
@@ -45,7 +85,8 @@
 };
 
 &ethernet {
-	mtd-mac-address = <&factory 0x28>;
+	nvmem-cells = <&macaddr_factory_28>;
+	nvmem-cell-names = "mac-address";
 };
 
 &esw {
@@ -55,3 +96,13 @@
 &wmac {
 	ralink,mtd-eeprom = <&factory 0x0>;
 };
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_28: macaddr@28 {
+		reg = <0x28 0x6>;
+	};
+};

+ 15 - 0
target/linux/ramips/dts/rt3050_alphanetworks_asl26555-16m.dts

@@ -62,3 +62,18 @@
 		};
 	};
 };
+
+&ethernet {
+	nvmem-cells = <&macaddr_devdata_4004>;
+	nvmem-cell-names = "mac-address";
+};
+
+&devdata {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_devdata_4004: macaddr@4004 {
+		reg = <0x4004 0x6>;
+	};
+};

+ 15 - 0
target/linux/ramips/dts/rt3050_alphanetworks_asl26555-8m.dts

@@ -56,3 +56,18 @@
 		};
 	};
 };
+
+&ethernet {
+	nvmem-cells = <&macaddr_devdata_4004>;
+	nvmem-cell-names = "mac-address";
+};
+
+&devdata {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_devdata_4004: macaddr@4004 {
+		reg = <0x4004 0x6>;
+	};
+};

+ 0 - 4
target/linux/ramips/dts/rt3050_alphanetworks_asl26555.dtsi

@@ -84,10 +84,6 @@
 	};
 };
 
-&ethernet {
-	mtd-mac-address = <&devdata 0x4004>;
-};
-
 &esw {
 	mediatek,portmap = <0x1e>;
 };

+ 2 - 38
target/linux/ramips/dts/rt5350_7links_px-4885-4m.dts

@@ -5,42 +5,6 @@
 	model = "7Links PX-4885 (4M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x20000>;
-				read-only;
-			};
-
-			partition@20000 {
-				label = "devdata";
-				reg = <0x20000 0x20000>;
-				read-only;
-			};
-
-			devconf: partition@40000 {
-				label = "devconf";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x3b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x3b0000>;
 };

+ 2 - 38
target/linux/ramips/dts/rt5350_7links_px-4885-8m.dts

@@ -5,42 +5,6 @@
 	model = "7Links PX-4885 (8M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x20000>;
-				read-only;
-			};
-
-			partition@20000 {
-				label = "devdata";
-				reg = <0x20000 0x20000>;
-				read-only;
-			};
-
-			devconf: partition@40000 {
-				label = "devconf";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x7b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x7b0000>;
 };

+ 52 - 1
target/linux/ramips/dts/rt5350_7links_px-4885.dtsi

@@ -41,6 +41,46 @@
 	};
 };
 
+&spi0 {
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0 0x20000>;
+				read-only;
+			};
+
+			partition@20000 {
+				label = "devdata";
+				reg = <0x20000 0x20000>;
+				read-only;
+			};
+
+			devconf: partition@40000 {
+				label = "devconf";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			firmware: partition@50000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				/* reg property is set based on flash size in DTS files */
+			};
+		};
+	};
+};
+
 &state_default {
 	gpio {
 		groups = "i2c", "jtag", "uartf";
@@ -49,7 +89,8 @@
 };
 
 &ethernet {
-	mtd-mac-address = <&devconf 0x28>;
+	nvmem-cells = <&macaddr_devconf_28>;
+	nvmem-cell-names = "mac-address";
 };
 
 &esw {
@@ -59,3 +100,13 @@
 &wmac {
 	ralink,mtd-eeprom = <&devconf 0x0>;
 };
+
+&devconf {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_devconf_28: macaddr@28 {
+		reg = <0x28 0x6>;
+	};
+};

+ 2 - 38
target/linux/ramips/dts/rt5350_asiarf_awm002-evb-4m.dts

@@ -5,42 +5,6 @@
 	model = "AsiaRF AWM002 EVB (4M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		reg = <0>;
-		compatible = "jedec,spi-nor";
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x3b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x3b0000>;
 };

+ 2 - 38
target/linux/ramips/dts/rt5350_asiarf_awm002-evb-8m.dts

@@ -5,42 +5,6 @@
 	model = "AsiaRF AWM002 EVB (8M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		reg = <0>;
-		compatible = "jedec,spi-nor";
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x7b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x7b0000>;
 };

+ 52 - 1
target/linux/ramips/dts/rt5350_asiarf_awm002-evb.dtsi

@@ -43,8 +43,49 @@
 	};
 };
 
+&spi0 {
+	status = "okay";
+
+	flash@0 {
+		reg = <0>;
+		compatible = "jedec,spi-nor";
+		spi-max-frequency = <10000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition@30000 {
+				label = "u-boot-env";
+				reg = <0x30000 0x10000>;
+				read-only;
+			};
+
+			factory: partition@40000 {
+				label = "factory";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			firmware: partition@50000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				/* reg property is set based on flash size in DTS files */
+			};
+		};
+	};
+};
+
 &ethernet {
-	mtd-mac-address = <&factory 0x28>;
+	nvmem-cells = <&macaddr_factory_28>;
+	nvmem-cell-names = "mac-address";
 };
 
 &wmac {
@@ -61,3 +102,13 @@
 &esw {
 	mediatek,portmap = <0x3f>;
 };
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_28: macaddr@28 {
+		reg = <0x28 0x6>;
+	};
+};

+ 2 - 38
target/linux/ramips/dts/rt5350_nexx_wt1520-4m.dts

@@ -5,42 +5,6 @@
 	model = "Nexx WT1520 (4M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x3b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x3b0000>;
 };

+ 2 - 38
target/linux/ramips/dts/rt5350_nexx_wt1520-8m.dts

@@ -5,42 +5,6 @@
 	model = "Nexx WT1520 (8M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x7b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x7b0000>;
 };

+ 52 - 1
target/linux/ramips/dts/rt5350_nexx_wt1520.dtsi

@@ -18,6 +18,46 @@
 	};
 };
 
+&spi0 {
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition@30000 {
+				label = "u-boot-env";
+				reg = <0x30000 0x10000>;
+				read-only;
+			};
+
+			factory: partition@40000 {
+				label = "factory";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			firmware: partition@50000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				/* reg property is set based on flash size in DTS files */
+			};
+		};
+	};
+};
+
 &state_default {
 	gpio {
 		groups = "jtag", "uartf";
@@ -26,9 +66,20 @@
 };
 
 &ethernet {
-	mtd-mac-address = <&factory 0x4>;
+	nvmem-cells = <&macaddr_factory_4>;
+	nvmem-cell-names = "mac-address";
 };
 
 &wmac {
 	ralink,mtd-eeprom = <&factory 0x0>;
 };
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_4: macaddr@4 {
+		reg = <0x4 0x6>;
+	};
+};

+ 2 - 38
target/linux/ramips/dts/rt5350_nixcore_x1-16m.dts

@@ -5,42 +5,6 @@
 	model = "NixcoreX1 (16M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "uboot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "uboot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0xfb0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0xfb0000>;
 };

+ 2 - 38
target/linux/ramips/dts/rt5350_nixcore_x1-8m.dts

@@ -5,42 +5,6 @@
 	model = "NixcoreX1 (8M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "uboot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "uboot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x7b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x7b0000>;
 };

+ 52 - 1
target/linux/ramips/dts/rt5350_nixcore_x1.dtsi

@@ -108,6 +108,46 @@
 	};
 };
 
+&spi0 {
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "uboot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition@30000 {
+				label = "uboot-env";
+				reg = <0x30000 0x10000>;
+				read-only;
+			};
+
+			factory: partition@40000 {
+				label = "factory";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			firmware: partition@50000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				/* reg property is set based on flash size in DTS files */
+			};
+		};
+	};
+};
+
 &gpio1 {
 	status = "okay";
 };
@@ -129,7 +169,8 @@
 };
 
 &ethernet {
-	mtd-mac-address = <&factory 0x4>;
+	nvmem-cells = <&macaddr_factory_4>;
+	nvmem-cell-names = "mac-address";
 };
 
 &esw {
@@ -139,3 +180,13 @@
 &wmac {
 	ralink,mtd-eeprom = <&factory 0x0>;
 };
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_4: macaddr@4 {
+		reg = <0x4 0x6>;
+	};
+};

+ 2 - 38
target/linux/ramips/dts/rt5350_poray_m4-4m.dts

@@ -5,42 +5,6 @@
 	model = "Poray M4 (4M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x3b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x3b0000>;
 };

+ 2 - 38
target/linux/ramips/dts/rt5350_poray_m4-8m.dts

@@ -5,42 +5,6 @@
 	model = "Poray M4 (8M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "u-boot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "u-boot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x7b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x7b0000>;
 };

+ 52 - 1
target/linux/ramips/dts/rt5350_poray_m4.dtsi

@@ -34,6 +34,46 @@
 	};
 };
 
+&spi0 {
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition@30000 {
+				label = "u-boot-env";
+				reg = <0x30000 0x10000>;
+				read-only;
+			};
+
+			factory: partition@40000 {
+				label = "factory";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			firmware: partition@50000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				/* reg property is set based on flash size in DTS files */
+			};
+		};
+	};
+};
+
 &state_default {
 	gpio {
 		groups = "i2c", "jtag", "uartf";
@@ -42,7 +82,8 @@
 };
 
 &ethernet {
-	mtd-mac-address = <&factory 0x4>;
+	nvmem-cells = <&macaddr_factory_4>;
+	nvmem-cell-names = "mac-address";
 };
 
 &esw {
@@ -54,3 +95,13 @@
 	ralink,mtd-eeprom = <&factory 0x0>;
 	ralink,led-polarity = <1>;
 };
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_4: macaddr@4 {
+		reg = <0x4 0x6>;
+	};
+};

+ 2 - 38
target/linux/ramips/dts/rt5350_vocore_vocore-16m.dts

@@ -5,42 +5,6 @@
 	model = "VoCore (16M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "uboot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "uboot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0xfb0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0xfb0000>;
 };

+ 2 - 38
target/linux/ramips/dts/rt5350_vocore_vocore-8m.dts

@@ -5,42 +5,6 @@
 	model = "VoCore (8M)";
 };
 
-&spi0 {
-	status = "okay";
-
-	flash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <10000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@0 {
-				label = "uboot";
-				reg = <0x0 0x30000>;
-				read-only;
-			};
-
-			partition@30000 {
-				label = "uboot-env";
-				reg = <0x30000 0x10000>;
-				read-only;
-			};
-
-			factory: partition@40000 {
-				label = "factory";
-				reg = <0x40000 0x10000>;
-				read-only;
-			};
-
-			partition@50000 {
-				compatible = "denx,uimage";
-				label = "firmware";
-				reg = <0x50000 0x7b0000>;
-			};
-		};
-	};
+&firmware {
+	reg = <0x50000 0x7b0000>;
 };

+ 52 - 1
target/linux/ramips/dts/rt5350_vocore_vocore.dtsi

@@ -156,6 +156,46 @@
 	};
 };
 
+&spi0 {
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "uboot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition@30000 {
+				label = "uboot-env";
+				reg = <0x30000 0x10000>;
+				read-only;
+			};
+
+			factory: partition@40000 {
+				label = "factory";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			firmware: partition@50000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				/* reg property is set based on flash size in DTS files */
+			};
+		};
+	};
+};
+
 &gpio1 {
 	status = "okay";
 };
@@ -172,7 +212,8 @@
 };
 
 &ethernet {
-	mtd-mac-address = <&factory 0x4>;
+	nvmem-cells = <&macaddr_factory_4>;
+	nvmem-cell-names = "mac-address";
 };
 
 &esw {
@@ -193,3 +234,13 @@
 		reg = <0>;
 	};
 };
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_4: macaddr@4 {
+		reg = <0x4 0x6>;
+	};
+};