* [PATCH net-next 1/3] net: nixge: Make mdio child node optional
2019-02-04 17:30 [PATCH net-next 0/3] nixge: Fixed-link support Moritz Fischer
@ 2019-02-04 17:30 ` Moritz Fischer
2019-02-04 17:30 ` [PATCH net-next 2/3] net: nixge: Add support for fixed-link configurations Moritz Fischer
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Moritz Fischer @ 2019-02-04 17:30 UTC (permalink / raw)
To: netdev
Cc: devicetree, linux-kernel, alex.williams, andrew, robh+dt, davem,
moritz.fischer, Moritz Fischer
From: Moritz Fischer <mdf@kernel.org>
Make MDIO child optional and only instantiate the
MDIO bus if the child is actually present.
There are currently no (in-tree) users of this
binding; all (out-of-tree) users use overlays that
get shipped together with the FPGA images that contain
the IP.
This will significantly increase maintainabilty
of future revisions of this IP.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
Changes from RFC:
- Add Andrew's Reviewed-by tag
- Rebased on top of net-next
---
.../devicetree/bindings/net/nixge.txt | 27 ++++++++++++++++---
drivers/net/ethernet/ni/nixge.c | 19 ++++++++-----
2 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/nixge.txt b/Documentation/devicetree/bindings/net/nixge.txt
index 44a7358b4399..bb2929f9c64f 100644
--- a/Documentation/devicetree/bindings/net/nixge.txt
+++ b/Documentation/devicetree/bindings/net/nixge.txt
@@ -16,6 +16,9 @@ Required properties:
- nvmem-cells: Phandle of nvmem cell containing the MAC address
- nvmem-cell-names: Should be "address"
+Optional properties:
+- mdio subnode to indicate presence of MDIO controller
+
Examples (10G generic PHY):
nixge0: ethernet@40000000 {
compatible = "ni,xge-enet-3.00";
@@ -33,8 +36,26 @@ Examples (10G generic PHY):
phy-mode = "xgmii";
phy-handle = <ðernet_phy1>;
- ethernet_phy1: ethernet-phy@4 {
- compatible = "ethernet-phy-ieee802.3-c45";
- reg = <4>;
+ mdio {
+ ethernet_phy1: ethernet-phy@4 {
+ compatible = "ethernet-phy-ieee802.3-c45";
+ reg = <4>;
+ };
};
};
+
+Examples (10G generic PHY, no MDIO):
+ nixge0: ethernet@40000000 {
+ compatible = "ni,xge-enet-2.00";
+ reg = <0x40000000 0x6000>;
+
+ nvmem-cells = <ð1_addr>;
+ nvmem-cell-names = "address";
+
+ interrupts = <0 29 IRQ_TYPE_LEVEL_HIGH>, <0 30 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "rx", "tx";
+ interrupt-parent = <&intc>;
+
+ phy-mode = "xgmii";
+ phy-handle = <ðernet_phy1>;
+ };
diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
index 73a98bd2fcd2..c8dd1e4c759d 100644
--- a/drivers/net/ethernet/ni/nixge.c
+++ b/drivers/net/ethernet/ni/nixge.c
@@ -1284,6 +1284,7 @@ static int nixge_probe(struct platform_device *pdev)
{
struct nixge_priv *priv;
struct net_device *ndev;
+ struct device_node *mn;
const u8 *mac_addr;
int err;
@@ -1335,10 +1336,14 @@ static int nixge_probe(struct platform_device *pdev)
priv->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD;
priv->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD;
- err = nixge_mdio_setup(priv, pdev->dev.of_node);
- if (err) {
- netdev_err(ndev, "error registering mdio bus");
- goto free_netdev;
+ mn = of_get_child_by_name(pdev->dev.of_node, "mdio");
+ if (mn) {
+ err = nixge_mdio_setup(priv, mn);
+ of_node_put(mn);
+ if (err) {
+ netdev_err(ndev, "error registering mdio bus");
+ goto free_netdev;
+ }
}
priv->phy_mode = of_get_phy_mode(pdev->dev.of_node);
@@ -1364,7 +1369,8 @@ static int nixge_probe(struct platform_device *pdev)
return 0;
unregister_mdio:
- mdiobus_unregister(priv->mii_bus);
+ if (priv->mii_bus)
+ mdiobus_unregister(priv->mii_bus);
free_netdev:
free_netdev(ndev);
@@ -1379,7 +1385,8 @@ static int nixge_remove(struct platform_device *pdev)
unregister_netdev(ndev);
- mdiobus_unregister(priv->mii_bus);
+ if (priv->mii_bus)
+ mdiobus_unregister(priv->mii_bus);
free_netdev(ndev);
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 2/3] net: nixge: Add support for fixed-link configurations
2019-02-04 17:30 [PATCH net-next 0/3] nixge: Fixed-link support Moritz Fischer
2019-02-04 17:30 ` [PATCH net-next 1/3] net: nixge: Make mdio child node optional Moritz Fischer
@ 2019-02-04 17:30 ` Moritz Fischer
2019-02-04 17:30 ` [PATCH net-next 3/3] dt-bindings: net: Add fixed-link support Moritz Fischer
2019-02-05 18:34 ` [PATCH net-next 0/3] nixge: Fixed-link support David Miller
3 siblings, 0 replies; 6+ messages in thread
From: Moritz Fischer @ 2019-02-04 17:30 UTC (permalink / raw)
To: netdev
Cc: devicetree, linux-kernel, alex.williams, andrew, robh+dt, davem,
moritz.fischer, Moritz Fischer
From: Moritz Fischer <mdf@kernel.org>
Add support for fixed-link configurations to nixge driver.
Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
drivers/net/ethernet/ni/nixge.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
index c8dd1e4c759d..96f7a9818294 100644
--- a/drivers/net/ethernet/ni/nixge.c
+++ b/drivers/net/ethernet/ni/nixge.c
@@ -1282,9 +1282,9 @@ static int nixge_of_get_resources(struct platform_device *pdev)
static int nixge_probe(struct platform_device *pdev)
{
+ struct device_node *mn, *phy_node;
struct nixge_priv *priv;
struct net_device *ndev;
- struct device_node *mn;
const u8 *mac_addr;
int err;
@@ -1353,21 +1353,30 @@ static int nixge_probe(struct platform_device *pdev)
goto unregister_mdio;
}
- priv->phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
- if (!priv->phy_node) {
- netdev_err(ndev, "not find \"phy-handle\" property\n");
- err = -EINVAL;
- goto unregister_mdio;
+ phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
+ if (!phy_node && of_phy_is_fixed_link(pdev->dev.of_node)) {
+ err = of_phy_register_fixed_link(pdev->dev.of_node);
+ if (err < 0) {
+ netdev_err(ndev, "broken fixed-link specification\n");
+ goto unregister_mdio;
+ }
+ phy_node = of_node_get(pdev->dev.of_node);
}
+ priv->phy_node = phy_node;
err = register_netdev(priv->ndev);
if (err) {
netdev_err(ndev, "register_netdev() error (%i)\n", err);
- goto unregister_mdio;
+ goto free_phy;
}
return 0;
+free_phy:
+ if (of_phy_is_fixed_link(pdev->dev.of_node))
+ of_phy_deregister_fixed_link(pdev->dev.of_node);
+ of_node_put(phy_node);
+
unregister_mdio:
if (priv->mii_bus)
mdiobus_unregister(priv->mii_bus);
@@ -1385,6 +1394,10 @@ static int nixge_remove(struct platform_device *pdev)
unregister_netdev(ndev);
+ if (of_phy_is_fixed_link(pdev->dev.of_node))
+ of_phy_deregister_fixed_link(pdev->dev.of_node);
+ of_node_put(priv->phy_node);
+
if (priv->mii_bus)
mdiobus_unregister(priv->mii_bus);
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 3/3] dt-bindings: net: Add fixed-link support
2019-02-04 17:30 [PATCH net-next 0/3] nixge: Fixed-link support Moritz Fischer
2019-02-04 17:30 ` [PATCH net-next 1/3] net: nixge: Make mdio child node optional Moritz Fischer
2019-02-04 17:30 ` [PATCH net-next 2/3] net: nixge: Add support for fixed-link configurations Moritz Fischer
@ 2019-02-04 17:30 ` Moritz Fischer
2019-02-05 18:34 ` [PATCH net-next 0/3] nixge: Fixed-link support David Miller
3 siblings, 0 replies; 6+ messages in thread
From: Moritz Fischer @ 2019-02-04 17:30 UTC (permalink / raw)
To: netdev
Cc: devicetree, linux-kernel, alex.williams, andrew, robh+dt, davem,
moritz.fischer, Moritz Fischer
From: Moritz Fischer <mdf@kernel.org>
Update device-tree binding with fixed-link support.
With fixed-link support the formerly required property 'phy-handle'
is now optional if 'fixed-link' child is present.
Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
.../devicetree/bindings/net/nixge.txt | 33 ++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/net/nixge.txt b/Documentation/devicetree/bindings/net/nixge.txt
index bb2929f9c64f..85d7240a9b20 100644
--- a/Documentation/devicetree/bindings/net/nixge.txt
+++ b/Documentation/devicetree/bindings/net/nixge.txt
@@ -12,12 +12,14 @@ Required properties:
- interrupts: Should contain tx and rx interrupt
- interrupt-names: Should be "rx" and "tx"
- phy-mode: See ethernet.txt file in the same directory.
-- phy-handle: See ethernet.txt file in the same directory.
- nvmem-cells: Phandle of nvmem cell containing the MAC address
- nvmem-cell-names: Should be "address"
Optional properties:
- mdio subnode to indicate presence of MDIO controller
+- fixed-link : Assume a fixed link. See fixed-link.txt in the same directory.
+ Use instead of phy-handle.
+- phy-handle: See ethernet.txt file in the same directory.
Examples (10G generic PHY):
nixge0: ethernet@40000000 {
@@ -59,3 +61,32 @@ Examples (10G generic PHY, no MDIO):
phy-mode = "xgmii";
phy-handle = <ðernet_phy1>;
};
+
+Examples (1G generic fixed-link + MDIO):
+ nixge0: ethernet@40000000 {
+ compatible = "ni,xge-enet-2.00";
+ reg = <0x40000000 0x6000>;
+
+ nvmem-cells = <ð1_addr>;
+ nvmem-cell-names = "address";
+
+ interrupts = <0 29 IRQ_TYPE_LEVEL_HIGH>, <0 30 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "rx", "tx";
+ interrupt-parent = <&intc>;
+
+ phy-mode = "xgmii";
+
+ fixed-link {
+ speed = <1000>;
+ pause;
+ link-gpios = <&gpio0 63 GPIO_ACTIVE_HIGH>;
+ };
+
+ mdio {
+ ethernet_phy1: ethernet-phy@4 {
+ compatible = "ethernet-phy-ieee802.3-c22";
+ reg = <4>;
+ };
+ };
+
+ };
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 0/3] nixge: Fixed-link support
2019-02-04 17:30 [PATCH net-next 0/3] nixge: Fixed-link support Moritz Fischer
` (2 preceding siblings ...)
2019-02-04 17:30 ` [PATCH net-next 3/3] dt-bindings: net: Add fixed-link support Moritz Fischer
@ 2019-02-05 18:34 ` David Miller
3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-02-05 18:34 UTC (permalink / raw)
To: moritz.fischer
Cc: netdev, devicetree, linux-kernel, alex.williams, andrew, robh+dt,
mdf
From: Moritz Fischer <moritz.fischer@ettus.com>
Date: Mon, 4 Feb 2019 09:30:37 -0800
> From: Moritz Fischer <mdf@kernel.org>
>
> This series adds fixed-link support to nixge.
>
> The first patch corrects the binding to correctly reflect
> hardware that does not come with MDIO cores instantiated.
>
> The second patch adds fixed link support to the driver.
>
> The third patch updates the binding document with the now
> optional (formerly required) phy-handle property and references
> the fixed-link docs.
Series applied, thank you.
^ permalink raw reply [flat|nested] 6+ messages in thread