From patchwork Mon Mar 27 17:01:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13189681 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 333CCC6FD1D for ; Mon, 27 Mar 2023 17:03:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232685AbjC0RDC (ORCPT ); Mon, 27 Mar 2023 13:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232688AbjC0RCo (ORCPT ); Mon, 27 Mar 2023 13:02:44 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13B3A46A4 for ; Mon, 27 Mar 2023 10:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=U9I8cGC+Iw9tqj18MtioCd57yi+zZX7H81VO9S6W+Pk=; b=AbVW/6xfT1sFnp0hIRnaRFdG5N YkR6HRIFcH7bpzUkP2JTYf67RXCliz1VFQ0qXF1jOIuzpfNUwyAG0hvuNZ1TqJRbjYs93BxdlKWag 1/QnXOTUgVTB7XrEaPaYLYzzGNnIdwVlxewBCDuQJb2bMN++YRSZhGzUwlP9pBskiLxM=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pgqEU-008XqU-I8; Mon, 27 Mar 2023 19:02:10 +0200 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Heiner Kallweit , Russell King , Oleksij Rempel , Andrew Lunn Subject: [RFC/RFT 03/23] net: phy: Add helper to set EEE Clock stop enable bit Date: Mon, 27 Mar 2023 19:01:41 +0200 Message-Id: <20230327170201.2036708-4-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230327170201.2036708-1-andrew@lunn.ch> References: <20230327170201.2036708-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The MAC driver can request that the PHY stops the clock during EEE LPI. This has normally been does as part of phy_init_eee(), however that function is overly complex and often wrongly used. Add a standalone helper, to aid removing phy_init_eee(). Signed-off-by: Andrew Lunn Reviewed-by: Russell King (Oracle) --- v2: Add missing EXPORT_SYMBOL_GPL --- drivers/net/phy/phy.c | 20 ++++++++++++++++++++ include/linux/phy.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 68e1ce942dd6..d3d6ff4ed488 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1503,6 +1503,26 @@ void phy_mac_interrupt(struct phy_device *phydev) } EXPORT_SYMBOL(phy_mac_interrupt); +/** + * phy_eee_clk_stop_enable - Clock should stop during LIP + * @phydev: target phy_device struct + * + * Description: Program the MMD register 3.0 setting the "Clock stop enable" + * bit. + */ +int phy_eee_clk_stop_enable(struct phy_device *phydev) +{ + int ret; + + mutex_lock(&phydev->lock); + ret = phy_set_bits_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, + MDIO_PCS_CTRL1_CLKSTOP_EN); + mutex_unlock(&phydev->lock); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_eee_clk_stop_enable); + /** * phy_init_eee - init and check the EEE feature * @phydev: target phy_device struct diff --git a/include/linux/phy.h b/include/linux/phy.h index 2508f1d99777..12addd1c29f2 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1846,6 +1846,7 @@ int phy_unregister_fixup_for_id(const char *bus_id); int phy_unregister_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask); int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable); +int phy_eee_clk_stop_enable(struct phy_device *phydev); int phy_get_eee_err(struct phy_device *phydev); int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data); int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data);