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 5E152FA373D for ; Tue, 1 Nov 2022 11:47:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6708485020; Tue, 1 Nov 2022 12:47:01 +0100 (CET) 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="OAhgGcHu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E512184D42; Tue, 1 Nov 2022 04:58:11 +0100 (CET) Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) (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 10DB784D37 for ; Tue, 1 Nov 2022 04:58:09 +0100 (CET) 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-pl1-x62b.google.com with SMTP id j12so12493173plj.5 for ; Mon, 31 Oct 2022 20:58:08 -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=cy4SQvmMb3k54P56LW92UsZV3kzz9Tsu2jBbcvKbrdM=; b=OAhgGcHuP/Q8DayNLY7Oy00qH74PWQjsT2Idtm8BQu6qMbXCzRaaW/wl8AGX+tNBW1 J1uo8hSQISiMUiU6dLnZXb+sZeWOPcQV+8+jYjVRWTmISvxvOyx/b+HLW1cjz4j7H54c LLUqkQO0FJ2wWups8SWU90R1bN1AklT/F6noBGbxlNL3pH0NFEwXMWZVoFfphd7OJwjz Omp+LR11U7oRFhgSNan4wOcmMW8xSNQrXhqapFk2SIRtmbCiUUqtfepA4wJzctyL5oTk Eg5ulF+6l3+bVvJlOhCmTcOXBPlwKJWo84B2n2KlaFL/h7mrvbLNxkbBj2n6k+OQCF9P uGww== 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=cy4SQvmMb3k54P56LW92UsZV3kzz9Tsu2jBbcvKbrdM=; b=YeJJh7kaJmsIF0ifIg6FUTivjoLQNKvVZsfEt2DYuMWAYHF4EJWiejx14132s9JAOc knTMnDuHa9EwYG4nqTZ2IqE/DJxkFMe18ZOqANsRpUfddFJq2N66K6iAgEIAFor8HYyj 8x/B88O9/Vkw8f1slKkGdA69PJ5+EsPuRhKaZDW26mMRPX0xWALRpbAumUhkzsOSZSkQ wCWtmHnRy7TueIQOhmkvKGWWdWVZ76RIwdP/JvQvU2tE9XdZlOS65rGiTbH+TWR9vszZ OeUkm+hF2Dh5ZLq4pa+vvWSkBj+a+deKRXNqMr5l0Ad6VXkVqvOYTpIWYfMIaVwn3FRc hJmw== X-Gm-Message-State: ACrzQf0i8/QiC+g3zxAxckw0dOX/XBLusKJtKJDanHT/yGji+J3kba7z bcIAX6T1KSRIHnDCY5XxzgFsUw== X-Google-Smtp-Source: AMsMyM4A7pm/QUnrd6tfmNz5YjT5ADjBrBbFf9iK0JwAj5+kaB5w0xdcLfo7pMLfo5VOPxDIm0czEQ== X-Received: by 2002:a17:903:240a:b0:183:6555:7a89 with SMTP id e10-20020a170903240a00b0018365557a89mr17385969plo.68.1667275087310; Mon, 31 Oct 2022 20:58:07 -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 y1-20020a17090a104100b00200a85fa777sm5088278pjd.1.2022.10.31.20.58.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 20:58:06 -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 v2 1/2] net: xilinx_axi: add PCS/PMA PHY Date: Tue, 1 Nov 2022 11:57:59 +0800 Message-Id: <20221101035800.912644-2-andy.chiu@sifive.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20221101035800.912644-1-andy.chiu@sifive.com> References: <20221101035800.912644-1-andy.chiu@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Tue, 01 Nov 2022 12:46:58 +0100 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-handle 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..cb5487c437 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-handle"); + if (offset > 0) { + plat->pcsaddr = fdtdec_get_int(gd->fdt_blob, + offset, "reg", -1); + } + } } return 0; -- 2.36.0