From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37465CCFA18 for ; Tue, 11 Nov 2025 08:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=n+f2vnS/DsYTAF+aCbY0rqGLNCQaEV2shwak8otAGeo=; b=EiEmoAq1/GiVoTwqrhTrLPKCPB fcyuXEM2pOz2IW1a95WxK3Z4PGd+BO5lVagZZgYwLDL26EY8gYlvfj3LIEJYc1MLHCjgYLrrqtO8C VKWB9R5u/19os6NKw/AWN72emM4qRnE0V4trWbV9+66NRoxmZAZPL2lKlBtMyFNEtYGGSWHY07LLS TevCHrtiSwRfatnk30PWTH8A5Z6uTBAmtAAr9ljeZPPggQ0LheWdEhTWBeFEYw5pWtmUQlCLdQDVn zFprdP2vZ5rFozrCaHUB+FW2gcRg3YUIpwLfMuwEKhdVghHSYgqDtHNCP8M92OxGnROLImnt0no/c PCbx3waQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vIjUv-00000006lYN-35V7; Tue, 11 Nov 2025 08:13:05 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vIjUr-00000006lQl-2zWN; Tue, 11 Nov 2025 08:13:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=n+f2vnS/DsYTAF+aCbY0rqGLNCQaEV2shwak8otAGeo=; b=oqR3/Wsd8N0S/3HfZbMbmvWL3j d7tO7FSkJl45JDD9AOLv1j9Ha402wc4sTtZvB3jMFc1rf/pr60y1RHESw8CgFJrG1SbuSawksAtSr DX4bS1e6LoA5pAC6ZhwUtNzmTBtoytDvJnxblGJ7IStzwr8yLfmsYGJCyy3+2SsE/qQ5iau7hMIY/ r2dlFbF6VYauGcpjC9Z59DLb5F2+EqcavYLSlanhI6MTihq2nX0bp0edHEom1w6pni/BxidNA6zR3 26A7EOR8OCno4U++jV0ZFWlSXgzowF+JXyhxo9VBPpv+IT+tyOvtnpEm4VvIiJ+LP0wJmDH5bQhGm 8eONkoHw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:48894 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vIjUg-000000002DZ-2AyO; Tue, 11 Nov 2025 08:12:50 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1vIjUe-0000000DquB-3JDY; Tue, 11 Nov 2025 08:12:48 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , AngeloGioacchino Del Regno , "David S. Miller" , Emil Renner Berthing , Eric Dumazet , Jakub Kicinski , Keguang Zhang , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-mips@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Matthias Brugger , Maxime Coquelin , Minda Chen , netdev@vger.kernel.org, Nobuhiro Iwamatsu , Paolo Abeni Subject: [PATCH net-next v2 13/13] net: stmmac: visconti: use stmmac_get_phy_intf_sel() MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Date: Tue, 11 Nov 2025 08:12:48 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251111_001301_812223_4D0F9184 X-CRM114-Status: GOOD ( 12.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use stmmac_get_phy_intf_sel() to decode the PHY interface mode to the phy_intf_sel value, validate the result and use that to set the control register to select the operating mode for the DWMAC core. Note that this will allow GMII as well as MII as the phy_intf_sel value is the same for both. Signed-off-by: Russell King (Oracle) --- .../ethernet/stmicro/stmmac/dwmac-visconti.c | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c index 7b6b048e1be0..9497b13a5753 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c @@ -42,10 +42,6 @@ #define ETHER_CLK_SEL_RX_TX_CLK_EN (ETHER_CLK_SEL_RX_CLK_EN | ETHER_CLK_SEL_TX_CLK_EN) -#define ETHER_CONFIG_INTF_MII PHY_INTF_SEL_GMII_MII -#define ETHER_CONFIG_INTF_RGMII PHY_INTF_SEL_RGMII -#define ETHER_CONFIG_INTF_RMII PHY_INTF_SEL_RMII - struct visconti_eth { void __iomem *reg; struct clk *phy_ref_clk; @@ -150,22 +146,12 @@ static int visconti_eth_init_hw(struct platform_device *pdev, struct plat_stmmac { struct visconti_eth *dwmac = plat_dat->bsp_priv; unsigned int clk_sel_val; - u32 phy_intf_sel; - - switch (plat_dat->phy_interface) { - case PHY_INTERFACE_MODE_RGMII: - case PHY_INTERFACE_MODE_RGMII_ID: - case PHY_INTERFACE_MODE_RGMII_RXID: - case PHY_INTERFACE_MODE_RGMII_TXID: - phy_intf_sel = ETHER_CONFIG_INTF_RGMII; - break; - case PHY_INTERFACE_MODE_MII: - phy_intf_sel = ETHER_CONFIG_INTF_MII; - break; - case PHY_INTERFACE_MODE_RMII: - phy_intf_sel = ETHER_CONFIG_INTF_RMII; - break; - default: + int phy_intf_sel; + + phy_intf_sel = stmmac_get_phy_intf_sel(plat_dat->phy_interface); + if (phy_intf_sel != PHY_INTF_SEL_GMII_MII && + phy_intf_sel != PHY_INTF_SEL_RGMII && + phy_intf_sel != PHY_INTF_SEL_RMII) { dev_err(&pdev->dev, "Unsupported phy-mode (%d)\n", plat_dat->phy_interface); return -EOPNOTSUPP; } -- 2.47.3