[openwrt/openwrt] mediatek: convert eeprom/macaddr to nvmem format for cmcc rax3000m
LEDE Commits
lede-commits at lists.infradead.org
Thu Jul 18 05:22:27 PDT 2024
dangole pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/eb510d21588cfa48cb70e696469be03f2d7404e1
commit eb510d21588cfa48cb70e696469be03f2d7404e1
Author: Tianling Shen <cnsztl at immortalwrt.org>
AuthorDate: Tue Apr 2 20:26:45 2024 +0800
mediatek: convert eeprom/macaddr to nvmem format for cmcc rax3000m
Switch to new nvmem binding.
Also fixes a issue that the MAC address assigned to lan/wan was
reversed on eMMC boards.
Signed-off-by: Tianling Shen <cnsztl at immortalwrt.org>
---
.../mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso | 63 +++++++++++++++++++++-
.../mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso | 9 +++-
.../filogic/base-files/etc/board.d/02_network | 9 ----
.../etc/hotplug.d/firmware/11-mt76-caldata | 7 ---
.../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 11 +---
5 files changed, 71 insertions(+), 28 deletions(-)
diff --git a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso
index c1c9c75c27..bfccc923a4 100644
--- a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso
+++ b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso
@@ -7,6 +7,22 @@
compatible = "cmcc,rax3000m", "mediatek,mt7981";
fragment at 0 {
+ target = <&gmac0>;
+ __overlay__ {
+ nvmem-cells = <&macaddr_factory_2a 0>;
+ nvmem-cell-names = "mac-address";
+ };
+ };
+
+ fragment at 1 {
+ target = <&gmac1>;
+ __overlay__ {
+ nvmem-cells = <&macaddr_factory_24 0>;
+ nvmem-cell-names = "mac-address";
+ };
+ };
+
+ fragment at 2 {
target = <&mmc0>;
__overlay__ {
bus-width = <8>;
@@ -19,10 +35,47 @@
pinctrl-1 = <&mmc0_pins_uhs>;
vmmc-supply = <®_3p3v>;
status = "okay";
+
+ card at 0 {
+ compatible = "mmc-card";
+ reg = <0>;
+
+ block {
+ compatible = "block-device";
+
+ partitions {
+ block-partition-factory {
+ partname = "factory";
+
+ nvmem-layout {
+ compatible = "fixed-layout";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ eeprom_factory_0: eeprom at 0 {
+ reg = <0x0 0x1000>;
+ };
+
+ macaddr_factory_24: macaddr at 24 {
+ compatible = "mac-base";
+ reg = <0x24 0x6>;
+ #nvmem-cell-cells = <1>;
+ };
+
+ macaddr_factory_2a: macaddr at 2a {
+ compatible = "mac-base";
+ reg = <0x2a 0x6>;
+ #nvmem-cell-cells = <1>;
+ };
+ };
+ };
+ };
+ };
+ };
};
};
- fragment at 1 {
+ fragment at 3 {
target = <&pio>;
__overlay__ {
mmc0_pins_default: mmc0-pins {
@@ -40,4 +93,12 @@
};
};
};
+
+ fragment at 4 {
+ target = <&wifi>;
+ __overlay__ {
+ nvmem-cells = <&eeprom_factory_0>;
+ nvmem-cell-names = "eeprom";
+ };
+ };
};
diff --git a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso
index 4d2b01cb63..3f401b53d3 100644
--- a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso
+++ b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso
@@ -79,7 +79,7 @@
reg = <0x100000 0x80000>;
};
- factory: partition at 180000 {
+ partition at 180000 {
label = "factory";
reg = <0x180000 0x200000>;
read-only;
@@ -89,6 +89,10 @@
#address-cells = <1>;
#size-cells = <1>;
+ eeprom_factory_0: eeprom at 0 {
+ reg = <0x0 0x1000>;
+ };
+
macaddr_factory_24: macaddr at 24 {
compatible = "mac-base";
reg = <0x24 0x6>;
@@ -121,7 +125,8 @@
fragment at 4 {
target = <&wifi>;
__overlay__ {
- mediatek,mtd-eeprom = <&factory 0x0>;
+ nvmem-cells = <&eeprom_factory_0>;
+ nvmem-cell-names = "eeprom";
};
};
};
diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
index 1a210810bc..c9c8a87f54 100644
--- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
@@ -134,15 +134,6 @@ mediatek_setup_macs()
bananapi,bpi-r4)
wan_mac=$(macaddr_add $(cat /sys/class/net/eth0/address) 1)
;;
- cmcc,rax3000m)
- case "$(cmdline_get_var root)" in
- /dev/mmc*)
- wan_mac=$(mmc_get_mac_binary factory 0x2a)
- lan_mac=$(mmc_get_mac_binary factory 0x24)
- label_mac=$wan_mac
- ;;
- esac
- ;;
h3c,magic-nx30-pro)
wan_mac=$(mtd_get_mac_ascii pdt_data_1 ethaddr)
lan_mac=$(macaddr_add "$wan_mac" 1)
diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
index 920a16d05d..c6900e6ebd 100644
--- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
+++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
@@ -24,13 +24,6 @@ case "$FIRMWARE" in
;;
"mediatek/mt7981_eeprom_mt7976_dbdc.bin")
case "$board" in
- cmcc,rax3000m)
- case "$(cmdline_get_var root)" in
- /dev/mmc*)
- caldata_extract_mmc "factory" 0x0 0x1000
- ;;
- esac
- ;;
ubnt,unifi-6-plus)
caldata_extract_mmc "factory" 0x0 0x1000
;;
diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
index 942facee87..98b1023e3e 100644
--- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
+++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
@@ -55,15 +55,8 @@ case "$board" in
[ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 2) > /sys${DEVPATH}/macaddress
;;
cmcc,rax3000m)
- case "$(cmdline_get_var root)" in
- /dev/mmc*)
- addr=$(mmc_get_mac_binary factory 0xa)
- ;;
- *)
- addr=$(mtd_get_mac_binary factory 0xa)
- ;;
- esac
- [ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
+ addr=$(cat /sys/class/net/eth0/address)
+ [ "$PHYNBR" = "1" ] && macaddr_add $addr -1 > /sys${DEVPATH}/macaddress
;;
comfast,cf-e393ax)
addr=$(mtd_get_mac_binary "Factory" 0x8000)
More information about the lede-commits
mailing list