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 65C7EEB64D8 for ; Thu, 15 Jun 2023 00:44:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BE5B8861F5; Thu, 15 Jun 2023 02:44:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="U/NU9hps"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 97A40861F3; Thu, 15 Jun 2023 00:29:04 +0200 (CEST) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 65886861C2 for ; Thu, 15 Jun 2023 00:28:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dannenberg@ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 35EMSuRu088229; Wed, 14 Jun 2023 17:28:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1686781736; bh=4T5N3Fcz3RHk+vSTftrryArOVjzK2TsLIcpfbSGk3ZE=; h=From:To:CC:Subject:Date; b=U/NU9hpsTyvqR4i40/yeQhBnJYgbR7A4a0c66lRHYLHPYQeKUTPsVnQQJaeyrez7J iVkMU4bAg71vlMLh45izFgdwNjVBy/xrjH163LSri9HkbuGp9hvIBtFCBKynux4M7F 6neU4jpZR1GzGpS5i443cawdAnCOA0tkCca1VvPQ= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 35EMSuVI100738 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Jun 2023 17:28:56 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 14 Jun 2023 17:28:56 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 14 Jun 2023 17:28:56 -0500 Received: from dasso.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 35EMSuYn097875; Wed, 14 Jun 2023 17:28:56 -0500 From: Andreas Dannenberg To: , CC: Andreas Dannenberg , Joe Hershberger , Ramon Fried , "Ravi Gunasekaran" , Grygorii Strashko , Simon Glass , "Siddharth Vadapalli" Subject: [PATCH] net: ti: am65-cpsw-nuss: Use dedicated port mode control registers Date: Wed, 14 Jun 2023 17:28:53 -0500 Message-ID: <20230614222853.574427-1-dannenberg@ti.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Approved-At: Thu, 15 Jun 2023 02:44:38 +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.8 at phobos.denx.de X-Virus-Status: Clean The different CPSW sub-system Ethernet ports have different PHY mode control registers. In order to allow the modes to get configured independently only the register for the port in question must be accessed, otherwise we would just be re-configuring the mode for port 1, while leaving all others at their power-on defaults. Fix this issue by adding a port-number based offset to the mode control base register address based on the fact that the control registers for the different ports are spaced exactly 0x4 bytes apart. Fixes: 9d0dca1199d1 ("net: ethernet: ti: Introduce am654 gigabit eth switch subsystem driver") Signed-off-by: Andreas Dannenberg Reviewed-by: Siddharth Vadapalli --- Driver changes bench-tested on an SK-AM62 EVM by iterating through different variations of RGMII and RMII modes for CPSW ports 1 and 2 and checking operation as well as CTRL_ENET1_CTRL and CTRL_ENET2_CTRL control register contents from the U-Boot command line via 'md.l'. Testing was done on top of today's 'next' branch. drivers/net/ti/am65-cpsw-nuss.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c index f674b0baa3..523a4c9f91 100644 --- a/drivers/net/ti/am65-cpsw-nuss.c +++ b/drivers/net/ti/am65-cpsw-nuss.c @@ -223,6 +223,8 @@ out: return phy->link; } +#define AM65_GMII_SEL_PORT_OFFS(x) (0x4 * ((x) - 1)) + #define AM65_GMII_SEL_MODE_MII 0 #define AM65_GMII_SEL_MODE_RMII 1 #define AM65_GMII_SEL_MODE_RGMII 2 @@ -233,11 +235,12 @@ static void am65_cpsw_gmii_sel_k3(struct am65_cpsw_priv *priv, phy_interface_t phy_mode, int slave) { struct am65_cpsw_common *common = priv->cpsw_common; + fdt_addr_t gmii_sel = common->gmii_sel + AM65_GMII_SEL_PORT_OFFS(slave); u32 reg; u32 mode = 0; bool rgmii_id = false; - reg = readl(common->gmii_sel); + reg = readl(gmii_sel); dev_dbg(common->dev, "old gmii_sel: %08x\n", reg); @@ -273,9 +276,9 @@ static void am65_cpsw_gmii_sel_k3(struct am65_cpsw_priv *priv, reg = mode; dev_dbg(common->dev, "gmii_sel PHY mode: %u, new gmii_sel: %08x\n", phy_mode, reg); - writel(reg, common->gmii_sel); + writel(reg, gmii_sel); - reg = readl(common->gmii_sel); + reg = readl(gmii_sel); if (reg != mode) dev_err(common->dev, "gmii_sel PHY mode NOT SET!: requested: %08x, gmii_sel: %08x\n", -- 2.34.1