Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1A19C43219 for ; Mon, 17 Oct 2022 12:01:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BF05084F79; Mon, 17 Oct 2022 14:01:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.b="fWXYT6w9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 31A3F84F28; Mon, 17 Oct 2022 13:19:43 +0200 (CEST) Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 08BF584575 for ; Mon, 17 Oct 2022 13:19:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andy.chiu@sifive.com Received: by mail-pj1-x102b.google.com with SMTP id x31-20020a17090a38a200b0020d2afec803so10671020pjb.2 for ; Mon, 17 Oct 2022 04:19:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GCwtgCEOF/8WzJqEbuHLubtDm3BibxVw2Wh04P73wHM=; b=fWXYT6w9LXEfv/xcR+SpLQ5NqrGdi6rbJoCglFJ5yN+zvqNYvFbEa0Mg3Y9JeZeC5O mBNGiI+jldQbN/5tP1GJiTy2RYHuH/raed/wdgVDha47OQRMQ09GlNsEXJIuQMj7Y2KG YQJeV0vNC9/ANiBp38dvZYLxkjP9IgV3lC+DW+BbgUlzEp6UwVUgj0pldtaxjwxu1HpO PEFtdB68wCBscXDFljCeymS5VDBD6mJeR3tKtZIlFKF7tIGo9GmBPZVKJ8APCMl0gLlM FFwfbt/6GiUVT4oJmsdRTwCemddzyMxCG2OpaxdjByNPwVUSRXwk/jEcGidCi8kePrw2 9afg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GCwtgCEOF/8WzJqEbuHLubtDm3BibxVw2Wh04P73wHM=; b=trVMZRQt3ntNbn9ISE983a7ogM/u9qz/rwaUNKLKTCjqH5Yfa6s+JdPVel0pBmlR8/ Z2Ggvns2jjUx8+XEbkw76xKAT2ikF0nGGQekheZoYjn+s1xwHrZcJ7PFBzuslKlIYkjz XBMO6zJ7yp8CtR0MZAMWEmADToSQnBsDBy0IdgdFD/GNvTWqcoIDed1veniHw0J8X7FV 7uh/i4hsvF15m4/sTLRHboK7e3aJC/DoDNP2uU61KGDoFhF4esLp4YsFoXZptDLa1yRP Bmqwou3r6Slrquz7l7WAKDl1J65Rapw3CsKiPaFl0kGKX9moIvZOt57waejqNY1Pefuo tB3A== X-Gm-Message-State: ACrzQf2KumuU5YjnGTJZOlg3bZYXAXrUWGQkjrr5hqkqsnXt622nkpnr RNrIQpkP9unE8gTVBzhJbsU4FpIX4fbSRg== X-Google-Smtp-Source: AMsMyM7F7GK84+KFVXMubnyf5rDGw+eEpv0RvirmTvEFC/9jOG1gxDdTPC4vDM8egRr0x+mGce+PuA== X-Received: by 2002:a17:902:ea06:b0:185:4c1f:7460 with SMTP id s6-20020a170902ea0600b001854c1f7460mr9862745plg.99.1666005578254; Mon, 17 Oct 2022 04:19:38 -0700 (PDT) Received: from archlinux.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id r12-20020a632b0c000000b004582e25a595sm5983582pgr.41.2022.10.17.04.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 04:19:37 -0700 (PDT) From: Andy Chiu To: michal.simek@amd.com Cc: rfried.dev@gmail.com, joe.hershberger@ni.com, u-boot@lists.denx.de, andy.chiu@sifive.com, greentime.hu@sifive.com Subject: [PATCH 1/2] net:xilinx_axi: add PCS/PMA PHY Date: Mon, 17 Oct 2022 19:19:27 +0800 Message-Id: <20221017111928.462866-2-andy.chiu@sifive.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20221017111928.462866-1-andy.chiu@sifive.com> References: <20221017111928.462866-1-andy.chiu@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Mon, 17 Oct 2022 14:01:22 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean If we bridge an external PHY to Xilinx's PCS/PMA PHY and would like to get and set the real status of the PHY facing the external world. Then we should phy_connect() to the external PHY instead of the PCS/PMA one. Thus, we add a pcs-phy DT entry, which have been merged in Linux, and leave the configuration of it to the driver itself. Unlike Linux, where the PCS/PMA PHY is managed by phylink, managing the PCS/PMA PHY is only internal to the driver in U-Boot. The PCS/PMA PHY pressents only when the phy-mode is configured as SGMII or 1000Base-X, so it is always 1 Gbps and full-duplex and we may skip passing link information out. Signed-off-by: Andy Chiu Reviewed-by: Greentime Hu --- drivers/net/xilinx_axi_emac.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c index 04277b1269..447e1d4c9c 100644 --- a/drivers/net/xilinx_axi_emac.c +++ b/drivers/net/xilinx_axi_emac.c @@ -107,6 +107,7 @@ struct axidma_plat { struct eth_pdata eth_pdata; struct axidma_reg *dmatx; struct axidma_reg *dmarx; + int pcsaddr; int phyaddr; u8 eth_hasnobuf; int phy_of_handle; @@ -117,6 +118,7 @@ struct axidma_plat { struct axidma_priv { struct axidma_reg *dmatx; struct axidma_reg *dmarx; + int pcsaddr; int phyaddr; struct axi_regs *iobase; phy_interface_t interface; @@ -299,6 +301,13 @@ static int axiemac_phy_init(struct udevice *dev) if (IS_ENABLED(CONFIG_DM_ETH_PHY)) priv->phyaddr = eth_phy_get_addr(dev); + /* + * Set address of PCS/PMA PHY to the one pointed by phy-handle for + * backward compatibility. + */ + if (priv->phyaddr != -1 && priv->pcsaddr == 0) + priv->pcsaddr = priv->phyaddr; + if (priv->phyaddr == -1) { /* Detect the PHY address */ for (i = 31; i >= 0; i--) { @@ -342,12 +351,12 @@ static int setup_phy(struct udevice *dev) * after DMA and ethernet resets and hence * check and clear if set. */ - ret = phyread(priv, priv->phyaddr, MII_BMCR, &temp); + ret = phyread(priv, priv->pcsaddr, MII_BMCR, &temp); if (ret) return 0; if (temp & BMCR_ISOLATE) { temp &= ~BMCR_ISOLATE; - ret = phywrite(priv, priv->phyaddr, MII_BMCR, temp); + ret = phywrite(priv, priv->pcsaddr, MII_BMCR, temp); if (ret) return 0; } @@ -778,6 +787,7 @@ static int axi_emac_probe(struct udevice *dev) if (priv->mactype == EMAC_1G) { priv->eth_hasnobuf = plat->eth_hasnobuf; + priv->pcsaddr = plat->pcsaddr; priv->phyaddr = plat->phyaddr; priv->phy_of_handle = plat->phy_of_handle; priv->interface = pdata->phy_interface; @@ -855,6 +865,8 @@ static int axi_emac_of_to_plat(struct udevice *dev) if (plat->mactype == EMAC_1G) { plat->phyaddr = -1; + /* PHYAD 0 always redirects to the PCS/PMA PHY */ + plat->pcsaddr = 0; offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle"); @@ -872,6 +884,16 @@ static int axi_emac_of_to_plat(struct udevice *dev) plat->eth_hasnobuf = fdtdec_get_bool(gd->fdt_blob, node, "xlnx,eth-hasnobuf"); + + if (pdata->phy_interface == PHY_INTERFACE_MODE_SGMII || + pdata->phy_interface == PHY_INTERFACE_MODE_1000BASEX) { + offset = fdtdec_lookup_phandle(gd->fdt_blob, node, + "pcs-phy"); + if (offset > 0) { + plat->pcsaddr = fdtdec_get_int(gd->fdt_blob, + offset, "reg", -1); + } + } } return 0; -- 2.36.0