From nobody Mon Dec 1 22:05:59 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 2843A26FA4E for ; Sat, 29 Nov 2025 08:22:56 +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=1764404580; cv=none; b=I/otM7IUUyPrhb22V9DTAYChvrBjfDm3A5d4p+dlrIk/Xhrn2DgnLmXYLA15MWm00audI7pYUSYWCM5pE/fImx/cE6QKP4sHV7KVDw4eY1HTbALhOMIZguMt/mGN/YV3+xL+4NdGfX458+h+Eb8wTDL2HpcpgE/T7AOwkMJ0Myo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764404580; c=relaxed/simple; bh=pi/yUiE0GLIh3NoCUC5adF6wKjp71KSefaDgIXV/uPc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r5JEMB2/pm0qYaQQjVYJSIyEew8/i4k40Q9ddcSpGScczrrxQd3ytYs0biXxVNLDD2rTfXG52PX1GtBN+B13z0uMh+cEpI5oYZAYEI23xTNQOuM35X44EgcYGzmkohTxDsgMrpJdKBTtgKWBx6J9JUB/nJBGLlsnCfrit23WqAA= 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=nlmGiuJ8; 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="nlmGiuJ8" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id A167B1A1E21; Sat, 29 Nov 2025 08:22:55 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 7764360706; Sat, 29 Nov 2025 08:22:55 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E72FD102F274D; Sat, 29 Nov 2025 09:22:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1764404573; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=KSlMJCkHN3qoiesq+GZbeTPd6cykEBxG8JM7oiO9bAg=; b=nlmGiuJ8eQkjSBXk4t3faGsrjcsFWiTDxlqOpsfc92M/fxzkmrOr2NoiH1kB/TkMCLTiDs 7pmaqcjl4mjFMMq3bYtuv/82B2Kr1DPehiLLTzzv15KIgPdcqdMXqKCByjjdTg7lRTcWdL 2QDQVM1tZXkJIXQDjVfws70SYHb+nwojGp//ERBLcfLY3fPP16OzCCSQfpsvgqtHvVwoBv 7ygeNI6aJhQtkdQ10GoIpqXbjc/PNQKjGmm3m7D/RUbAUioKzLagPQrZ6Mhe7CCOGAcCOZ 9pxyF5DiubvMl5wwy00kSi1gQxZYHh5oTLxtT55my2simTFFTigAOR2s+5i5iA== 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 , Tariq Toukan Subject: [PATCH net-next v21 04/14] net: phy: dp83822: Add support for phy_port representation Date: Sat, 29 Nov 2025 09:22:16 +0100 Message-ID: <20251129082228.454678-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20251129082228.454678-1-maxime.chevallier@bootlin.com> References: <20251129082228.454678-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. Reviewed-by: Christophe Leroy Reviewed-by: Andrew Lunn Tested-by: Christophe Leroy Signed-off-by: Maxime Chevallier --- drivers/net/phy/dp83822.c | 71 +++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index 33db21251f2e..c012dfab3171 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,48 @@ 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->mediums =3D BIT(ETHTOOL_LINK_MEDIUM_BASEF); + } else { + /* This PHY can only to 100BaseTX max, so on 2 pairs */ + port->pairs =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 +1000,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 +1190,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