[PATCH v3 4/7] ath79: ja76pf2: use nvmem cells to specify MAC adresses

Tomasz Maciej Nowak tmn505 at terefe.re
Tue Jun 7 06:58:29 PDT 2022


From: Tomasz Maciej Nowak <tmn505 at gmail.com>

The bootloader on this board hid the partition containig MAC addresses
and prevented adding this space to FIS directory, therefore those had to
be stored in RedBoot configuration as aliases to be able to assigne them
to proper interfaces. Now that fixed partition size are used instead of
redboot-fis parser, the partition containig MAC adresses could be
specified, and with marking it as nvmem cell, we can assign them without
userspace involvement.

Signed-off-by: Tomasz Maciej Nowak <tmn505 at gmail.com>
---
 target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts  | 15 +++++++++++++++
 .../generic/base-files/etc/board.d/02_network     |  4 ----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts b/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts
index bcb017c88c54..a3d66da61414 100644
--- a/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts
+++ b/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts
@@ -103,12 +103,16 @@
 &eth0 {
 	status = "okay";
 
+	nvmem-cells = <&macaddr_lan>;
+	nvmem-cell-names = "mac-address";
 	phy-handle = <&phy0>;
 };
 
 &eth1 {
 	status = "okay";
 
+	nvmem-cells = <&macaddr_wan>;
+	nvmem-cell-names = "mac-address";
 	phy-handle = <&phy4>;
 };
 
@@ -163,6 +167,17 @@
 				label = "Atheros Board Data";
 				reg = <0xff0000 0x10000>;
 				read-only;
+				compatible = "nvmem-cells";
+				#address-cells = <1>;
+				#size-cells = <1>;
+
+				macaddr_wan: macaddr at 1000 {
+					reg = <0x1000 0x6>;
+				};
+
+				macaddr_lan: macaddr at 1006 {
+					reg = <0x1006 0x6>;
+				};
 			};
 		};
 	};
diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network
index 48cd81fb2117..662bf3145ba2 100644
--- a/target/linux/ath79/generic/base-files/etc/board.d/02_network
+++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network
@@ -660,10 +660,6 @@ ath79_setup_macs()
 		wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
 		label_mac=$wan_mac
 		;;
-	jjplus,ja76pf2)
-		wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n alias/ethaddr)
-		lan_mac=$(macaddr_add "$wan_mac" 1)
-		;;
 	mercury,mw4530r-v1|\
 	tplink,tl-wdr3600-v1|\
 	tplink,tl-wdr4300-v1|\
-- 
2.36.1




More information about the openwrt-devel mailing list