From: Tianling Shen Date: Tue, 2 Apr 2024 12:26:45 +0000 (+0800) Subject: mediatek: convert eeprom/macaddr to nvmem format for cmcc rax3000m X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=eb510d21588cfa48cb70e696469be03f2d7404e1;p=openwrt%2Fstaging%2Fthess.git 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 --- 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@0 { + target = <&gmac0>; + __overlay__ { + nvmem-cells = <&macaddr_factory_2a 0>; + nvmem-cell-names = "mac-address"; + }; + }; + + fragment@1 { + target = <&gmac1>; + __overlay__ { + nvmem-cells = <&macaddr_factory_24 0>; + nvmem-cell-names = "mac-address"; + }; + }; + + fragment@2 { target = <&mmc0>; __overlay__ { bus-width = <8>; @@ -19,10 +35,47 @@ pinctrl-1 = <&mmc0_pins_uhs>; vmmc-supply = <®_3p3v>; status = "okay"; + + card@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@0 { + reg = <0x0 0x1000>; + }; + + macaddr_factory_24: macaddr@24 { + compatible = "mac-base"; + reg = <0x24 0x6>; + #nvmem-cell-cells = <1>; + }; + + macaddr_factory_2a: macaddr@2a { + compatible = "mac-base"; + reg = <0x2a 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; + }; }; }; - fragment@1 { + fragment@3 { target = <&pio>; __overlay__ { mmc0_pins_default: mmc0-pins { @@ -40,4 +93,12 @@ }; }; }; + + fragment@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@180000 { + partition@180000 { label = "factory"; reg = <0x180000 0x200000>; read-only; @@ -89,6 +89,10 @@ #address-cells = <1>; #size-cells = <1>; + eeprom_factory_0: eeprom@0 { + reg = <0x0 0x1000>; + }; + macaddr_factory_24: macaddr@24 { compatible = "mac-base"; reg = <0x24 0x6>; @@ -121,7 +125,8 @@ fragment@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)