From patchwork Fri Aug 4 17:58:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13342155 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D860AC2CA for ; Fri, 4 Aug 2023 17:59:04 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1366F122 for ; Fri, 4 Aug 2023 10:59:02 -0700 (PDT) Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id CF53A86660; Fri, 4 Aug 2023 19:58:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1691171939; bh=MOr9Qlya1CnuxR4ka35e0UNVov/FCjAij7AB7i19F7k=; h=From:To:Cc:Subject:Date:From; b=nLjrMirenK+KBdYoOuP0DQWRM+dfDnkNGOMO/KwK6zke8fIeSBwICjPrlJFPbrPrx cPYuloHCYrynf82lFsQ0Ou/cQcP2tUT7kgJxu3M+b55rJVR3VKdeLKVvUpZY4AAnyC +Xsv46WgJ8NC56BSfzq7ei4vRoj290BDwtLCHd0WCqoeV+wywD96RqE9BRc+yapFT+ K5woxd9xHZElBzjgcc0WBaixfPtmYyhB064m7v68FaDLcS9nFMMZTDY6HjKHLe5uCN z926A6be8UQojcrswOwdbKDycyLDdt8TE/qPA0DmQy0NpUhQPU0CgMUcIDo5AlEK8l POtiP0PvL246g== From: Marek Vasut To: netdev@vger.kernel.org Cc: Marek Vasut , "David S. Miller" , Andrew Lunn , Eric Dumazet , Heiner Kallweit , Jakub Kicinski , Oleksij Rempel , Paolo Abeni , Russell King , Wei Fang Subject: [PATCH] net: phy: at803x: Improve hibernation support on start up Date: Fri, 4 Aug 2023 19:58:42 +0200 Message-Id: <20230804175842.209537-1-marex@denx.de> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Toggle hibernation mode OFF and ON to wake the PHY up and make it generate clock on RX_CLK pin for about 10 seconds. These clock are needed during start up by MACs like DWMAC in NXP i.MX8M Plus to release their DMA from reset. After the MAC has started up, the PHY can enter hibernation and disable the RX_CLK clock, this poses no problem for the MAC. Originally, this issue has been described by NXP in commit 9ecf04016c87 ("net: phy: at803x: add disable hibernation mode support") but this approach fully disables the hibernation support and takes away any power saving benefit. This patch instead makes the PHY generate the clock on start up for 10 seconds, which should be long enough for the EQoS MAC to release DMA from reset. Before this patch on i.MX8M Plus board with AR8031 PHY: " $ ifconfig eth1 up [ 25.576734] imx-dwmac 30bf0000.ethernet eth1: Register MEM_TYPE_PAGE_POOL RxQ-0 [ 25.658916] imx-dwmac 30bf0000.ethernet eth1: PHY [stmmac-1:00] driver [Qualcomm Atheros AR8031/AR8033] (irq=38) [ 26.670276] imx-dwmac 30bf0000.ethernet: Failed to reset the dma [ 26.676322] imx-dwmac 30bf0000.ethernet eth1: stmmac_hw_setup: DMA engine initialization failed [ 26.685103] imx-dwmac 30bf0000.ethernet eth1: __stmmac_open: Hw setup failed ifconfig: SIOCSIFFLAGS: Connection timed out " After this patch on i.MX8M Plus board with AR8031 PHY: " $ ifconfig eth1 up [ 19.419085] imx-dwmac 30bf0000.ethernet eth1: Register MEM_TYPE_PAGE_POOL RxQ-0 [ 19.507380] imx-dwmac 30bf0000.ethernet eth1: PHY [stmmac-1:00] driver [Qualcomm Atheros AR8031/AR8033] (irq=38) [ 19.528464] imx-dwmac 30bf0000.ethernet eth1: No Safety Features support found [ 19.535769] imx-dwmac 30bf0000.ethernet eth1: IEEE 1588-2008 Advanced Timestamp supported [ 19.544302] imx-dwmac 30bf0000.ethernet eth1: registered PTP clock [ 19.552008] imx-dwmac 30bf0000.ethernet eth1: FPE workqueue start [ 19.558152] imx-dwmac 30bf0000.ethernet eth1: configuring for phy/rgmii-id link mode " Signed-off-by: Marek Vasut --- Cc: "David S. Miller" Cc: Andrew Lunn Cc: Eric Dumazet Cc: Heiner Kallweit Cc: Jakub Kicinski Cc: Oleksij Rempel Cc: Paolo Abeni Cc: Russell King Cc: Wei Fang Cc: netdev@vger.kernel.org --- drivers/net/phy/at803x.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 13c4121fa3092..8cb7b39c6cddc 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -986,6 +986,25 @@ static int at8031_pll_config(struct phy_device *phydev) static int at803x_hibernation_mode_config(struct phy_device *phydev) { struct at803x_priv *priv = phydev->priv; + int ret; + + /* Toggle hibernation mode OFF and ON to wake the PHY up and + * make it generate clock on RX_CLK pin for about 10 seconds. + * These clock are needed during start up by MACs like DWMAC + * in NXP i.MX8M Plus to release their DMA from reset. After + * the MAC has started up, the PHY can enter hibernation and + * disable the RX_CLK clock, this poses no problem for the MAC. + */ + ret = at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL, + AT803X_DEBUG_HIB_CTRL_PS_HIB_EN, 0); + if (ret < 0) + return ret; + + ret = at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL, + AT803X_DEBUG_HIB_CTRL_PS_HIB_EN, + AT803X_DEBUG_HIB_CTRL_PS_HIB_EN); + if (ret < 0) + return ret; /* The default after hardware reset is hibernation mode enabled. After * software reset, the value is retained.