From: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Date: Wed, 18 Aug 2021 23:16:39 +0000 (+0200)
Subject: ramips: convert mtd-mac-address to nvmem for D-Link DIR-8xx
X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=7f1b0f68f16c3f063322887ee10b0ae8f47603af;p=openwrt%2Fstaging%2Fwigyori.git

ramips: convert mtd-mac-address to nvmem for D-Link DIR-8xx

Convert this series by moving the definitions to the individual
devices.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---

diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-853-a3.dts b/target/linux/ramips/dts/mt7621_dlink_dir-853-a3.dts
index e866fb1242..49d0c050f5 100644
--- a/target/linux/ramips/dts/mt7621_dlink_dir-853-a3.dts
+++ b/target/linux/ramips/dts/mt7621_dlink_dir-853-a3.dts
@@ -11,6 +11,7 @@
 
 	aliases {
 		label-mac-device = &gmac0;
+
 		led-boot = &led_power_orange;
 		led-failsafe = &led_power_blue;
 		led-running = &led_power_blue;
diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-853-r1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-853-r1.dts
index 09e46b011e..c0ad172939 100644
--- a/target/linux/ramips/dts/mt7621_dlink_dir-853-r1.dts
+++ b/target/linux/ramips/dts/mt7621_dlink_dir-853-r1.dts
@@ -13,6 +13,7 @@
 
 	aliases {
 		label-mac-device = &wan;
+
 		led-boot = &led_power_orange;
 		led-failsafe = &led_power_blue;
 		led-running = &led_power_blue;
@@ -93,16 +94,20 @@
 	wifi@0,0 {
 		compatible = "mediatek,mt76";
 		reg = <0x0000 0 0 0 0>;
+
 		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 0x4>;
-	mtd-mac-address-increment = <(-1)>;
+	nvmem-cells = <&macaddr_factory_4>;
+	nvmem-cell-names = "mac-address";
+	mac-address-increment = <(-1)>;
 };
 
 &switch0 {
@@ -130,8 +135,9 @@
 		wan: port@4 {
 			status = "okay";
 			label = "wan";
-			mtd-mac-address = <&factory 0x4>;
-			mtd-mac-address-increment = <(-2)>;
+			nvmem-cells = <&macaddr_factory_4>;
+			nvmem-cell-names = "mac-address";
+			mac-address-increment = <(-2)>;
 		};
 	};
 };
@@ -142,3 +148,13 @@
 		function = "gpio";
 	};
 };
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_4: macaddr@4 {
+		reg = <0x4 0x6>;
+	};
+};
diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-860l-b1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-860l-b1.dts
index 26f142dcff..7a48a931e7 100644
--- a/target/linux/ramips/dts/mt7621_dlink_dir-860l-b1.dts
+++ b/target/linux/ramips/dts/mt7621_dlink_dir-860l-b1.dts
@@ -8,11 +8,12 @@
 	model = "D-Link DIR-860L B1";
 
 	aliases {
+		label-mac-device = &gmac0;
+
 		led-boot = &led_power_green;
 		led-failsafe = &led_power_green;
 		led-running = &led_power_green;
 		led-upgrade = &led_power_green;
-		label-mac-device = &gmac0;
 	};
 
 	leds {
diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-867-a1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-867-a1.dts
index e02eb9eebf..0f09fae246 100644
--- a/target/linux/ramips/dts/mt7621_dlink_dir-867-a1.dts
+++ b/target/linux/ramips/dts/mt7621_dlink_dir-867-a1.dts
@@ -6,4 +6,32 @@
 / {
 	compatible = "dlink,dir-867-a1", "mediatek,mt7621-soc";
 	model = "D-Link DIR-867 A1";
+
+	aliases {
+		label-mac-device = &gmac0;
+	};
+};
+
+&gmac0 {
+	nvmem-cells = <&macaddr_factory_e000>;
+	nvmem-cell-names = "mac-address";
+};
+
+&wan {
+	nvmem-cells = <&macaddr_factory_e006>;
+	nvmem-cell-names = "mac-address";
+};
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_e000: macaddr@e000 {
+		reg = <0xe000 0x6>;
+	};
+
+	macaddr_factory_e006: macaddr@e006 {
+		reg = <0xe006 0x6>;
+	};
 };
diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-878-a1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-878-a1.dts
index 1f1d5824f2..9c73ffa123 100644
--- a/target/linux/ramips/dts/mt7621_dlink_dir-878-a1.dts
+++ b/target/linux/ramips/dts/mt7621_dlink_dir-878-a1.dts
@@ -6,4 +6,32 @@
 / {
 	compatible = "dlink,dir-878-a1", "mediatek,mt7621-soc";
 	model = "D-Link DIR-878 A1";
+
+	aliases {
+		label-mac-device = &gmac0;
+	};
+};
+
+&gmac0 {
+	nvmem-cells = <&macaddr_factory_e000>;
+	nvmem-cell-names = "mac-address";
+};
+
+&wan {
+	nvmem-cells = <&macaddr_factory_e006>;
+	nvmem-cell-names = "mac-address";
+};
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_e000: macaddr@e000 {
+		reg = <0xe000 0x6>;
+	};
+
+	macaddr_factory_e006: macaddr@e006 {
+		reg = <0xe006 0x6>;
+	};
 };
diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-882-a1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-882-a1.dts
index 01739fc258..3db056f68f 100644
--- a/target/linux/ramips/dts/mt7621_dlink_dir-882-a1.dts
+++ b/target/linux/ramips/dts/mt7621_dlink_dir-882-a1.dts
@@ -6,6 +6,10 @@
 / {
 	compatible = "dlink,dir-882-a1", "mediatek,mt7621-soc";
 	model = "D-Link DIR-882 A1";
+
+	aliases {
+		label-mac-device = &gmac0;
+	};
 };
 
 &leds {
@@ -23,3 +27,27 @@
 		linux,default-trigger = "usbport";
 	};
 };
+
+&gmac0 {
+	nvmem-cells = <&macaddr_factory_e000>;
+	nvmem-cell-names = "mac-address";
+};
+
+&wan {
+	nvmem-cells = <&macaddr_factory_e006>;
+	nvmem-cell-names = "mac-address";
+};
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_e000: macaddr@e000 {
+		reg = <0xe000 0x6>;
+	};
+
+	macaddr_factory_e006: macaddr@e006 {
+		reg = <0xe006 0x6>;
+	};
+};
diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-882-r1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-882-r1.dts
index 9b0cd8e7be..6cfa28b7cf 100644
--- a/target/linux/ramips/dts/mt7621_dlink_dir-882-r1.dts
+++ b/target/linux/ramips/dts/mt7621_dlink_dir-882-r1.dts
@@ -6,6 +6,10 @@
 / {
 	compatible = "dlink,dir-882-r1", "mediatek,mt7621-soc";
 	model = "D-Link DIR-882 R1";
+
+	aliases {
+		label-mac-device = &gmac0;
+	};
 };
 
 &leds {
@@ -23,3 +27,27 @@
 		linux,default-trigger = "usbport";
 	};
 };
+
+&gmac0 {
+	nvmem-cells = <&macaddr_factory_e000>;
+	nvmem-cell-names = "mac-address";
+};
+
+&wan {
+	nvmem-cells = <&macaddr_factory_e006>;
+	nvmem-cell-names = "mac-address";
+};
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_factory_e000: macaddr@e000 {
+		reg = <0xe000 0x6>;
+	};
+
+	macaddr_factory_e006: macaddr@e006 {
+		reg = <0xe006 0x6>;
+	};
+};
diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-8xx.dtsi b/target/linux/ramips/dts/mt7621_dlink_dir-8xx.dtsi
index 7ab0e8bd5d..556ca8b003 100644
--- a/target/linux/ramips/dts/mt7621_dlink_dir-8xx.dtsi
+++ b/target/linux/ramips/dts/mt7621_dlink_dir-8xx.dtsi
@@ -7,7 +7,6 @@
 
 / {
 	aliases {
-		label-mac-device = &gmac0;
 		led-boot = &led_power_orange;
 		led-failsafe = &led_power_green;
 		led-running = &led_power_green;
@@ -91,10 +90,6 @@
 	};
 };
 
-&gmac0 {
-	mtd-mac-address = <&factory 0xe000>;
-};
-
 &switch0 {
 	ports {
 		port@0 {
@@ -117,10 +112,9 @@
 			label = "lan1";
 		};
 
-		port@4 {
+		wan: port@4 {
 			status = "okay";
 			label = "wan";
-			mtd-mac-address = <&factory 0xe006>;
 		};
 	};
 };