From: Weijie Gao Date: Mon, 22 Jan 2024 02:08:16 +0000 (+0800) Subject: net: mediatek: add support for XGMII interface X-Git-Url: http://git.dujemihanovic.xyz/img/sics.gif?a=commitdiff_plain;h=172e32add3d0332073538412c8d3b788e91b4d9c;p=u-boot.git net: mediatek: add support for XGMII interface This patch add XGMII support for connecting 2.5G PHY. Signed-off-by: Bo-Cun Chen Signed-off-by: Weijie Gao --- diff --git a/drivers/net/mtk_eth.c b/drivers/net/mtk_eth.c index 726aedad3f..75e7bcf83b 100644 --- a/drivers/net/mtk_eth.c +++ b/drivers/net/mtk_eth.c @@ -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); diff --git a/drivers/net/mtk_eth.h b/drivers/net/mtk_eth.h index 45229c0f9a..fd31c782c7 100644 --- a/drivers/net/mtk_eth.h +++ b/drivers/net/mtk_eth.h @@ -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))