]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: mediatek: add support for XGMII interface
authorWeijie Gao <weijie.gao@mediatek.com>
Mon, 22 Jan 2024 02:08:16 +0000 (10:08 +0800)
committerTom Rini <trini@konsulko.com>
Fri, 1 Mar 2024 21:35:52 +0000 (16:35 -0500)
This patch add XGMII support for connecting 2.5G PHY.

Signed-off-by: Bo-Cun Chen <bc-bocun.chen@mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
drivers/net/mtk_eth.c
drivers/net/mtk_eth.h

index 726aedad3fae16bfa785ff120bf46bc7f1a0a595..75e7bcf83b768ac0d4f14927b4cfd83157296ae0 100644 (file)
@@ -1246,7 +1246,8 @@ static int mtk_phy_start(struct mtk_eth_priv *priv)
        }
 
        if (!priv->force_mode) {
-               if (priv->phy_interface == PHY_INTERFACE_MODE_USXGMII)
+               if (priv->phy_interface == PHY_INTERFACE_MODE_USXGMII ||
+                   priv->phy_interface == PHY_INTERFACE_MODE_XGMII)
                        mtk_xphy_link_adjust(priv);
                else
                        mtk_phy_link_adjust(priv);
@@ -1516,7 +1517,7 @@ static void mtk_mac_init(struct mtk_eth_priv *priv)
 
 static void mtk_xmac_init(struct mtk_eth_priv *priv)
 {
-       u32 sts;
+       u32 force_link = 0;
 
        switch (priv->phy_interface) {
        case PHY_INTERFACE_MODE_USXGMII:
@@ -1531,15 +1532,19 @@ static void mtk_xmac_init(struct mtk_eth_priv *priv)
                       SYSCFG0_GE_MODE_M << SYSCFG0_GE_MODE_S(priv->gmac_id),
                       0);
 
-       if (priv->gmac_id == 1) {
+       if (priv->phy_interface == PHY_INTERFACE_MODE_USXGMII &&
+           priv->gmac_id == 1) {
                mtk_infra_rmw(priv, TOPMISC_NETSYS_PCS_MUX,
                              NETSYS_PCS_MUX_MASK, MUX_G2_USXGMII_SEL);
-       } else if (priv->gmac_id == 2) {
-               sts = mtk_gmac_read(priv, XGMAC_STS(priv->gmac_id));
-               sts |= XGMAC_FORCE_LINK;
-               mtk_gmac_write(priv, XGMAC_STS(priv->gmac_id), sts);
        }
 
+       if (priv->phy_interface == PHY_INTERFACE_MODE_XGMII ||
+           priv->gmac_id == 2)
+               force_link = XGMAC_FORCE_LINK(priv->gmac_id);
+
+       mtk_gmac_rmw(priv, XGMAC_STS(priv->gmac_id),
+                    XGMAC_FORCE_LINK(priv->gmac_id), force_link);
+
        /* Force GMAC link down */
        mtk_gmac_write(priv, GMAC_PORT_MCR(priv->gmac_id), FORCE_MODE);
 }
@@ -1828,7 +1833,8 @@ static int mtk_eth_probe(struct udevice *dev)
        mtk_eth_mdc_init(priv);
 
        /* Set MAC mode */
-       if (priv->phy_interface == PHY_INTERFACE_MODE_USXGMII)
+       if (priv->phy_interface == PHY_INTERFACE_MODE_USXGMII ||
+           priv->phy_interface == PHY_INTERFACE_MODE_XGMII)
                mtk_xmac_init(priv);
        else
                mtk_mac_init(priv);
index 45229c0f9a963452f765a4708410016d9c700c93..fd31c782c7f2a3b9e0811818aca3537e92e8373a 100644 (file)
@@ -268,7 +268,7 @@ enum mkt_eth_capabilities {
 
 /* XGMAC Status Registers */
 #define XGMAC_STS(x)                   (((x) == 2) ? 0x001C : 0x000C)
-#define XGMAC_FORCE_LINK               BIT(15)
+#define XGMAC_FORCE_LINK(x)            (((x) == 1) ? BIT(31) : BIT(15))
 
 /* XGMAC Registers */
 #define XGMAC_PORT_MCR(x)              (0x2000 + (((x) - 1) * 0x1000))