From patchwork Fri Feb 17 03:42:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13144281 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 9E0E9C6379F for ; Fri, 17 Feb 2023 03:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbjBQDnE (ORCPT ); Thu, 16 Feb 2023 22:43:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230320AbjBQDm6 (ORCPT ); Thu, 16 Feb 2023 22:42:58 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA994CA00 for ; Thu, 16 Feb 2023 19:42:52 -0800 (PST) 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=eWWiBhiqBljb89lpSMM0ClqHrglv98JnoZgViyF6MrE=; b=cSSkGJogvDaLpd4s/XL1NIrmvT 4Nt9znQtxFJrAogqEIDg2+qbn3iQX4uaiCFs7Q2lyFSiWgTJC34Be80Vex/DO0pHauAd5Fm1IBg0i hS/vrXr9VhwyI53dy2NoI7yg+3GuJQvtOpqK36syyAqPActVtQZvgKIOyNaa9ZxFrFmQ=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pSrdz-005F67-Vf; Fri, 17 Feb 2023 04:42:43 +0100 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Woojung Huh , Oleksij Rempel , Andrew Lunn Subject: [PATCH RFC 02/18] net: phy: Add helper to set EEE Clock stop enable bit Date: Fri, 17 Feb 2023 04:42:14 +0100 Message-Id: <20230217034230.1249661-3-andrew@lunn.ch> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217034230.1249661-1-andrew@lunn.ch> References: <20230217034230.1249661-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 --- drivers/net/phy/phy.c | 19 +++++++++++++++++++ include/linux/phy.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 1e6df250d0d0..b25e0946405b 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1475,6 +1475,25 @@ 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; +} + /** * 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 b1fbb52ac5a4..4f72ffcb8b02 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1840,6 +1840,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);