From patchwork Thu Feb 13 10:15:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13973081 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 2B963C0219D for ; Thu, 13 Feb 2025 10:38:09 +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=Cy7CRn2v50cOcoa5xE7o+oFKOeGd2eTmB8xhpniJoz4=; b=UGh/aAQRr+mXqD2GgzUD/3TsQh IPv4eU/4dhIo/HBVZHplI3xQQoEmNcuLJBpAxoZ+P3gYO/kXc4WQ3DtMZQluVwGPpbPNv9TmRF5tS VsrTEhnScoBXfPYEXV8DTG+/DB1i13aqKa4bZN/6oG/RDrcgwTGJhuKqc5xCvlIFMf6gN0HNMKpeF S1tlEhHi2sWBmxB5cBjkkouLsqENVKwWlN+nL8H3IKuCDgtsS8HhgVG/qJ1B6CcqrJDSZnoCV9Qu2 xXi2SCUStMkptFJO9hczQGQ4Vr7c+3cj9sheRJlyS1vXGK1/qf68dnu3Wo9SQIIh3kuXdQDBYaEXs DtIna6Mw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tiWbX-0000000AhC6-451d; Thu, 13 Feb 2025 10:38:00 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tiWGp-0000000Ad1M-2QUD for linux-arm-kernel@bombadil.infradead.org; Thu, 13 Feb 2025 10:16:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Cy7CRn2v50cOcoa5xE7o+oFKOeGd2eTmB8xhpniJoz4=; b=lp73UvRHtlNYKV+YC9HIg9OouX ZX9bik47Yj5TgGBgdJRNCiMH87vSO/SlK+m2MI3wlrPrr1GSJTIfUVEWyy/eyG2yfoHheqB9Ud5hs T1/fRxbxsNvDXdKJe4HUZuBMI7YpPQvBQqV94vjTJDlZq0AXNUPujbHqZRK+5JswwNjiMnBKfRNnG PV0ISOVJQBSjcQTXG1eu01bWtCO3mNtC20u60bj7DnbigK3UsMO/5N8fVtoytRqhWnmcm0cgbkQ4s aG7nYBynKKAbUG7K9sd8NosEe/e8Rf0HGekj6HtvuiO1RVHY4Q/YoqVIZTvuprS/PsAm8ty5kT4fg An2TeMbg==; Received: from relay9-d.mail.gandi.net ([217.70.183.199]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tiWGm-00000000xOC-2i5d for linux-arm-kernel@lists.infradead.org; Thu, 13 Feb 2025 10:16:34 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 575814328F; Thu, 13 Feb 2025 10:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1739441788; 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=Cy7CRn2v50cOcoa5xE7o+oFKOeGd2eTmB8xhpniJoz4=; b=XWAfN/xeqWvPbm1Sn+91PaD3TglUNRZpLnI4Qjuke0gbPZ2OMHNoJIBwYuFv/pMV9+xG94 bN0szw68gq+wDq3rNnhOrc4ftIza0f9S9wjJx/J/Hijq/AMUZASK93wM66A2iYSmm3rArT KimBQC2bQ+mPgdArPizvM79+YrC/vRzMG04TD+qBk7+wzWmpe/M2g/HvbDBNv7CdpgKUth vAahDX7ZvHdYNEt3zUBBr5CUGWG9b/pI95Azh5lOh00jekyVq9+ffGWOtUUdC2d3xTMOsf 1ii/2xKIm824DJZPVCh0Hih9g6GQBiD1IbM6XRr+A9fUn2RHIgOww9DTMRa/0A== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@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?K=C3=B6ry_Maincent?= , =?utf-8?q?Marek?= =?utf-8?q?_Beh=C3=BAn?= , Oleksij Rempel , =?utf-8?q?Nicol=C3=B2_Veronese?= , Simon Horman , mwojtas@chromium.org, Antoine Tenart , devicetree@vger.kernel.org, Conor Dooley , Krzysztof Kozlowski , Rob Herring , Romain Gantois , Daniel Golle , Dimitri Fedrau , Sean Anderson Subject: [PATCH net-next v4 10/15] net: phy: at803x: Support SFP through phy_port interface Date: Thu, 13 Feb 2025 11:15:58 +0100 Message-ID: <20250213101606.1154014-11-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250213101606.1154014-1-maxime.chevallier@bootlin.com> References: <20250213101606.1154014-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdegieehudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgvucevhhgvvhgrlhhlihgvrhcuoehmrgigihhmvgdrtghhvghvrghllhhivghrsegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpeevgedtffelffelveeuleelgfejfeevvdejhfehgeefgfffvdefteegvedutefftdenucfkphepvdgrtddumegtsgduleemkegugegtmeelfhdttdemsggtvddumeekkeelleemheegtdgtmegvheelvgenucevlhhushhtvghrufhiiigvpeelnecurfgrrhgrmhepihhnvghtpedvrgdtudemtggsudelmeekugegtgemlehftddtmegstgdvudemkeekleelmeehgedttgemvgehlegvpdhhvghlohepfhgvughorhgrrdhhohhmvgdpmhgrihhlfhhrohhmpehmrgigihhmvgdrtghhvghvrghllhhivghrsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeefvddprhgtphhtthhopegurghvvghmsegurghvvghmlhhofhhtrdhnvghtpdhrtghpthhtohepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehnvghtuggvvhesvhhgvghrrdhkv ghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdgrrhhmqdhmshhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhhohhmrghsrdhpvghtrgiiiihonhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtoheprghnughrvgifsehluhhnnhdrtghhpdhrtghpthhtohepkhhusggrsehkvghrnhgvlhdrohhrgh X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250213_101632_854264_5AA1407C X-CRM114-Status: GOOD ( 18.18 ) 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 Convert the at803x driver to use the generic phylib SFP handling, via a dedicated .attach_port() callback, populating the supported interfaces. As these devices are limited to 1000BaseX, a workaround is used to also support, in a very limited way, copper modules. This is done by supporting SGMII but limiting it to 1G full duplex (in which case it's somwhat compatible with 1000BaseX). Signed-off-by: Maxime Chevallier --- V4: no changes drivers/net/phy/qcom/at803x.c | 64 ++++++++++------------------------- 1 file changed, 17 insertions(+), 47 deletions(-) diff --git a/drivers/net/phy/qcom/at803x.c b/drivers/net/phy/qcom/at803x.c index 26350b962890..87145c4b4cbd 100644 --- a/drivers/net/phy/qcom/at803x.c +++ b/drivers/net/phy/qcom/at803x.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include "qcom.h" @@ -722,58 +722,28 @@ static int at8031_register_regulators(struct phy_device *phydev) return 0; } -static int at8031_sfp_insert(void *upstream, const struct sfp_eeprom_id *id) +static int at8031_attach_port(struct phy_device *phydev, struct phy_port *port) { - struct phy_device *phydev = upstream; - __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_support); - __ETHTOOL_DECLARE_LINK_MODE_MASK(sfp_support); - DECLARE_PHY_INTERFACE_MASK(interfaces); - phy_interface_t iface; - - linkmode_zero(phy_support); - phylink_set(phy_support, 1000baseX_Full); - phylink_set(phy_support, 1000baseT_Full); - phylink_set(phy_support, Autoneg); - phylink_set(phy_support, Pause); - phylink_set(phy_support, Asym_Pause); - - linkmode_zero(sfp_support); - sfp_parse_support(phydev->sfp_bus, id, sfp_support, interfaces); - /* Some modules support 10G modes as well as others we support. - * Mask out non-supported modes so the correct interface is picked. - */ - linkmode_and(sfp_support, phy_support, sfp_support); - - if (linkmode_empty(sfp_support)) { - dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n"); - return -EINVAL; - } + if (!port->is_serdes) + return 0; - iface = sfp_select_interface(phydev->sfp_bus, sfp_support); + linkmode_zero(port->supported); + phylink_set(port->supported, 1000baseX_Full); + phylink_set(port->supported, 1000baseT_Full); + phylink_set(port->supported, Autoneg); + phylink_set(port->supported, Pause); + phylink_set(port->supported, Asym_Pause); - /* Only 1000Base-X is supported by AR8031/8033 as the downstream SerDes - * interface for use with SFP modules. - * However, some copper modules detected as having a preferred SGMII - * interface do default to and function in 1000Base-X mode, so just - * print a warning and allow such modules, as they may have some chance - * of working. + /* This device doesn't really support SGMII. However, do our best + * to be compatible with copper modules (that usually require SGMII), + * in a degraded mode as we only allow 1000BaseT Full */ - if (iface == PHY_INTERFACE_MODE_SGMII) - dev_warn(&phydev->mdio.dev, "module may not function if 1000Base-X not supported\n"); - else if (iface != PHY_INTERFACE_MODE_1000BASEX) - return -EINVAL; + __set_bit(PHY_INTERFACE_MODE_SGMII, port->interfaces); + __set_bit(PHY_INTERFACE_MODE_1000BASEX, port->interfaces); return 0; } -static const struct sfp_upstream_ops at8031_sfp_ops = { - .attach = phy_sfp_attach, - .detach = phy_sfp_detach, - .module_insert = at8031_sfp_insert, - .connect_phy = phy_sfp_connect_phy, - .disconnect_phy = phy_sfp_disconnect_phy, -}; - static int at8031_parse_dt(struct phy_device *phydev) { struct device_node *node = phydev->mdio.dev.of_node; @@ -794,8 +764,7 @@ static int at8031_parse_dt(struct phy_device *phydev) return ret; } - /* Only AR8031/8033 support 1000Base-X for SFP modules */ - return phy_sfp_probe(phydev, &at8031_sfp_ops); + return 0; } static int at8031_probe(struct phy_device *phydev) @@ -1047,6 +1016,7 @@ static struct phy_driver at803x_driver[] = { .set_tunable = at803x_set_tunable, .cable_test_start = at8031_cable_test_start, .cable_test_get_status = at8031_cable_test_get_status, + .attach_port = at8031_attach_port, }, { /* Qualcomm Atheros AR8032 */ PHY_ID_MATCH_EXACT(ATH8032_PHY_ID),