From: Sean Anderson <sean.anderson@linux.dev>
To: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Russell King <linux@armlinux.org.uk>
Cc: upstream@airoha.com, Simon Horman <horms@kernel.org>,
Heiner Kallweit <hkallweit1@gmail.com>,
Kory Maincent <kory.maincent@bootlin.com>,
linux-kernel@vger.kernel.org,
Christian Marangi <ansuelsmth@gmail.com>,
Sean Anderson <sean.anderson@linux.dev>,
Claudiu Beznea <claudiu.beznea@microchip.com>,
Nicolas Ferre <nicolas.ferre@microchip.com>
Subject: [net-next PATCH v4 10/11] net: macb: Support external PCSs
Date: Mon, 12 May 2025 12:14:14 -0400 [thread overview]
Message-ID: <20250512161416.732239-2-sean.anderson@linux.dev> (raw)
In-Reply-To: <20250512161416.732239-1-sean.anderson@linux.dev>
This adds support for external PCSs. For example, the Xilinx UltraScale+
processor exposes its GMII interface to the FPGA fabric. This fabric may
implement PCS to convert GMII to a serial interface such as SGMII or
1000BASE-X. When present, the external PCS takes precedence over the
internal PCSs.
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
---
Changes in v4:
- Convert to dev-less pcs_put
Changes in v2:
- Move update to macb_pcs_get_state to previous patch
drivers/net/ethernet/cadence/macb.h | 1 +
drivers/net/ethernet/cadence/macb_main.c | 26 ++++++++++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index c9a5c8beb2fa..9d310814f052 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -1291,6 +1291,7 @@ struct macb {
struct phylink_config phylink_config;
struct phylink_pcs phylink_usx_pcs;
struct phylink_pcs phylink_sgmii_pcs;
+ struct phylink_pcs *phylink_ext_pcs;
u32 caps;
unsigned int dma_burst_length;
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index ed37b1d85212..c644e5055022 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -21,6 +21,7 @@
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/dma-mapping.h>
+#include <linux/pcs.h>
#include <linux/platform_device.h>
#include <linux/phylink.h>
#include <linux/of.h>
@@ -707,7 +708,10 @@ static struct phylink_pcs *macb_mac_select_pcs(struct phylink_config *config,
struct net_device *ndev = to_net_dev(config->dev);
struct macb *bp = netdev_priv(ndev);
- if (interface == PHY_INTERFACE_MODE_10GBASER)
+ if (bp->phylink_ext_pcs &&
+ test_bit(interface, bp->phylink_ext_pcs->supported_interfaces))
+ return bp->phylink_ext_pcs;
+ else if (interface == PHY_INTERFACE_MODE_10GBASER)
return &bp->phylink_usx_pcs;
else if (interface == PHY_INTERFACE_MODE_SGMII)
return &bp->phylink_sgmii_pcs;
@@ -733,7 +737,10 @@ static void macb_mac_config(struct phylink_config *config, unsigned int mode,
if (state->interface == PHY_INTERFACE_MODE_RMII)
ctrl |= MACB_BIT(RM9200_RMII);
} else if (macb_is_gem(bp)) {
- if (macb_mac_select_pcs(config, state->interface))
+ struct phylink_pcs *pcs = macb_mac_select_pcs(config,
+ state->interface);
+
+ if (pcs && pcs != bp->phylink_ext_pcs)
ctrl |= GEM_BIT(PCSSEL);
else
ctrl &= ~GEM_BIT(PCSSEL);
@@ -907,6 +914,14 @@ static int macb_mii_probe(struct net_device *dev)
bp->phylink_sgmii_pcs.ops = &macb_phylink_pcs_ops;
bp->phylink_usx_pcs.ops = &macb_phylink_usx_pcs_ops;
+ bp->phylink_ext_pcs = pcs_get_by_fwnode_optional(&bp->pdev->dev,
+ bp->pdev->dev.fwnode,
+ NULL);
+ if (IS_ERR(bp->phylink_ext_pcs))
+ return dev_err_probe(&bp->pdev->dev,
+ PTR_ERR(bp->phylink_ext_pcs),
+ "Could not get external PCS\n");
+
bp->phylink_config.dev = &dev->dev;
bp->phylink_config.type = PHYLINK_NETDEV;
bp->phylink_config.mac_managed_pm = true;
@@ -924,6 +939,11 @@ static int macb_mii_probe(struct net_device *dev)
__set_bit(PHY_INTERFACE_MODE_RMII,
bp->phylink_config.supported_interfaces);
+ if (bp->phylink_ext_pcs)
+ phy_interface_or(bp->phylink_config.supported_interfaces,
+ bp->phylink_config.supported_interfaces,
+ bp->phylink_ext_pcs->supported_interfaces);
+
/* Determine what modes are supported */
if (macb_is_gem(bp) && (bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE)) {
bp->phylink_config.mac_capabilities |= MAC_1000FD;
@@ -950,6 +970,7 @@ static int macb_mii_probe(struct net_device *dev)
if (IS_ERR(bp->phylink)) {
netdev_err(dev, "Could not create a phylink instance (%ld)\n",
PTR_ERR(bp->phylink));
+ pcs_put(bp->phylink_ext_pcs);
return PTR_ERR(bp->phylink);
}
@@ -5462,6 +5483,7 @@ static void macb_remove(struct platform_device *pdev)
bp->rx_clk, bp->tsu_clk);
pm_runtime_set_suspended(&pdev->dev);
}
+ pcs_put(bp->phylink_ext_pcs);
phylink_destroy(bp->phylink);
free_netdev(dev);
}
--
2.35.1.1320.gc452695387.dirty
next prev parent reply other threads:[~2025-05-12 16:14 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 16:10 [net-next PATCH v4 00/11] Add PCS core support Sean Anderson
2025-05-12 16:10 ` [net-next PATCH v4 01/11] dt-bindings: net: Add Xilinx PCS Sean Anderson
2025-05-12 16:10 ` [net-next PATCH v4 02/11] net: phylink: Support setting PCS link change callbacks Sean Anderson
2025-05-12 16:10 ` [net-next PATCH v4 03/11] net: pcs: Add subsystem Sean Anderson
2025-05-14 16:22 ` Lei Wei
2025-05-19 17:43 ` Sean Anderson
2025-05-21 12:50 ` Lei Wei
2025-05-22 15:14 ` Sean Anderson
2025-05-12 16:10 ` [net-next PATCH v4 04/11] net: dsa: ocelot: suppress PHY device scanning on the internal MDIO bus Sean Anderson
2025-05-12 16:10 ` [net-next PATCH v4 05/11] net: pcs: lynx: Convert to an MDIO driver Sean Anderson
2025-05-12 16:10 ` [net-next PATCH v4 06/11] net: phy: Export some functions Sean Anderson
2025-05-15 2:57 ` Jakub Kicinski
2025-05-15 5:38 ` Heiner Kallweit
2025-05-19 18:17 ` Sean Anderson
2025-05-15 8:12 ` Russell King (Oracle)
2025-05-15 8:39 ` Christian Marangi (Ansuel)
2025-05-19 18:14 ` Sean Anderson
2025-05-19 15:29 ` Sean Anderson
2025-05-12 16:10 ` [net-next PATCH v4 07/11] net: pcs: Add Xilinx PCS driver Sean Anderson
2025-05-14 16:18 ` Lei Wei
2025-05-19 15:31 ` Sean Anderson
2025-05-12 16:10 ` [net-next PATCH v4 08/11] net: axienet: Convert to use PCS subsystem Sean Anderson
2025-05-12 16:14 ` [net-next PATCH v4 09/11] net: macb: Move most of mac_config to mac_prepare Sean Anderson
2025-05-12 16:14 ` Sean Anderson [this message]
2025-05-12 16:14 ` [net-next PATCH v4 11/11] of: property: Add device link support for PCS Sean Anderson
2025-05-13 15:29 ` [net-next PATCH v4 09/11] net: macb: Move most of mac_config to mac_prepare Karumanchi, Vineeth
2025-05-13 15:49 ` Sean Anderson
2025-05-15 6:14 ` Karumanchi, Vineeth
2025-05-13 16:40 ` Sean Anderson
2025-05-15 6:20 ` Karumanchi, Vineeth
2025-05-12 17:11 ` [net-next PATCH v4 00/11] Add PCS core support Daniel Golle
2025-05-12 17:15 ` Sean Anderson
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=20250512161416.732239-2-sean.anderson@linux.dev \
--to=sean.anderson@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=claudiu.beznea@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
--cc=upstream@airoha.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.