Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp459341lqb; Thu, 29 Feb 2024 06:09:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXAHQLqd28y5YuOb2T+ovgI+QeGtrBZMac5UForZH1+9f5z3TDd8zSnSAKxuL0+T0p93aDDMPysDJg4NJiS252Dt4ukuhj0cIzyneH5fA== X-Google-Smtp-Source: AGHT+IFHxRzt6IyS9SVzIk0eiDiTgFpRHr6sqddz1tTnQXnDGHpSvmm/7n9k4K8Ef9oEezdKrfx6 X-Received: by 2002:a05:6214:9ce:b0:690:4942:dd89 with SMTP id dp14-20020a05621409ce00b006904942dd89mr1604119qvb.28.1709215794524; Thu, 29 Feb 2024 06:09:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709215794; cv=pass; d=google.com; s=arc-20160816; b=Iw76bVwcd4sHR0nNre/Mdsgb36hElcLiemAf2JD5Kw+73H7S2RN+4wmrA4IBqSPqSK jOL2X0HwbJSoe0+eFvWT1kicPjndya5SzwY+X31ocSHYY293srVo0xXciMr+qpX9+TSZ 2f6o9NI4sMQIq846dzzO+j+Op4arINLx+L58W8+rWRrTxZQEKV1RbH/iZCvgZLprtT58 AFdkBytnafISyOetv2aYFeyvtkRulSxoGEIxj15JCECVJ7zx076oFDJJfNKYp2vJCpbh wCgLf7hd7w3YwRI0m+nTBY1Couu5EkzJ8mwaXc5UimBn1nqvYBPFpK/JENq4r5B6YV3+ 8ltg== 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=NyxtrrfPF1ZCY86CuuRsRN73vXtsXGCsQS9K13cjhjowbdKXcgTel5EvyHkbbec7vv 730w5vnDzx4MMqlGp+IZtstX8Vfx4IxrFQqX9OGkeuFRAJ0M/zCR7rcLzwxd7pfEy3ZS 2181XH0KVCy0LB+VeRviJsyhkKRzO81l5R4cxGoMjQnXxfqzCW/JVu8Awy0b4QULyODp KOPy3FuNqXiajXbWSja7SmtnqYC53u2akDgjK2RF/Gui0Jz9DXmnm01886X9tvbT8Fk3 4U8lQvXLFI73whIg995/cfYQzUQSpYWVbaophpouJHEhs9aaQh2EeIt3nz1CGS7TysL5 d/bw==; 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-86801-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86801-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 mv5-20020a056214338500b0068cbab014absi1319945qvb.595.2024.02.29.06.09.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 06:09:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86801-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-86801-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86801-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 4454B1C214E4 for ; Thu, 29 Feb 2024 14:09:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D0B1813B281; Thu, 29 Feb 2024 14:08:25 +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 C96AB12F580 for ; Thu, 29 Feb 2024 14:08:20 +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=1709215704; cv=none; b=swyVACeI6MhZQqaAElI08aq1AnM0vQNO/VUXjnfQHGXhwMxJC+K877puFfkt10icOw13lf707hAknTToNwHohirKv8rLujZIRwlk3xhn/MMdG4xoMUWnm2j4rdemaLWBUCOVYivYCXhJwStwHJqeYbJk5TJI5SGXXSxnCbMMebA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709215704; c=relaxed/simple; bh=uCZhXHLSFkdy7i0Gfza9gulaJphXTOfQr0iTmcrT+Y0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b1s+4zSoI46z+SwrnPTJphed35DuT3c558CSzmS5uD7kH3KyRmmi4ZsJEgTMSL/vojIuHs8QDPcwMSS5sc2cYGjQCfhs5Cl3F1ONgBT7PFID5kpBi0BNVhkb5wm2at8P0O4i5Qls9Wv6GARUZhdIiS6ivSa4H2/cGUl3+9yZko4= 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 1rfh4t-0000Su-MV; Thu, 29 Feb 2024 15:08:03 +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 1rfh4r-003bZs-PR; Thu, 29 Feb 2024 15:08:01 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rfh4r-00ELmH-1t; Thu, 29 Feb 2024 15:08:01 +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 v7 3/8] net: phy: Add helper to set EEE Clock stop enable bit Date: Thu, 29 Feb 2024 15:07:55 +0100 Message-Id: <20240229140800.3420180-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240229140800.3420180-1-o.rempel@pengutronix.de> References: <20240229140800.3420180-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 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); -- 2.39.2