qualcommax: ipq50xx: use ascii-env driver to set mac address for Linksys MX devices
authorGeorge Moussalem <george.moussalem@outlook.com>
Thu, 6 Feb 2025 08:14:27 +0000 (12:14 +0400)
committerRobert Marko <robimarko@gmail.com>
Thu, 20 Feb 2025 17:24:39 +0000 (18:24 +0100)
The ascii-env driver enables reading name pair values from nand in ascii layout.
So, let's pick up and set the mac address accordingly.

Signed-off-by: George Moussalem <george.moussalem@outlook.com>
Link: https://github.com/openwrt/openwrt/pull/18029
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/qualcommax/config-6.6
target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx-base.dtsi
target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx2000.dts
target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx5500.dts
target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-spnmx56.dts
target/linux/qualcommax/ipq50xx/base-files/etc/board.d/02_network

index a24a6171241146545b20168953d962a04ddbd72e..1467bc968ba87b0899e699f3908151a2d438ea80 100644 (file)
@@ -278,6 +278,7 @@ CONFIG_NR_CPUS=4
 CONFIG_NVIDIA_CARMEL_CNP_ERRATUM=y
 CONFIG_NVMEM=y
 CONFIG_NVMEM_LAYOUTS=y
+CONFIG_NVMEM_LAYOUT_ASCII_ENV=y
 CONFIG_NVMEM_LAYOUT_U_BOOT_ENV=y
 CONFIG_NVMEM_QCOM_QFPROM=y
 # CONFIG_NVMEM_QCOM_SEC_QFPROM is not set
index 57fe5c53a94467bb2521ec70f74ad9e37f9d4731..a015fcbd34ba326e0c08caccc066fa9c19c51b1a 100644 (file)
@@ -8,8 +8,6 @@
 / {
 
        aliases {
-               ethernet0 = &dp1;
-               ethernet1 = &dp2;
                led-boot = &led_system_blue;
                led-failsafe = &led_system_red;
                led-running = &led_system_blue;
                                label = "devinfo";
                                reg = <0x00680000 0x40000>;
                                read-only;
+
+                               nvmem-layout {
+                                       compatible = "ascii-eq-delim-env";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       hw_mac_addr: hw_mac_addr {
+                                               compatible = "mac-base";
+
+                                               #nvmem-cell-cells = <1>;
+                                       };
+                               };
                        };
 
                        partition@6c0000 {
index 108b26f8d1201d714d74b3d5c2399945c6f6ff70..e563cca779ed343807394b36c53d7f10c0e22c21 100644 (file)
 // MAC1 ---SGMII---> QCA8337 SerDes
 &dp2 {
        status = "okay";
+
        phy-mode = "sgmii";
 
+       nvmem-cells = <&hw_mac_addr 0>;
+       nvmem-cell-names = "mac-address";
+
        fixed-link {
                speed = <1000>;
                full-duplex;
index 630e8ba310f34eeaef1e301777ea69ba6ea79e77..ab3e00a9ccda343f932c2949de3298bd448c83e7 100644 (file)
 // MAC1 ---SGMII---> QCA8337 SerDes
 &dp2 {
        status = "okay";
+
        phy-mode = "sgmii";
 
+       nvmem-cells = <&hw_mac_addr 0>;
+       nvmem-cell-names = "mac-address";
+
        fixed-link {
                speed = <1000>;
                full-duplex;
index 75b94445140b189860ccdda8103db5e5aa9505ee..d25ff0f1cbf15931644577bdaf8f775ca442d777 100644 (file)
@@ -53,6 +53,9 @@
 // MAC0 -> GE Phy
 &dp1 {
        status = "okay";
+
+       nvmem-cells = <&hw_mac_addr 0>;
+       nvmem-cell-names = "mac-address";
 };
 
 // MAC1 ---SGMII---> QCA8081
@@ -61,6 +64,8 @@
 
        label = "wan";
        phy-handle = <&qca8081>;
+       nvmem-cells = <&hw_mac_addr 0>;
+       nvmem-cell-names = "mac-address";
 };
 
 &mdio0 {
index c80b259d27f28d791018eb0690350f08915e05e2..6c8574c474362b2177a8e699d4901ca3756113ae 100644 (file)
@@ -15,33 +15,9 @@ ipq50xx_setup_interfaces()
        esac
 }
 
-ipq50xx_setup_macs()
-{
-       local board="$1"
-       local lan_mac=""
-       local wan_mac=""
-       local label_mac=""
-
-       case "$board" in
-       linksys,mx2000|\
-       linksys,mx5500|\
-       linksys,spnmx56)
-               label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
-               lan_mac=$label_mac
-               wan_mac=$label_mac
-               ucidef_set_network_device_mac eth0 $label_mac
-               ;;
-       esac
-
-       [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
-       [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
-       [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
-}
-
 board_config_update
 board=$(board_name)
 ipq50xx_setup_interfaces $board
-ipq50xx_setup_macs $board
 board_config_flush
 
 exit 0