Skip to content

Commit aba43bd

Browse files
committed
Merge branch 'pcs-xpcs-mmap' into main
Serge Semin <fancer says: ==================== net: pcs: xpcs: Add memory-mapped device support The main goal of this series is to extend the DW XPCS device support in the kernel. Particularly the patchset adds a support of the DW XPCS device with the MCI/APB3 IO interface registered as a platform device. In order to have them utilized by the DW XPCS core the fwnode-based DW XPCS descriptor creation procedure has been introduced. Finally the STMMAC driver has been altered to support the DW XPCS passed via the 'pcs-handle' property. Note the series has been significantly re-developed since v1. So I even had to change the subject. Anyway I've done my best to take all the noted into account. The series traditionally starts with a set of the preparation patches. First one just moves the generic DW XPCS IDs macros from the internal header file to the external one where some other IDs also reside. Second patch splits up the xpcs_create() method to a set of the coherent sub-functions for the sake of the further easier updates and to have it looking less complicated. The goal of the next three patches is to extend the DW XPCS ID management code by defining a new dw_xpcs_info structure with both PCS and PMA IDs. The next two patches provide the DW XPCS device DT-bindings and the respective platform-device driver for the memory-mapped DW XPCS devices. Besides the later patch makes use of the introduced dw_xpcs_info structure to pre-define the DW XPCS IDs based on the platform-device compatible string. Thus if there is no way to auto-identify the XPCS device capabilities it can be done based on the custom device IDs passed via the MDIO-device platform data. Final DW XPCS driver change is about adding a new method of the DW XPCS descriptor creation. The xpcs_create_fwnode() function has been introduced with the same semantics as a similar method recently added to the Lynx PCS driver. It's supposed to be called with the fwnode pointing to the DW XPCS device node, for which the XPCS descriptor will be created. The series is terminated with two STMMAC driver patches. The former one simplifies the DW XPCS descriptor registration procedure by dropping the MDIO-bus scanning and creating the descriptor for the particular device address. The later patch alters the STMMAC PCS setup method so one would support the DW XPCS specified via the "pcs-handle" property. That's it for now. Thanks for review in advance. Any tests are very welcome. After this series is merged in, I'll submit another one which adds the generic 10GBase-R and 10GBase-X interfaces support to the STMMAC and DW XPCS driver with the proper CSRs re-initialization, PMA initialization and reference clock selection as it's described in the Synopsys DW XPCS HW manual. Link: https://lore.kernel.org/netdev/[email protected] Changelog v2: - Drop the patches: [PATCH net-next 01/16] net: pcs: xpcs: Drop sentinel entry from 2500basex ifaces list [PATCH net-next 02/16] net: pcs: xpcs: Drop redundant workqueue.h include directive [PATCH net-next 03/16] net: pcs: xpcs: Return EINVAL in the internal methods [PATCH net-next 04/16] net: pcs: xpcs: Explicitly return error on caps validation as ones have already been merged into the kernel repo: Link: https://lore.kernel.org/netdev/[email protected]/ - Drop the patches: [PATCH net-next 14/16] net: stmmac: Pass netdev to XPCS setup function [PATCH net-next 15/16] net: stmmac: Add dedicated XPCS cleanup method as ones have already been merged into the kernel repo: Link: https://lore.kernel.org/netdev/[email protected]/ - Drop the patch: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device [PATCH net-next 09/16] net: mdio: Add Synopsys DW XPCS management interface support [PATCH net-next 11/16] net: pcs: xpcs: Change xpcs_create_mdiodev() suffix to "byaddr" [PATCH net-next 13/16] net: stmmac: intel: Register generic MDIO device as no longer relevant. - Add new patches: [PATCH net-next v2 03/10] net: pcs: xpcs: Convert xpcs_id to dw_xpcs_desc [PATCH net-next v2 04/10] net: pcs: xpcs: Convert xpcs_compat to dw_xpcs_compat [PATCH net-next v2 05/10] net: pcs: xpcs: Introduce DW XPCS info structure [PATCH net-next v2 09/10] net: stmmac: Create DW XPCS device with particular address - Use the xpcs_create_fwnode() function name and semantics similar to the Lynx PCS driver. - Add kdoc describing the DW XPCS registration functions. - Convert the memory-mapped DW XPCS device driver to being the platform-device driver. - Convert the DW XPCS DT-bindings to defining both memory-mapped and MDIO devices. - Drop inline'es from the methods statically defined in *.c. (@maxime) - Preserve the strict refcount-ing pattern. (@russell) Link: https://lore.kernel.org/netdev/[email protected]/ Changelov v3: - Implement the ordered clocks constraint. (@rob) - Convert xpcs_plat_pm_ops to being defined as static. (@simon) - Add the "@interface" argument kdoc to the xpcs_create_mdiodev() function. (@simon) - Fix the "@fwnode" argument name in the xpcs_create_fwnode() method kdoc. (@simon) - Move the return value descriptions to the "Return:" section of the xpcs_create_mdiodev() and xpcs_create_fwnode() kdoc. (@simon) - Drop stmmac_mdio_bus_data::has_xpcs flag and define the PCS-address mask with particular XPCS address instead. Link: https://lore.kernel.org/netdev/[email protected]/ Changelog v4: - Make sure the series is applicable to the net-next tree. (@vladimir) - Rename entry to desc in the xpcs_init_id() method. (@andrew) - Add a comment to the clock-names property constraint about the oneOf-subschemas applicability. (@conor) - Convert "pclk" clock name to "csr" to match the DW XPCS IP-core input signal name. (@rob) ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 390b14b + 357768c commit aba43bd

