]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
ipq40xx: use nvmem for mikrotik mac address 16257/head
authorRosen Penev <rosenp@gmail.com>
Sat, 24 Aug 2024 20:54:10 +0000 (13:54 -0700)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Thu, 11 Jun 2026 07:04:28 +0000 (09:04 +0200)
Userspace handling is deprecated.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/16257
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
target/linux/ipq40xx/base-files/etc/board.d/02_network
target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh
target/linux/ipq40xx/dts/qcom-ipq4018-cap-ac.dts
target/linux/ipq40xx/dts/qcom-ipq4018-hap-ac2.dts
target/linux/ipq40xx/dts/qcom-ipq4018-sxtsq-5-ac.dts
target/linux/ipq40xx/dts/qcom-ipq4018-wap-ac.dtsi
target/linux/ipq40xx/dts/qcom-ipq4019-hap-ac3-lte6-kit.dts
target/linux/ipq40xx/dts/qcom-ipq4019-hap-ac3.dts
target/linux/ipq40xx/dts/qcom-ipq4019-lhgg-60ad.dts
target/linux/ipq40xx/mikrotik/config-default

index 715c439a845135ec8fd27bbac720794fe79e9847..c3aced4df4d9ff8ae129aae9cfee86ee7c8286d8 100644 (file)
@@ -228,19 +228,6 @@ ipq40xx_setup_macs()
                wan_mac=$(get_mac_label)
                lan_mac=$(macaddr_add "$wan_mac" 1)
                ;;
-       mikrotik,cap-ac|\
-       mikrotik,hap-ac2|\
-       mikrotik,hap-ac3|\
-       mikrotik,hap-ac3-lte6-kit)
-               wan_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base)
-               lan_mac=$(macaddr_add $wan_mac 1)
-               label_mac="$wan_mac"
-               ;;
-       mikrotik,lhgg-60ad|\
-       mikrotik,sxtsq-5-ac)
-               lan_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base)
-               label_mac="$lan_mac"
-               ;;
        netgear,rbr40|\
        netgear,rbr50|\
        netgear,srr60|\
index 3ba21353483390ea1ce0a9ff913448140becad3f..4331e617dc9111f80a573075d8eb5da295ec0415 100644 (file)
@@ -19,13 +19,6 @@ preinit_set_mac_address() {
        extreme-networks,ws-ap391x)
                ip link set dev eth0 address $(mtd_get_mac_ascii CFG1 ethaddr)
                ;;
-       mikrotik,wap-ac|\
-       mikrotik,wap-ac-lte|\
-       mikrotik,wap-r-ac)
-               base_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base)
-               ip link set dev sw-eth1 address "$base_mac"
-               ip link set dev sw-eth2 address $(macaddr_add "$base_mac" 1)
-               ;;
        teltonika,rutx50)
                # Vendor Bootloader removes nvmem-cells from partition,
                # so this needs to be done here.
