Merge branch 'nixge-Fixed-link-support'

Moritz Fischer says:

====================
nixge: Fixed-link support

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.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2019-02-05 10:34:34 -08:00
commit 7194d92b23
2 changed files with 88 additions and 16 deletions

View File

@ -12,10 +12,15 @@ 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 {
compatible = "ni,xge-enet-3.00";
@ -33,8 +38,55 @@ Examples (10G generic PHY):
phy-mode = "xgmii";
phy-handle = <&ethernet_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 = <&eth1_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 = <&ethernet_phy1>;
};
Examples (1G generic fixed-link + MDIO):
nixge0: ethernet@40000000 {
compatible = "ni,xge-enet-2.00";
reg = <0x40000000 0x6000>;
nvmem-cells = <&eth1_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>;
};
};
};

View File

@ -1282,6 +1282,7 @@ 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;
const u8 *mac_addr;
@ -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);
@ -1348,23 +1353,33 @@ 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:
mdiobus_unregister(priv->mii_bus);
if (priv->mii_bus)
mdiobus_unregister(priv->mii_bus);
free_netdev:
free_netdev(ndev);
@ -1379,7 +1394,12 @@ static int nixge_remove(struct platform_device *pdev)
unregister_netdev(ndev);
mdiobus_unregister(priv->mii_bus);
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);
free_netdev(ndev);