File tree

10 files changed

+910
-148
lines changed

10 files changed

+910
-148
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/net/pcs/snps,dw-xpcs.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Synopsys DesignWare Ethernet PCS
8+
9+
maintainers:
10+
- Serge Semin <[email protected]>
11+
12+
description:
13+
Synopsys DesignWare Ethernet Physical Coding Sublayer provides an interface
14+
between Media Access Control and Physical Medium Attachment Sublayer through
15+
the Media Independent Interface (XGMII, USXGMII, XLGMII, GMII, etc)
16+
controlled by means of the IEEE std. Clause 45 registers set. The PCS can be
17+
optionally synthesized with a vendor-specific interface connected to
18+
Synopsys PMA (also called DesignWare Consumer/Enterprise PHY) although in
19+
general it can be used to communicate with any compatible PHY.
20+
21+
The PCS CSRs can be accessible either over the Ethernet MDIO bus or directly
22+
by means of the APB3/MCI interfaces. In the later case the XPCS can be mapped
23+
right to the system IO memory space.
24+
25+
properties:
26+
compatible:
27+
oneOf:
28+
- description: Synopsys DesignWare XPCS with none or unknown PMA
29+
const: snps,dw-xpcs
30+
- description: Synopsys DesignWare XPCS with Consumer Gen1 3G PMA
31+
const: snps,dw-xpcs-gen1-3g
32+
- description: Synopsys DesignWare XPCS with Consumer Gen2 3G PMA
33+
const: snps,dw-xpcs-gen2-3g
34+
- description: Synopsys DesignWare XPCS with Consumer Gen2 6G PMA
35+
const: snps,dw-xpcs-gen2-6g
36+
- description: Synopsys DesignWare XPCS with Consumer Gen4 3G PMA
37+
const: snps,dw-xpcs-gen4-3g
38+
- description: Synopsys DesignWare XPCS with Consumer Gen4 6G PMA
39+
const: snps,dw-xpcs-gen4-6g
40+
- description: Synopsys DesignWare XPCS with Consumer Gen5 10G PMA
41+
const: snps,dw-xpcs-gen5-10g
42+
- description: Synopsys DesignWare XPCS with Consumer Gen5 12G PMA
43+
const: snps,dw-xpcs-gen5-12g
44+
45+
reg:
46+
items:
47+
- description:
48+
In case of the MDIO management interface this just a 5-bits ID
49+
of the MDIO bus device. If DW XPCS CSRs space is accessed over the
50+
MCI or APB3 management interfaces, then the space mapping can be
51+
either 'direct' or 'indirect'. In the former case all Clause 45
52+
registers are contiguously mapped within the address space
53+
MMD '[20:16]', Reg '[15:0]'. In the later case the space is divided
54+
to the multiple 256 register sets. There is a special viewport CSR
55+
which is responsible for the set selection. The upper part of
56+
the CSR address MMD+REG[20:8] is supposed to be written in there
57+
so the corresponding subset would be mapped to the lowest 255 CSRs.
58+
59+
reg-names:
60+
items:
61+
- enum: [ direct, indirect ]
62+
63+
reg-io-width:
64+
description:
65+
The way the CSRs are mapped to the memory is platform depended. Since
66+
each Clause 45 CSR is of 16-bits wide the access instructions must be
67+
two bytes aligned at least.
68+
default: 2
69+
enum: [ 2, 4 ]
70+
71+
interrupts:
72+
description:
73+
System interface interrupt output (sbd_intr_o) indicating Clause 73/37
74+
auto-negotiation events':' Page received, AN is completed or incompatible
75+
link partner.
76+
maxItems: 1
77+
78+
clocks:
79+
description:
80+
The MCI and APB3 interfaces are supposed to be equipped with a clock
81+
source connected to the clk_csr_i line.
82+
83+
PCS/PMA layer can be clocked by an internal reference clock source
84+
(phyN_core_refclk) or by an externally connected (phyN_pad_refclk) clock
85+
generator. Both clocks can be supplied at a time.
86+
minItems: 1
87+
maxItems: 3
88+
89+
clock-names:
90+
oneOf:
91+
- minItems: 1
92+
items: # MDIO
93+
- enum: [core, pad]
94+
- const: pad
95+
- minItems: 1
96+
items: # MCI or APB
97+
- const: csr
98+
- enum: [core, pad]
99+
- const: pad
100+
101+
required:
102+
- compatible
103+
- reg
104+
105+
additionalProperties: false
106+
107+
examples:
108+
- |
109+
#include <dt-bindings/interrupt-controller/irq.h>
110+
111+
ethernet-pcs@1f05d000 {
112+
compatible = "snps,dw-xpcs";
113+
reg = <0x1f05d000 0x1000>;
114+
reg-names = "indirect";
115+
116+
reg-io-width = <4>;
117+
118+
interrupts = <79 IRQ_TYPE_LEVEL_HIGH>;
119+
120+
clocks = <&ccu_pclk>, <&ccu_core>, <&ccu_pad>;
121+
clock-names = "csr", "core", "pad";
122+
};
123+
- |
124+
mdio-bus {
125+
#address-cells = <1>;
126+
#size-cells = <0>;
127+
128+
ethernet-pcs@0 {
129+
compatible = "snps,dw-xpcs";
130+
reg = <0>;
131+
132+
clocks = <&ccu_core>, <&ccu_pad>;
133+
clock-names = "core", "pad";
134+
};
135+
};
136+
...

drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
595595
/* Intel mgbe SGMII interface uses pcs-xcps */
596596
if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII ||
597597
plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) {
598-
plat->mdio_bus_data->has_xpcs = true;
598+
plat->mdio_bus_data->pcs_mask = BIT(INTEL_MGBE_XPCS_ADDR);
599599
plat->mdio_bus_data->default_an_inband = true;
600600
plat->select_pcs = intel_mgbe_select_pcs;
601601
}

drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -497,35 +497,33 @@ int stmmac_mdio_reset(struct mii_bus *bus)
497497

498498
int stmmac_pcs_setup(struct net_device *ndev)
499499
{
500+
struct fwnode_handle *devnode, *pcsnode;
500501
struct dw_xpcs *xpcs = NULL;
501502
struct stmmac_priv *priv;
502-
int ret = -ENODEV;
503-
int mode, addr;
503+
int addr, mode, ret;
504504

505505
priv = netdev_priv(ndev);
506506
mode = priv->plat->phy_interface;
507+
devnode = priv->plat->port_node;
507508

508509
if (priv->plat->pcs_init) {
509510
ret = priv->plat->pcs_init(priv);
511+
} else if (fwnode_property_present(devnode, "pcs-handle")) {
512+
pcsnode = fwnode_find_reference(devnode, "pcs-handle", 0);
513+
xpcs = xpcs_create_fwnode(pcsnode, mode);
514+
fwnode_handle_put(pcsnode);
515+
ret = PTR_ERR_OR_ZERO(xpcs);
510516
} else if (priv->plat->mdio_bus_data &&
511-
priv->plat->mdio_bus_data->has_xpcs) {
512-
/* Try to probe the XPCS by scanning all addresses */
513-
for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
514-
xpcs = xpcs_create_mdiodev(priv->mii, addr, mode);
515-
if (IS_ERR(xpcs))
516-
continue;
517-
518-
ret = 0;
519-
break;
520-
}
517+
priv->plat->mdio_bus_data->pcs_mask) {
518+
addr = ffs(priv->plat->mdio_bus_data->pcs_mask) - 1;
519+
xpcs = xpcs_create_mdiodev(priv->mii, addr, mode);
520+
ret = PTR_ERR_OR_ZERO(xpcs);
521521
} else {
522522
return 0;
523523
}
524524

525-
if (ret) {
526-
dev_warn(priv->device, "No xPCS found\n");
527-
return ret;
528-
}
525+
if (ret)
526+
return dev_err_probe(priv->device, ret, "No xPCS found\n");
529527

530528
priv->hw->xpcs = xpcs;
531529

@@ -610,7 +608,7 @@ int stmmac_mdio_register(struct net_device *ndev)
610608
snprintf(new_bus->id, MII_BUS_ID_SIZE, "%s-%x",
611609
new_bus->name, priv->plat->bus_id);
612610
new_bus->priv = ndev;
613-
new_bus->phy_mask = mdio_bus_data->phy_mask;
611+
new_bus->phy_mask = mdio_bus_data->phy_mask | mdio_bus_data->pcs_mask;
614612
new_bus->parent = priv->device;
615613

616614
err = of_mdiobus_register(new_bus, mdio_node);

drivers/net/pcs/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
menu "PCS device drivers"
77

88
config PCS_XPCS
9-
tristate
9+
tristate "Synopsys DesignWare Ethernet XPCS"
1010
select PHYLINK
1111
help
12-
This module provides helper functions for Synopsys DesignWare XPCS
13-
controllers.
12+
This module provides a driver and helper functions for Synopsys
13+
DesignWare XPCS controllers.
1414

1515
config PCS_LYNX
1616
tristate

drivers/net/pcs/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# SPDX-License-Identifier: GPL-2.0
22
# Makefile for Linux PCS drivers
33

4-
pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-nxp.o pcs-xpcs-wx.o
4+
pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-plat.o \
5+
pcs-xpcs-nxp.o pcs-xpcs-wx.o
56

67
obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o
78
obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o

0 commit comments

Comments
 (0)