From patchwork Thu Feb 29 14:07:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 208376 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp421683dyb; Thu, 29 Feb 2024 06:12:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWTZ4THFIJ7F7jYaBRPDi8c3ckzBmHfnH6JUtbf8gPCZVqm0N4qVmeBgysYvsv9K/utGcSJ8EdO03AK1TeGGsWVfC5oQA== X-Google-Smtp-Source: AGHT+IHsiKYZZejvavIMnMXUEEZzIBEKmZ2NfnFQlcb8rL3SSGxw3r99Kt7mQOSN4IxHvOl8FbCN X-Received: by 2002:aa7:8750:0:b0:6e5:568b:d72c with SMTP id g16-20020aa78750000000b006e5568bd72cmr2125666pfo.8.1709215921405; Thu, 29 Feb 2024 06:12:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709215921; cv=pass; d=google.com; s=arc-20160816; b=FHK764KiYQLWQ+EPOQ+mmTlmZ7WJ2ETtFYOwvgCUNwxWxVmTRZzJUZ+0UHEp7BpCdl TYwh71e73k9rnTWvuK16gLiYKTdZ+mNJGR/VZXWwUz1AHWzOmvIVG2PEL/TPLU69R5ag WyXG3FRqVlGaNTa5f7QTtiUx5tItngU9tDphX/7BFIbenq7iev0ZPqj2xS4UkQFI+U0J p38MJEzRaNnf0FfsfZPnG73/Ovk8RX/s86l5rxEziFBQEwcl9DGQdcDXL9rpsNUv2O6p 9RrxnUBvv+z1XgWcTZpnPIeCK+5olIZdYw3/ZMg/Xqs9gUnDroO/kj9gs6DKr1bq2wWY ZS9Q== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86801-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id a17-20020aa78e91000000b006e5736fa38asi1379538pfr.260.2024.02.29.06.12.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 06:12:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86801-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-86801-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86801-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E57E7B235AF for ; Thu, 29 Feb 2024 14:10:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82B4714A4CA; Thu, 29 Feb 2024 14:08:27 +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 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: 1792242794148563181 X-GMAIL-MSGID: 1792242794148563181 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);