index 1d1b381be073434094eef105d3d100560d00a00b..7124397df071869366ec78777672bff92cf50ce5 100644 (file)
        };
 
        aliases {
-               // TODO: Verify if the ethernet0 alias is needed
-               ethernet0 = &gmac;
                led-boot = &led_user;
                led-failsafe = &led_user;
                led-running = &led_user;
                led-upgrade = &led_user;
+               label-mac-device = &gmac;
        };
 
        soc {
 
                                hard_config {
                                        read-only;
+
+                                       nvmem-layout {
+                                               compatible = "mikrotik,routerboot-nvmem";
+
+                                               macaddr_hard: base-mac-address {
+                                                       #nvmem-cell-cells = <1>;
+                                               };
+                                       };
                                };
 
                                dtb_config {
 
 &gmac {
        status = "okay";
+
+       nvmem-cells = <&macaddr_hard 0>;
+       nvmem-cell-names = "mac-address";
 };
 
 &switch {
        status = "okay";
 
        label = "lan";
+
+       nvmem-cells = <&macaddr_hard 1>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport5 {
index ddf6ef2df7deb7b3f2459ba7cf70f43bd2b8ede2..05664d5485b971356bf8aa87846ca609b2e180c5 100644 (file)
        };
 
        aliases {
-               // TODO: Verify if the ethernet0 alias is needed
-               ethernet0 = &gmac;
                led-boot = &led_user;
                led-failsafe = &led_user;
                led-running = &led_user;
                led-upgrade = &led_user;
+               label-mac-device = &gmac;
        };
 
        soc {
                                hard_config {
                                        read-only;
                                        size = <0x2000>;
+
+                                       nvmem-layout {
+                                               compatible = "mikrotik,routerboot-nvmem";
+
+                                               macaddr_hard: base-mac-address {
+                                                       #nvmem-cell-cells = <1>;
+                                               };
+                                       };
                                };
 
                                dtb_config {
 
 &gmac {
        status = "okay";
+
+       nvmem-cells = <&macaddr_hard 0>;
+       nvmem-cell-names = "mac-address";
 };
 
 &switch {
 &swport1 {
        status = "okay";
        label = "lan4";
+
+       nvmem-cells = <&macaddr_hard 4>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport2 {
        status = "okay";
        label = "lan3";
+
+       nvmem-cells = <&macaddr_hard 3>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport3 {
        status = "okay";
        label = "lan2";
+
+       nvmem-cells = <&macaddr_hard 2>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport4 {
        status = "okay";
        label = "lan1";
+
+       nvmem-cells = <&macaddr_hard 1>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport5 {
index be58defe961560ac5c0154d45016307e53d0d1f3..c3f88a16fee61a0eb30fba9823c18b16434c7ef7 100644 (file)
        };
 
        aliases {
-               // TODO: Verify if the ethernet0 alias is needed
-               ethernet0 = &gmac;
                led-boot = &led_user;
                led-failsafe = &led_user;
                led-running = &led_user;
                led-upgrade = &led_user;
+               label-mac-device = &gmac;
        };
 
        soc {
 
                                hard_config {
                                        read-only;
+
+                                       nvmem-layout {
+                                               compatible = "mikrotik,routerboot-nvmem";
+
+                                               macaddr_hard: base-mac-address {
+                                                       #nvmem-cell-cells = <1>;
+                                               };
+                                       };
                                };
 
                                dtb_config {
 
 &gmac {
        status = "okay";
+
+       nvmem-cells = <&macaddr_hard 0>;
+       nvmem-cell-names = "mac-address";
 };
 
 &switch {
index 9ce753f87de300cef62c06a4f1ef46b2384645d4..a37808b21ca1f14ccd21328393325ebc425c75fd 100644 (file)
        };
 
        aliases {
-               // TODO: Verify if the ethernet0 alias is needed
-               ethernet0 = &gmac;
                led-boot = &led_user;
                led-failsafe = &led_user;
                led-running = &led_user;
                led-upgrade = &led_user;
+               label-mac-device = &gmac;
        };
 
        soc {
                                hard_config {
                                        read-only;
                                        size = <0x2000>;
+
+                                       nvmem-layout {
+                                               compatible = "mikrotik,routerboot-nvmem";
+
+                                               macaddr_hard: base-mac-address {
+                                                       #nvmem-cell-cells = <1>;
+                                               };
+                                       };
                                };
 
                                dtb_config {
 
 &gmac {
        status = "okay";
+
+       nvmem-cells = <&macaddr_hard 0>;
+       nvmem-cell-names = "mac-address";
 };
 
 &switch {
 &swport4 {
        status = "okay";
        label = "sw-eth2";
+
+       nvmem-cells = <&macaddr_hard 1>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport5 {
index 80b536de7b4ef352be6c38ecfad46350279c7cbc..119e71d93473e6358fe95a874053ef07b65f7b6d 100644 (file)
        };
 
        aliases {
-               // TODO: Verify if the ethernet0 alias is needed
-               ethernet0 = &gmac;
                led-boot = &led_status_blue;
                led-failsafe = &led_status_red;
                led-running = &led_status_blue;
                led-upgrade = &led_status_red;
+               label-mac-device = &gmac;
        };
 
        soc {
 
                                hard_config {
                                        size = <0x2000>;
+
+                                       nvmem-layout {
+                                               compatible = "mikrotik,routerboot-nvmem";
+
+                                               macaddr_hard: base-mac-address {
+                                                       #nvmem-cell-cells = <1>;
+                                               };
+                                       };
                                };
 
                                dtb_config {
 
 &gmac {
        status = "okay";
+
+       nvmem-cells = <&macaddr_hard 0>;
+       nvmem-cell-names = "mac-address";
 };
 
 &switch {
 &swport1 {
        status = "okay";
        label = "lan4";
+
+       nvmem-cells = <&macaddr_hard 4>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport2 {
        status = "okay";
        label = "lan3";
+
+       nvmem-cells = <&macaddr_hard 3>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport3 {
        status = "okay";
        label = "lan2";
+
+       nvmem-cells = <&macaddr_hard 2>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport4 {
        status = "okay";
        label = "lan1";
+
+       nvmem-cells = <&macaddr_hard 1>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport5 {
index 0f311d0e2e8697dc3d53c68721a6a6a374654c91..c4a6622b0f6c7af892bdc8da82655a871620db7e 100644 (file)
        };
 
        aliases {
-               // TODO: Verify if the ethernet0 alias is needed
-               ethernet0 = &gmac;
                led-boot = &led_status_blue;
                led-failsafe = &led_status_red;
                led-running = &led_status_blue;
                led-upgrade = &led_status_red;
+               label-mac-device = &gmac;
        };
 
        soc {
                                hard_config {
                                        read-only;
                                        size = <0x2000>;
+
+                                       nvmem-layout {
+                                               compatible = "mikrotik,routerboot-nvmem";
+
+                                               macaddr_hard: base-mac-address {
+                                                       #nvmem-cell-cells = <1>;
+                                               };
+                                       };
                                };
 
                                dtb_config {
 
 &gmac {
        status = "okay";
+
+       nvmem-cells = <&macaddr_hard 0>;
+       nvmem-cell-names = "mac-address";
 };
 
 &switch {
 &swport1 {
        status = "okay";
        label = "lan4";
+
+       nvmem-cells = <&macaddr_hard 4>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport2 {
        status = "okay";
        label = "lan3";
+
+       nvmem-cells = <&macaddr_hard 3>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport3 {
        status = "okay";
        label = "lan2";
+
+       nvmem-cells = <&macaddr_hard 2>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport4 {
        status = "okay";
        label = "lan1";
+
+       nvmem-cells = <&macaddr_hard 1>;
+       nvmem-cell-names = "mac-address";
 };
 
 &swport5 {
index ad3509ddc54bca572347db26919ca246c1ae21f8..9c17e75d8d19e6c4d525e11c97d314bb1ece0895 100644 (file)
        };
 
        aliases {
-               // TODO: Verify if the ethernet0 alias is needed
-               ethernet0 = &gmac;
                led-boot = &user;
                led-failsafe = &user;
                led-running = &user;
                led-upgrade = &user;
+               label-mac-device = &gmac;
        };
 
        soc {
                                hard_config {
                                        read-only;
                                        size = <0x2000>;
+
+                                       nvmem-layout {
+                                               compatible = "mikrotik,routerboot-nvmem";
+
+                                               macaddr_hard: base-mac-address {
+                                                       #nvmem-cell-cells = <1>;
+                                               };
+                                       };
                                };
 
                                dtb_config {
 
 &gmac {
        status = "okay";
+
+       nvmem-cells = <&macaddr_hard 0>;
+       nvmem-cell-names = "mac-address";
 };
 
 &switch {
index c334f8c2928035547ac38ee5fde9340d676251c9..37bbbd0f7c19421e9d22f48655a38847887be439 100644 (file)
@@ -11,5 +11,5 @@ CONFIG_MTD_UBI_BEB_LIMIT=20
 CONFIG_MTD_UBI_BLOCK=y
 CONFIG_MTD_UBI_NVMEM=y
 CONFIG_MTD_UBI_WL_THRESHOLD=4096
-# CONFIG_NVMEM_LAYOUT_MIKROTIK is not set
+CONFIG_NVMEM_LAYOUT_MIKROTIK=y
 CONFIG_UBIFS_FS=y