From patchwork Fri Mar 1 10:01:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 208735 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp973773dyb; Fri, 1 Mar 2024 02:04:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCURCvep+0VSG2/YrqX70o3yLpiCMV0fKwjzT5RNJkiCdsLNpYn/XukZcY3PghTZX6hLuN2I59sYFZ9RBhKnK3SKefwOhQ== X-Google-Smtp-Source: AGHT+IGETC0NwU94uN7Gp0hT00X/HY5Ajsw9/vjfr0VMjeFGiaoGAttNzNA/ThdvfMDNJeA2Vshw X-Received: by 2002:a05:6808:a89:b0:3c1:bc9c:3865 with SMTP id q9-20020a0568080a8900b003c1bc9c3865mr1151183oij.19.1709287452369; Fri, 01 Mar 2024 02:04:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287452; cv=pass; d=google.com; s=arc-20160816; b=ruuDzJ2BgTiTw2DpwUOLuDF6UXrPscMIbEBvbKa1sf+VpOWXoLqIg/ZTdiuxSVpx4p f7m18n4tIuZ7tj9D18DQ6J/ob9O6BKSqgZ2gyTWW1tGsr3GrfzbxwV8erc4xJU3xqLFG aEAYTywG4GoYEoEGZ15ZFbh6VjXJI1ii0Rv9WveSWkQL6rAdo1lYBayUBmR1TzkY9xji T+Vow3uLU8etv1XmAV3GgP2jviuZCvz4WJjrs9naczByTEwSxKPGJCb2VEpFDlurO/uS T9gWEQFmBnC5ZvFrmP/GywqubqyiDGKMZhs8nSug0RKxMt7NoFNsNUoHXnxi0Q1qwI4f ceiw== 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=YxLqpfGEexTK0JV4X7kB9kkD3dWrPVESJYoHgjLCMi4=; fh=/mFbHcqW6l4fLIJBfKVNbHEV0oGb2iio8Q6EPf9P78A=; b=i4ys6vqTXEAIFOOm79FW6WsSMI61O+R9Zf3IhcDKzR3j6+ei+aqUzAf3DU/bw5iIlY Z7omnnfkgjLtkhGrxxPVV2Tl/DLpD7X+3zLtn+UL5U7edBTGPVHvQQi7OU+PnDRpRsRP zSkW6VQWBmSPWgqNC0Rx0vB9dN686Drg5EIDJl8gD/J08+ObmBqTCiOefuoBziPCDda+ 3XFwemmsYjn3E8SnTWCzXv3oroALqnzZdUp06Y8ZM4FjGdU2/gNqHu+kJZfkXu6Cd05y q6KYdu5WZ+Pn3rn2aepgybXSg7Ey1LoHYplBCEeLbz1vQR2cdMBuY6V8wB623vnhFbq1 EwiQ==; 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-88217-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88217-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y6-20020a62f246000000b006e5936840dfsi2974284pfl.336.2024.03.01.02.04.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:04:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88217-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-88217-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88217-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9E246288095 for ; Fri, 1 Mar 2024 10:03:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D5BD6CDC8; Fri, 1 Mar 2024 10:02:10 +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 CA43C482C1 for ; Fri, 1 Mar 2024 10:02:05 +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=1709287327; cv=none; b=a6F0cj9jclKP3juafFEwyWJb6CNC38bQMIEldBDHr3pGzr/geMAOupryNagTBlpP9qtOBYszm3DDYAPpCo20eQ/EhQgKa5vpkZuoyntOsbyE9xXyQne0fkbg1J0meER1Xj999qzg9Bbcc9ldMiddvfNrmie0Xwnun21Z671oGyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287327; c=relaxed/simple; bh=uCZhXHLSFkdy7i0Gfza9gulaJphXTOfQr0iTmcrT+Y0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=spRkd+eDHRXbMy1z3hu8v92woegWvu6SHPB1Je1rkuOpdO2dL7t4OYLUdOLqhlfO4oHenRfNYkgO5n+B21Kr+s5bA0QjxsvUWZAZPQwV7fkmgsZ1E3bRYbC2BCXTtBhPMlWAZ6BCbtrccqczQbVqo16e642cFiWR32979B+tAKo= 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 1rfziG-0003og-LB; Fri, 01 Mar 2024 11:01:56 +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 1rfziE-003kq5-Ii; Fri, 01 Mar 2024 11:01:54 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rfziE-003tMe-1b; Fri, 01 Mar 2024 11:01:54 +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 v8 3/8] net: phy: Add helper to set EEE Clock stop enable bit Date: Fri, 1 Mar 2024 11:01:48 +0100 Message-Id: <20240301100153.927743-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240301100153.927743-1-o.rempel@pengutronix.de> References: <20240301100153.927743-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: 1792317799466288705 X-GMAIL-MSGID: 1792317799466288705 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 2bc0a7d51c63f..ab18b0d9beb47 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 a880f6d7170ea..432c561f58098 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);