From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3638CF8840 for ; Fri, 4 Oct 2024 17:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=la8SYFLXiQbvELSBNxA6DPB/JK9HrzHWiWkj/zCFpDg=; b=VsBehqq8OqFryYuWxoRb5dZ22h x9TWd3MqwPid7NLIpbpnI8Q2Irz4v/0rlABpgYR1I7hvVvHfBh85OkoGOC1G7TYMRcxMOHIOTHIUe 9csmOLMmST8hR2asnJB1unNTt+iB0bHgwTb0/vlZCym706e7b/alSyJMXRdisfJg+XkRwF6iByhQB YyWSbbC4ZAIXmoJ1SwOgXI+eWfhUlVnm1WG6P+XyazIc6noCW5iEcRuR+BX1qtfmJhP7kdgU6rsqG /wwmXb0dM6fYMJN71bFQKW+1ovs7wXJXo1Ndf8w3S69dHcD6rhh7Vp3AqqhPzMZm9dvJ8gq848YTs ZjvPkjRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swlqT-0000000DSAB-2z65; Fri, 04 Oct 2024 17:12:01 +0000 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1swkyR-0000000DCdr-2628 for linux-arm-kernel@lists.infradead.org; Fri, 04 Oct 2024 16:16:13 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id C14C120009; Fri, 4 Oct 2024 16:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728058568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=la8SYFLXiQbvELSBNxA6DPB/JK9HrzHWiWkj/zCFpDg=; b=jQ3ra73DjV+eY3z7qTSpp6U8ixANJh4PvBVhFTSwwoVxspGtNZbfbR+U11E13a5Nryasan UACUOKrq5dom/rPejVvYr1YM+VJBUk9iEb9Tid7JNfs3SB2WQ4IFYVBSYafK3CF7JLRkcg KG1jckkj0hwFY+fSlYyn1arKslIVUZx/bw/QWEaH4d7T7FZ+AQ1m/VfFFdqNEWYaRz/3+U 70RuwdHgbSlS+hAoOcJ+sOvrGQCQ38eynEeRjcsVuwolqNhYOfvK1PX+T++Y9AuG5aYr3h dQhRSPCQsY5U/dXU2122WBx6mBFTtyxRpBfO/oZStCeffLZlhYyUpWyjUKlzNQ== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?K=C3=B6ry=20Maincent?= , Oleksij Rempel Subject: [PATCH net-next v2 3/9] net: phy: Allow PHY drivers to report isolation support Date: Fri, 4 Oct 2024 18:15:53 +0200 Message-ID: <20241004161601.2932901-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> References: <20241004161601.2932901-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241004_091611_838420_4D32FBCA X-CRM114-Status: GOOD ( 13.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some PHYs have malfunctionning isolation modes, where the MII lines aren't correctly set in high-impedance, potentially interfering with the MII bus in unexpected ways. Some other PHYs simply don't support it. The isolation support may depend on the interface mode being used, so introduce a new driver callback to report the isolation support in the current PHY configuration. As some PHYs just never support isolation, introduce a genphy helper that can be used for strictly non-isolating PHYs. Signed-off-by: Maxime Chevallier --- V2 : Moved from flag to callback, introduced genphy helper drivers/net/phy/phy_device.c | 11 +++++++++++ include/linux/phy.h | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index a0d8ff995024..9294b73c391a 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2127,6 +2127,14 @@ int phy_loopback(struct phy_device *phydev, bool enable) } EXPORT_SYMBOL(phy_loopback); +static bool phy_can_isolate(struct phy_device *phydev) +{ + if (phydev->drv && phydev->drv->can_isolate) + return phydev->drv->can_isolate(phydev); + + return true; +} + int phy_isolate(struct phy_device *phydev, bool enable) { int ret = 0; @@ -2134,6 +2142,9 @@ int phy_isolate(struct phy_device *phydev, bool enable) if (!phydev->drv) return -EIO; + if (!phy_can_isolate(phydev)) + return -EOPNOTSUPP; + mutex_lock(&phydev->lock); if (enable && phydev->isolated) { diff --git a/include/linux/phy.h b/include/linux/phy.h index ae33919aa0f5..e43f7169c57d 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1192,6 +1192,19 @@ struct phy_driver { */ int (*led_polarity_set)(struct phy_device *dev, int index, unsigned long modes); + + /** + * @can_isolate: Query the PHY isolation capability + * @dev: PHY device to query + * + * Although PHY isolation is part of 802.3, not all PHYs support that + * feature. Some PHYs can only support isolation when using a specific + * phy_interface_mode, and some don't support it at all. + * + * Returns true if the PHY can isolate in its current configuration, + * false otherwise. + */ + bool (*can_isolate)(struct phy_device *dev); }; #define to_phy_driver(d) container_of_const(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv) @@ -1910,6 +1923,12 @@ static inline int genphy_no_config_intr(struct phy_device *phydev) { return 0; } + +static inline bool genphy_no_isolate(struct phy_device *phydev) +{ + return false; +} + int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad, u16 regnum); int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum, -- 2.46.1