[][kernel][common][eth][Add the new firmware for Aquantia AQR113C and CUX3410]

[Description]
Add the new firmware for Aquantia AQR113C and CUX3410.

In addition to adding new firmware, we also modified the LED
configuration of the new firmware in Aquantia PHY driver.
This firmware has passed throughput, packet loss and HW CTS
verification.

Without this patch, we cannot TX/RX packets via CUX3410 and
PHY LED cannot display PHY status correctly.

Notice: Do not use the new firmware for AQR113C and CUX3410
without this patch.

[Release-log]
N/A


Change-Id: Idb0dc9c2b1c3bfb840c8dcbde631ffc2c279569b
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8710381
diff --git a/21.02/files/target/linux/mediatek/mt7988/base-files/lib/firmware/AQR-G4_v5.7.0-AQR_EVB_Generic_X3410_StdCfg_MDISwap_USX_ID46316_VER2140.cld b/21.02/files/target/linux/mediatek/mt7988/base-files/lib/firmware/AQR-G4_v5.7.0-AQR_EVB_Generic_X3410_StdCfg_MDISwap_USX_ID46316_VER2140.cld
new file mode 100644
index 0000000..1baac15
--- /dev/null
+++ b/21.02/files/target/linux/mediatek/mt7988/base-files/lib/firmware/AQR-G4_v5.7.0-AQR_EVB_Generic_X3410_StdCfg_MDISwap_USX_ID46316_VER2140.cld
Binary files differ
diff --git a/21.02/files/target/linux/mediatek/mt7988/config-5.4 b/21.02/files/target/linux/mediatek/mt7988/config-5.4
index 714ff5d..9595e68 100644
--- a/21.02/files/target/linux/mediatek/mt7988/config-5.4
+++ b/21.02/files/target/linux/mediatek/mt7988/config-5.4
@@ -7,7 +7,7 @@
 CONFIG_AQUANTIA_PHY_FW_DOWNLOAD=y
 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_FW_FILE="AQR-G4_v5.7.0-AQR_EVB_Generic_X3410_StdCfg_MDISwap_USX_ID46316_VER2140.cld"
 CONFIG_AQUANTIA_PHY_MIB=y
 CONFIG_ARCH_CLOCKSOURCE_DATA=y
 CONFIG_ARCH_DMA_ADDR_T_64BIT=y
diff --git a/21.02/files/target/linux/mediatek/patches-5.4/999-2739-net-phy-aquantia-add-CUX3410.patch b/21.02/files/target/linux/mediatek/patches-5.4/999-2739-net-phy-aquantia-add-CUX3410.patch
index 07a50af..fcd1fee 100644
--- a/21.02/files/target/linux/mediatek/patches-5.4/999-2739-net-phy-aquantia-add-CUX3410.patch
+++ b/21.02/files/target/linux/mediatek/patches-5.4/999-2739-net-phy-aquantia-add-CUX3410.patch
@@ -1,20 +1,21 @@
 diff --git a/drivers/net/phy/aquantia.h b/drivers/net/phy/aquantia.h
-index f46d95f..6590580 100644
+index f46d95f..135b103 100644
 --- a/drivers/net/phy/aquantia.h
 +++ b/drivers/net/phy/aquantia.h
