Skip to content

Commit 9386d18

Browse files
committed
Merge branch 'axienet-broken-link'
Andy Chiu says: ==================== Fix broken link on Xilinx's AXI Ethernet in SGMII mode The Ethernet driver use phy-handle to reference the PCS/PMA PHY. This could be a problem if one wants to configure an external PHY via phylink, since it use the same phandle to get the PHY. To fix this, introduce a dedicated pcs-handle to point to the PCS/PMA PHY and deprecate the use of pointing it with phy-handle. A similar use case of pcs-handle can be seen on dpaa2 as well. --- patch v5 --- - Re-apply the v4 patch on the net tree. - Describe the pcs-handle DT binding at ethernet-controller level. --- patch v6 --- - Remove "preferrably" to clearify usage of pcs_handle. --- patch v7 --- - Rebase the patch on latest net/master --- patch v8 --- - Rebase the patch on net-next/master - Add "reviewed-by" tag in PATCH 3/4: dt-bindings: net: add pcs-handle attribute - Remove "fix" tag in last commit message since this is not a critical bug and will not be back ported to stable. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents fb5833d + 19c7a43 commit 9386d18

4 files changed

Lines changed: 31 additions & 18 deletions

File tree

Documentation/devicetree/bindings/net/ethernet-controller.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ properties:
106106
phy-mode:
107107
$ref: "#/properties/phy-connection-type"
108108

109+
pcs-handle:
110+
$ref: /schemas/types.yaml#/definitions/phandle
111+
description:
112+
Specifies a reference to a node representing a PCS PHY device on a MDIO
113+
bus to link with an external PHY (phy-handle) if exists.
114+
109115
phy-handle:
110116
$ref: /schemas/types.yaml#/definitions/phandle
111117
description:

Documentation/devicetree/bindings/net/xilinx_axienet.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Required properties:
2626
specified, the TX/RX DMA interrupts should be on that node
2727
instead, and only the Ethernet core interrupt is optionally
2828
specified here.
29-
- phy-handle : Should point to the external phy device.
29+
- phy-handle : Should point to the external phy device if exists. Pointing
30+
this to the PCS/PMA PHY is deprecated and should be avoided.
3031
See ethernet.txt file in the same directory.
3132
- xlnx,rxmem : Set to allocated memory buffer for Rx/Tx in the hardware
3233

@@ -68,6 +69,11 @@ Optional properties:
6869
required through the core's MDIO interface (i.e. always,
6970
unless the PHY is accessed through a different bus).
7071

72+
- pcs-handle: Phandle to the internal PCS/PMA PHY in SGMII or 1000Base-X
73+
modes, where "pcs-handle" should be used to point
74+
to the PCS/PMA PHY, and "phy-handle" should point to an
75+
external PHY if exists.
76+
7177
Example:
7278
axi_ethernet_eth: ethernet@40c00000 {
7379
compatible = "xlnx,axi-ethernet-1.00.a";

drivers/net/ethernet/xilinx/xilinx_axienet.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,6 @@ struct axienet_local {
433433
struct net_device *ndev;
434434
struct device *dev;
435435

436-
struct device_node *phy_node;
437-
438436
struct phylink *phylink;
439437
struct phylink_config phylink_config;
440438

drivers/net/ethernet/xilinx/xilinx_axienet_main.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,25 +2064,33 @@ static int axienet_probe(struct platform_device *pdev)
20642064
if (ret)
20652065
goto cleanup_clk;
20662066

2067-
lp->phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
2068-
if (lp->phy_node) {
2069-
ret = axienet_mdio_setup(lp);
2070-
if (ret)
2071-
dev_warn(&pdev->dev,
2072-
"error registering MDIO bus: %d\n", ret);
2073-
}
2067+
ret = axienet_mdio_setup(lp);
2068+
if (ret)
2069+
dev_warn(&pdev->dev,
2070+
"error registering MDIO bus: %d\n", ret);
2071+
20742072
if (lp->phy_mode == PHY_INTERFACE_MODE_SGMII ||
20752073
lp->phy_mode == PHY_INTERFACE_MODE_1000BASEX) {
2076-
if (!lp->phy_node) {
2077-
dev_err(&pdev->dev, "phy-handle required for 1000BaseX/SGMII\n");
2074+
np = of_parse_phandle(pdev->dev.of_node, "pcs-handle", 0);
2075+
if (!np) {
2076+
/* Deprecated: Always use "pcs-handle" for pcs_phy.
2077+
* Falling back to "phy-handle" here is only for
2078+
* backward compatibility with old device trees.
2079+
*/
2080+
np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
2081+
}
2082+
if (!np) {
2083+
dev_err(&pdev->dev, "pcs-handle (preferred) or phy-handle required for 1000BaseX/SGMII\n");
20782084
ret = -EINVAL;
20792085
goto cleanup_mdio;
20802086
}
2081-
lp->pcs_phy = of_mdio_find_device(lp->phy_node);
2087+
lp->pcs_phy = of_mdio_find_device(np);
20822088
if (!lp->pcs_phy) {
20832089
ret = -EPROBE_DEFER;
2090+
of_node_put(np);
20842091
goto cleanup_mdio;
20852092
}
2093+
of_node_put(np);
20862094
lp->pcs.ops = &axienet_pcs_ops;
20872095
lp->pcs.poll = true;
20882096
}
@@ -2125,8 +2133,6 @@ static int axienet_probe(struct platform_device *pdev)
21252133
put_device(&lp->pcs_phy->dev);
21262134
if (lp->mii_bus)
21272135
axienet_mdio_teardown(lp);
2128-
of_node_put(lp->phy_node);
2129-
21302136
cleanup_clk:
21312137
clk_bulk_disable_unprepare(XAE_NUM_MISC_CLOCKS, lp->misc_clks);
21322138
clk_disable_unprepare(lp->axi_clk);
@@ -2155,9 +2161,6 @@ static int axienet_remove(struct platform_device *pdev)
21552161
clk_bulk_disable_unprepare(XAE_NUM_MISC_CLOCKS, lp->misc_clks);
21562162
clk_disable_unprepare(lp->axi_clk);
21572163

2158-
of_node_put(lp->phy_node);
2159-
lp->phy_node = NULL;
2160-
21612164
free_netdev(ndev);
21622165

21632166
return 0;

0 commit comments

Comments
 (0)