[openwrt/openwrt] ipq40xx: Meraki MR33: convert MAC addresses to nvmem

LEDE Commits lede-commits at lists.infradead.org
Sun Oct 2 14:05:53 PDT 2022


blocktrron pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/b9b4c51b2b78ba501cbf47b7d9fc19cf8bcd65ea

commit b9b4c51b2b78ba501cbf47b7d9fc19cf8bcd65ea
Author: Lech Perczak <lech.perczak at gmail.com>
AuthorDate: Wed Dec 15 21:10:11 2021 +0100

    ipq40xx: Meraki MR33: convert MAC addresses to nvmem
    
    This fixes assigning random MAC to br-lan interface upon boot.
    While at that, rename at24 at 50 node to eeprom at 50, to align with upstream
    device tree style.
    
    Signed-off-by: Lech Perczak <lech.perczak at gmail.com>
---
 .../etc/hotplug.d/firmware/11-ath10k-caldata         |  3 ---
 .../lib/preinit/05_set_iface_mac_ipq40xx.sh          |  5 -----
 .../arm/boot/dts/qcom-ipq4029-insect-common.dtsi     | 20 +++++++++++++++++++-
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index f8d270a659..64215746d5 100644
--- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -13,7 +13,6 @@ case "$FIRMWARE" in
 	meraki,mr74)
 		caldata_extract_ubi "ART" 0x9000 0x844
 		caldata_valid "4408" || caldata_extract "ART" 0x9000 0x844
-		ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) 1)
 		;;
 	esac
 	;;
@@ -117,7 +116,6 @@ case "$FIRMWARE" in
 	meraki,mr74)
 		caldata_extract_ubi "ART" 0x1000 0x2f20
 		caldata_valid "202f" || caldata_extract "ART" 0x1000 0x2f20
-		ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) 2)
 		;;
 	mikrotik,cap-ac |\
 	mikrotik,hap-ac2 |\
@@ -214,7 +212,6 @@ case "$FIRMWARE" in
 	meraki,mr74)
 		caldata_extract_ubi "ART" 0x5000 0x2f20
 		caldata_valid "202f" || caldata_extract "ART" 0x5000 0x2f20
-		ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) 3)
 		;;
 	mikrotik,cap-ac |\
 	mikrotik,hap-ac2 |\
diff --git a/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh b/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh
index 3c247ae6aa..18c24e0511 100644
--- a/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh
+++ b/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh
@@ -24,11 +24,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)
 		;;
-	meraki,mr33|\
-	meraki,mr74)
-		mac_lan=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66)
-		[ -n "$mac_lan" ] && ip link set dev eth0 address "$mac_lan"
-		;;
 	mikrotik,wap-ac)
 		base_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base)
 		ip link set dev eth0 address "$base_mac"
diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-insect-common.dtsi b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-insect-common.dtsi
index bc385d330e..ebfab171f5 100644
--- a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-insect-common.dtsi
+++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-insect-common.dtsi
@@ -127,11 +127,18 @@
 	pinctrl-0 = <&i2c_0_pins>;
 	pinctrl-names = "default";
 	status = "okay";
-	at24 at 50 {
+
+	eeprom at 50 {
 		compatible = "atmel,24c64";
 		pagesize = <32>;
 		reg = <0x50>;
 		read-only; /* This holds our MAC & Meraki board-data */
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		mac_address: mac-address at 66 {
+			reg = <0x66 0x6>;
+		};
 	};
 };
 
@@ -277,6 +284,9 @@
 			compatible = "qcom,ath10k";
 			status = "okay";
 			reg = <0x00010000 0 0 0 0>;
+			nvmem-cells = <&mac_address>;
+			nvmem-cell-names = "mac-address";
+			mac-address-increment = <1>;
 		};
 	};
 };
@@ -380,15 +390,23 @@
 &wifi0 {
 	status = "okay";
 	qcom,ath10k-calibration-variant = "Meraki-MR33";
+	nvmem-cells = <&mac_address>;
+	nvmem-cell-names = "mac-address";
+	mac-address-increment = <2>;
 };
 
 &wifi1 {
 	status = "okay";
 	qcom,ath10k-calibration-variant = "Meraki-MR33";
+	nvmem-cells = <&mac_address>;
+	nvmem-cell-names = "mac-address";
+	mac-address-increment = <3>;
 };
 
 &gmac {
 	status = "okay";
+	nvmem-cells = <&mac_address>;
+	nvmem-cell-names = "mac-address";
 };
 
 &switch {




More information about the lede-commits mailing list