[][kernel][common][eth][Update MDI Reversal feature for the Aquantia PHY driver]
[Description]
Refactor MDI Reversal feature for the Aquantia PHY driver.
Kindly determine the most suitable configuration based on the hardware
design.
1. MDI Reversed
mdi-reversal = /bits/ 16 <1>;
2. MDI Normal
mdi-reversal = /bits/ 16 <0>;
If without this patch, kernel cannot configure MDI Reversal of the
Aquantia PHY device by the DTS.
[Release-log]
N/A
Change-Id: I23cc00e810f1a6b37749b225eb25fe142a5b2f72
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7534218
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-88d-10g-spim-nand.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-88d-10g-spim-nand.dts
index 3dbbae8..9e2e9a9 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-88d-10g-spim-nand.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-88d-10g-spim-nand.dts
@@ -426,6 +426,7 @@
reset-gpios = <&pio 72 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
phy1: ethernet-phy@8 {
@@ -434,6 +435,7 @@
reset-gpios = <&pio 71 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
switch@0 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-emmc.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-emmc.dts
index 1011cb3..201f9ee 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-emmc.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-emmc.dts
@@ -237,6 +237,7 @@
reset-gpios = <&pio 72 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
phy1: ethernet-phy@8 {
@@ -245,6 +246,7 @@
reset-gpios = <&pio 71 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
switch@0 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-sd.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-sd.dts
index 5548023..d664a46 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-sd.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-sd.dts
@@ -228,6 +228,7 @@
reset-gpios = <&pio 72 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
phy1: ethernet-phy@8 {
@@ -236,6 +237,7 @@
reset-gpios = <&pio 71 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
switch@0 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-snfi-nand.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-snfi-nand.dts
index eb076ed..c7e83fd 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-snfi-nand.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-snfi-nand.dts
@@ -263,6 +263,7 @@
reset-gpios = <&pio 72 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
phy1: ethernet-phy@8 {
@@ -271,6 +272,7 @@
reset-gpios = <&pio 71 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
switch@0 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-spim-nand.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-spim-nand.dts
index d305570..cf117ca 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-spim-nand.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-spim-nand.dts
@@ -421,6 +421,7 @@
reset-gpios = <&pio 72 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
phy1: ethernet-phy@8 {
@@ -429,6 +430,7 @@
reset-gpios = <&pio 71 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
switch@0 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-spim-nor.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-spim-nor.dts
index 62cb90e..a9fc3c5 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-spim-nor.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-10g-spim-nor.dts
@@ -255,6 +255,7 @@
reset-gpios = <&pio 72 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
phy1: ethernet-phy@8 {
@@ -263,6 +264,7 @@
reset-gpios = <&pio 71 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
switch@0 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-i2p5g-spim-nand.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-i2p5g-spim-nand.dts
index ebc7846..2a24f7d 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-i2p5g-spim-nand.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-dsa-i2p5g-spim-nand.dts
@@ -263,6 +263,10 @@
phy1: ethernet-phy@8 {
reg = <8>;
compatible = "ethernet-phy-ieee802.3-c45";
+ reset-gpios = <&pio 71 1>;
+ reset-assert-us = <100000>;
+ reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
switch@0 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-gsw-10g-spim-nand-4pcie.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-gsw-10g-spim-nand-4pcie.dts
index 5969966..fde3572 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-gsw-10g-spim-nand-4pcie.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-gsw-10g-spim-nand-4pcie.dts
@@ -359,6 +359,7 @@
reset-gpios = <&pio 72 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
phy1: ethernet-phy@8 {
@@ -367,6 +368,7 @@
reset-gpios = <&pio 71 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
};
};
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-gsw-10g-spim-nand.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-gsw-10g-spim-nand.dts
index d1371c4..0941b06 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-gsw-10g-spim-nand.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988a-gsw-10g-spim-nand.dts
@@ -392,6 +392,7 @@
reset-gpios = <&pio 72 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
phy1: ethernet-phy@8 {
@@ -400,6 +401,7 @@
reset-gpios = <&pio 71 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
};
};
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-emmc.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-emmc.dts
index bfa63ba..ba29680 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-emmc.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-emmc.dts
@@ -252,6 +252,7 @@
reset-gpios = <&pio 3 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
switch@0 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-sd.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-sd.dts
index 7635fe4..133da0c 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-sd.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-sd.dts
@@ -243,6 +243,7 @@
reset-gpios = <&pio 3 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
switch@0 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-snfi-nand.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-snfi-nand.dts
index 887ff0f..7721c07 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-snfi-nand.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-snfi-nand.dts
@@ -278,6 +278,7 @@
reset-gpios = <&pio 3 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
switch@0 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-spim-nand.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-spim-nand.dts
index 6bb5bdf..06b5702 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-spim-nand.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-spim-nand.dts
@@ -418,6 +418,7 @@
reset-gpios = <&pio 3 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
switch@0 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-spim-nor.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-spim-nor.dts
index 08f9b27..61cdf7b 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-spim-nor.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-dsa-10g-spim-nor.dts
@@ -270,6 +270,7 @@
reset-gpios = <&pio 3 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
switch@0 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-gsw-10g-spim-nand.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-gsw-10g-spim-nand.dts
index eea19a7..a86e77e 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-gsw-10g-spim-nand.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7988d-gsw-10g-spim-nand.dts
@@ -394,6 +394,7 @@
reset-gpios = <&pio 3 1>;
reset-assert-us = <100000>;
reset-deassert-us = <221000>;
+ mdi-reversal = /bits/ 16 <1>;
};
};
};
diff --git a/target/linux/mediatek/mt7988/config-5.4 b/target/linux/mediatek/mt7988/config-5.4
index e542a51..e706419 100644
--- a/target/linux/mediatek/mt7988/config-5.4
+++ b/target/linux/mediatek/mt7988/config-5.4
@@ -7,7 +7,6 @@
CONFIG_AQUANTIA_PHY_FW_DOWNLOAD_GANG=y
# CONFIG_AQUANTIA_PHY_FW_DOWNLOAD_SINGLE is not set
CONFIG_AQUANTIA_PHY_FW_FILE="Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld"
-# CONFIG_AQUANTIA_PHY_MDI_SWAP is not set
CONFIG_ARCH_CLOCKSOURCE_DATA=y
CONFIG_ARCH_DMA_ADDR_T_64BIT=y
CONFIG_ARCH_KEEP_MEMBLOCK=y
diff --git a/target/linux/mediatek/patches-5.4/751-net-phy-aquantia-add-firmware-download.patch b/target/linux/mediatek/patches-5.4/751-net-phy-aquantia-add-firmware-download.patch
index f6e0f95..0e38dad 100644
--- a/target/linux/mediatek/patches-5.4/751-net-phy-aquantia-add-firmware-download.patch
+++ b/target/linux/mediatek/patches-5.4/751-net-phy-aquantia-add-firmware-download.patch
@@ -2,31 +2,13 @@
index 7b49c94..5a79af2 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
-@@ -372,7 +372,56 @@ config AMD_PHY
+@@ -372,7 +372,38 @@ config AMD_PHY
config AQUANTIA_PHY
tristate "Aquantia PHYs"
---help---
- Currently supports the Aquantia AQ1202, AQ2104, AQR105, AQR405
+ Currently supports the Aquantia AQ1202, AQ2104, AQR105, AQR405, AQR113C
+
-+config AQUANTIA_PHY_MDI_SWAP
-+ tristate "MDI Swap Enable"
-+ depends on AQUANTIA_PHY
-+ ---help---
-+ Currently supports the Aquantia AQR113C
-+
-+choice
-+ prompt "Swap mode"
-+ default AQUANTIA_PHY_MDI_REVERSED
-+ depends on AQUANTIA_PHY_MDI_SWAP
-+
-+ config AQUANTIA_PHY_MDI_NORMAL
-+ bool "Normal"
-+
-+ config AQUANTIA_PHY_MDI_REVERSED
-+ bool "Reversed"
-+endchoice
-+
+config AQUANTIA_PHY_FW_DOWNLOAD
+ tristate "Firmware Download Enable"
+ depends on AQUANTIA_PHY
@@ -155,7 +137,7 @@
index 0000000..622557c
--- /dev/null
+++ b/drivers/net/phy/aquantia_firmware.c
-@@ -0,0 +1,1092 @@
+@@ -0,0 +1,1090 @@
+// SPDX-License-Identifier: GPL-2.0
+/* FW download driver for Aquantia PHY
+ */
@@ -1129,9 +1111,7 @@
+
+ aqr107_chip_info(phydevs[i]);
+
-+#ifdef CONFIG_AQUANTIA_PHY_MDI_SWAP
+ aqr107_config_mdi(phydevs[i]);
-+#endif
+
+ aqr107_set_downshift(phydevs[i],
+ MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT);
@@ -1252,7 +1232,7 @@
index a8c828b..d98757f 100644
--- a/drivers/net/phy/aquantia_main.c
+++ b/drivers/net/phy/aquantia_main.c
-@@ -8,6 +8,7 @@
+@@ -8,10 +8,12 @@
*/
#include <linux/kernel.h>
@@ -1260,6 +1240,11 @@
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/bitfield.h>
+ #include <linux/phy.h>
++#include <linux/of.h>
+
+ #include "aquantia.h"
+
@@ -39,7 +40,6 @@
#define MDIO_AN_VEND_PROV_2500BASET_FULL BIT(10)
#define MDIO_AN_VEND_PROV_DOWNSHIFT_EN BIT(4)
@@ -1337,25 +1322,29 @@
{
u8 fw_major, fw_minor, build_id, prov_id;
int val;
-@@ -505,6 +444,17 @@ static void aqr107_chip_info(struct phy_device *phydev)
+@@ -505,6 +444,21 @@ static void aqr107_chip_info(struct phy_device *phydev)
fw_major, fw_minor, build_id, prov_id);
}
+int aqr107_config_mdi(struct phy_device *phydev)
+{
-+#ifdef CONFIG_AQUANTIA_PHY_MDI_REVERSED
-+ return phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, PMAPMD_RSVD_VEND_PROV,
-+ PMAPMD_RSVD_VEND_PROV_MDI_CONF, 1);
-+#else
++ struct device_node *np = phydev->mdio.dev.of_node;
++ u16 val;
++
++ if (of_property_read_u16(np, "mdi-reversal", &val))
++ return -ENOENT;
++
++ if (!FIELD_FIT(PMAPMD_RSVD_VEND_PROV_MDI_CONF, val))
++ return -E2BIG;
++
+ return phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, PMAPMD_RSVD_VEND_PROV,
-+ PMAPMD_RSVD_VEND_PROV_MDI_CONF, 0);
-+#endif
++ PMAPMD_RSVD_VEND_PROV_MDI_CONF, val);
+}
+
static int aqr107_config_init(struct phy_device *phydev)
{
int ret;
-@@ -520,6 +470,14 @@ static int aqr107_config_init(struct phy_device *phydev)
+@@ -520,6 +470,12 @@ static int aqr107_config_init(struct phy_device *phydev)
ret = aqr107_wait_reset_complete(phydev);
if (!ret)
aqr107_chip_info(phydev);
@@ -1364,9 +1353,7 @@
+ return aqr_firmware_download(phydev);
+#endif
+
-+#ifdef CONFIG_AQUANTIA_PHY_MDI_SWAP
+ aqr107_config_mdi(phydev);
-+#endif
return aqr107_set_downshift(phydev, MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT);
}