From patchwork Fri Feb 23 09:44:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 205261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp480013dyb; Fri, 23 Feb 2024 01:49:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUn68DEmk9IaHVq1MJmniKs857OGSsc4VBuHyNM/Mg3ALZ6Hlr8A20ROXBnfocTcWSWouVbyFijiwIeOCtCDC+n67+oyw== X-Google-Smtp-Source: AGHT+IF1PB8j9AEo4mE/aHhAD1XhOfNbbnE2d/+GEH5AiSYromQ6ycYnOElnQGDh1hGQ8Xp0HAZ1 X-Received: by 2002:a05:6102:32c3:b0:470:4aa5:2c5b with SMTP id o3-20020a05610232c300b004704aa52c5bmr1675869vss.0.1708681761378; Fri, 23 Feb 2024 01:49:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708681761; cv=pass; d=google.com; s=arc-20160816; b=BCIFDhMH5qy6zopGBBTZ2a5QkMzE4ZjWJR0MiQIJiD+84idMUMmr8XOg0Ha3e/qe9u yiyUK4Kf9Apv0WImZ546ayvlEXt5eE/vHEPxeaXb4bh+BNRfACQqX2o1lf1c3tY4PXqi G3uLr6sScPU07VWRjMoJOSAhItqjvn3MmdBxGOFP8waV51Wu3ni4gG8a3hQhnvecmnPc /o9JHqmv8XhtaeWe8Jo7lEG7JT+10Z7s66g5O7g8Nb+YAIwCJ6Cd9eTbCwG7bsY2kCYT o8vd5Mc0QF+tP8vc/IQtc3CpCIA688kYydSxo+aq4tfJIilYEQ4jHnewIV1EVUhnWdK1 hqYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=zCp7BA6mWer8o+IS54iUdXDIJ8On/1WEXgkoDVAL7YA=; fh=/mFbHcqW6l4fLIJBfKVNbHEV0oGb2iio8Q6EPf9P78A=; b=GbSTw/eBLKy8NGDNH1A6h8EqXkoKLiWTNpnla8jTIQXDP2qpYBcZhOjx6PPzuhm6m1 Keas8koEwkaN7xCTMCaX50gUH/0UwlJz8HWcs1LJnpxtZSVCfyzgONxI7xcBXKviAcbb vpIB/usn/dF+TfOc+TCaIWN86oozNpH3iCB5CuLqkRMZa8PdCpBMM6OeBnWRBAC8Cwu0 oVTnDrf1CRzc9lM15rDuCK4cSNscN/wO9XAU4ULX1a/jhI4tVfiLc+gxpD/OndYcXprd tIP1fQCh84dkxgoPqMzd4LEVeqHvUPr+NFdZ+TG/Hm8ynySqjOwl4tPX7Tx8D+x+meAd eeWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78066-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78066-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g7-20020a05620a13c700b0078724a3d83bsi14763591qkl.178.2024.02.23.01.49.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:49:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78066-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78066-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78066-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2484D1C24840 for ; Fri, 23 Feb 2024 09:49:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 288F65FF16; Fri, 23 Feb 2024 09:45:03 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 99E4D5C91F for ; Fri, 23 Feb 2024 09:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681498; cv=none; b=AGgOghVegss1Kb5qxGeW59HSKdIB+OBwMQqbf1ARIj8RVS01n4JQ9HGUMwbKbWDkdZnsVkTpizhDeuc0G9p8QGDUOnyHpmd1CY5rpFqTqLh2USEPVwClqTwmuVx9E16ISLlSMsT4P3NdVytsARFp3FaW0D+0H778sec9rsEeUx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681498; c=relaxed/simple; bh=Q16DNgegfwpHQ9ZZfUC5bEHajPNhkT5JWZ+zZi0btB4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rFk9MPPEOcwUHra3CE8MnaMbyeG3igvUT2xwNMuHBKvYi17NTCR2cItv80ETxILpP3Ti8Xu4YFOPXbMN4YFpULtSO3dhVVJupN9UREXUHnir8fIT2M65LiYR+GvavX0pphuQlyOv1qhrEqSIGnj7CK4fuhVT3J2cA4K5X8QE1SY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rdS6W-00080l-LM; Fri, 23 Feb 2024 10:44:28 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rdS6V-002OkU-B6; Fri, 23 Feb 2024 10:44:27 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rdS6V-002tpl-0s; Fri, 23 Feb 2024 10:44:27 +0100 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Florian Fainelli , Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team Subject: [PATCH net-next v6 3/8] net: phy: Add helper to set EEE Clock stop enable bit Date: Fri, 23 Feb 2024 10:44:20 +0100 Message-Id: <20240223094425.691209-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223094425.691209-1-o.rempel@pengutronix.de> References: <20240223094425.691209-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791682686907973232 X-GMAIL-MSGID: 1791682686907973232 From: Andrew Lunn 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: Florian Fainelli Signed-off-by: Oleksij Rempel --- 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 2bc0a7d51c63..ab18b0d9beb4 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1579,6 +1579,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 a880f6d7170e..432c561f5809 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1995,6 +1995,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_keee *data); int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_keee *data);