mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Maxime Chevallier <maxime.chevallier@bootlin.com>, davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, thomas.petazzoni@bootlin.com,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Eric Dumazet" <edumazet@google.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Russell King" <linux@armlinux.org.uk>,
	linux-arm-kernel@lists.infradead.org,
	"Herve Codina" <herve.codina@bootlin.com>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Heiner Kallweit" <hkallweit1@gmail.com>,
	"Vladimir Oltean" <vladimir.oltean@nxp.com>,
	"Köry Maincent" <kory.maincent@bootlin.com>,
	"Marek Behún" <kabel@kernel.org>,
	"Oleksij Rempel" <o.rempel@pengutronix.de>,
	"Nicolò Veronese" <nicveronese@gmail.com>,
	"Simon Horman" <horms@kernel.org>,
	mwojtas@chromium.org, "Antoine Tenart" <atenart@kernel.org>,
	devicetree@vger.kernel.org, "Conor Dooley" <conor+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Romain Gantois" <romain.gantois@bootlin.com>,
	"Daniel Golle" <daniel@makrotopia.org>,
	"Dimitri Fedrau" <dimitri.fedrau@liebherr.com>
Subject: Re: [PATCH net-next v12 14/18] net: phy: at803x: Support SFP through phy_port interface
Date: Wed, 17 Sep 2025 09:02:49 +0200	[thread overview]
Message-ID: <586c0c4c-e1e8-4413-b9e1-53301fad7ab4@csgroup.eu> (raw)
In-Reply-To: <20250909152617.119554-15-maxime.chevallier@bootlin.com>



