From nobody Fri Dec 19 17:18:48 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 33FAB3093BA; Mon, 13 Oct 2025 14:33:29 +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=1760366012; cv=none; b=WZTovhcLhFG8ZABBfBVV0H50Fdck4nlLYvNdjW8Ytg8fQ9BhTTz89G5GCeVTPEzMjLQDhjRhpN+MPMgFENA9APp2ZDeoZRFD7akCwmwqAAiycg58LU5GWQ2An4HPzbeS5B7Wr/Lb4cQxIU0stlK/YiqLTzQNR6eNLEfs9I8SKZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760366012; c=relaxed/simple; bh=EGpaNfxyC4E7+JRHE1vXAnzcCc73W5xSCtpGQxamfnA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PydeZxxewxFJ9b+GTXKLOs5YJXwDvplyj3Q5qyqEPgtm1wIllGhy5qSac/+88nhLM8KFcg/y+LgYZ+qQ5Us79cMMDpWAzB9S4Xvcw0lgqVHGG4WuU0Kf6FSyhJgWqiT3H6xpS+Cheb8l5mmry7ShlL7GvxqocD3WiFemYpHE2Tg= 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=WGK8h+V6; 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="WGK8h+V6" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 9CC601A12FF; Mon, 13 Oct 2025 14:33:28 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 6F8AC606C6; Mon, 13 Oct 2025 14:33:28 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id F0F05102F2272; Mon, 13 Oct 2025 16:33:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760366007; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=pKW4Tz6kLvVm8pPfHuxwW/bwHdSgZMzUZysGRCdCYk8=; b=WGK8h+V60fFBDN5Cu3+39sl1G+7s+4EQsFz3Tc9GgyaCqUx4/dvFxfYACsndYSV0iX2OK4 MVn/iN8xijmUmLDOnRn2zt7Q9a9AcgI3Hck4PY7upb1yObZQOijUG87fdWhgDrvg5Gl7AX hhc7hVF000edF48Td3tMHCtm0t4iUKJekVCXSsNqNpjfHg5So1dGK/K5kpL1oC5F9FgsQw UlQrhG0EAwngUdPLTYlp3tBMn7vhKUNmUtjYPIOj9w8gwhrHdn8ayO8Gsp+hpMMsxSypCZ 47+SjPLC6CXr2WMAyAHuE0kDHLiG5nFtc1qurBvQeUYG11BOaO1Mo3id8OLa3w== 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 , Florian Fainelli Subject: [PATCH net-next v14 13/16] net: phy: qca807x: Support SFP through phy_port interface Date: Mon, 13 Oct 2025 16:31:39 +0200 Message-ID: <20251013143146.364919-14-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20251013143146.364919-1-maxime.chevallier@bootlin.com> References: <20251013143146.364919-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" QCA8072/8075 may be used as combo-port PHYs, with Serdes (100/1000BaseX) and Copper interfaces. The PHY has the ability to read the configuration it's in. If the configuration indicates the PHY is in combo mode, allow registering up to 2 ports. Register a dedicated set of port ops to handle the serdes port, and rely on generic phylib SFP support for the SFP handling. Reviewed-by: Christophe Leroy Tested-by: Oleksij Rempel Tested-by: Florian Fainelli Tested-by: Christophe Leroy Signed-off-by: Maxime Chevallier --- drivers/net/phy/qcom/qca807x.c | 72 ++++++++++++++-------------------- 1 file changed, 30 insertions(+), 42 deletions(-) diff --git a/drivers/net/phy/qcom/qca807x.c b/drivers/net/phy/qcom/qca807x.c index 1be8295a95cb..d8f1ce5a7128 100644 --- a/drivers/net/phy/qcom/qca807x.c +++ b/drivers/net/phy/qcom/qca807x.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include =20 #include "../phylib.h" #include "qcom.h" @@ -643,67 +643,54 @@ static int qca807x_phy_package_config_init_once(struc= t phy_device *phydev) return ret; } =20 -static int qca807x_sfp_insert(void *upstream, const struct sfp_eeprom_id *= id) +static int qca807x_configure_serdes(struct phy_port *port, bool enable, + phy_interface_t interface) { - struct phy_device *phydev =3D upstream; - const struct sfp_module_caps *caps; - phy_interface_t iface; + struct phy_device *phydev =3D port_phydev(port); int ret; =20 - caps =3D sfp_get_module_caps(phydev->sfp_bus); - iface =3D sfp_select_interface(phydev->sfp_bus, caps->link_modes); + if (!phydev) + return -ENODEV; =20 - dev_info(&phydev->mdio.dev, "%s SFP module inserted\n", phy_modes(iface)); - - switch (iface) { - case PHY_INTERFACE_MODE_1000BASEX: - case PHY_INTERFACE_MODE_100BASEX: + if (enable) { /* Set PHY mode to PSGMII combo (1/4 copper + combo ports) mode */ ret =3D phy_modify(phydev, QCA807X_CHIP_CONFIGURATION, QCA807X_CHIP_CONFIGURATION_MODE_CFG_MASK, QCA807X_CHIP_CONFIGURATION_MODE_PSGMII_FIBER); + if (ret) + return ret; /* Enable fiber mode autodection (1000Base-X or 100Base-FX) */ ret =3D phy_set_bits_mmd(phydev, MDIO_MMD_AN, QCA807X_MMD7_FIBER_MODE_AUTO_DETECTION, QCA807X_MMD7_FIBER_MODE_AUTO_DETECTION_EN); - /* Select fiber page */ - ret =3D phy_clear_bits(phydev, - QCA807X_CHIP_CONFIGURATION, - QCA807X_BT_BX_REG_SEL); - - phydev->port =3D PORT_FIBRE; - break; - default: - dev_err(&phydev->mdio.dev, "Incompatible SFP module inserted\n"); - return -EINVAL; + if (ret) + return ret; } =20 - return ret; + phydev->port =3D enable ? PORT_FIBRE : PORT_TP; + + return phy_modify(phydev, QCA807X_CHIP_CONFIGURATION, + QCA807X_BT_BX_REG_SEL, + enable ? 0 : QCA807X_BT_BX_REG_SEL); } =20 -static void qca807x_sfp_remove(void *upstream) +static const struct phy_port_ops qca807x_serdes_port_ops =3D { + .configure_mii =3D qca807x_configure_serdes, +}; + +static int qca807x_attach_mii_port(struct phy_device *phydev, + struct phy_port *port) { - struct phy_device *phydev =3D upstream; + __set_bit(PHY_INTERFACE_MODE_1000BASEX, port->interfaces); + __set_bit(PHY_INTERFACE_MODE_100BASEX, port->interfaces); =20 - /* Select copper page */ - phy_set_bits(phydev, - QCA807X_CHIP_CONFIGURATION, - QCA807X_BT_BX_REG_SEL); + port->ops =3D &qca807x_serdes_port_ops; =20 - phydev->port =3D PORT_TP; + return 0; } =20 -static const struct sfp_upstream_ops qca807x_sfp_ops =3D { - .attach =3D phy_sfp_attach, - .detach =3D phy_sfp_detach, - .module_insert =3D qca807x_sfp_insert, - .module_remove =3D qca807x_sfp_remove, - .connect_phy =3D phy_sfp_connect_phy, - .disconnect_phy =3D phy_sfp_disconnect_phy, -}; - static int qca807x_probe(struct phy_device *phydev) { struct device_node *node =3D phydev->mdio.dev.of_node; @@ -744,9 +731,8 @@ static int qca807x_probe(struct phy_device *phydev) =20 /* Attach SFP bus on combo port*/ if (phy_read(phydev, QCA807X_CHIP_CONFIGURATION)) { - ret =3D phy_sfp_probe(phydev, &qca807x_sfp_ops); - if (ret) - return ret; + phydev->max_n_ports =3D 2; + linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->supported); linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->advertising); } @@ -824,6 +810,7 @@ static struct phy_driver qca807x_drivers[] =3D { .get_phy_stats =3D qca807x_get_phy_stats, .set_wol =3D at8031_set_wol, .get_wol =3D at803x_get_wol, + .attach_mii_port =3D qca807x_attach_mii_port, }, { PHY_ID_MATCH_EXACT(PHY_ID_QCA8075), @@ -851,6 +838,7 @@ static struct phy_driver qca807x_drivers[] =3D { .get_phy_stats =3D qca807x_get_phy_stats, .set_wol =3D at8031_set_wol, .get_wol =3D at803x_get_wol, + .attach_mii_port =3D qca807x_attach_mii_port, }, }; module_phy_driver(qca807x_drivers); --=20 2.49.0