From nobody Fri Oct 3 00:03:12 2025 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 16AB83570C4; Tue, 9 Sep 2025 15:27:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757431653; cv=none; b=X1WITHbXS+GSDoYFNNmOyAg5HE4PabVHj50RIAr7ugclQWSPfYLBHEpPTYqLZIeL0ZCDGFFcL/4jCjigJCcEQg7HxDg2M2pwyOUmfT9NXB2jAW3Tni3eTKk5nWCxvIanaRoryNupptQ0pSQqXbwwCQ8ecZ2HnC4MyOkvAzGG5Bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757431653; c=relaxed/simple; bh=D2jcMQua3eSrJB6pY6nhLWxJt4N7RjySISDihOnq7/M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Eu5D3oXTFk2GY7t3pyxAsB+trc8JqcplbrRNwC3QCAw5h19O6H2oWZ4mDboHCyK/E8NJOlpb71RiHuQbjZBUR1N40oQT4hHWmtn33K5rO/VXAA/aG/KnGPrQUTDF/yTWlIOWd6gP/Y4sMlJ8BwwtvDDeQ87sIQxNmhL7C3akXck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=GWjlKDqa; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="GWjlKDqa" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 9ABA21A087F; Tue, 9 Sep 2025 15:27:30 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 6C8DD60630; Tue, 9 Sep 2025 15:27:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DB8D6102F2835; Tue, 9 Sep 2025 17:27:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1757431649; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=cnnPXVHMdN2zHZd/dXgZMnTBDE0Y5BUkh+t5k0w6Te0=; b=GWjlKDqaXRidRMVPrNLgCYY3xq8fVaCEAdVeHV/DrG+jSeUxe/MF+7VgAdnOuYRcu/v/pZ a5lc5F5FNwL1xrMRYNKdf/armwI5gwcIqrpHX0xUiSPEl6IBQ4mu+Lha2LwLSXU+Ac5CPk 6t0cQLsbAXyJBXPdbAXaZqoVa2gjn5QidXbjkh2UM+zlBzC76QlpBnHWFZ+t1FtCyWVuyR 1DKvf9XXahKgQQtHg2az+NA9prLP29knsyseNx3BA5RK3Yszd2FU29UzPzr1kbw4DMcGFR s4McXvI8VAkL2YQfiPuJBjopW2w8nCaD+PNQeS0pilvk+X37wEnYuUxjFO3p5A== 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=20Maincent?= , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Oleksij Rempel , =?UTF-8?q?Nicol=C3=B2=20Veronese?= , Simon Horman , mwojtas@chromium.org, Antoine Tenart , devicetree@vger.kernel.org, Conor Dooley , Krzysztof Kozlowski , Rob Herring , Romain Gantois , Daniel Golle , Dimitri Fedrau Subject: [PATCH net-next v12 05/18] net: phy: dp83822: Add support for phy_port representation Date: Tue, 9 Sep 2025 17:26:01 +0200 Message-ID: <20250909152617.119554-6-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250909152617.119554-1-maxime.chevallier@bootlin.com> References: <20250909152617.119554-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" With the phy_port representation introduced, we can use .attach_port to populate the port information based on either the straps or the ti,fiber-mode property. This allows simplifying the probe function and allow users to override the strapping configuration. Signed-off-by: Maxime Chevallier Reviewed-by: Christophe Leroy --- drivers/net/phy/dp83822.c | 72 +++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index 33db21251f2e..c6e5b7244658 100644 --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include =20 @@ -811,17 +812,6 @@ static int dp83822_of_init(struct phy_device *phydev) int i, ret; u32 val; =20 - /* Signal detection for the PHY is only enabled if the FX_EN and the - * SD_EN pins are strapped. Signal detection can only enabled if FX_EN - * is strapped otherwise signal detection is disabled for the PHY. - */ - if (dp83822->fx_enabled && dp83822->fx_sd_enable) - dp83822->fx_signal_det_low =3D device_property_present(dev, - "ti,link-loss-low"); - if (!dp83822->fx_enabled) - dp83822->fx_enabled =3D device_property_present(dev, - "ti,fiber-mode"); - if (!device_property_read_string(dev, "ti,gpio2-clk-out", &of_val)) { if (strcmp(of_val, "mac-if") =3D=3D 0) { dp83822->gpio2_clk_out =3D DP83822_CLK_SRC_MAC_IF; @@ -950,6 +940,49 @@ static int dp83822_read_straps(struct phy_device *phyd= ev) return 0; } =20 +static int dp83822_attach_mdi_port(struct phy_device *phydev, + struct phy_port *port) +{ + struct dp83822_private *dp83822 =3D phydev->priv; + int ret; + + if (port->mediums) { + if (phy_port_is_fiber(port)) + dp83822->fx_enabled =3D true; + } else { + ret =3D dp83822_read_straps(phydev); + if (ret) + return ret; + +#if IS_ENABLED(CONFIG_OF_MDIO) + if (dp83822->fx_enabled && dp83822->fx_sd_enable) + dp83822->fx_signal_det_low =3D + device_property_present(&phydev->mdio.dev, + "ti,link-loss-low"); + + /* ti,fiber-mode is still used for backwards compatibility, but + * has been replaced with the mdi node definition, see + * ethernet-port.yaml + */ + if (!dp83822->fx_enabled) + dp83822->fx_enabled =3D + device_property_present(&phydev->mdio.dev, + "ti,fiber-mode"); +#endif /* CONFIG_OF_MDIO */ + + if (dp83822->fx_enabled) { + port->lanes =3D 1; + port->mediums =3D BIT(ETHTOOL_LINK_MEDIUM_BASEF); + } else { + /* This PHY can only to 100BaseTX max, so on 2 lanes */ + port->lanes =3D 2; + port->mediums =3D BIT(ETHTOOL_LINK_MEDIUM_BASET); + } + } + + return 0; +} + static int dp8382x_probe(struct phy_device *phydev) { struct dp83822_private *dp83822; @@ -968,27 +1001,13 @@ static int dp8382x_probe(struct phy_device *phydev) =20 static int dp83822_probe(struct phy_device *phydev) { - struct dp83822_private *dp83822; int ret; =20 ret =3D dp8382x_probe(phydev); if (ret) return ret; =20 - dp83822 =3D phydev->priv; - - ret =3D dp83822_read_straps(phydev); - if (ret) - return ret; - - ret =3D dp83822_of_init(phydev); - if (ret) - return ret; - - if (dp83822->fx_enabled) - phydev->port =3D PORT_FIBRE; - - return 0; + return dp83822_of_init(phydev); } =20 static int dp83826_probe(struct phy_device *phydev) @@ -1172,6 +1191,7 @@ static int dp83822_led_hw_control_get(struct phy_devi= ce *phydev, u8 index, .led_hw_is_supported =3D dp83822_led_hw_is_supported, \ .led_hw_control_set =3D dp83822_led_hw_control_set, \ .led_hw_control_get =3D dp83822_led_hw_control_get, \ + .attach_mdi_port =3D dp83822_attach_mdi_port \ } =20 #define DP83825_PHY_DRIVER(_id, _name) \ --=20 2.49.0