Le 09/09/2025 à 17:26, Maxime Chevallier a écrit :
> 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
> somewhat compatible with 1000BaseX).
> 
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   drivers/net/phy/qcom/at803x.c | 78 ++++++++++++++---------------------
>   1 file changed, 32 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/net/phy/qcom/at803x.c b/drivers/net/phy/qcom/at803x.c
> index 51a132242462..2995b08bac96 100644
> --- a/drivers/net/phy/qcom/at803x.c
> +++ b/drivers/net/phy/qcom/at803x.c
> @@ -20,7 +20,7 @@
>   #include <linux/of.h>
>   #include <linux/phylink.h>
>   #include <linux/reset.h>
> -#include <linux/sfp.h>
> +#include <linux/phy_port.h>
>   #include <dt-bindings/net/qca-ar803x.h>
>   
>   #include "qcom.h"
> @@ -769,58 +769,44 @@ 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 at803x_configure_mii(struct phy_port *port, bool enable,
> +				phy_interface_t interface)
>   {
> -	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);
> +	struct phy_device *phydev = port_phydev(port);
>   
> -	if (linkmode_empty(sfp_support)) {
> -		dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n");
> -		return -EINVAL;
> -	}
> +	if (interface == PHY_INTERFACE_MODE_SGMII)
> +		dev_warn(&phydev->mdio.dev,
> +			 "module may not function if 1000Base-X not supported\n");
> +
> +	return 0;
> +}
>   
> -	iface = sfp_select_interface(phydev->sfp_bus, sfp_support);
> +static const struct phy_port_ops at803x_port_ops = {
> +	.configure_mii = at803x_configure_mii,
> +};
>   
> -	/* 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.
> +static int at8031_attach_mii_port(struct phy_device *phydev,
> +				  struct phy_port *port)
> +{
> +	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);
> +
> +	/* 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);
> +
> +	port->ops = &at803x_port_ops;
>   
>   	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;
> @@ -841,8 +827,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)
> @@ -1173,6 +1158,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_mii_port	= at8031_attach_mii_port,
>   }, {
>   	/* Qualcomm Atheros AR8032 */
>   	PHY_ID_MATCH_EXACT(ATH8032_PHY_ID),


  reply	other threads:[~2025-09-17  7:21 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-09 15:25 [PATCH net-next v12 00/18] net: phy: Introduce PHY ports representation Maxime Chevallier
2025-09-09 15:25 ` [PATCH net-next v12 01/18] dt-bindings: net: Introduce the ethernet-connector description Maxime Chevallier
2025-09-09 15:25 ` [PATCH net-next v12 02/18] net: ethtool: common: Indicate that BaseT works on up to 4 lanes Maxime Chevallier
2025-09-09 15:25 ` [PATCH net-next v12 03/18] net: ethtool: Introduce ETHTOOL_LINK_MEDIUM_* values Maxime Chevallier
2025-09-09 15:26 ` [PATCH net-next v12 04/18] net: phy: Introduce PHY ports representation Maxime Chevallier
2025-09-17  6:59   ` Christophe Leroy
2025-09-09 15:26 ` [PATCH net-next v12 05/18] net: phy: dp83822: Add support for phy_port representation Maxime Chevallier
2025-09-17  6:59   ` Christophe Leroy
2025-09-09 15:26 ` [PATCH net-next v12 06/18] dt-bindings: net: dp83822: Deprecate ti,fiber-mode Maxime Chevallier
2025-09-17  7:00   ` Christophe Leroy
2025-09-09 15:26 ` [PATCH net-next v12 07/18] net: phy: Create a phy_port for PHY-driven SFPs Maxime Chevallier
2025-09-09 15:26 ` [PATCH net-next v12 08/18] net: phylink: Move phylink_interface_max_speed to phy_caps Maxime Chevallier
2025-09-17  7:00   ` Christophe Leroy
2025-09-09 15:26 ` [PATCH net-next v12 09/18] net: phylink: Move sfp interface selection and filtering " Maxime Chevallier
2025-09-11  0:59   ` kernel test robot
2025-09-17  7:01   ` Christophe Leroy
2025-09-09 15:26 ` [PATCH net-next v12 10/18] net: phy: Introduce generic SFP handling for PHY drivers Maxime Chevallier
2025-09-09 15:26 ` [PATCH net-next v12 11/18] net: phy: marvell-88x2222: Support SFP through phy_port interface Maxime Chevallier
2025-09-17  7:01   ` Christophe Leroy
2025-09-09 15:26 ` [PATCH net-next v12 12/18] net: phy: marvell: " Maxime Chevallier
2025-09-17  7:02   ` Christophe Leroy
2025-09-09 15:26 ` [PATCH net-next v12 13/18] net: phy: marvell10g: Support SFP through phy_port Maxime Chevallier
2025-09-17  7:02   ` Christophe Leroy
2025-09-09 15:26 ` [PATCH net-next v12 14/18] net: phy: at803x: Support SFP through phy_port interface Maxime Chevallier
2025-09-17  7:02   ` Christophe Leroy [this message]
2025-09-09 15:26 ` [PATCH net-next v12 15/18] net: phy: qca807x: " Maxime Chevallier
2025-09-17  7:03   ` Christophe Leroy
2025-09-09 15:26 ` [PATCH net-next v12 16/18] net: phy: Only rely on phy_port for PHY-driven SFP Maxime Chevallier
2025-09-09 15:26 ` [PATCH net-next v12 17/18] net: phy: dp83822: Add SFP support through the phy_port interface Maxime Chevallier
2025-09-09 15:26 ` [PATCH net-next v12 18/18] Documentation: networking: Document the phy_port infrastructure Maxime Chevallier
2025-09-10 10:22 ` [PATCH net-next v12 00/18] net: phy: Introduce PHY ports representation Oleksij Rempel
2025-09-10 22:19 ` Florian Fainelli
2025-09-17  7:04 ` Christophe Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=586c0c4c-e1e8-4413-b9e1-53301fad7ab4@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=andrew@lunn.ch \
    --cc=atenart@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dimitri.fedrau@liebherr.com \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=herve.codina@bootlin.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=kabel@kernel.org \
    --cc=kory.maincent@bootlin.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mwojtas@chromium.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicveronese@gmail.com \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=romain.gantois@bootlin.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®