Add PCS core support
Subsystems (21)
Sean Anderson
reviewerv6 cover Add PCS core support
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
- The Lynx PCS (and all of its users) is converted to this system (patches 4-5)
- The Xilinx PCS is broken out from the AXI Ethernet driver (patches 6-7)
- The Cadence MACB driver is converted to support external PCSs (namely the Xilinx PCS) (patches 8-9).
Care has been taken to ensure backwards-compatibility. The main source of this is that many PCS devices lack compatibles and get detected as PHYs. To address this, pcs_get_by_fwnode_compat allows drivers to edit the devicetree to add appropriate compatibles.
There is another series [1] with the same goal by Christian Marangi. In comparison, I believe this series
- Implements a simpler and more-robust method of PCS access.
- Provides a more-direct upgrade path for existing MAC and PCS drivers.
[1] https://lore.kernel.org/netdev/[email protected]/
Changes in v6:
- Define lynx_pcs_of_match only when OF_MATCH is enabled
- Fix use of spin_lock instead of spin_unlock
- Introduce config for compatibility helpers
- Move axienet_pcs_fixup to AXI Ethernet commit
- Reduce line lengths to under 80 characters
- Remove duplicate include of phylink.h
- Remove unneccessary Kconfig selects
- Use an empty statement for next label
- Use guard(srcu)
Changes in v5:
- Export get_phy_c22_id when it is used
- Expose bind attributes, since there is no issue in doing so
- Rebase onto net-next
- Use MDIO_BUS instead of MDIO_DEVICE
Changes in v4:
- Add a note about the license
- Adjust variable ordering in pcs_find_fwnode
- Annotate pcs_wrapper.wrapped with __rcu
- Fix PCS lookup functions missing ERR_PTR casts
- Fix documentation for devm_pcs_register_full
- Fix incorrect condition in pcs_post_config
- Fix linking when PCS && !OF_DYNAMIC
- Fix linking when PCS && OF_DYNAMIC && PHYLIB=m
- Re-add documentation for axienet_xilinx_pcs_get that was accidentally removed
- Reduce line lengths to under 80 characters
- Remove unused dev parameter to pcs_put
- Use a spinlock instead of a mutex to protect pcs_wrappers
Changes in v3:
- Add '>' modifier for paragraph to description
- Adjust axienet_xilinx_pcs_get for changes to pcs_find_fwnode API
- Drop patches destined for other trees, as they have either already been applied or are no longer necessary.
- Edit description to reference clocks instead of resets
- Remove support for #pcs-cells. Upon further investigation, the requested functionality can be accomplished by specifying the PCS's fwnode manually.
- Select PCS_XILINX unconditionally
Changes in v2:
- Add fallbacks for pcs_get* and pcs_put
- Add support for #pcs-cells
- Change base compatible to just xlnx,pcs
- Change compatible to just xlnx,pcs
- Defer devicetree updates for another series
- Drop #clock-cells description
- Drop PCS_ALTERA_TSE which was accidentally added while rebasing
- Move #clock-cells after compatible
- Move update to macb_pcs_get_state to previous patch
- Remove outdated comment
- Remove second example
- Remove unused variable
- Remove unused variable lynx_properties
- Rename pcs-modes to xlnx,pcs-modes
- Reorder pcs_handle to come before suffix props
- Reword commit message
- Rework xilinx_pcs_validate to just clear out half-duplex modes instead of constraining modes based on the interface.
Sean Anderson (9):
dt-bindings: net: Add Xilinx PCS
net: phylink: Support setting PCS link change callbacks
net: pcs: Add subsystem
net: pcs: lynx: Convert to an MDIO driver
net: pcs: Add Xilinx PCS driver
net: axienet: Convert to use PCS subsystem
net: macb: Move most of mac_config to mac_prepare
net: macb: Support external PCSs
of: property: Add device link support for PCS
Vladimir Oltean (1):
net: dsa: ocelot: suppress PHY device scanning on the internal MDIO
bus
.../devicetree/bindings/net/xilinx,pcs.yaml | 114 ++++ Documentation/networking/index.rst | 1 + Documentation/networking/kapi.rst | 4 + Documentation/networking/pcs.rst | 102 +++ MAINTAINERS | 8 + drivers/net/dsa/ocelot/felix_vsc9959.c | 15 +- drivers/net/dsa/ocelot/seville_vsc9953.c | 16 +- drivers/net/ethernet/altera/altera_tse_main.c | 7 +- drivers/net/ethernet/cadence/macb.h | 1 + drivers/net/ethernet/cadence/macb_main.c | 229 ++++--- drivers/net/ethernet/freescale/dpaa2/Kconfig | 1 + .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 11 +- .../net/ethernet/freescale/enetc/enetc_pf.c | 8 +- .../net/ethernet/freescale/enetc/enetc_pf.h | 1 - .../freescale/enetc/enetc_pf_common.c | 4 +- drivers/net/ethernet/freescale/fman/Kconfig | 2 +- .../net/ethernet/freescale/fman/fman_memac.c | 25 +- drivers/net/ethernet/stmicro/stmmac/Kconfig | 1 + .../ethernet/stmicro/stmmac/dwmac-socfpga.c | 6 +- drivers/net/ethernet/xilinx/Kconfig | 13 + drivers/net/ethernet/xilinx/xilinx_axienet.h | 4 +- .../net/ethernet/xilinx/xilinx_axienet_main.c | 160 +++-- drivers/net/pcs/Kconfig | 47 +- drivers/net/pcs/Makefile | 4 + drivers/net/pcs/core.c | 628 ++++++++++++++++++ drivers/net/pcs/pcs-lynx.c | 113 ++-- drivers/net/pcs/pcs-xilinx.c | 427 ++++++++++++ drivers/net/phy/phy_device.c | 3 +- drivers/net/phy/phylink.c | 24 +- drivers/of/property.c | 2 + include/linux/pcs-lynx.h | 13 +- include/linux/pcs.h | 205 ++++++ include/linux/phy.h | 1 + include/linux/phylink.h | 27 +- 34 files changed, 1931 insertions(+), 296 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/xilinx,pcs.yaml create mode 100644 Documentation/networking/pcs.rst create mode 100644 drivers/net/pcs/core.c create mode 100644 drivers/net/pcs/pcs-xilinx.c create mode 100644 include/linux/pcs.h
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerPATCH v6 1/10 dt-bindings: net: Add Xilinx PCS
Add a binding for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII LogiCORE IP. This device is a soft device typically used to adapt between GMII and SGMII or 1000BASE-X (possbilty in combination with a serdes). pcs-modes reflects the modes available with the as configured when the device is synthesized. Multiple modes may be specified if dynamic reconfiguration is supported.
One PCS may contain "shared logic in core" which can be connected to other PCSs with "shared logic in example design." This primarily refers to clocking resources, allowing a reference clock to be shared by a bank of PCSs. To support this, if #clock-cells is defined then the PCS will register itself as a clock provider for other PCSs.
---
(no changes since v3)
Changes in v3:
- Add '>' modifier for paragraph to description
- Edit description to reference clocks instead of resets
Changes in v2:
- Change base compatible to just xlnx,pcs
- Drop #clock-cells description
- Move #clock-cells after compatible
- Remove second example
- Rename pcs-modes to xlnx,pcs-modes
- Reword commit message
.../devicetree/bindings/net/xilinx,pcs.yaml | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/xilinx,pcs.yaml
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +114 -0
@@ -0,0 +1,114 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/xilinx,pcs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII LogiCORE IP + +maintainers: + - Sean Anderson <[email protected]> + +description: > + This is a soft device which implements the PCS and (depending on + configuration) PMA layers of an IEEE Ethernet PHY. On the MAC side, it + implements GMII. It may have an attached SERDES (internal or external), or + may directly use LVDS IO resources. Depending on the configuration, it may + implement 1000BASE-X, SGMII, 2500BASE-X, or 2.5G SGMII. + + This device has a notion of "shared logic" such as reset and clocking + resources which must be shared between multiple PCSs using the same I/O + banks. Each PCS can be configured to have the shared logic in the "core" + (instantiated internally and made available to other PCSs) or in the "example + design" (provided by another PCS). PCSs with shared logic in the core provide + a clock for other PCSs in the same bank. + +properties: + compatible: + items: + - const: xlnx,pcs-16.2 + - const: xlnx,pcs + + reg: + maxItems: 1 + + "#clock-cells": + const: 0 + + clocks: + items: + - description: + The reference clock for the PCS. Depending on your setup, this may be + the gtrefclk, refclk, clk125m signal, or clocks from another PCS. + + clock-names: + const: refclk + + done-gpios: + maxItems: 1 + description: + GPIO connected to the reset-done output, if present. + + interrupts: + items: + - description: + The an_interrupt autonegotiation-complete interrupt. + + interrupt-names: + const: an + + xlnx,pcs-modes: + description: + The interfaces that the PCS supports. Multiple interfaces may be + specified if dynamic reconfiguration is enabled. + oneOf: + - const: sgmii + - const: 1000base-x + - const: 2500base-x + - items: + - const: sgmii + - const: 1000base-x + + reset-gpios: + maxItems: 1 + description: + GPIO connected to the reset input. + +required: + - compatible + - reg + - xlnx,pcs-modes + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + pcs0: ethernet-pcs@0 { + compatible = "xlnx,pcs-16.2", "xlnx,pcs"; + reg = <0>; + #clock-cells = <0>; + clocks = <&si570>; + clock-names = "refclk"; + interrupts-extended = <&gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "an"; + reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; + done-gpios = <&gpio 6 GPIO_ACTIVE_HIGH>; + xlnx,pcs-modes = "sgmii", "1000base-x"; + }; + + pcs1: ethernet-pcs@1 { + compatible = "xlnx,pcs-16.2", "xlnx,pcs"; + reg = <1>; + xlnx,pcs-modes = "sgmii"; + clocks = <&pcs0>; + clock-names = "refclk"; + }; + };
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerPATCH v6 2/10 net: phylink: Support setting PCS link change callbacks
In reply to Sean AndersonSupport changing the link change callback, similar to how PHYs do it. This will allow the PCS wrapper to forward link changes to the wrapped PCS.
---
(no changes since v1)
drivers/net/phy/phylink.c | 24 +++++++----------------- include/linux/phylink.h | 27 ++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 22 deletions(-)
drivers/net/phy/phylink.c +7 -17
@@ -1199,6 +1199,8 @@ static void phylink_pcs_neg_mode(struct phylink *pl, struct phylink_pcs *pcs, pl->act_link_an_mode = mode; } +static void pcs_change_callback (void *priv,bool up); +static void phylink_major_config (struct phylink *pl,bool restart,const struct phylink_link_state *state) {
@@ -1254,10 +1256,10 @@ static void phylink_major_config(struct phylink *pl, bool restart,phylink_pcs_disable (pl->pcs);if (pl->pcs) - pl->pcs->phylink =NULL ; - - pcs->phylink = pl; + pl->pcs->link_change_priv =NULL ; + pcs->link_change = pcs_change_callback; + pcs->link_change_priv = pl; pl->pcs = pcs; }
@@ -2327,25 +2329,13 @@ void phylink_mac_change(struct phylink *pl, bool up) }EXPORT_SYMBOL_GPL (phylink_mac_change); -/** -* phylink_pcs_change() - notify phylink of a change to PCS link state -* @pcs: pointer to &struct phylink_pcs -* @up: indicates whether the link is currently up. -* -* The PCS driver should call this when the state of its link changes -* (e.g. link failure, new negotiation results, etc.) Note: it should -* not determine "up" by reading the BMSR. If in doubt about the link -* state at interrupt time, then pass true if pcs_get_state() returns -* the latched link-down state, otherwise pass false. -*/ -void phylink_pcs_change (struct phylink_pcs *pcs,bool up) +static void pcs_change_callback (void *priv,bool up) { -struct phylink *pl = pcs->phylink; +struct phylink *pl = priv;if (pl)phylink_link_changed (pl, up,"pcs" ); } -EXPORT_SYMBOL_GPL (phylink_pcs_change);static irqreturn_t phylink_link_handler (int irq,void *data) {
include/linux/phylink.h +22 -5
@@ -450,7 +450,8 @@ struct phylink_pcs_ops;* @supported_interfaces: describing which PHY_INTERFACE_MODE_xxx * are supported by this PCS. * @ops: a pointer to the &struct phylink_pcs_ops structure -* @phylink: pointer to &struct phylink_config +* @link_change: callback for when the link changes +* @link_change_priv: first argument to @link_change * @poll: poll the PCS for link changes * @rxc_always_on: The MAC driver requires the reference clock * to always be on. Standalone PCS drivers which
@@ -460,13 +461,14 @@ struct phylink_pcs_ops;* This structure is designed to be embedded within the PCS private data, * and will be passed between phylink and the PCS. * -* The @phylink member is private to phylink and must not be touched by -* the PCS driver. +* @link_change, @link_change_priv, and @rxc_always_on will be filled in by +* phylink. */ struct phylink_pcs {DECLARE_PHY_INTERFACE_MASK (supported_interfaces);const struct phylink_pcs_ops *ops; -struct phylink *phylink; +void (*link_change)(void *priv,bool up); +void *link_change_priv;bool poll;bool rxc_always_on; };
@@ -708,7 +710,22 @@ int phylink_set_fixed_link(struct phylink *, const struct phylink_link_state *); void phylink_mac_change(struct phylink *, bool up); -void phylink_pcs_change (struct phylink_pcs *,bool up); +/** +* phylink_pcs_change() - notify phylink of a change to PCS link state +* @pcs: pointer to &struct phylink_pcs +* @up: indicates whether the link is currently up. +* +* The PCS driver should call this when the state of its link changes +* (e.g. link failure, new negotiation results, etc.) Note: it should +* not determine "up" by reading the BMSR. If in doubt about the link +* state at interrupt time, then pass true if pcs_get_state() returns +* the latched link-down state, otherwise pass false. +*/ +static inline void phylink_pcs_change (struct phylink_pcs *pcs,bool up) +{ +if (pcs->link_change) + pcs->link_change (pcs->link_change_priv, up); +}int phylink_pcs_pre_init (struct phylink *pl,struct phylink_pcs *pcs);
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerPATCH v6 3/10 net: pcs: Add subsystem
In reply to Sean AndersonThis adds support for getting PCS devices from the device tree. PCS drivers must first register with phylink_register_pcs. After that, MAC drivers may look up their PCS using phylink_get_pcs.
We wrap registered PCSs in another PCS. This wrapper PCS is refcounted and can outlive the wrapped PCS (such as if the wrapped PCS's driver is unbound). The wrapper forwards all PCS callbacks to the wrapped PCS, first checking to make sure the wrapped PCS still exists. This design was inspired by Bartosz Golaszewski's talk at LPC [1].
One downside of this approach is that if a PCS provider gets rebound, the consumer must put the old PCS and re-get it. Typically this means rebinding the consumer as well. I don't consider this a major downside:
- There is no guarantee that the PCS provider will support the same PHY interfaces as before. At the moment there is no way to handle this other than rebinding the consumer.
- Unbinding a PCS can generally happen in three ways:
- The entire MAC and PCS is on a removable bus and everything is getting unbound because the whole thing is being removed. In this case we do not need to worry about the PCS coming back without the MAC having been unbound.
- The PCS is on an FPGA that is being reconfigured but the MAC is not. This is a legitimate (if uncommon) use case. However, given that such arrangements were not possible at all before this series I think this is an acceptible limitation (at least initially).
- The user has manually rebound the PCS (directly or indirectly) through sysfs. In this case I think it is fine to require them to manually rebind the MACs as well.
pcs_get_by_fwnode_compat is a bit hairy, but it's necessary for compatibility with existing drivers, which often attach to (devicetree) nodes directly. We use the devicetree changeset system instead of adding a (secondary) software node because mdio_bus_match calls of_driver_match_device to match devices, and that function only works on devicetree nodes.
[1] https://lpc.events/event/17/contributions/1627/
---
Changes in v6:
- Reduce line lengths to under 80 characters
- Use guard(srcu)
Changes in v4:
- Adjust variable ordering in pcs_find_fwnode
- Annotate pcs_wrapper.wrapped with __rcu
- Fix PCS lookup functions missing ERR_PTR casts
- Fix documentation for devm_pcs_register_full
- Fix incorrect condition in pcs_post_config
- Fix linking when PCS && !OF_DYNAMIC
- Fix linking when PCS && OF_DYNAMIC && PHYLIB=m
- Reduce line lengths to under 80 characters
- Remove unused dev parameter to pcs_put
- Use a spinlock instead of a mutex to protect pcs_wrappers
Changes in v3:
- Remove support for #pcs-cells. Upon further investigation, the requested functionality can be accomplished by specifying the PCS's fwnode manually.
Changes in v2:
- Add fallbacks for pcs_get* and pcs_put
- Add support for #pcs-cells
- Remove outdated comment
- Remove unused variable
Documentation/networking/index.rst | 1 + Documentation/networking/kapi.rst | 4 + Documentation/networking/pcs.rst | 102 +++++ MAINTAINERS | 2 + drivers/net/pcs/Kconfig | 13 + drivers/net/pcs/Makefile | 2 + drivers/net/pcs/core.c | 628 +++++++++++++++++++++++++++++ include/linux/pcs.h | 205 ++++++++++ 8 files changed, 957 insertions(+) create mode 100644 Documentation/networking/pcs.rst create mode 100644 drivers/net/pcs/core.c create mode 100644 include/linux/pcs.h
Documentation/networking/index.rst +1 -0
@@ -30,6 +30,7 @@ Contents: page_pool phy sfp-phylink + pcs alias bridge snmp_counter
Documentation/networking/kapi.rst +4 -0
@@ -146,6 +146,10 @@ PHYLINK .. kernel-doc:: include/linux/phylink.h :internal: + :no-identifiers: phylink_pcs phylink_pcs_ops pcs_validate pcs_inband_caps + pcs_enable pcs_disable pcs_pre_config pcs_post_config pcs_get_state + pcs_config pcs_an_restart pcs_link_up pcs_disable_eee pcs_enable_eee + pcs_pre_init .. kernel-doc:: drivers/net/phy/phylink.c
Documentation/networking/pcs.rst new file +102 -0
102 lines not on this page · raw message
MAINTAINERS +2 -0
@@ -8906,6 +8906,7 @@ F: Documentation/ABI/testing/sysfs-class-net-phydev F: Documentation/devicetree/bindings/net/ethernet-phy.yaml F: Documentation/devicetree/bindings/net/mdio* F: Documentation/devicetree/bindings/net/qca,ar803x.yaml +F: Documentation/networking/pcs.rst F: Documentation/networking/phy.rst F: drivers/net/mdio/ F: drivers/net/mdio/acpi_mdio.c
@@ -8919,6 +8920,7 @@ F: include/linux/linkmode.h F: include/linux/mdio/*.h F: include/linux/mii.h F: include/linux/of_net.h +F: include/linux/pcs.h F: include/linux/phy.h F: include/linux/phy_fixed.h F: include/linux/phy_link_topology.h
drivers/net/pcs/Kconfig +13 -0
@@ -5,6 +5,19 @@ menu "PCS device drivers" +config PCS + bool "PCS subsystem" + select PHYLIB if OF_DYNAMIC + help + This provides common helper functions for registering and looking up + Physical Coding Sublayer (PCS) devices. PCS devices translate between + different interface types. In some use cases, they may either + translate between different types of Medium-Independent Interfaces + (MIIs), such as translating GMII to SGMII. This allows using a fast + serial interface to talk to the phy which translates the MII to the + Medium-Dependent Interface. Alternatively, they may translate a MII + directly to an MDI, such as translating GMII to 1000Base-X. + config PCS_XPCS tristate "Synopsys DesignWare Ethernet XPCS" select PHYLINK
drivers/net/pcs/Makefile +2 -0
@@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Linux PCS drivers +obj-$(CONFIG_PCS) += core.o + pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-plat.o \ pcs-xpcs-nxp.o pcs-xpcs-wx.o
drivers/net/pcs/core.c new file +628 -0
628 lines not on this page · raw message
include/linux/pcs.h new file +205 -0
205 lines not on this page · raw message
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Randy Dunlap
reviewerRe: [net-next PATCH v6 03/10] net: pcs: Add subsystem
Hi,
Quoted 32 lines
Documentation/networking/pcs.rst new file +26
-0@@ -0,0 +1,102 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============= +PCS Subsystem +============= + +The PCS (Physical Coding Sublayer) subsystem handles the registration and lookup +of PCS devices. These devices contain the upper sublayers of the Ethernet +physical layer, generally handling framing, scrambling, and encoding tasks. PCS +devices may also include PMA (Physical Medium Attachment) components. PCS +devices transfer data between the Link-layer MAC device, and the rest of the +physical layer, typically via a serdes. The output of the serdes may be +connected more-or-less directly to the medium when using fiber-optic or +backplane connections (1000BASE-SX, 1000BASE-KX, etc). It may also communicate +with a separate PHY (such as over SGMII) which handles the connection to the +medium (such as 1000BASE-T). + +Looking up PCS Devices +---------------------- + +There are generally two ways to look up a PCS device. If the PCS device is +internal to a larger device (such as a MAC or switch), and it does not share an +implementation with an existing PCS, then it does not need to be registered with +the PCS subsystem. Instead, you can populate a :c:type:`phylink_pcs` +in your probe function. Otherwise, you must look up the PCS. +
Documentation/networking/pcs.rst line 36
Quoted 10 lines
Documentation/networking/pcs.rst new file +10
-0+If your device has a :c:type:`fwnode_handle`, you can add a PCS using the +``pcs-handle`` property:: + + ethernet-controller { + // ... + pcs-handle = <&pcs>; + pcs-handle-names = "internal"; + }; + +Then, during your probe function, you can get the PCS using :c:func:`pcs_get`::
It's preferable to use PCS using pcs_get()::
instead of the :c:func: notation to make the .rst file more human-readable. They produce the same generated output.
Documentation/networking/pcs.rst line 45
Quoted 9 lines
Documentation/networking/pcs.rst new file +9
-0+ + mac->pcs = pcs_get(dev, "internal"); + if (IS_ERR(mac->pcs)) { + err = PTR_ERR(mac->pcs); + return dev_err_probe(dev, "Could not get PCS\n"); + } + +If your device doesn't have a :c:type:`fwnode_handle`, you can get the PCS +based on the providing device using :c:func:`pcs_get_by_dev`. Typically, you
ditto.
Documentation/networking/pcs.rst line 49
Quoted 4 lines
Documentation/networking/pcs.rst new file +4
-0+will create the device and bind your PCS driver to it before calling this +function. This allows reuse of an existing PCS driver. + +Once you are done using the PCS, you must call :c:func:`pcs_put`.
ditto.
Quoted 20 lines
Documentation/networking/pcs.rst new file +20
-0+ +Using PCS Devices +----------------- + +To select the PCS from a MAC driver, implement the ``mac_select_pcs`` callback +of :c:type:`phylink_mac_ops`. In this example, the PCS is selected for SGMII +and 1000BASE-X, and deselected for other interfaces:: + + static struct phylink_pcs *mac_select_pcs(struct phylink_config *config, + phy_interface_t iface) + { + struct mac *mac = config_to_mac(config); + + switch (iface) { + case PHY_INTERFACE_MODE_SGMII: + case PHY_INTERFACE_MODE_1000BASEX: + return mac->pcs; + default: + return NULL; + }
Documentation/networking/pcs.rst line 79
Quoted 10 lines
Documentation/networking/pcs.rst new file +10
-0+ } + +To do the same from a DSA driver, implement the ``phylink_mac_select_pcs`` +callback of :c:type:`dsa_switch_ops`. + +Writing PCS Drivers +------------------- + +To write a PCS driver, first implement :c:type:`phylink_pcs_ops`. Then, +register your PCS in your probe function using :c:func:`pcs_register`. If you
ditto
Documentation/networking/pcs.rst line 83
Quoted 4 lines
Documentation/networking/pcs.rst new file +4
-0+need to provide multiple PCSs for the same device, then you can pass specific +firmware nodes using :c:macro:`pcs_register_full`. + +You must call :c:func:`pcs_unregister` from your remove function. You can avoid
ditto.
Quoted 9 lines
Documentation/networking/pcs.rst new file +9
-0+this step by registering with :c:func:`devm_pcs_unregister`. + +API Reference +------------- + +.. kernel-doc:: include/linux/phylink.h + :identifiers: phylink_pcs phylink_pcs_ops pcs_validate pcs_inband_caps + pcs_enable pcs_disable pcs_pre_config pcs_post_config pcs_get_state + pcs_config pcs_an_restart pcs_link_up pcs_disable_eee pcs_enable_eee
Documentation/networking/pcs.rst line 102
Quoted 10 lines
Documentation/networking/pcs.rst new file +10
-0+ pcs_pre_init + +.. kernel-doc:: include/linux/pcs.h + :internal: + +.. kernel-doc:: drivers/net/pcs/core.c + :export: + +.. kernel-doc:: drivers/net/pcs/core.c + :internal:
Thanks.
Signature · 1 line
~Randy
Sean Anderson
reviewerRe: [net-next PATCH v6 03/10] net: pcs: Add subsystem
Quoted 41 lines · Randy Dunlap
Hi,
Quoted 38 lines
Documentation/networking/pcs.rst new file +32
-0@@ -0,0 +1,102 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============= +PCS Subsystem +============= + +The PCS (Physical Coding Sublayer) subsystem handles the registration and lookup +of PCS devices. These devices contain the upper sublayers of the Ethernet +physical layer, generally handling framing, scrambling, and encoding tasks. PCS +devices may also include PMA (Physical Medium Attachment) components. PCS +devices transfer data between the Link-layer MAC device, and the rest of the +physical layer, typically via a serdes. The output of the serdes may be +connected more-or-less directly to the medium when using fiber-optic or +backplane connections (1000BASE-SX, 1000BASE-KX, etc). It may also communicate +with a separate PHY (such as over SGMII) which handles the connection to the +medium (such as 1000BASE-T). + +Looking up PCS Devices +---------------------- + +There are generally two ways to look up a PCS device. If the PCS device is +internal to a larger device (such as a MAC or switch), and it does not share an +implementation with an existing PCS, then it does not need to be registered with +the PCS subsystem. Instead, you can populate a :c:type:`phylink_pcs` +in your probe function. Otherwise, you must look up the PCS. + +If your device has a :c:type:`fwnode_handle`, you can add a PCS using the +``pcs-handle`` property:: + + ethernet-controller { + // ... + pcs-handle = <&pcs>;
Quoted 8 lines
Documentation/networking/pcs.rst line 36
Quoted 4 lines
Documentation/networking/pcs.rst new file +4
-0+ pcs-handle-names = "internal"; + }; + +Then, during your probe function, you can get the PCS using :c:func:`pcs_get`::It's preferable to use PCS using
pcs_get()::
instead of the :c:func: notation to make the .rst file more human-readable. They produce the same generated output.
If you find this syntax useful, then you should update Documentation/doc-guide/{kernel-doc,sphinx}.rst. I did not use it because it I did not know about it because it is not documented.
--Sean
Randy Dunlap
reviewerRe: [net-next PATCH v6 03/10] net: pcs: Add subsystem
Hi,
Sorry for the delay.
Quoted 51 lines · Sean Anderson
Quoted 41 lines · Randy Dunlap
Hi,
Quoted 38 lines
Documentation/networking/pcs.rst new file +32
-0@@ -0,0 +1,102 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============= +PCS Subsystem +============= + +The PCS (Physical Coding Sublayer) subsystem handles the registration and lookup +of PCS devices. These devices contain the upper sublayers of the Ethernet +physical layer, generally handling framing, scrambling, and encoding tasks. PCS +devices may also include PMA (Physical Medium Attachment) components. PCS +devices transfer data between the Link-layer MAC device, and the rest of the +physical layer, typically via a serdes. The output of the serdes may be +connected more-or-less directly to the medium when using fiber-optic or +backplane connections (1000BASE-SX, 1000BASE-KX, etc). It may also communicate +with a separate PHY (such as over SGMII) which handles the connection to the +medium (such as 1000BASE-T). + +Looking up PCS Devices +---------------------- + +There are generally two ways to look up a PCS device. If the PCS device is +internal to a larger device (such as a MAC or switch), and it does not share an +implementation with an existing PCS, then it does not need to be registered with +the PCS subsystem. Instead, you can populate a :c:type:`phylink_pcs` +in your probe function. Otherwise, you must look up the PCS. + +If your device has a :c:type:`fwnode_handle`, you can add a PCS using the +``pcs-handle`` property:: + + ethernet-controller { + // ... + pcs-handle = <&pcs>;Quoted 8 lines
Documentation/networking/pcs.rst line 36
Quoted 4 lines
Documentation/networking/pcs.rst new file +4
-0+ pcs-handle-names = "internal"; + }; + +Then, during your probe function, you can get the PCS using :c:func:`pcs_get`::It's preferable to use PCS using
pcs_get()::
instead of the :c:func: notation to make the .rst file more human-readable. They produce the same generated output.
Quoted 3 lines
If you find this syntax useful, then you should update
Documentation/doc-guide/{kernel-doc,sphinx}.rst. I did not use it because it I did not know about it because it is not documented.
See Documentation/doc-guide/kernel-doc.rst,
commit 7c8b9e3000f8
Author: Nícolas F. R. A. Prado <[email protected]> Date: Thu Sep 3 00:58:26 2020 +0000
kernel-doc: Update "cross-referencing from rST" section to use automarkup
Cross-referencing from reStructuredText
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
No additional syntax is needed to cross-reference the functions and types defined in the kernel-doc comments from reStructuredText documents. Just end function names with ``()`` and write ``struct``, ``union``, ``enum`` or ``typedef`` before types.
Signature · 1 line
~Randy
Sean Anderson
reviewerPATCH v6 4/10 net: dsa: ocelot: suppress PHY device scanning on the internal MDIO bus
In reply to Sean AndersonFrom: Vladimir Oltean <[email protected]>
This bus contains Lynx PCS devices, and if the lynx-pcs driver ever decided to call mdio_device_register(), it would fail due to mdiobus_scan() having created a dummy phydev for the same address (the PCS responds to standard clause 22 PHY ID registers and can therefore by autodetected by phylib which thinks it's a PHY).
On the Seville driver, things are a bit more complicated, since bus creation is handled by mscc_miim_setup() and that is shared with the dedicated mscc-miim driver. Suppress PHY scanning only for the Seville internal MDIO bus rather than for the whole mscc-miim driver, since we know that on NXP T1040, this bus only contains Lynx PCS devices.
---
(no changes since v1)
drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++++ drivers/net/dsa/ocelot/seville_vsc9953.c | 5 +++++ 2 files changed, 9 insertions(+)
drivers/net/dsa/ocelot/felix_vsc9959.c +4 -0
@@ -1001,6 +1001,10 @@ static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot) bus->read_c45 = enetc_mdio_read_c45; bus->write_c45 = enetc_mdio_write_c45; bus->parent = dev; +/* Suppress PHY device creation in mdiobus_scan(), +* we have Lynx PCSs +*/ + bus->phy_mask = ~0 ; mdio_priv = bus->priv; mdio_priv->hw = hw;/* This gets added to imdio_regs, which already maps addresses
drivers/net/dsa/ocelot/seville_vsc9953.c +5 -0
@@ -901,6 +901,11 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)return rc; } +/* Suppress PHY device creation in mdiobus_scan(), +* we have Lynx PCSs +*/ + bus->phy_mask = ~0 ; +/* Needed in order to initialize the bus mutex lock */ rc =devm_of_mdiobus_register (dev, bus,NULL );if (rc <0 ) {
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerPATCH v6 5/10 net: pcs: lynx: Convert to an MDIO driver
In reply to Sean AndersonThis converts the lynx PCS driver to a proper MDIO driver. This allows using a more conventional driver lifecycle (e.g. with a probe and remove). It will also make it easier to add interrupt support.
The existing helpers are converted to bind the MDIO driver instead of creating the PCS directly. As lynx_pcs_create_mdiodev creates the PCS device, we can just set the modalias. For lynx_pcs_create_fwnode, we try to get the PCS the usual way, and if that fails we edit the devicetree to add a compatible and reprobe the device.
To ensure my contributions remain free software, remove the BSD option from the license. This is permitted because the SPDX uses "OR".
---
Changes in v6:
- Define lynx_pcs_of_match only when OF_MATCH is enabled
- Remove duplicate include of phylink.h
- Remove unneccessary Kconfig selects
Changes in v5:
- Use MDIO_BUS instead of MDIO_DEVICE
Changes in v4:
- Add a note about the license
- Convert to dev-less pcs_put
Changes in v3:
- Call devm_pcs_register instead of devm_pcs_register_provider
Changes in v2:
- Add support for #pcs-cells
- Remove unused variable lynx_properties
drivers/net/dsa/ocelot/felix_vsc9959.c | 11 +- drivers/net/dsa/ocelot/seville_vsc9953.c | 11 +- drivers/net/ethernet/altera/altera_tse_main.c | 7 +- drivers/net/ethernet/freescale/dpaa2/Kconfig | 1 + .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 11 +- .../net/ethernet/freescale/enetc/enetc_pf.c | 8 +- .../net/ethernet/freescale/enetc/enetc_pf.h | 1 - .../freescale/enetc/enetc_pf_common.c | 4 +- drivers/net/ethernet/freescale/fman/Kconfig | 2 +- .../net/ethernet/freescale/fman/fman_memac.c | 25 ++-- drivers/net/ethernet/stmicro/stmmac/Kconfig | 1 + .../ethernet/stmicro/stmmac/dwmac-socfpga.c | 6 +- drivers/net/pcs/Kconfig | 12 +- drivers/net/pcs/pcs-lynx.c | 113 ++++++++++-------- include/linux/pcs-lynx.h | 13 +- 15 files changed, 116 insertions(+), 110 deletions(-)
drivers/net/dsa/ocelot/felix_vsc9959.c +4 -7
@@ -12,6 +12,7 @@#include <net/tc_act/tc_gate.h> #include <soc/mscc/ocelot.h> #include <linux/dsa/ocelot.h> +#include <linux/pcs.h> #include <linux/pcs-lynx.h> #include <net/pkt_sched.h> #include <linux/iopoll.h>
@@ -1033,7 +1034,7 @@ static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)if (ocelot_port->phy_mode ==PHY_INTERFACE_MODE_INTERNAL )continue ; - phylink_pcs =lynx_pcs_create_mdiodev (felix->imdio, port); + phylink_pcs =lynx_pcs_create_mdiodev (dev, felix->imdio, port);if (IS_ERR (phylink_pcs))continue ;
@@ -1050,12 +1051,8 @@ static void vsc9959_mdio_bus_free(struct ocelot *ocelot)struct felix *felix =ocelot_to_felix (ocelot);int port; -for (port =0 ; port < ocelot->num_phys_ports; port++) { -struct phylink_pcs *phylink_pcs = felix->pcs[port]; - -if (phylink_pcs) -lynx_pcs_destroy (phylink_pcs); - } +for (port =0 ; port < ocelot->num_phys_ports; port++) +pcs_put (felix->pcs[port]);mdiobus_unregister (felix->imdio);mdiobus_free (felix->imdio); }
drivers/net/dsa/ocelot/seville_vsc9953.c +4 -7
@@ -10,6 +10,7 @@#include <linux/mdio/mdio-mscc-miim.h> #include <linux/mod_devicetable.h> #include <linux/of_mdio.h> +#include <linux/pcs.h> #include <linux/pcs-lynx.h> #include <linux/dsa/ocelot.h> #include <linux/iopoll.h>
@@ -926,7 +927,7 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)if (ocelot_port->phy_mode ==PHY_INTERFACE_MODE_INTERNAL )continue ; - phylink_pcs =lynx_pcs_create_mdiodev (felix->imdio, addr); + phylink_pcs =lynx_pcs_create_mdiodev (dev, felix->imdio, addr);if (IS_ERR (phylink_pcs))continue ;
@@ -943,12 +944,8 @@ static void vsc9953_mdio_bus_free(struct ocelot *ocelot)struct felix *felix =ocelot_to_felix (ocelot);int port; -for (port =0 ; port < ocelot->num_phys_ports; port++) { -struct phylink_pcs *phylink_pcs = felix->pcs[port]; - -if (phylink_pcs) -lynx_pcs_destroy (phylink_pcs); - } +for (port =0 ; port < ocelot->num_phys_ports; port++) +pcs_put (felix->pcs[port]);/* mdiobus_unregister and mdiobus_free handled by devres */ }
drivers/net/ethernet/altera/altera_tse_main.c +4 -3
@@ -32,6 +32,7 @@#include <linux/of.h> #include <linux/of_mdio.h> #include <linux/of_net.h> +#include <linux/pcs.h> #include <linux/pcs-lynx.h> #include <linux/phy.h> #include <linux/platform_device.h>
@@ -1412,7 +1413,7 @@ static int altera_tse_probe(struct platform_device *pdev) goto err_init_pcs; } - priv->pcs =lynx_pcs_create_mdiodev (pcs_bus,0 ); + priv->pcs =lynx_pcs_create_mdiodev (&pdev->dev, pcs_bus,0 );if (IS_ERR (priv->pcs)) { ret =PTR_ERR (priv->pcs); goto err_init_pcs;
@@ -1444,7 +1445,7 @@ static int altera_tse_probe(struct platform_device *pdev)return 0 ; err_init_phylink: -lynx_pcs_destroy (priv->pcs); +pcs_put (priv->pcs); err_init_pcs:unregister_netdev (ndev); err_register_netdev:
@@ -1466,7 +1467,7 @@ static void altera_tse_remove(struct platform_device *pdev)altera_tse_mdio_destroy (ndev);unregister_netdev (ndev);phylink_destroy (priv->phylink); -lynx_pcs_destroy (priv->pcs); +pcs_put (priv->pcs);free_netdev (ndev); }
drivers/net/ethernet/freescale/dpaa2/Kconfig +1 -0
@@ -2,6 +2,7 @@ config FSL_DPAA2_ETH tristate "Freescale DPAA2 Ethernet" depends on FSL_MC_BUS && FSL_MC_DPIO + select OF_DYNAMIC select PHYLINK select PCS_LYNX select FSL_XGMAC_MDIO
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +4 -7
@@ -2,6 +2,7 @@/* Copyright 2019 NXP */ #include <linux/acpi.h> +#include <linux/pcs.h> #include <linux/pcs-lynx.h> #include <linux/phy/phy.h> #include <linux/property.h>
@@ -262,7 +263,7 @@ static int dpaa2_pcs_create(struct dpaa2_mac *mac,return 0 ; } - pcs =lynx_pcs_create_fwnode (node); + pcs =lynx_pcs_create_fwnode (&mac->mc_dev->dev, node);fwnode_handle_put (node);if (pcs ==ERR_PTR (-EPROBE_DEFER )) {
@@ -288,12 +289,8 @@ static int dpaa2_pcs_create(struct dpaa2_mac *mac,static void dpaa2_pcs_destroy (struct dpaa2_mac *mac) { -struct phylink_pcs *phylink_pcs = mac->pcs; - -if (phylink_pcs) { -lynx_pcs_destroy (phylink_pcs); - mac->pcs =NULL ; - } +pcs_put (mac->pcs); + mac->pcs =NULL ; }static void dpaa2_mac_set_supported_interfaces (struct dpaa2_mac *mac)
drivers/net/ethernet/freescale/enetc/enetc_pf.c +1 -7
@@ -34,12 +34,7 @@ static void enetc_pf_set_primary_mac_addr(struct enetc_hw *hw, int si,static struct phylink_pcs *enetc_pf_create_pcs (struct enetc_pf *pf,struct mii_bus *bus) { -return lynx_pcs_create_mdiodev (bus,0 ); -} - -static void enetc_pf_destroy_pcs (struct phylink_pcs *pcs) -{ -lynx_pcs_destroy (pcs); +return lynx_pcs_create_mdiodev (&pf->si->pdev->dev, bus,0 ); }static void enetc_set_vlan_promisc (struct enetc_hw *hw,char si_map)
@@ -914,7 +909,6 @@ static const struct enetc_pf_ops enetc_pf_ops = { .set_si_primary_mac = enetc_pf_set_primary_mac_addr, .get_si_primary_mac = enetc_pf_get_primary_mac_addr, .create_pcs = enetc_pf_create_pcs, - .destroy_pcs = enetc_pf_destroy_pcs, .enable_psfp = enetc_psfp_enable, };
drivers/net/ethernet/freescale/enetc/enetc_pf.h +0 -1
@@ -32,7 +32,6 @@ struct enetc_pf_ops {void (*set_si_primary_mac)(struct enetc_hw *hw,int si,const u8 *addr);void (*get_si_primary_mac)(struct enetc_hw *hw,int si,u8 *addr);struct phylink_pcs *(*create_pcs)(struct enetc_pf *pf,struct mii_bus *bus); -void (*destroy_pcs)(struct phylink_pcs *pcs);int (*enable_psfp)(struct enetc_ndev_priv *priv); };
drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +2 -2
@@ -4,6 +4,7 @@#include <linux/fsl/enetc_mdio.h> #include <linux/of_mdio.h> #include <linux/of_net.h> +#include <linux/pcs.h> #include "enetc_pf_common.h"
@@ -248,8 +249,7 @@ static int enetc_imdio_create(struct enetc_pf *pf)static void enetc_imdio_remove (struct enetc_pf *pf) { -if (pf->pcs && pf->ops->destroy_pcs) - pf->ops->destroy_pcs (pf->pcs); +pcs_put (pf->pcs);if (pf->imdio) {mdiobus_unregister (pf->imdio);
drivers/net/ethernet/freescale/fman/Kconfig +1 -1
@@ -3,10 +3,10 @@ config FSL_FMAN tristate "FMan support" depends on FSL_SOC || ARCH_LAYERSCAPE || COMPILE_TEST select GENERIC_ALLOCATOR + select OF_DYNAMIC select PHYLINK select PCS_LYNX select CRC32 - default n help Freescale Data-Path Acceleration Architecture Frame Manager (FMan) support
drivers/net/ethernet/freescale/fman/fman_memac.c +14 -11
@@ -11,6 +11,7 @@#include <linux/slab.h> #include <linux/io.h> +#include <linux/pcs.h> #include <linux/pcs-lynx.h> #include <linux/phy.h> #include <linux/phy_fixed.h>
@@ -972,21 +973,21 @@ static int memac_init(struct fman_mac *memac)return 0 ; } -static void pcs_put (struct phylink_pcs *pcs) +static void memac_pcs_put (struct phylink_pcs *pcs) {if (IS_ERR_OR_NULL (pcs))return ; -lynx_pcs_destroy (pcs); +pcs_put (pcs); }static int memac_free (struct fman_mac *memac) {free_init_resources (memac); -pcs_put (memac->sgmii_pcs); -pcs_put (memac->qsgmii_pcs); -pcs_put (memac->xfi_pcs); +memac_pcs_put (memac->sgmii_pcs); +memac_pcs_put (memac->qsgmii_pcs); +memac_pcs_put (memac->xfi_pcs);kfree (memac->memac_drv_param);kfree (memac);
@@ -1033,7 +1034,8 @@ static struct fman_mac *memac_config(struct mac_device *mac_dev,return memac; } -static struct phylink_pcs *memac_pcs_create (struct device_node *mac_node, +static struct phylink_pcs *memac_pcs_create (struct device *dev, +struct device_node *mac_node,int index) {struct device_node *node;
@@ -1043,7 +1045,7 @@ static struct phylink_pcs *memac_pcs_create(struct device_node *mac_node,if (!node)return ERR_PTR (-ENODEV ); - pcs =lynx_pcs_create_fwnode (of_fwnode_handle (node)); + pcs =lynx_pcs_create_fwnode (dev,of_fwnode_handle (node));of_node_put (node);return pcs;
@@ -1100,7 +1102,7 @@ int memac_initialization(struct mac_device *mac_dev, err =of_property_match_string (mac_node,"pcs-handle-names" ,"xfi" );if (err >=0 ) { - memac->xfi_pcs =memac_pcs_create (mac_node, err); + memac->xfi_pcs =memac_pcs_create (mac_dev->dev, mac_node, err);if (IS_ERR (memac->xfi_pcs)) { err =PTR_ERR (memac->xfi_pcs);dev_err_probe (mac_dev->dev, err,"missing xfi pcs\n" );
@@ -1112,7 +1114,8 @@ int memac_initialization(struct mac_device *mac_dev, err =of_property_match_string (mac_node,"pcs-handle-names" ,"qsgmii" );if (err >=0 ) { - memac->qsgmii_pcs =memac_pcs_create (mac_node, err); + memac->qsgmii_pcs =memac_pcs_create (mac_dev->dev, mac_node, + err);if (IS_ERR (memac->qsgmii_pcs)) { err =PTR_ERR (memac->qsgmii_pcs); dev_err_probe(mac_dev->dev, err,
@@ -1128,11 +1131,11 @@ int memac_initialization(struct mac_device *mac_dev,*/ err =of_property_match_string (mac_node,"pcs-handle-names" ,"sgmii" );if (err == -EINVAL || err == -ENODATA ) - pcs =memac_pcs_create (mac_node,0 ); + pcs =memac_pcs_create (mac_dev->dev, mac_node,0 );else if (err <0 ) goto _return_fm_mac_free;else - pcs =memac_pcs_create (mac_node, err); + pcs =memac_pcs_create (mac_dev->dev, mac_node, err);if (IS_ERR (pcs)) { err =PTR_ERR (pcs);
drivers/net/ethernet/stmicro/stmmac/Kconfig +1 -0
@@ -182,6 +182,7 @@ config DWMAC_SOCFPGA tristate "SOCFPGA dwmac support" default ARCH_INTEL_SOCFPGA depends on OF && (ARCH_INTEL_SOCFPGA || COMPILE_TEST) + select OF_DYNAMIC select MFD_SYSCON select MDIO_REGMAP select REGMAP_MMIO
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +3 -3
@@ -8,6 +8,7 @@#include <linux/of.h> #include <linux/of_address.h> #include <linux/of_net.h> +#include <linux/pcs.h> #include <linux/phy.h> #include <linux/regmap.h> #include <linux/mdio/mdio-regmap.h>
@@ -414,7 +415,7 @@ static int socfpga_dwmac_pcs_init(struct stmmac_priv *priv)if (IS_ERR (pcs_bus))return PTR_ERR (pcs_bus); - pcs =lynx_pcs_create_mdiodev (pcs_bus,0 ); + pcs =lynx_pcs_create_mdiodev (priv->device, pcs_bus,0 );if (IS_ERR (pcs))return PTR_ERR (pcs);
@@ -424,8 +425,7 @@ static int socfpga_dwmac_pcs_init(struct stmmac_priv *priv)static void socfpga_dwmac_pcs_exit (struct stmmac_priv *priv) { -if (priv->hw->phylink_pcs) -lynx_pcs_destroy (priv->hw->phylink_pcs); +pcs_put (priv->hw->phylink_pcs); } static struct phylink_pcs *socfpga_dwmac_select_pcs(struct stmmac_priv *priv,
drivers/net/pcs/Kconfig +9 -3
@@ -26,10 +26,16 @@ config PCS_XPCS DesignWare XPCS controllers. config PCS_LYNX - tristate + tristate "NXP Lynx PCS driver" + select MDIO_BUS + select PCS help - This module provides helpers to phylink for managing the Lynx PCS - which is part of the Layerscape and QorIQ Ethernet SERDES. + This module provides driver support for the PCSs in Lynx 10g and 28g + SerDes devices. These devices are present in NXP QorIQ SoCs, + including the Layerscape series. + + If you want to use Ethernet on a QorIQ SoC, say "Y". If compiled as a + module, it will be called "pcs-lynx". config PCS_MTK_LYNXI tristate
drivers/net/pcs/pcs-lynx.c +61 -52
160 lines not on this page · raw message
include/linux/pcs-lynx.h +7 -6
@@ -6,12 +6,13 @@#ifndef __LINUX_PCS_LYNX_H#define __LINUX_PCS_LYNX_H -#include <linux/mdio.h> -#include <linux/phylink.h> +struct device ; +struct mii_bus ; +struct phylink_pcs ; -struct phylink_pcs *lynx_pcs_create_mdiodev (struct mii_bus *bus,int addr); -struct phylink_pcs *lynx_pcs_create_fwnode (struct fwnode_handle *node); - -void lynx_pcs_destroy (struct phylink_pcs *pcs); +struct phylink_pcs *lynx_pcs_create_mdiodev (struct device *dev, +struct mii_bus *bus,int addr); +struct phylink_pcs *lynx_pcs_create_fwnode (struct device *dev, +struct fwnode_handle *node);#endif /* __LINUX_PCS_LYNX_H */
Signature · 1 line
2.35.1.1320.gc452695387.dirty
kernel test robot
build botRe: [net-next PATCH v6 05/10] net: pcs: lynx: Convert to an MDIO driver
kernel test robot noticed the following build errors:
Hi Sean,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Sean-Anderson/dt-bindings-net-Add-Xilinx-PCS/20250611-143544 base: net-next/main patch link: https://lore.kernel.org/r/20250610233134.3588011-6-sean.anderson%40linux.dev patch subject: [net-next PATCH v6 05/10] net: pcs: lynx: Convert to an MDIO driver config: parisc-randconfig-002-20250613 (https://download.01.org/0day-ci/archive/20250613/[email protected]/config) compiler: hppa-linux-gcc (GCC) 13.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250613/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
In file included from drivers/regulator/mt6358-regulator.c:8:
include/linux/of.h: In function 'of_changeset_attach_node':
>> include/linux/of.h:1616:41: error: 'OF_RECONFIG_ATTACH_NODE' undeclared (first use in this function); did you mean 'OF_RECONFIG_NO_CHANGE'?
1616 | return of_changeset_action(ocs, OF_RECONFIG_ATTACH_NODE, np, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~
| OF_RECONFIG_NO_CHANGE
include/linux/of.h:1616:41: note: each undeclared identifier is reported only once for each function it appears in
include/linux/of.h: In function 'of_changeset_detach_node':
>> include/linux/of.h:1622:41: error: 'OF_RECONFIG_DETACH_NODE' undeclared (first use in this function); did you mean 'OF_RECONFIG_NO_CHANGE'?
1622 | return of_changeset_action(ocs, OF_RECONFIG_DETACH_NODE, np, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~
| OF_RECONFIG_NO_CHANGE
include/linux/of.h: In function 'of_changeset_add_property':
>> include/linux/of.h:1628:41: error: 'OF_RECONFIG_ADD_PROPERTY' undeclared (first use in this function)
1628 | return of_changeset_action(ocs, OF_RECONFIG_ADD_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/of.h: In function 'of_changeset_remove_property':
>> include/linux/of.h:1634:41: error: 'OF_RECONFIG_REMOVE_PROPERTY' undeclared (first use in this function)
1634 | return of_changeset_action(ocs, OF_RECONFIG_REMOVE_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/of.h: In function 'of_changeset_update_property':
>> include/linux/of.h:1640:41: error: 'OF_RECONFIG_UPDATE_PROPERTY' undeclared (first use in this function)
1640 | return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from drivers/regulator/pbias-regulator.c:27:
include/linux/of.h: In function 'of_changeset_attach_node':
>> include/linux/of.h:1616:41: error: 'OF_RECONFIG_ATTACH_NODE' undeclared (first use in this function); did you mean 'OF_RECONFIG_NO_CHANGE'?
1616 | return of_changeset_action(ocs, OF_RECONFIG_ATTACH_NODE, np, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~
| OF_RECONFIG_NO_CHANGE
include/linux/of.h:1616:41: note: each undeclared identifier is reported only once for each function it appears in
include/linux/of.h: In function 'of_changeset_detach_node':
>> include/linux/of.h:1622:41: error: 'OF_RECONFIG_DETACH_NODE' undeclared (first use in this function); did you mean 'OF_RECONFIG_NO_CHANGE'?
1622 | return of_changeset_action(ocs, OF_RECONFIG_DETACH_NODE, np, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~
| OF_RECONFIG_NO_CHANGE
include/linux/of.h: In function 'of_changeset_add_property':
>> include/linux/of.h:1628:41: error: 'OF_RECONFIG_ADD_PROPERTY' undeclared (first use in this function)
1628 | return of_changeset_action(ocs, OF_RECONFIG_ADD_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/of.h: In function 'of_changeset_remove_property':
>> include/linux/of.h:1634:41: error: 'OF_RECONFIG_REMOVE_PROPERTY' undeclared (first use in this function)
1634 | return of_changeset_action(ocs, OF_RECONFIG_REMOVE_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/of.h: In function 'of_changeset_update_property':
>> include/linux/of.h:1640:41: error: 'OF_RECONFIG_UPDATE_PROPERTY' undeclared (first use in this function)
1640 | return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/regulator/pbias-regulator.c: At top level:
drivers/regulator/pbias-regulator.c:136:34: warning: 'pbias_of_match' defined but not used [-Wunused-const-variable=]
136 | static const struct of_device_id pbias_of_match[] = {
| ^~~~~~~~~~~~~~
--
In file included from drivers/regulator/twl-regulator.c:14:
include/linux/of.h: In function 'of_changeset_attach_node':
>> include/linux/of.h:1616:41: error: 'OF_RECONFIG_ATTACH_NODE' undeclared (first use in this function); did you mean 'OF_RECONFIG_NO_CHANGE'?
1616 | return of_changeset_action(ocs, OF_RECONFIG_ATTACH_NODE, np, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~
| OF_RECONFIG_NO_CHANGE
include/linux/of.h:1616:41: note: each undeclared identifier is reported only once for each function it appears in
include/linux/of.h: In function 'of_changeset_detach_node':
>> include/linux/of.h:1622:41: error: 'OF_RECONFIG_DETACH_NODE' undeclared (first use in this function); did you mean 'OF_RECONFIG_NO_CHANGE'?
1622 | return of_changeset_action(ocs, OF_RECONFIG_DETACH_NODE, np, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~
| OF_RECONFIG_NO_CHANGE
include/linux/of.h: In function 'of_changeset_add_property':
>> include/linux/of.h:1628:41: error: 'OF_RECONFIG_ADD_PROPERTY' undeclared (first use in this function)
1628 | return of_changeset_action(ocs, OF_RECONFIG_ADD_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/of.h: In function 'of_changeset_remove_property':
>> include/linux/of.h:1634:41: error: 'OF_RECONFIG_REMOVE_PROPERTY' undeclared (first use in this function)
1634 | return of_changeset_action(ocs, OF_RECONFIG_REMOVE_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/of.h: In function 'of_changeset_update_property':
>> include/linux/of.h:1640:41: error: 'OF_RECONFIG_UPDATE_PROPERTY' undeclared (first use in this function)
1640 | return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/regulator/twl-regulator.c: At top level:
drivers/regulator/twl-regulator.c:552:34: warning: 'twl_of_match' defined but not used [-Wunused-const-variable=]
552 | static const struct of_device_id twl_of_match[] = {
| ^~~~~~~~~~~~
--
In file included from drivers/regulator/twl6030-regulator.c:15:
include/linux/of.h: In function 'of_changeset_attach_node':
>> include/linux/of.h:1616:41: error: 'OF_RECONFIG_ATTACH_NODE' undeclared (first use in this function); did you mean 'OF_RECONFIG_NO_CHANGE'?
1616 | return of_changeset_action(ocs, OF_RECONFIG_ATTACH_NODE, np, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~
| OF_RECONFIG_NO_CHANGE
include/linux/of.h:1616:41: note: each undeclared identifier is reported only once for each function it appears in
include/linux/of.h: In function 'of_changeset_detach_node':
>> include/linux/of.h:1622:41: error: 'OF_RECONFIG_DETACH_NODE' undeclared (first use in this function); did you mean 'OF_RECONFIG_NO_CHANGE'?
1622 | return of_changeset_action(ocs, OF_RECONFIG_DETACH_NODE, np, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~
| OF_RECONFIG_NO_CHANGE
include/linux/of.h: In function 'of_changeset_add_property':
>> include/linux/of.h:1628:41: error: 'OF_RECONFIG_ADD_PROPERTY' undeclared (first use in this function)
1628 | return of_changeset_action(ocs, OF_RECONFIG_ADD_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/of.h: In function 'of_changeset_remove_property':
>> include/linux/of.h:1634:41: error: 'OF_RECONFIG_REMOVE_PROPERTY' undeclared (first use in this function)
1634 | return of_changeset_action(ocs, OF_RECONFIG_REMOVE_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/of.h: In function 'of_changeset_update_property':
>> include/linux/of.h:1640:41: error: 'OF_RECONFIG_UPDATE_PROPERTY' undeclared (first use in this function)
1640 | return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/regulator/twl6030-regulator.c: At top level:
drivers/regulator/twl6030-regulator.c:645:34: warning: 'twl_of_match' defined but not used [-Wunused-const-variable=]
645 | static const struct of_device_id twl_of_match[] = {
| ^~~~~~~~~~~~
--
In file included from include/linux/irqdomain.h:14,
from include/linux/i2c.h:21,
from drivers/i2c/i2c-core-of-prober.c:14:
include/linux/of.h: In function 'of_changeset_attach_node':
>> include/linux/of.h:1616:41: error: 'OF_RECONFIG_ATTACH_NODE' undeclared (first use in this function); did you mean 'OF_RECONFIG_NO_CHANGE'?
1616 | return of_changeset_action(ocs, OF_RECONFIG_ATTACH_NODE, np, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~
| OF_RECONFIG_NO_CHANGE
include/linux/of.h:1616:41: note: each undeclared identifier is reported only once for each function it appears in
include/linux/of.h: In function 'of_changeset_detach_node':
>> include/linux/of.h:1622:41: error: 'OF_RECONFIG_DETACH_NODE' undeclared (first use in this function); did you mean 'OF_RECONFIG_NO_CHANGE'?
1622 | return of_changeset_action(ocs, OF_RECONFIG_DETACH_NODE, np, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~
| OF_RECONFIG_NO_CHANGE
include/linux/of.h: In function 'of_changeset_add_property':
>> include/linux/of.h:1628:41: error: 'OF_RECONFIG_ADD_PROPERTY' undeclared (first use in this function)
1628 | return of_changeset_action(ocs, OF_RECONFIG_ADD_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/of.h: In function 'of_changeset_remove_property':
>> include/linux/of.h:1634:41: error: 'OF_RECONFIG_REMOVE_PROPERTY' undeclared (first use in this function)
1634 | return of_changeset_action(ocs, OF_RECONFIG_REMOVE_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/of.h: In function 'of_changeset_update_property':
>> include/linux/of.h:1640:41: error: 'OF_RECONFIG_UPDATE_PROPERTY' undeclared (first use in this function)
1640 | return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/i2c/i2c-core-of-prober.c: In function 'i2c_of_probe_component':
>> include/linux/of.h:1478:14: error: implicit declaration of function 'of_get_next_child_with_prefix' [-Werror=implicit-function-declaration]
1478 | of_get_next_child_with_prefix(parent, NULL, prefix); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/i2c/i2c-core-of-prober.c:146:9: note: in expansion of macro 'for_each_child_of_node_with_prefix'
146 | for_each_child_of_node_with_prefix(i2c_node, node, type)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/of.h:1478:14: warning: initialization of 'struct device_node *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
1478 | of_get_next_child_with_prefix(parent, NULL, prefix); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/i2c/i2c-core-of-prober.c:146:9: note: in expansion of macro 'for_each_child_of_node_with_prefix'
146 | for_each_child_of_node_with_prefix(i2c_node, node, type)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/of.h:1477:9: error: declaration of non-variable 'of_get_next_child_with_prefix' in 'for' loop initial declaration
1477 | for (struct device_node *child __free(device_node) = \
| ^~~
drivers/i2c/i2c-core-of-prober.c:146:9: note: in expansion of macro 'for_each_child_of_node_with_prefix'
146 | for_each_child_of_node_with_prefix(i2c_node, node, type)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/of.h:1480:20: warning: assignment to 'struct device_node *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
1480 | child = of_get_next_child_with_prefix(parent, child, prefix))
| ^
drivers/i2c/i2c-core-of-prober.c:146:9: note: in expansion of macro 'for_each_child_of_node_with_prefix'
146 | for_each_child_of_node_with_prefix(i2c_node, node, type)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/of.h:1478:14: warning: initialization of 'struct device_node *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
1478 | of_get_next_child_with_prefix(parent, NULL, prefix); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/i2c/i2c-core-of-prober.c:161:9: note: in expansion of macro 'for_each_child_of_node_with_prefix'
161 | for_each_child_of_node_with_prefix(i2c_node, node, type) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/of.h:1477:9: error: declaration of non-variable 'of_get_next_child_with_prefix' in 'for' loop initial declaration
1477 | for (struct device_node *child __free(device_node) = \
| ^~~
drivers/i2c/i2c-core-of-prober.c:161:9: note: in expansion of macro 'for_each_child_of_node_with_prefix'
161 | for_each_child_of_node_with_prefix(i2c_node, node, type) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/of.h:1480:20: warning: assignment to 'struct device_node *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
1480 | child = of_get_next_child_with_prefix(parent, child, prefix))
| ^
drivers/i2c/i2c-core-of-prober.c:161:9: note: in expansion of macro 'for_each_child_of_node_with_prefix'
161 | for_each_child_of_node_with_prefix(i2c_node, node, type) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for OF_DYNAMIC
Depends on [n]: OF [=n]
Selected by [y]:
- FSL_FMAN [=y] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_FREESCALE [=y] && (FSL_SOC || ARCH_LAYERSCAPE || COMPILE_TEST [=y])
vim +1616 include/linux/of.h
e7a00e4210e4cc Sebastian Reichel 2014-04-06 1430
f623ce95a51bae Joerg Roedel 2016-04-04 1431 #define of_for_each_phandle(it, err, np, ln, cn, cc) \
f623ce95a51bae Joerg Roedel 2016-04-04 1432 for (of_phandle_iterator_init((it), (np), (ln), (cn), (cc)), \
f623ce95a51bae Joerg Roedel 2016-04-04 1433 err = of_phandle_iterator_next(it); \
f623ce95a51bae Joerg Roedel 2016-04-04 1434 err == 0; \
f623ce95a51bae Joerg Roedel 2016-04-04 1435 err = of_phandle_iterator_next(it))
f623ce95a51bae Joerg Roedel 2016-04-04 1436
9722c3b66e21ff Luca Ceresoli 2024-07-24 1437 #define of_property_for_each_u32(np, propname, u) \
9c63fea9acd077 Rob Herring (Arm 2024-10-10 1438) for (struct {const struct property *prop; const __be32 *item; } _it = \
9722c3b66e21ff Luca Ceresoli 2024-07-24 1439 {of_find_property(np, propname, NULL), \
9722c3b66e21ff Luca Ceresoli 2024-07-24 1440 of_prop_next_u32(_it.prop, NULL, &u)}; \
9722c3b66e21ff Luca Ceresoli 2024-07-24 1441 _it.item; \
9722c3b66e21ff Luca Ceresoli 2024-07-24 1442 _it.item = of_prop_next_u32(_it.prop, _it.item, &u))
2adfffa223500b Sebastian Andrzej Siewior 2013-06-17 1443
2adfffa223500b Sebastian Andrzej Siewior 2013-06-17 1444 #define of_property_for_each_string(np, propname, prop, s) \
2adfffa223500b Sebastian Andrzej Siewior 2013-06-17 1445 for (prop = of_find_property(np, propname, NULL), \
2adfffa223500b Sebastian Andrzej Siewior 2013-06-17 1446 s = of_prop_next_string(prop, NULL); \
2adfffa223500b Sebastian Andrzej Siewior 2013-06-17 1447 s; \
2adfffa223500b Sebastian Andrzej Siewior 2013-06-17 1448 s = of_prop_next_string(prop, s))
2adfffa223500b Sebastian Andrzej Siewior 2013-06-17 1449
662372e42e46d9 Rob Herring 2014-02-03 1450 #define for_each_node_by_name(dn, name) \
662372e42e46d9 Rob Herring 2014-02-03 1451 for (dn = of_find_node_by_name(NULL, name); dn; \
662372e42e46d9 Rob Herring 2014-02-03 1452 dn = of_find_node_by_name(dn, name))
662372e42e46d9 Rob Herring 2014-02-03 1453 #define for_each_node_by_type(dn, type) \
662372e42e46d9 Rob Herring 2014-02-03 1454 for (dn = of_find_node_by_type(NULL, type); dn; \
662372e42e46d9 Rob Herring 2014-02-03 1455 dn = of_find_node_by_type(dn, type))
662372e42e46d9 Rob Herring 2014-02-03 1456 #define for_each_compatible_node(dn, type, compatible) \
662372e42e46d9 Rob Herring 2014-02-03 1457 for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
662372e42e46d9 Rob Herring 2014-02-03 1458 dn = of_find_compatible_node(dn, type, compatible))
662372e42e46d9 Rob Herring 2014-02-03 1459 #define for_each_matching_node(dn, matches) \
662372e42e46d9 Rob Herring 2014-02-03 1460 for (dn = of_find_matching_node(NULL, matches); dn; \
662372e42e46d9 Rob Herring 2014-02-03 1461 dn = of_find_matching_node(dn, matches))
662372e42e46d9 Rob Herring 2014-02-03 1462 #define for_each_matching_node_and_match(dn, matches, match) \
662372e42e46d9 Rob Herring 2014-02-03 1463 for (dn = of_find_matching_node_and_match(NULL, matches, match); \
662372e42e46d9 Rob Herring 2014-02-03 1464 dn; dn = of_find_matching_node_and_match(dn, matches, match))
662372e42e46d9 Rob Herring 2014-02-03 1465
662372e42e46d9 Rob Herring 2014-02-03 1466 #define for_each_child_of_node(parent, child) \
662372e42e46d9 Rob Herring 2014-02-03 1467 for (child = of_get_next_child(parent, NULL); child != NULL; \
662372e42e46d9 Rob Herring 2014-02-03 1468 child = of_get_next_child(parent, child))
34af4554fb0ce1 Jonathan Cameron 2024-02-25 1469
34af4554fb0ce1 Jonathan Cameron 2024-02-25 1470 #define for_each_child_of_node_scoped(parent, child) \
34af4554fb0ce1 Jonathan Cameron 2024-02-25 1471 for (struct device_node *child __free(device_node) = \
34af4554fb0ce1 Jonathan Cameron 2024-02-25 1472 of_get_next_child(parent, NULL); \
34af4554fb0ce1 Jonathan Cameron 2024-02-25 1473 child != NULL; \
34af4554fb0ce1 Jonathan Cameron 2024-02-25 1474 child = of_get_next_child(parent, child))
34af4554fb0ce1 Jonathan Cameron 2024-02-25 1475
1fcc67e3a35486 Chen-Yu Tsai 2024-11-06 1476 #define for_each_child_of_node_with_prefix(parent, child, prefix) \
1fcc67e3a35486 Chen-Yu Tsai 2024-11-06 @1477 for (struct device_node *child __free(device_node) = \
1fcc67e3a35486 Chen-Yu Tsai 2024-11-06 @1478 of_get_next_child_with_prefix(parent, NULL, prefix); \
1fcc67e3a35486 Chen-Yu Tsai 2024-11-06 1479 child != NULL; \
1fcc67e3a35486 Chen-Yu Tsai 2024-11-06 @1480 child = of_get_next_child_with_prefix(parent, child, prefix))
1fcc67e3a35486 Chen-Yu Tsai 2024-11-06 1481
662372e42e46d9 Rob Herring 2014-02-03 1482 #define for_each_available_child_of_node(parent, child) \
662372e42e46d9 Rob Herring 2014-02-03 1483 for (child = of_get_next_available_child(parent, NULL); child != NULL; \
662372e42e46d9 Rob Herring 2014-02-03 1484 child = of_get_next_available_child(parent, child))
28c5d4e40752fc Kuninori Morimoto 2024-01-10 1485 #define for_each_reserved_child_of_node(parent, child) \
28c5d4e40752fc Kuninori Morimoto 2024-01-10 1486 for (child = of_get_next_reserved_child(parent, NULL); child != NULL; \
28c5d4e40752fc Kuninori Morimoto 2024-01-10 1487 child = of_get_next_reserved_child(parent, child))
662372e42e46d9 Rob Herring 2014-02-03 1488
34af4554fb0ce1 Jonathan Cameron 2024-02-25 1489 #define for_each_available_child_of_node_scoped(parent, child) \
34af4554fb0ce1 Jonathan Cameron 2024-02-25 1490 for (struct device_node *child __free(device_node) = \
34af4554fb0ce1 Jonathan Cameron 2024-02-25 1491 of_get_next_available_child(parent, NULL); \
34af4554fb0ce1 Jonathan Cameron 2024-02-25 1492 child != NULL; \
34af4554fb0ce1 Jonathan Cameron 2024-02-25 1493 child = of_get_next_available_child(parent, child))
662372e42e46d9 Rob Herring 2014-02-03 1494
f1f207e43b8a49 Rob Herring 2018-08-22 1495 #define for_each_of_cpu_node(cpu) \
f1f207e43b8a49 Rob Herring 2018-08-22 1496 for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \
f1f207e43b8a49 Rob Herring 2018-08-22 1497 cpu = of_get_next_cpu_node(cpu))
f1f207e43b8a49 Rob Herring 2018-08-22 1498
662372e42e46d9 Rob Herring 2014-02-03 1499 #define for_each_node_with_property(dn, prop_name) \
662372e42e46d9 Rob Herring 2014-02-03 1500 for (dn = of_find_node_with_property(NULL, prop_name); dn; \
662372e42e46d9 Rob Herring 2014-02-03 1501 dn = of_find_node_with_property(dn, prop_name))
662372e42e46d9 Rob Herring 2014-02-03 1502
662372e42e46d9 Rob Herring 2014-02-03 1503 static inline int of_get_child_count(const struct device_node *np)
662372e42e46d9 Rob Herring 2014-02-03 1504 {
662372e42e46d9 Rob Herring 2014-02-03 1505 struct device_node *child;
662372e42e46d9 Rob Herring 2014-02-03 1506 int num = 0;
662372e42e46d9 Rob Herring 2014-02-03 1507
662372e42e46d9 Rob Herring 2014-02-03 1508 for_each_child_of_node(np, child)
662372e42e46d9 Rob Herring 2014-02-03 1509 num++;
662372e42e46d9 Rob Herring 2014-02-03 1510
662372e42e46d9 Rob Herring 2014-02-03 1511 return num;
662372e42e46d9 Rob Herring 2014-02-03 1512 }
662372e42e46d9 Rob Herring 2014-02-03 1513
662372e42e46d9 Rob Herring 2014-02-03 1514 static inline int of_get_available_child_count(const struct device_node *np)
662372e42e46d9 Rob Herring 2014-02-03 1515 {
662372e42e46d9 Rob Herring 2014-02-03 1516 struct device_node *child;
662372e42e46d9 Rob Herring 2014-02-03 1517 int num = 0;
662372e42e46d9 Rob Herring 2014-02-03 1518
662372e42e46d9 Rob Herring 2014-02-03 1519 for_each_available_child_of_node(np, child)
662372e42e46d9 Rob Herring 2014-02-03 1520 num++;
662372e42e46d9 Rob Herring 2014-02-03 1521
662372e42e46d9 Rob Herring 2014-02-03 1522 return num;
662372e42e46d9 Rob Herring 2014-02-03 1523 }
662372e42e46d9 Rob Herring 2014-02-03 1524
67a066b35765d1 Dmitry Osipenko 2021-06-10 1525 #define _OF_DECLARE_STUB(table, name, compat, fn, fn_type) \
67a066b35765d1 Dmitry Osipenko 2021-06-10 1526 static const struct of_device_id __of_table_##name \
67a066b35765d1 Dmitry Osipenko 2021-06-10 1527 __attribute__((unused)) \
67a066b35765d1 Dmitry Osipenko 2021-06-10 1528 = { .compatible = compat, \
67a066b35765d1 Dmitry Osipenko 2021-06-10 1529 .data = (fn == (fn_type)NULL) ? fn : fn }
67a066b35765d1 Dmitry Osipenko 2021-06-10 1530
71f50c6d9a2276 Masahiro Yamada 2016-01-22 1531 #if defined(CONFIG_OF) && !defined(MODULE)
54196ccbe0ba1f Rob Herring 2014-05-08 1532 #define _OF_DECLARE(table, name, compat, fn, fn_type) \
54196ccbe0ba1f Rob Herring 2014-05-08 1533 static const struct of_device_id __of_table_##name \
33def8498fdde1 Joe Perches 2020-10-21 1534 __used __section("__" #table "_of_table") \
5812b32e01c6d8 Johan Hovold 2020-11-23 1535 __aligned(__alignof__(struct of_device_id)) \
54196ccbe0ba1f Rob Herring 2014-05-08 1536 = { .compatible = compat, \
54196ccbe0ba1f Rob Herring 2014-05-08 1537 .data = (fn == (fn_type)NULL) ? fn : fn }
54196ccbe0ba1f Rob Herring 2014-05-08 1538 #else
54196ccbe0ba1f Rob Herring 2014-05-08 1539 #define _OF_DECLARE(table, name, compat, fn, fn_type) \
67a066b35765d1 Dmitry Osipenko 2021-06-10 1540 _OF_DECLARE_STUB(table, name, compat, fn, fn_type)
54196ccbe0ba1f Rob Herring 2014-05-08 1541 #endif
54196ccbe0ba1f Rob Herring 2014-05-08 1542
54196ccbe0ba1f Rob Herring 2014-05-08 1543 typedef int (*of_init_fn_2)(struct device_node *, struct device_node *);
c35d9292fee047 Daniel Lezcano 2016-04-18 1544 typedef int (*of_init_fn_1_ret)(struct device_node *);
54196ccbe0ba1f Rob Herring 2014-05-08 1545 typedef void (*of_init_fn_1)(struct device_node *);
54196ccbe0ba1f Rob Herring 2014-05-08 1546
54196ccbe0ba1f Rob Herring 2014-05-08 1547 #define OF_DECLARE_1(table, name, compat, fn) \
54196ccbe0ba1f Rob Herring 2014-05-08 1548 _OF_DECLARE(table, name, compat, fn, of_init_fn_1)
c35d9292fee047 Daniel Lezcano 2016-04-18 1549 #define OF_DECLARE_1_RET(table, name, compat, fn) \
c35d9292fee047 Daniel Lezcano 2016-04-18 1550 _OF_DECLARE(table, name, compat, fn, of_init_fn_1_ret)
54196ccbe0ba1f Rob Herring 2014-05-08 1551 #define OF_DECLARE_2(table, name, compat, fn) \
54196ccbe0ba1f Rob Herring 2014-05-08 1552 _OF_DECLARE(table, name, compat, fn, of_init_fn_2)
54196ccbe0ba1f Rob Herring 2014-05-08 1553
201c910bd6898d Pantelis Antoniou 2014-07-04 1554 /**
201c910bd6898d Pantelis Antoniou 2014-07-04 1555 * struct of_changeset_entry - Holds a changeset entry
201c910bd6898d Pantelis Antoniou 2014-07-04 1556 *
201c910bd6898d Pantelis Antoniou 2014-07-04 1557 * @node: list_head for the log list
201c910bd6898d Pantelis Antoniou 2014-07-04 1558 * @action: notifier action
201c910bd6898d Pantelis Antoniou 2014-07-04 1559 * @np: pointer to the device node affected
201c910bd6898d Pantelis Antoniou 2014-07-04 1560 * @prop: pointer to the property affected
201c910bd6898d Pantelis Antoniou 2014-07-04 1561 * @old_prop: hold a pointer to the original property
201c910bd6898d Pantelis Antoniou 2014-07-04 1562 *
201c910bd6898d Pantelis Antoniou 2014-07-04 1563 * Every modification of the device tree during a changeset
201c910bd6898d Pantelis Antoniou 2014-07-04 1564 * is held in a list of of_changeset_entry structures.
201c910bd6898d Pantelis Antoniou 2014-07-04 1565 * That way we can recover from a partial application, or we can
201c910bd6898d Pantelis Antoniou 2014-07-04 1566 * revert the changeset
201c910bd6898d Pantelis Antoniou 2014-07-04 1567 */
201c910bd6898d Pantelis Antoniou 2014-07-04 1568 struct of_changeset_entry {
201c910bd6898d Pantelis Antoniou 2014-07-04 1569 struct list_head node;
201c910bd6898d Pantelis Antoniou 2014-07-04 1570 unsigned long action;
201c910bd6898d Pantelis Antoniou 2014-07-04 1571 struct device_node *np;
201c910bd6898d Pantelis Antoniou 2014-07-04 1572 struct property *prop;
201c910bd6898d Pantelis Antoniou 2014-07-04 1573 struct property *old_prop;
201c910bd6898d Pantelis Antoniou 2014-07-04 1574 };
201c910bd6898d Pantelis Antoniou 2014-07-04 1575
201c910bd6898d Pantelis Antoniou 2014-07-04 1576 /**
201c910bd6898d Pantelis Antoniou 2014-07-04 1577 * struct of_changeset - changeset tracker structure
201c910bd6898d Pantelis Antoniou 2014-07-04 1578 *
201c910bd6898d Pantelis Antoniou 2014-07-04 1579 * @entries: list_head for the changeset entries
201c910bd6898d Pantelis Antoniou 2014-07-04 1580 *
201c910bd6898d Pantelis Antoniou 2014-07-04 1581 * changesets are a convenient way to apply bulk changes to the
201c910bd6898d Pantelis Antoniou 2014-07-04 1582 * live tree. In case of an error, changes are rolled-back.
201c910bd6898d Pantelis Antoniou 2014-07-04 1583 * changesets live on after initial application, and if not
201c910bd6898d Pantelis Antoniou 2014-07-04 1584 * destroyed after use, they can be reverted in one single call.
201c910bd6898d Pantelis Antoniou 2014-07-04 1585 */
201c910bd6898d Pantelis Antoniou 2014-07-04 1586 struct of_changeset {
201c910bd6898d Pantelis Antoniou 2014-07-04 1587 struct list_head entries;
201c910bd6898d Pantelis Antoniou 2014-07-04 1588 };
201c910bd6898d Pantelis Antoniou 2014-07-04 1589
b53a2340d0d304 Pantelis Antoniou 2014-10-28 1590 enum of_reconfig_change {
b53a2340d0d304 Pantelis Antoniou 2014-10-28 1591 OF_RECONFIG_NO_CHANGE = 0,
b53a2340d0d304 Pantelis Antoniou 2014-10-28 1592 OF_RECONFIG_CHANGE_ADD,
b53a2340d0d304 Pantelis Antoniou 2014-10-28 1593 OF_RECONFIG_CHANGE_REMOVE,
b53a2340d0d304 Pantelis Antoniou 2014-10-28 1594 };
b53a2340d0d304 Pantelis Antoniou 2014-10-28 1595
2e8fff668dc14e Rob Herring 2023-03-29 1596 struct notifier_block;
2e8fff668dc14e Rob Herring 2023-03-29 1597
201c910bd6898d Pantelis Antoniou 2014-07-04 1598 #ifdef CONFIG_OF_DYNAMIC
f6892d193fb9d6 Grant Likely 2014-11-21 1599 extern int of_reconfig_notifier_register(struct notifier_block *);
f6892d193fb9d6 Grant Likely 2014-11-21 1600 extern int of_reconfig_notifier_unregister(struct notifier_block *);
f5242e5a883bf1 Grant Likely 2014-11-24 1601 extern int of_reconfig_notify(unsigned long, struct of_reconfig_data *rd);
f5242e5a883bf1 Grant Likely 2014-11-24 1602 extern int of_reconfig_get_state_change(unsigned long action,
f5242e5a883bf1 Grant Likely 2014-11-24 1603 struct of_reconfig_data *arg);
f6892d193fb9d6 Grant Likely 2014-11-21 1604
201c910bd6898d Pantelis Antoniou 2014-07-04 1605 extern void of_changeset_init(struct of_changeset *ocs);
201c910bd6898d Pantelis Antoniou 2014-07-04 1606 extern void of_changeset_destroy(struct of_changeset *ocs);
201c910bd6898d Pantelis Antoniou 2014-07-04 1607 extern int of_changeset_apply(struct of_changeset *ocs);
201c910bd6898d Pantelis Antoniou 2014-07-04 1608 extern int of_changeset_revert(struct of_changeset *ocs);
201c910bd6898d Pantelis Antoniou 2014-07-04 1609 extern int of_changeset_action(struct of_changeset *ocs,
201c910bd6898d Pantelis Antoniou 2014-07-04 1610 unsigned long action, struct device_node *np,
201c910bd6898d Pantelis Antoniou 2014-07-04 1611 struct property *prop);
201c910bd6898d Pantelis Antoniou 2014-07-04 1612
201c910bd6898d Pantelis Antoniou 2014-07-04 1613 static inline int of_changeset_attach_node(struct of_changeset *ocs,
201c910bd6898d Pantelis Antoniou 2014-07-04 1614 struct device_node *np)
201c910bd6898d Pantelis Antoniou 2014-07-04 1615 {
201c910bd6898d Pantelis Antoniou 2014-07-04 @1616 return of_changeset_action(ocs, OF_RECONFIG_ATTACH_NODE, np, NULL);
201c910bd6898d Pantelis Antoniou 2014-07-04 1617 }
201c910bd6898d Pantelis Antoniou 2014-07-04 1618
201c910bd6898d Pantelis Antoniou 2014-07-04 1619 static inline int of_changeset_detach_node(struct of_changeset *ocs,
201c910bd6898d Pantelis Antoniou 2014-07-04 1620 struct device_node *np)
201c910bd6898d Pantelis Antoniou 2014-07-04 1621 {
201c910bd6898d Pantelis Antoniou 2014-07-04 @1622 return of_changeset_action(ocs, OF_RECONFIG_DETACH_NODE, np, NULL);
201c910bd6898d Pantelis Antoniou 2014-07-04 1623 }
201c910bd6898d Pantelis Antoniou 2014-07-04 1624
201c910bd6898d Pantelis Antoniou 2014-07-04 1625 static inline int of_changeset_add_property(struct of_changeset *ocs,
201c910bd6898d Pantelis Antoniou 2014-07-04 1626 struct device_node *np, struct property *prop)
201c910bd6898d Pantelis Antoniou 2014-07-04 1627 {
201c910bd6898d Pantelis Antoniou 2014-07-04 @1628 return of_changeset_action(ocs, OF_RECONFIG_ADD_PROPERTY, np, prop);
201c910bd6898d Pantelis Antoniou 2014-07-04 1629 }
201c910bd6898d Pantelis Antoniou 2014-07-04 1630
201c910bd6898d Pantelis Antoniou 2014-07-04 1631 static inline int of_changeset_remove_property(struct of_changeset *ocs,
201c910bd6898d Pantelis Antoniou 2014-07-04 1632 struct device_node *np, struct property *prop)
201c910bd6898d Pantelis Antoniou 2014-07-04 1633 {
201c910bd6898d Pantelis Antoniou 2014-07-04 @1634 return of_changeset_action(ocs, OF_RECONFIG_REMOVE_PROPERTY, np, prop);
201c910bd6898d Pantelis Antoniou 2014-07-04 1635 }
201c910bd6898d Pantelis Antoniou 2014-07-04 1636
201c910bd6898d Pantelis Antoniou 2014-07-04 1637 static inline int of_changeset_update_property(struct of_changeset *ocs,
201c910bd6898d Pantelis Antoniou 2014-07-04 1638 struct device_node *np, struct property *prop)
201c910bd6898d Pantelis Antoniou 2014-07-04 1639 {
201c910bd6898d Pantelis Antoniou 2014-07-04 @1640 return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop);
201c910bd6898d Pantelis Antoniou 2014-07-04 1641 }
b544fc2b8606d7 Lizhi Hou 2023-08-15 1642 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Sean Anderson
reviewerPATCH v6 6/10 net: pcs: Add Xilinx PCS driver
In reply to Sean AndersonThis adds support for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII device. This is a soft device which converts between GMII and either SGMII, 1000Base-X, or 2500Base-X. If configured correctly, it can also switch between SGMII and 1000BASE-X at runtime. Thoretically this is also possible for 2500Base-X, but that requires reconfiguring the serdes. The exact capabilities depend on synthesis parameters, so they are read from the devicetree.
This device has a c22-compliant PHY interface, so for the most part we can just use the phylink helpers. This device supports an interrupt which is triggered on autonegotiation completion. I'm not sure how useful this is, since we can never detect a link down (in the PCS).
This device supports sharing some logic between different implementations of the device. In this case, one device contains the "shared logic" and the clocks are connected to other devices. To coordinate this, one device registers a clock that the other devices can request. The clock is enabled in the probe function by releasing the device from reset. There are no othe software controls, so the clock ops are empty.
---
Changes in v6:
- Move axienet_pcs_fixup to AXI Ethernet commit
- Use an empty statement for next label
Changes in v5:
- Export get_phy_c22_id when it is used
- Expose bind attributes, since there is no issue in doing so
- Use MDIO_BUS instead of MDIO_DEVICE
Changes in v4:
- Re-add documentation for axienet_xilinx_pcs_get that was accidentally removed
Changes in v3:
- Adjust axienet_xilinx_pcs_get for changes to pcs_find_fwnode API
- Call devm_pcs_register instead of devm_pcs_register_provider
Changes in v2:
- Add support for #pcs-cells
- Change compatible to just xlnx,pcs
- Drop PCS_ALTERA_TSE which was accidentally added while rebasing
- Rework xilinx_pcs_validate to just clear out half-duplex modes instead of constraining modes based on the interface.
MAINTAINERS | 6 + drivers/net/pcs/Kconfig | 22 ++ drivers/net/pcs/Makefile | 2 + drivers/net/pcs/pcs-xilinx.c | 427 +++++++++++++++++++++++++++++++++++ drivers/net/phy/phy_device.c | 3 +- include/linux/phy.h | 1 + 6 files changed, 460 insertions(+), 1 deletion(-) create mode 100644 drivers/net/pcs/pcs-xilinx.c
MAINTAINERS +6 -0
@@ -27060,6 +27060,12 @@ L: [email protected] S: Orphan F: drivers/net/ethernet/xilinx/ll_temac* +XILINX PCS DRIVER +M: Sean Anderson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/net/xilinx,pcs.yaml +F: drivers/net/pcs/pcs-xilinx.c + XILINX PWM DRIVER M: Sean Anderson <[email protected]> S: Maintained
drivers/net/pcs/Kconfig +22 -0
@@ -52,4 +52,26 @@ config PCS_RZN1_MIIC on RZ/N1 SoCs. This PCS converts MII to RMII/RGMII or can be set in pass-through mode for MII. +config PCS_XILINX + tristate "Xilinx PCS driver" + default XILINX_AXI_EMAC + select COMMON_CLK + select GPIOLIB + select MDIO_BUS + select OF + select PCS + select PHYLINK + help + PCS driver for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII device. + This device can either act as a PCS+PMA for 1000BASE-X or 2500BASE-X, + or as a GMII-to-SGMII bridge. It can also switch between 1000BASE-X + and SGMII dynamically if configured correctly when synthesized. + Typical applications use this device on an FPGA connected to a GEM or + TEMAC on the GMII side. The other side is typically connected to + on-device gigabit transceivers, off-device SERDES devices using TBI, + or LVDS IO resources directly. + + To compile this driver as a module, choose M here: the module + will be called pcs-xilinx. + endmenu
drivers/net/pcs/Makefile +2 -0
@@ -10,3 +10,5 @@ obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o obj-$(CONFIG_PCS_MTK_LYNXI) += pcs-mtk-lynxi.o obj-$(CONFIG_PCS_RZN1_MIIC) += pcs-rzn1-miic.o +obj-$(CONFIG_PCS_ALTERA_TSE) += pcs-altera-tse.o +obj-$(CONFIG_PCS_XILINX) += pcs-xilinx.o
drivers/net/pcs/pcs-xilinx.c new file +427 -0
427 lines not on this page · raw message
drivers/net/phy/phy_device.c +2 -1
@@ -921,7 +921,7 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,* valid, %-EIO on bus access error, or %-ENODEV if no device responds * or invalid ID. */ -static int get_phy_c22_id (struct mii_bus *bus,int addr,u32 *phy_id) +int get_phy_c22_id (struct mii_bus *bus,int addr,u32 *phy_id) {int phy_reg;
@@ -949,6 +949,7 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)return 0 ; } +EXPORT_SYMBOL_GPL (get_phy_c22_id);/* Extract the phy ID from the compatible string of the form * ethernet-phy-idAAAA.BBBB.
include/linux/phy.h +1 -0
@@ -1751,6 +1751,7 @@ int phy_modify_paged(struct phy_device *phydev, int page, u32 regnum,struct phy_device *phy_device_create (struct mii_bus *bus,int addr,u32 phy_id,bool is_c45,struct phy_c45_device_ids *c45_ids); +int get_phy_c22_id (struct mii_bus *bus,int addr,u32 *phy_id);int fwnode_get_phy_id (struct fwnode_handle *fwnode,u32 *phy_id);struct mdio_device *fwnode_mdio_find_device (struct fwnode_handle *fwnode);struct phy_device *fwnode_phy_find_device (struct fwnode_handle *phy_fwnode);
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Maxime Chevallier
maintainerRe: [net-next PATCH v6 06/10] net: pcs: Add Xilinx PCS driver
Hi Sean,
I only
Quoted 109 lines · On Tue, 10 Jun 2025 19:31:30 -0400 Sean Anderson <[email protected]>…
This adds support for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII device. This is a soft device which converts between GMII and either SGMII, 1000Base-X, or 2500Base-X. If configured correctly, it can also switch between SGMII and 1000BASE-X at runtime. Thoretically this is also possible for 2500Base-X, but that requires reconfiguring the serdes. The exact capabilities depend on synthesis parameters, so they are read from the devicetree.
This device has a c22-compliant PHY interface, so for the most part we can just use the phylink helpers. This device supports an interrupt which is triggered on autonegotiation completion. I'm not sure how useful this is, since we can never detect a link down (in the PCS).
This device supports sharing some logic between different implementations of the device. In this case, one device contains the "shared logic" and the clocks are connected to other devices. To coordinate this, one device registers a clock that the other devices can request. The clock is enabled in the probe function by releasing the device from reset. There are no othe software controls, so the clock ops are empty.
Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Moveaxienet_pcs_fixupto AXI Ethernet commit
- Use an empty statement for next labelChanges in v5:
- Exportget_phy_c22_idwhen it is used
- Expose bind attributes, since there is no issue in doing so
- UseMDIO_BUSinstead ofMDIO_DEVICEChanges in v4:
- Re-add documentation foraxienet_xilinx_pcs_getthat was accidentally removedChanges in v3:
- Adjustaxienet_xilinx_pcs_getfor changes topcs_find_fwnodeAPI
- Calldevm_pcs_registerinstead ofdevm_pcs_register_providerChanges in v2:
- Add support for #pcs-cells
- Change compatible to just xlnx,pcs
- DropPCS_ALTERA_TSEwhich was accidentally added while rebasing
- Reworkxilinx_pcs_validateto just clear out half-duplex modes instead of constraining modes based on the interface.MAINTAINERS | 6 + drivers/net/pcs/Kconfig | 22 ++ drivers/net/pcs/Makefile | 2 + drivers/net/pcs/pcs-xilinx.c | 427 +++++++++++++++++++++++++++++++++++ drivers/net/phy/phy_device.c | 3 +- include/linux/phy.h | 1 + 6 files changed, 460 insertions(+), 1 deletion(-) create mode 100644 drivers/net/pcs/pcs-xilinx.cMAINTAINERS +6
-0@@ -27060,6 +27060,12 @@ L: [email protected] S: Orphan F: drivers/net/ethernet/xilinx/ll_temac* +XILINX PCS DRIVER +M: Sean Anderson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/net/xilinx,pcs.yaml +F: drivers/net/pcs/pcs-xilinx.c + XILINX PWM DRIVER M: Sean Anderson <[email protected]> S: Maintaineddrivers/net/pcs/Kconfig +22
-0@@ -52,4 +52,26 @@ config PCS_RZN1_MIIC on RZ/N1 SoCs. This PCS converts MII to RMII/RGMII or can be set in pass-through mode for MII. +config PCS_XILINX + tristate "Xilinx PCS driver" + default XILINX_AXI_EMAC + select COMMON_CLK + select GPIOLIB + select MDIO_BUS + select OF + select PCS + select PHYLINK + help + PCS driver for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII device. + This device can either act as a PCS+PMA for 1000BASE-X or 2500BASE-X, + or as a GMII-to-SGMII bridge. It can also switch between 1000BASE-X + and SGMII dynamically if configured correctly when synthesized. + Typical applications use this device on an FPGA connected to a GEM or + TEMAC on the GMII side. The other side is typically connected to + on-device gigabit transceivers, off-device SERDES devices using TBI, + or LVDS IO resources directly. + + To compile this driver as a module, choose M here: the module + will be called pcs-xilinx. + endmenudrivers/net/pcs/Makefile +0
-0
drivers/net/pcs/Makefile obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o · line 13
Quoted 4 lines
drivers/net/pcs/Makefile +1
-0@@ -10,3 +10,5 @@ obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o obj-$(CONFIG_PCS_MTK_LYNXI) += pcs-mtk-lynxi.o obj-$(CONFIG_PCS_RZN1_MIIC) += pcs-rzn1-miic.o +obj-$(CONFIG_PCS_ALTERA_TSE) += pcs-altera-tse.o
There's something strange going-on here, as pcs-altera-tse was removed in v6.4 :)
drivers/net/pcs/Makefile obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o · line 14
Quoted 1 line
drivers/net/pcs/Makefile +1
-0+obj-$(CONFIG_PCS_XILINX) += pcs-xilinx.o
Maxime
Sean Anderson
reviewerRe: [net-next PATCH v6 06/10] net: pcs: Add Xilinx PCS driver
Quoted 115 lines · Maxime Chevallier
Hi Sean,
I only
Quoted 108 lines · On Tue, 10 Jun 2025 19:31:30 -0400 Sean Anderson <[email protected]>…
This adds support for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII device. This is a soft device which converts between GMII and either SGMII, 1000Base-X, or 2500Base-X. If configured correctly, it can also switch between SGMII and 1000BASE-X at runtime. Thoretically this is also possible for 2500Base-X, but that requires reconfiguring the serdes. The exact capabilities depend on synthesis parameters, so they are read from the devicetree.
This device has a c22-compliant PHY interface, so for the most part we can just use the phylink helpers. This device supports an interrupt which is triggered on autonegotiation completion. I'm not sure how useful this is, since we can never detect a link down (in the PCS).
This device supports sharing some logic between different implementations of the device. In this case, one device contains the "shared logic" and the clocks are connected to other devices. To coordinate this, one device registers a clock that the other devices can request. The clock is enabled in the probe function by releasing the device from reset. There are no othe software controls, so the clock ops are empty.
Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Moveaxienet_pcs_fixupto AXI Ethernet commit
- Use an empty statement for next labelChanges in v5:
- Exportget_phy_c22_idwhen it is used
- Expose bind attributes, since there is no issue in doing so
- UseMDIO_BUSinstead ofMDIO_DEVICEChanges in v4:
- Re-add documentation foraxienet_xilinx_pcs_getthat was accidentally removedChanges in v3:
- Adjustaxienet_xilinx_pcs_getfor changes topcs_find_fwnodeAPI
- Calldevm_pcs_registerinstead ofdevm_pcs_register_providerChanges in v2:
- Add support for #pcs-cells
- Change compatible to just xlnx,pcs
- DropPCS_ALTERA_TSEwhich was accidentally added while rebasing
- Reworkxilinx_pcs_validateto just clear out half-duplex modes instead of constraining modes based on the interface.MAINTAINERS | 6 + drivers/net/pcs/Kconfig | 22 ++ drivers/net/pcs/Makefile | 2 + drivers/net/pcs/pcs-xilinx.c | 427 +++++++++++++++++++++++++++++++++++ drivers/net/phy/phy_device.c | 3 +- include/linux/phy.h | 1 + 6 files changed, 460 insertions(+), 1 deletion(-) create mode 100644 drivers/net/pcs/pcs-xilinx.cMAINTAINERS +6
-0@@ -27060,6 +27060,12 @@ L: [email protected] S: Orphan F: drivers/net/ethernet/xilinx/ll_temac* +XILINX PCS DRIVER +M: Sean Anderson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/net/xilinx,pcs.yaml +F: drivers/net/pcs/pcs-xilinx.c + XILINX PWM DRIVER M: Sean Anderson <[email protected]> S: Maintaineddrivers/net/pcs/Kconfig +22
-0@@ -52,4 +52,26 @@ config PCS_RZN1_MIIC on RZ/N1 SoCs. This PCS converts MII to RMII/RGMII or can be set in pass-through mode for MII. +config PCS_XILINX + tristate "Xilinx PCS driver" + default XILINX_AXI_EMAC + select COMMON_CLK + select GPIOLIB + select MDIO_BUS + select OF + select PCS + select PHYLINK + help + PCS driver for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII device. + This device can either act as a PCS+PMA for 1000BASE-X or 2500BASE-X, + or as a GMII-to-SGMII bridge. It can also switch between 1000BASE-X + and SGMII dynamically if configured correctly when synthesized. + Typical applications use this device on an FPGA connected to a GEM or + TEMAC on the GMII side. The other side is typically connected to + on-device gigabit transceivers, off-device SERDES devices using TBI, + or LVDS IO resources directly. + + To compile this driver as a module, choose M here: the module + will be called pcs-xilinx. + endmenudrivers/net/pcs/Makefile +0
-0
Quoted 8 lines
drivers/net/pcs/Makefile obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o · line 13
Quoted 5 lines
drivers/net/pcs/Makefile +1
-0@@ -10,3 +10,5 @@ obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o obj-$(CONFIG_PCS_MTK_LYNXI) += pcs-mtk-lynxi.o obj-$(CONFIG_PCS_RZN1_MIIC) += pcs-rzn1-miic.o +obj-$(CONFIG_PCS_ALTERA_TSE) += pcs-altera-tse.oThere's something strange going-on here, as pcs-altera-tse was removed in v6.4 :)
Ah, well as it happens I have been working on this series since at least 5.10, so I guess it is left over. I will remove it for v7.
--Sean
kernel test robot
build botRe: [net-next PATCH v6 06/10] net: pcs: Add Xilinx PCS driver
In reply to Sean Andersonkernel test robot noticed the following build warnings:
Hi Sean,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Sean-Anderson/dt-bindings-net-Add-Xilinx-PCS/20250611-143544 base: net-next/main patch link: https://lore.kernel.org/r/20250610233134.3588011-7-sean.anderson%40linux.dev patch subject: [net-next PATCH v6 06/10] net: pcs: Add Xilinx PCS driver config: sh-kismet-CONFIG_COMMON_CLK-CONFIG_PCS_XILINX-0-0 (https://download.01.org/0day-ci/archive/20250612/[email protected]/config) reproduce: (https://download.01.org/0day-ci/archive/20250612/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
kismet warnings: (new ones prefixed by >>)
>> kismet: WARNING: unmet direct dependencies detected for COMMON_CLK when selected by PCS_XILINX
WARNING: unmet direct dependencies detected for COMMON_CLK
Depends on [n]: !HAVE_LEGACY_CLK [=y]
Selected by [y]:
- PCS_XILINX [=y] && NETDEVICES [=y]
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Sean Anderson
reviewerPATCH v6 7/10 net: axienet: Convert to use PCS subsystem
In reply to Sean AndersonConvert the AXI Ethernet driver to use the PCS subsystem, including the new Xilinx PCA/PMA driver. Unfortunately, we must use a helper to work with bare MDIO nodes without a compatible. This functionality is gated behind a config to allow it to be disabled by vendors who have fixed all of their devicetrees.
---
Changes in v6:
- Introduce config for compatibility helpers
- Move axienet_pcs_fixup to this commit
Changes in v5:
- Use MDIO_BUS instead of MDIO_DEVICE
Changes in v4:
- Convert to dev-less pcs_put
Changes in v3:
- Select PCS_XILINX unconditionally
drivers/net/ethernet/xilinx/Kconfig | 13 ++ drivers/net/ethernet/xilinx/xilinx_axienet.h | 4 +- .../net/ethernet/xilinx/xilinx_axienet_main.c | 160 +++++++++--------- 3 files changed, 90 insertions(+), 87 deletions(-)
drivers/net/ethernet/xilinx/Kconfig +13 -0
@@ -27,12 +27,25 @@ config XILINX_AXI_EMAC tristate "Xilinx 10/100/1000 AXI Ethernet support" depends on HAS_IOMEM depends on XILINX_DMA + select MDIO_BUS + select OF_DYNAMIC select PHYLINK select DIMLIB help This driver supports the 10/100/1000 Ethernet from Xilinx for the AXI bus interface used in Xilinx Virtex FPGAs and Soc's. +config XILINX_AXI_EMAC_PCS_COMPAT + bool "Xilinx AXI Ethernet PCS compatibility shim" + default PCS_XILINX + depends on XILINX_AXI_EMAC + select OF_DYNAMIC + help + Enable support for older devicetrees which do not have compatibles + for the Xilinx PCS/PMA. If you enable this option, you should + probably enable PCS_XILINX too. If you do not use 1G speeds, or you + do not have a (Xilinx) PCS, say n. If unsure, say y. + config XILINX_LL_TEMAC tristate "Xilinx LL TEMAC (LocalLink Tri-mode Ethernet MAC) driver" depends on HAS_IOMEM
drivers/net/ethernet/xilinx/xilinx_axienet.h +1 -3
@@ -473,7 +473,6 @@ struct skbuf_dma_descriptor {* @dev: Pointer to device structure * @phylink: Pointer to phylink instance * @phylink_config: phylink configuration settings -* @pcs_phy: Reference to PCS/PMA PHY if used * @pcs: phylink pcs structure for PCS PHY * @switch_x_sgmii: Whether switchable 1000BaseX/SGMII mode is enabled in the core * @axi_clk: AXI4-Lite bus clock
@@ -553,8 +552,7 @@ struct axienet_local {struct phylink *phylink;struct phylink_config phylink_config; -struct mdio_device *pcs_phy; -struct phylink_pcs pcs; +struct phylink_pcs *pcs;bool switch_x_sgmii;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +76 -84
204 lines not on this page · raw message
Signature · 1 line
2.35.1.1320.gc452695387.dirty
kernel test robot
build botRe: [net-next PATCH v6 07/10] net: axienet: Convert to use PCS subsystem
kernel test robot noticed the following build warnings:
Hi Sean,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Sean-Anderson/dt-bindings-net-Add-Xilinx-PCS/20250611-143544 base: net-next/main patch link: https://lore.kernel.org/r/20250610233134.3588011-8-sean.anderson%40linux.dev patch subject: [net-next PATCH v6 07/10] net: axienet: Convert to use PCS subsystem config: alpha-kismet-CONFIG_OF_DYNAMIC-CONFIG_XILINX_AXI_EMAC-0-0 (https://download.01.org/0day-ci/archive/20250612/[email protected]/config) reproduce: (https://download.01.org/0day-ci/archive/20250612/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
kismet warnings: (new ones prefixed by >>)
>> kismet: WARNING: unmet direct dependencies detected for OF_DYNAMIC when selected by XILINX_AXI_EMAC
WARNING: unmet direct dependencies detected for OF_DYNAMIC
Depends on [n]: OF [=n]
Selected by [y]:
- XILINX_AXI_EMAC [=y] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_XILINX [=y] && HAS_IOMEM [=y] && XILINX_DMA [=y]
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [net-next PATCH v6 07/10] net: axienet: Convert to use PCS subsystem
In reply to Sean Andersonkernel test robot noticed the following build warnings:
Hi Sean,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Sean-Anderson/dt-bindings-net-Add-Xilinx-PCS/20250611-143544 base: net-next/main patch link: https://lore.kernel.org/r/20250610233134.3588011-8-sean.anderson%40linux.dev patch subject: [net-next PATCH v6 07/10] net: axienet: Convert to use PCS subsystem config: alpha-kismet-CONFIG_OF_DYNAMIC-CONFIG_XILINX_AXI_EMAC_PCS_COMPAT-0-0 (https://download.01.org/0day-ci/archive/20250612/[email protected]/config) reproduce: (https://download.01.org/0day-ci/archive/20250612/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
kismet warnings: (new ones prefixed by >>)
>> kismet: WARNING: unmet direct dependencies detected for OF_DYNAMIC when selected by XILINX_AXI_EMAC_PCS_COMPAT
WARNING: unmet direct dependencies detected for OF_DYNAMIC
Depends on [n]: OF [=n]
Selected by [y]:
- XILINX_AXI_EMAC [=y] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_XILINX [=y] && HAS_IOMEM [=y] && XILINX_DMA [=y]
- XILINX_AXI_EMAC_PCS_COMPAT [=y] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_XILINX [=y] && XILINX_AXI_EMAC [=y]
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Sean Anderson
reviewerPATCH v6 8/10 net: macb: Move most of mac_config to mac_prepare
In reply to Sean Andersonmac_prepare is called every time the interface is changed, so we can do all of our configuration there, instead of in mac_config. This will be useful for the next patch where we will set the PCS bit based on whether we are using our internal PCS. No functional change intended.
---
Changes in v6:
- Fix use of spin_lock instead of spin_unlock
Changes in v2:
- Fix docs for macb_pcs_config_an
- Include change to macb_pcs_get_state which was previously in the next patch
drivers/net/ethernet/cadence/macb_main.c | 209 ++++++++++++++--------- 1 file changed, 132 insertions(+), 77 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +132 -77
@@ -549,19 +549,91 @@ static void macb_set_tx_clk(struct macb *bp, int speed)netdev_err (bp->dev,"adjusting tx_clk failed.\n" ); } -static void macb_usx_pcs_link_up (struct phylink_pcs *pcs,unsigned int neg_mode, -phy_interface_t interface,int speed, -int duplex) -{ - struct macb *bp = container_of(pcs, struct macb, phylink_usx_pcs); -u32 config; - - config =gem_readl (bp,USX_CONTROL ); - config =GEM_BFINS (SERDES_RATE ,MACB_SERDES_RATE_10G , config); - config =GEM_BFINS (USX_CTRL_SPEED ,HS_SPEED_10000M , config); - config &= ~(GEM_BIT (TX_SCR_BYPASS ) |GEM_BIT (RX_SCR_BYPASS )); - config |=GEM_BIT (TX_EN ); -gem_writel (bp,USX_CONTROL , config); +static void macb_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode, +struct phylink_link_state *state) +{ + struct macb *bp = container_of(pcs, struct macb, phylink_sgmii_pcs); + +phylink_mii_c22_pcs_decode_state (state, neg_mode,gem_readl (bp,PCSSTS ), +gem_readl (bp,PCSANLPBASE )); +} + +/** +* macb_pcs_config_an() - Configure autonegotiation settings for PCSs +* @bp: The macb to operate on +* @neg_mode: The autonegotiation mode +* @interface: The interface to use +* @advertising: The advertisement mask +* +* This provides common configuration for PCS autonegotiation. +* +* Context: Call with @bp->lock held. +* Return: 1 if any registers were changed; 0 otherwise +*/ +static int macb_pcs_config_an (struct macb *bp,unsigned int neg_mode, +phy_interface_t interface, +const unsigned long *advertising) +{ +bool changed = false; +int old, new; + + old =gem_readl (bp,PCSANADV ); + new =phylink_mii_c22_pcs_encode_advertisement (interface, advertising); +if (new != -EINVAL && old != new) { + changed = true; +gem_writel (bp,PCSANADV , new); + } + + old = new =gem_readl (bp,PCSCNTRL ); +if (neg_mode ==PHYLINK_PCS_NEG_INBAND_ENABLED ) + new |=BMCR_ANENABLE ; +else + new &= ~BMCR_ANENABLE ; +if (old != new) { + changed = true; +gem_writel (bp,PCSCNTRL , new); + } +return changed; +} + +static int macb_pcs_config (struct phylink_pcs *pcs,unsigned int mode, +phy_interface_t interface, +const unsigned long *advertising, +bool permit_pause_to_mac) +{ + struct macb *bp = container_of(pcs, struct macb, phylink_sgmii_pcs); +bool changed = false; +unsigned long flags; +u32 old, new; + +spin_lock_irqsave (&bp->lock, flags); + old = new =gem_readl (bp,NCFGR ); + new |=GEM_BIT (SGMIIEN ); +if (old != new) { + changed = true; +gem_writel (bp,NCFGR , new); + } + +if (macb_pcs_config_an (bp, mode, interface, advertising)) + changed = true; + +spin_unlock_irqrestore (&bp->lock, flags); +return changed; +} + +static void macb_pcs_an_restart (struct phylink_pcs *pcs) +{ + struct macb *bp = container_of(pcs, struct macb, phylink_sgmii_pcs); +u32 bmcr; +unsigned long flags; + +spin_lock_irqsave (&bp->lock, flags); + + bmcr =gem_readl (bp,PCSCNTRL ); + bmcr |=BMCR_ANENABLE ; +gem_writel (bp,PCSCNTRL , bmcr); + +spin_unlock_irqrestore (&bp->lock, flags); } static void macb_usx_pcs_get_state(struct phylink_pcs *pcs,
@@ -589,45 +661,60 @@ static int macb_usx_pcs_config(struct phylink_pcs *pcs, bool permit_pause_to_mac) { struct macb *bp = container_of(pcs, struct macb, phylink_usx_pcs); +unsigned long flags; +bool changed; +u16 old, new; -gem_writel (bp,USX_CONTROL ,gem_readl (bp,USX_CONTROL ) | -GEM_BIT (SIGNAL_OK )); +spin_lock_irqsave (&bp->lock, flags); +if (macb_pcs_config_an (bp, neg_mode, interface, advertising)) + changed = true; -return 0 ; -} + old = new =gem_readl (bp,USX_CONTROL ); + new |=GEM_BIT (SIGNAL_OK ); +if (old != new) { + changed = true; +gem_writel (bp,USX_CONTROL , new); + } -static void macb_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode, -struct phylink_link_state *state) -{ - state->link =0 ; -} + old = new =gem_readl (bp,USX_CONTROL ); + new =GEM_BFINS (SERDES_RATE ,MACB_SERDES_RATE_10G , new); + new =GEM_BFINS (USX_CTRL_SPEED ,HS_SPEED_10000M , new); + new &= ~(GEM_BIT (TX_SCR_BYPASS ) |GEM_BIT (RX_SCR_BYPASS )); + new |=GEM_BIT (TX_EN ); +if (old != new) { + changed = true; +gem_writel (bp,USX_CONTROL , new); + } -static void macb_pcs_an_restart (struct phylink_pcs *pcs) -{ -/* Not supported */ -} - -static int macb_pcs_config (struct phylink_pcs *pcs, -unsigned int neg_mode, -phy_interface_t interface, -const unsigned long *advertising, -bool permit_pause_to_mac) -{ -return 0 ; +spin_unlock_irqrestore (&bp->lock, flags); +return changed; }static const struct phylink_pcs_ops macb_phylink_usx_pcs_ops = { .pcs_get_state = macb_usx_pcs_get_state, .pcs_config = macb_usx_pcs_config, - .pcs_link_up = macb_usx_pcs_link_up, };static const struct phylink_pcs_ops macb_phylink_pcs_ops = { .pcs_get_state = macb_pcs_get_state, - .pcs_an_restart = macb_pcs_an_restart, .pcs_config = macb_pcs_config, + .pcs_an_restart = macb_pcs_an_restart, }; +static struct phylink_pcs *macb_mac_select_pcs (struct phylink_config *config, +phy_interface_t interface) +{ +struct net_device *ndev =to_net_dev (config->dev); +struct macb *bp =netdev_priv (ndev); + +if (interface ==PHY_INTERFACE_MODE_10GBASER ) +return &bp->phylink_usx_pcs; +else if (interface ==PHY_INTERFACE_MODE_SGMII ) +return &bp->phylink_sgmii_pcs; +else +return NULL ; +} +static void macb_mac_config (struct phylink_config *config,unsigned int mode,const struct phylink_link_state *state) {
@@ -646,18 +733,14 @@ 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)) { - ctrl &= ~(GEM_BIT (SGMIIEN ) |GEM_BIT (PCSSEL )); - ncr &= ~GEM_BIT (ENABLE_HS_MAC ); - -if (state->interface ==PHY_INTERFACE_MODE_SGMII ) { - ctrl |=GEM_BIT (SGMIIEN ) |GEM_BIT (PCSSEL ); - }else if (state->interface ==PHY_INTERFACE_MODE_10GBASER ) { +if (macb_mac_select_pcs (config, state->interface)) ctrl |=GEM_BIT (PCSSEL ); - ncr |=GEM_BIT (ENABLE_HS_MAC ); - }else if (bp->caps &MACB_CAPS_MIIONRGMII && - bp->phy_interface ==PHY_INTERFACE_MODE_MII ) { +else + ctrl &= ~GEM_BIT (PCSSEL ); + +if (bp->caps &MACB_CAPS_MIIONRGMII && + bp->phy_interface ==PHY_INTERFACE_MODE_MII ) ncr |=MACB_BIT (MIIONRGMII ); - } }/* Apply the new configuration, if any */
@@ -667,22 +750,6 @@ static void macb_mac_config(struct phylink_config *config, unsigned int mode,if (old_ncr ^ ncr)macb_or_gem_writel (bp,NCR , ncr); -/* Disable AN for SGMII fixed link configuration, enable otherwise. -* Must be written after PCSSEL is set in NCFGR, -* otherwise writes will not take effect. -*/ -if (macb_is_gem (bp) && state->interface ==PHY_INTERFACE_MODE_SGMII ) { -u32 pcsctrl, old_pcsctrl; - - old_pcsctrl =gem_readl (bp,PCSCNTRL ); -if (mode ==MLO_AN_FIXED ) - pcsctrl = old_pcsctrl & ~GEM_BIT (PCSAUTONEG ); -else - pcsctrl = old_pcsctrl |GEM_BIT (PCSAUTONEG ); -if (old_pcsctrl != pcsctrl) -gem_writel (bp,PCSCNTRL , pcsctrl); - } -spin_unlock_irqrestore (&bp->lock, flags); }
@@ -735,10 +802,12 @@ static void macb_mac_link_up(struct phylink_config *config,if (!(bp->caps &MACB_CAPS_MACB_IS_EMAC )) { ctrl &= ~MACB_BIT (PAE );if (macb_is_gem (bp)) { - ctrl &= ~GEM_BIT (GBE ); + ctrl &= ~(GEM_BIT (GBE ) |GEM_BIT (ENABLE_HS_MAC ));if (speed ==SPEED_1000 ) ctrl |=GEM_BIT (GBE ); +else if (speed ==SPEED_10000 ) + ctrl |=GEM_BIT (ENABLE_HS_MAC ); }if (rx_pause)
@@ -776,20 +845,6 @@ static void macb_mac_link_up(struct phylink_config *config,netif_tx_wake_all_queues (ndev); } -static struct phylink_pcs *macb_mac_select_pcs (struct phylink_config *config, -phy_interface_t interface) -{ -struct net_device *ndev =to_net_dev (config->dev); -struct macb *bp =netdev_priv (ndev); - -if (interface ==PHY_INTERFACE_MODE_10GBASER ) -return &bp->phylink_usx_pcs; -else if (interface ==PHY_INTERFACE_MODE_SGMII ) -return &bp->phylink_sgmii_pcs; -else -return NULL ; -} -static const struct phylink_mac_ops macb_phylink_ops = { .mac_select_pcs = macb_mac_select_pcs, .mac_config = macb_mac_config,
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerPATCH v6 8/10 net: macb: Move most of mac_config to mac_prepare
In reply to Sean Andersonmac_prepare is called every time the interface is changed, so we can do all of our configuration there, instead of in mac_config. This will be useful for the next patch where we will set the PCS bit based on whether we are using our internal PCS. No functional change intended.
---
Changes in v6:
- Fix use of spin_lock instead of spin_unlock
Changes in v2:
- Fix docs for macb_pcs_config_an
- Include change to macb_pcs_get_state which was previously in the next patch
drivers/net/ethernet/cadence/macb_main.c | 209 ++++++++++++++--------- 1 file changed, 132 insertions(+), 77 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +132 -77
@@ -549,19 +549,91 @@ static void macb_set_tx_clk(struct macb *bp, int speed)netdev_err (bp->dev,"adjusting tx_clk failed.\n" ); } -static void macb_usx_pcs_link_up (struct phylink_pcs *pcs,unsigned int neg_mode, -phy_interface_t interface,int speed, -int duplex) -{ - struct macb *bp = container_of(pcs, struct macb, phylink_usx_pcs); -u32 config; - - config =gem_readl (bp,USX_CONTROL ); - config =GEM_BFINS (SERDES_RATE ,MACB_SERDES_RATE_10G , config); - config =GEM_BFINS (USX_CTRL_SPEED ,HS_SPEED_10000M , config); - config &= ~(GEM_BIT (TX_SCR_BYPASS ) |GEM_BIT (RX_SCR_BYPASS )); - config |=GEM_BIT (TX_EN ); -gem_writel (bp,USX_CONTROL , config); +static void macb_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode, +struct phylink_link_state *state) +{ + struct macb *bp = container_of(pcs, struct macb, phylink_sgmii_pcs); + +phylink_mii_c22_pcs_decode_state (state, neg_mode,gem_readl (bp,PCSSTS ), +gem_readl (bp,PCSANLPBASE )); +} + +/** +* macb_pcs_config_an() - Configure autonegotiation settings for PCSs +* @bp: The macb to operate on +* @neg_mode: The autonegotiation mode +* @interface: The interface to use +* @advertising: The advertisement mask +* +* This provides common configuration for PCS autonegotiation. +* +* Context: Call with @bp->lock held. +* Return: 1 if any registers were changed; 0 otherwise +*/ +static int macb_pcs_config_an (struct macb *bp,unsigned int neg_mode, +phy_interface_t interface, +const unsigned long *advertising) +{ +bool changed = false; +int old, new; + + old =gem_readl (bp,PCSANADV ); + new =phylink_mii_c22_pcs_encode_advertisement (interface, advertising); +if (new != -EINVAL && old != new) { + changed = true; +gem_writel (bp,PCSANADV , new); + } + + old = new =gem_readl (bp,PCSCNTRL ); +if (neg_mode ==PHYLINK_PCS_NEG_INBAND_ENABLED ) + new |=BMCR_ANENABLE ; +else + new &= ~BMCR_ANENABLE ; +if (old != new) { + changed = true; +gem_writel (bp,PCSCNTRL , new); + } +return changed; +} + +static int macb_pcs_config (struct phylink_pcs *pcs,unsigned int mode, +phy_interface_t interface, +const unsigned long *advertising, +bool permit_pause_to_mac) +{ + struct macb *bp = container_of(pcs, struct macb, phylink_sgmii_pcs); +bool changed = false; +unsigned long flags; +u32 old, new; + +spin_lock_irqsave (&bp->lock, flags); + old = new =gem_readl (bp,NCFGR ); + new |=GEM_BIT (SGMIIEN ); +if (old != new) { + changed = true; +gem_writel (bp,NCFGR , new); + } + +if (macb_pcs_config_an (bp, mode, interface, advertising)) + changed = true; + +spin_unlock_irqrestore (&bp->lock, flags); +return changed; +} + +static void macb_pcs_an_restart (struct phylink_pcs *pcs) +{ + struct macb *bp = container_of(pcs, struct macb, phylink_sgmii_pcs); +u32 bmcr; +unsigned long flags; + +spin_lock_irqsave (&bp->lock, flags); + + bmcr =gem_readl (bp,PCSCNTRL ); + bmcr |=BMCR_ANENABLE ; +gem_writel (bp,PCSCNTRL , bmcr); + +spin_unlock_irqrestore (&bp->lock, flags); } static void macb_usx_pcs_get_state(struct phylink_pcs *pcs,
@@ -589,45 +661,60 @@ static int macb_usx_pcs_config(struct phylink_pcs *pcs, bool permit_pause_to_mac) { struct macb *bp = container_of(pcs, struct macb, phylink_usx_pcs); +unsigned long flags; +bool changed; +u16 old, new; -gem_writel (bp,USX_CONTROL ,gem_readl (bp,USX_CONTROL ) | -GEM_BIT (SIGNAL_OK )); +spin_lock_irqsave (&bp->lock, flags); +if (macb_pcs_config_an (bp, neg_mode, interface, advertising)) + changed = true; -return 0 ; -} + old = new =gem_readl (bp,USX_CONTROL ); + new |=GEM_BIT (SIGNAL_OK ); +if (old != new) { + changed = true; +gem_writel (bp,USX_CONTROL , new); + } -static void macb_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode, -struct phylink_link_state *state) -{ - state->link =0 ; -} + old = new =gem_readl (bp,USX_CONTROL ); + new =GEM_BFINS (SERDES_RATE ,MACB_SERDES_RATE_10G , new); + new =GEM_BFINS (USX_CTRL_SPEED ,HS_SPEED_10000M , new); + new &= ~(GEM_BIT (TX_SCR_BYPASS ) |GEM_BIT (RX_SCR_BYPASS )); + new |=GEM_BIT (TX_EN ); +if (old != new) { + changed = true; +gem_writel (bp,USX_CONTROL , new); + } -static void macb_pcs_an_restart (struct phylink_pcs *pcs) -{ -/* Not supported */ -} - -static int macb_pcs_config (struct phylink_pcs *pcs, -unsigned int neg_mode, -phy_interface_t interface, -const unsigned long *advertising, -bool permit_pause_to_mac) -{ -return 0 ; +spin_unlock_irqrestore (&bp->lock, flags); +return changed; }static const struct phylink_pcs_ops macb_phylink_usx_pcs_ops = { .pcs_get_state = macb_usx_pcs_get_state, .pcs_config = macb_usx_pcs_config, - .pcs_link_up = macb_usx_pcs_link_up, };static const struct phylink_pcs_ops macb_phylink_pcs_ops = { .pcs_get_state = macb_pcs_get_state, - .pcs_an_restart = macb_pcs_an_restart, .pcs_config = macb_pcs_config, + .pcs_an_restart = macb_pcs_an_restart, }; +static struct phylink_pcs *macb_mac_select_pcs (struct phylink_config *config, +phy_interface_t interface) +{ +struct net_device *ndev =to_net_dev (config->dev); +struct macb *bp =netdev_priv (ndev); + +if (interface ==PHY_INTERFACE_MODE_10GBASER ) +return &bp->phylink_usx_pcs; +else if (interface ==PHY_INTERFACE_MODE_SGMII ) +return &bp->phylink_sgmii_pcs; +else +return NULL ; +} +static void macb_mac_config (struct phylink_config *config,unsigned int mode,const struct phylink_link_state *state) {
@@ -646,18 +733,14 @@ 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)) { - ctrl &= ~(GEM_BIT (SGMIIEN ) |GEM_BIT (PCSSEL )); - ncr &= ~GEM_BIT (ENABLE_HS_MAC ); - -if (state->interface ==PHY_INTERFACE_MODE_SGMII ) { - ctrl |=GEM_BIT (SGMIIEN ) |GEM_BIT (PCSSEL ); - }else if (state->interface ==PHY_INTERFACE_MODE_10GBASER ) { +if (macb_mac_select_pcs (config, state->interface)) ctrl |=GEM_BIT (PCSSEL ); - ncr |=GEM_BIT (ENABLE_HS_MAC ); - }else if (bp->caps &MACB_CAPS_MIIONRGMII && - bp->phy_interface ==PHY_INTERFACE_MODE_MII ) { +else + ctrl &= ~GEM_BIT (PCSSEL ); + +if (bp->caps &MACB_CAPS_MIIONRGMII && + bp->phy_interface ==PHY_INTERFACE_MODE_MII ) ncr |=MACB_BIT (MIIONRGMII ); - } }/* Apply the new configuration, if any */
@@ -667,22 +750,6 @@ static void macb_mac_config(struct phylink_config *config, unsigned int mode,if (old_ncr ^ ncr)macb_or_gem_writel (bp,NCR , ncr); -/* Disable AN for SGMII fixed link configuration, enable otherwise. -* Must be written after PCSSEL is set in NCFGR, -* otherwise writes will not take effect. -*/ -if (macb_is_gem (bp) && state->interface ==PHY_INTERFACE_MODE_SGMII ) { -u32 pcsctrl, old_pcsctrl; - - old_pcsctrl =gem_readl (bp,PCSCNTRL ); -if (mode ==MLO_AN_FIXED ) - pcsctrl = old_pcsctrl & ~GEM_BIT (PCSAUTONEG ); -else - pcsctrl = old_pcsctrl |GEM_BIT (PCSAUTONEG ); -if (old_pcsctrl != pcsctrl) -gem_writel (bp,PCSCNTRL , pcsctrl); - } -spin_unlock_irqrestore (&bp->lock, flags); }
@@ -735,10 +802,12 @@ static void macb_mac_link_up(struct phylink_config *config,if (!(bp->caps &MACB_CAPS_MACB_IS_EMAC )) { ctrl &= ~MACB_BIT (PAE );if (macb_is_gem (bp)) { - ctrl &= ~GEM_BIT (GBE ); + ctrl &= ~(GEM_BIT (GBE ) |GEM_BIT (ENABLE_HS_MAC ));if (speed ==SPEED_1000 ) ctrl |=GEM_BIT (GBE ); +else if (speed ==SPEED_10000 ) + ctrl |=GEM_BIT (ENABLE_HS_MAC ); }if (rx_pause)
@@ -776,20 +845,6 @@ static void macb_mac_link_up(struct phylink_config *config,netif_tx_wake_all_queues (ndev); } -static struct phylink_pcs *macb_mac_select_pcs (struct phylink_config *config, -phy_interface_t interface) -{ -struct net_device *ndev =to_net_dev (config->dev); -struct macb *bp =netdev_priv (ndev); - -if (interface ==PHY_INTERFACE_MODE_10GBASER ) -return &bp->phylink_usx_pcs; -else if (interface ==PHY_INTERFACE_MODE_SGMII ) -return &bp->phylink_sgmii_pcs; -else -return NULL ; -} -static const struct phylink_mac_ops macb_phylink_ops = { .mac_select_pcs = macb_mac_select_pcs, .mac_config = macb_mac_config,
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerPATCH v6 9/10 net: macb: Support external PCSs
In reply to Sean AndersonThis 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.
---
(no changes since v4)
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(-)
drivers/net/ethernet/cadence/macb.h +1 -0
@@ -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;
drivers/net/ethernet/cadence/macb_main.c +24 -2
@@ -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); }
@@ -5459,6 +5480,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); }
Signature · 1 line
2.35.1.1320.gc452695387.dirty
kernel test robot
build botRe: [net-next PATCH v6 09/10] net: macb: Support external PCSs
kernel test robot noticed the following build warnings:
Hi Sean,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Sean-Anderson/dt-bindings-net-Add-Xilinx-PCS/20250611-143544 base: net-next/main patch link: https://lore.kernel.org/r/20250610233642.3588414-1-sean.anderson%40linux.dev patch subject: [net-next PATCH v6 09/10] net: macb: Support external PCSs config: xtensa-randconfig-r062-20250613 (https://download.01.org/0day-ci/archive/20250613/[email protected]/config) compiler: xtensa-linux-gcc (GCC) 13.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250613/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from drivers/net/ethernet/cadence/macb_main.c:24:
include/linux/pcs.h: In function 'pcs_get_by_fwnode_compat':
include/linux/pcs.h:201:16: error: implicit declaration of function '_pcs_get_tail' [-Werror=implicit-function-declaration]
201 | return _pcs_get_tail(dev, fwnode, NULL);
| ^~~~~~~~~~~~~
>> include/linux/pcs.h:201:16: warning: returning 'int' from a function with return type 'struct phylink_pcs *' makes pointer from integer without a cast [-Wint-conversion]
201 | return _pcs_get_tail(dev, fwnode, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +201 include/linux/pcs.h
56201bc1ac71fc Sean Anderson 2025-06-10 187
56201bc1ac71fc Sean Anderson 2025-06-10 188 #ifdef CONFIG_OF_DYNAMIC
56201bc1ac71fc Sean Anderson 2025-06-10 189 struct phylink_pcs *
56201bc1ac71fc Sean Anderson 2025-06-10 190 pcs_get_by_fwnode_compat(struct device *dev, struct fwnode_handle *fwnode,
56201bc1ac71fc Sean Anderson 2025-06-10 191 int (*fixup)(struct of_changeset *ocs,
56201bc1ac71fc Sean Anderson 2025-06-10 192 struct device_node *np, void *data),
56201bc1ac71fc Sean Anderson 2025-06-10 193 void *data);
56201bc1ac71fc Sean Anderson 2025-06-10 194 #else
56201bc1ac71fc Sean Anderson 2025-06-10 195 static inline struct phylink_pcs *
56201bc1ac71fc Sean Anderson 2025-06-10 196 pcs_get_by_fwnode_compat(struct device *dev, struct fwnode_handle *fwnode,
56201bc1ac71fc Sean Anderson 2025-06-10 197 int (*fixup)(struct of_changeset *ocs,
56201bc1ac71fc Sean Anderson 2025-06-10 198 struct device_node *np, void *data),
56201bc1ac71fc Sean Anderson 2025-06-10 199 void *data)
56201bc1ac71fc Sean Anderson 2025-06-10 200 {
56201bc1ac71fc Sean Anderson 2025-06-10 @201 return _pcs_get_tail(dev, fwnode, NULL);
56201bc1ac71fc Sean Anderson 2025-06-10 202 }
56201bc1ac71fc Sean Anderson 2025-06-10 203 #endif56201bc1ac71fc Sean Anderson 2025-06-10 204
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Sean Anderson
reviewerPATCH v6 10/10 of: property: Add device link support for PCS
In reply to Sean AndersonThis adds device link support for PCS devices, providing better probe ordering.
---
(no changes since v2)
Changes in v2:
- Reorder pcs_handle to come before suffix props
drivers/of/property.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/of/property.c +2 -0
@@ -1377,6 +1377,7 @@ DEFINE_SIMPLE_PROP(post_init_providers, "post-init-providers", NULL) DEFINE_SIMPLE_PROP(access_controllers, "access-controllers", "#access-controller-cells") DEFINE_SIMPLE_PROP(pses, "pses", "#pse-cells") DEFINE_SIMPLE_PROP(power_supplies, "power-supplies", NULL) +DEFINE_SIMPLE_PROP(pcs_handle, "pcs-handle", NULL) DEFINE_SUFFIX_PROP(regulators, "-supply", NULL)DEFINE_SUFFIX_PROP (gpio,"-gpio" ,"#gpio-cells" )
@@ -1528,6 +1529,7 @@ static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_interrupts, }, { .parse_prop = parse_interrupt_map, }, { .parse_prop = parse_access_controllers, }, + { .parse_prop = parse_pcs_handle, }, { .parse_prop = parse_regulators, }, { .parse_prop = parse_gpio, }, { .parse_prop = parse_gpios, },
Signature · 1 line
2.35.1.1320.gc452695387.dirty