-@@ -81,6 +81,7 @@ struct aqr107_priv {
+@@ -81,6 +81,8 @@ struct aqr107_priv {
  int aqr107_set_downshift(struct phy_device *phydev, u8 cnt);
  void aqr107_chip_info(struct phy_device *phydev);
  int aqr107_config_mdi(struct phy_device *phydev);
 +int aqr107_config_usx_aneg_en(struct phy_device *phydev);
++int aqr107_config_led(struct phy_device *phydev);
  
  #if IS_REACHABLE(CONFIG_HWMON)
  int aqr_hwmon_probe(struct phy_device *phydev);
 diff --git a/drivers/net/phy/aquantia_firmware.c b/drivers/net/phy/aquantia_firmware.c
-index b4ce32f..314be88 100644
+index b4ce32f..f37bee1 100644
 --- a/drivers/net/phy/aquantia_firmware.c
 +++ b/drivers/net/phy/aquantia_firmware.c
-@@ -973,6 +973,10 @@ retry:
+@@ -973,6 +973,14 @@ retry:
  
  			aqr107_chip_info(phydevs[i]);
  
@@ -22,11 +23,15 @@
 +			if (ret)
 +				dev_err(dev, "USX autonegotiation disabled, ret: %d\n", ret);
 +
++			ret = aqr107_config_led(phydevs[i]);
++			if (ret)
++				dev_err(dev, "LED configuration failed, ret: %d\n", ret);
++
  			aqr107_config_mdi(phydevs[i]);
  
  			aqr107_set_downshift(phydevs[i],
 diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c
-index e545b28..89ea5d8 100644
+index e545b28..f445ef9 100644
 --- a/drivers/net/phy/aquantia_main.c
 +++ b/drivers/net/phy/aquantia_main.c
 @@ -25,6 +25,7 @@
@@ -47,10 +52,51 @@
  #define MDIO_AN_VEND_PROV			0xc400
  #define MDIO_AN_VEND_PROV_1000BASET_FULL	BIT(15)
  #define MDIO_AN_VEND_PROV_1000BASET_HALF	BIT(14)
-@@ -170,6 +174,16 @@ static void aqr107_get_stats(struct phy_device *phydev,
+@@ -113,6 +117,16 @@
+ #define VEND1_GLOBAL_INT_VEND_MASK_GLOBAL2	BIT(1)
+ #define VEND1_GLOBAL_INT_VEND_MASK_GLOBAL3	BIT(0)
+ 
++#define VEND1_GLOBAL_LED_PROV(x)		(0xc430 + (x - 1))
++#define VEND1_GLOBAL_LED_5000_LINK_EST		BIT(15)
++#define VEND1_GLOBAL_LED_2500_LINK_EST		BIT(14)
++#define VEND1_GLOBAL_LED_10G_LINK_EST		BIT(7)
++#define VEND1_GLOBAL_LED_1000_LINK_EST		BIT(6)
++#define VEND1_GLOBAL_LED_100_LINK_EST		BIT(5)
++#define VEND1_GLOBAL_LED_PROV_RX_ACT		BIT(3)
++#define VEND1_GLOBAL_LED_PROV_TX_ACT		BIT(2)
++#define VEND1_GLOBAL_LED_PROV_ACT_STRETCH_MASK	GENMASK(1, 0)
++
+ static int aqr107_get_sset_count(struct phy_device *phydev)
+ {
+ 	return AQR107_SGMII_STAT_SZ;
+@@ -170,6 +184,40 @@ static void aqr107_get_stats(struct phy_device *phydev,
  	}
  }
  
++int aqr107_config_led(struct phy_device *phydev)
++{
++	u16 val;
++	int err;
++
++	val = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLOBAL_LED_PROV(1));
++	val |= VEND1_GLOBAL_LED_10G_LINK_EST;
++	err = phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLOBAL_LED_PROV(1), val);
++	if (err < 0)
++		return err;
++
++	val = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLOBAL_LED_PROV(2));
++	val |= VEND1_GLOBAL_LED_100_LINK_EST | VEND1_GLOBAL_LED_1000_LINK_EST |
++	       VEND1_GLOBAL_LED_2500_LINK_EST | VEND1_GLOBAL_LED_5000_LINK_EST;
++	err = phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLOBAL_LED_PROV(2), val);
++	if (err < 0)
++		return err;
++
++	val = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLOBAL_LED_PROV(3));
++	val |= VEND1_GLOBAL_LED_PROV_ACT_STRETCH_MASK |
++	       VEND1_GLOBAL_LED_PROV_TX_ACT | VEND1_GLOBAL_LED_PROV_RX_ACT;
++	return phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLOBAL_LED_PROV(3), val);
++}
++
 +int aqr107_config_usx_aneg_en(struct phy_device *phydev)
 +{
 +	u16 val;
@@ -64,7 +110,7 @@
  static int aqr_config_aneg(struct phy_device *phydev)
  {
  	bool changed = false;
-@@ -483,6 +497,10 @@ static int aqr107_config_init(struct phy_device *phydev)
+@@ -483,6 +531,14 @@ static int aqr107_config_init(struct phy_device *phydev)
  		return aqr_firmware_download(phydev);
  #endif
  
@@ -72,10 +118,14 @@
 +	if (ret)
 +		dev_err(&phydev->mdio.dev, "USX autonegotiation disabled, ret: %d\n", ret);
 +
++	ret = aqr107_config_led(phydev);
++	if (ret)
++		dev_err(&phydev->mdio.dev, "LED configuration failed, ret: %d\n", ret);
++
  	aqr107_config_mdi(phydev);
  
  	return aqr107_set_downshift(phydev, MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT);
-@@ -711,6 +729,24 @@ static struct phy_driver aqr_driver[] = {
+@@ -711,6 +767,24 @@ static struct phy_driver aqr_driver[] = {
  	.get_stats      = aqr107_get_stats,
  	.link_change_notify = aqr107_link_change_notify,
  },
@@ -100,7 +150,7 @@
  };
  
  module_phy_driver(aqr_driver);
-@@ -724,6 +760,7 @@ static struct mdio_device_id __maybe_unused aqr_tbl[] = {
+@@ -724,6 +798,7 @@ static struct mdio_device_id __maybe_unused aqr_tbl[] = {
  	{ PHY_ID_MATCH_MODEL(PHY_ID_AQCS109) },
  	{ PHY_ID_MATCH_MODEL(PHY_ID_AQR405) },
  	{ PHY_ID_MATCH_MODEL(PHY_ID_AQR113C) },