Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2180601rdb; Tue, 20 Feb 2024 22:22:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVdZ046aKOXgV7fTw8mxC7m1huqCbB+mhfFlp1BA5bvZ+ynslgN6mRoAV1rs8Gb2DU0fAGDgiGT0FyZV1qS1zQeC8WBhSFqHS0r31qXjg== X-Google-Smtp-Source: AGHT+IGXaS7i7WK8lmkF4+yWVFZ0LUTtLptc9J+4K4Wdq41w+VNoY2D4kIAU0zCqZHB8LQ+ezBJ3 X-Received: by 2002:a05:6214:5297:b0:68f:6a4a:91ce with SMTP id kj23-20020a056214529700b0068f6a4a91cemr10799699qvb.40.1708496541891; Tue, 20 Feb 2024 22:22:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708496541; cv=pass; d=google.com; s=arc-20160816; b=EwU3/zSeFrln+8rXtprrpVEKkg1FrmSmp1jLpQ2i80QMsuxLpnCQWyP/rPP/7FFhxG k22l5w05KgHppW0PmDYfAA8P5XaUH2mhh2/6rAaCIT404wTBXn7Zm+qTKIs6jpxo+t9a y5x9xwrr/ybwhqfdoQnrWUct4uBEFvuRaN213MdTmvZm3pr/Kp8fIHqryLbvrbGCnuhU j2PGA6ElqlF5wxcaiM3emnix5w8Tm2QM0eFRP2tZWLPjUkJHnje+BhRN1JRyeKWVO1pK brmFDXpxRPdq2YHIFI6JhV0vrLKmkncyfivESr939o47pysdnzZ9xHV0AZt5wn6avyMe RPHA== 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=4uwACoY7PfB/L2vOWtCx2RIo88RNBJo1mlJKkDowtqo=; fh=Ie8Lg/4B6LRJEAkd22XcdyKITG9FXA4PEPaBJgtxF+0=; b=IuvDiVxTJ6cownMUGIsKbtzR/reBm/u2kHigONTuiJv1oqWkw1V6awkuz/WFA+QupY ktxN7jZLw8vpBtWoc/COtweYrwUfpqVQ0fHpqcWMk8N4bMUIQJiO8XtSOkIOT6drNTfB jrxYQ1FbT2lR2tRrSfvpu5fn7GOfoccTVHj2HKvHvuP1/ap4JEN3JiU6y1Mz93ovhUfk Vi62nuGjKn9qd3zSpupLBXKuPTr5zkPUmAYb5f74Q0LP9cOSGL7gWUUWobeYt93M534M 3YJXnpZKqV7eMeYxS1JLfMES5W/Jre99wtzSF12MWoPTo7iH+ZTf+ZWRz/fMSlDObtkS mFAg==; 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-74143-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74143-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id if3-20020a0562141c4300b0068f654af189si6801840qvb.110.2024.02.20.22.22.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 22:22:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74143-linux.lists.archive=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-74143-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74143-linux.lists.archive=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 96AE01C213A3 for ; Wed, 21 Feb 2024 06:22:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 26CF33B1A0; Wed, 21 Feb 2024 06:21:24 +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 C5AE63A1C4 for ; Wed, 21 Feb 2024 06:21:21 +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=1708496483; cv=none; b=o+9p9okzW/gr1lwEZSk19Qx9b7I/6sizjmgDHAI8dwp2jVcmfWwKtiG2LV2Z0AFqygCT/rZAC1F/3kNEdBZ2ZB08YhpFGQdGKwITglq/Njews0TQWYuEWAv5mZ/0lyv+hBBN2DfLEiE4sDY0iGlhGBW2mo0Yxc5jmpe+6JCvXBo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708496483; c=relaxed/simple; bh=khOgzNuhUwR+/t7Q3yLeHFj32/kIKZkezXpfDVKtJR0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZZRNFL94l7Hv/eA+QBcBVxL3dtsMVKAXov7wW7GtMjrecr0ooIUsLBEWVIucsC4VKjQRgnbCQknLhHlkKHLWC78geeCddcXCqG6KzBSl70zfJThs4eh5nP8TPw+/z8jxZoYuUQz0wa+annpOdVhR4iOnwLf5ucFbZZVBc1BCR8g= 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 1rcfyh-00010R-4X; Wed, 21 Feb 2024 07:21:11 +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 1rcfye-001zFB-Mj; Wed, 21 Feb 2024 07:21:08 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rcfye-003Ga6-21; Wed, 21 Feb 2024 07:21:08 +0100 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: 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 v5 3/8] net: phy: Add helper to set EEE Clock stop enable bit Date: Wed, 21 Feb 2024 07:21:02 +0100 Message-Id: <20240221062107.778661-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240221062107.778661-1-o.rempel@pengutronix.de> References: <20240221062107.778661-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 Content-Transfer-Encoding: 8bit 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 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 Signed-off-by: Oleksij Rempel --- 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 a54b1daf5d5f..207e68b0eec6 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); -- 2.39.2