Commit 7194d92b authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 5468e82f baaac2fb
...@@ -12,10 +12,15 @@ Required properties: ...@@ -12,10 +12,15 @@ Required properties:
- interrupts: Should contain tx and rx interrupt - interrupts: Should contain tx and rx interrupt
- interrupt-names: Should be "rx" and "tx" - interrupt-names: Should be "rx" and "tx"
- phy-mode: See ethernet.txt file in the same directory. - 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-cells: Phandle of nvmem cell containing the MAC address
- nvmem-cell-names: Should be "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): Examples (10G generic PHY):
nixge0: ethernet@40000000 { nixge0: ethernet@40000000 {
compatible = "ni,xge-enet-3.00"; compatible = "ni,xge-enet-3.00";
...@@ -33,8 +38,55 @@ Examples (10G generic PHY): ...@@ -33,8 +38,55 @@ Examples (10G generic PHY):
phy-mode = "xgmii"; phy-mode = "xgmii";
phy-handle = <&ethernet_phy1>; phy-handle = <&ethernet_phy1>;
ethernet_phy1: ethernet-phy@4 { mdio {
compatible = "ethernet-phy-ieee802.3-c45"; ethernet_phy1: ethernet-phy@4 {
reg = <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>;
};
};
};
...@@ -1282,6 +1282,7 @@ static int nixge_of_get_resources(struct platform_device *pdev) ...@@ -1282,6 +1282,7 @@ static int nixge_of_get_resources(struct platform_device *pdev)
static int nixge_probe(struct platform_device *pdev) static int nixge_probe(struct platform_device *pdev)
{ {
struct device_node *mn, *phy_node;
struct nixge_priv *priv; struct nixge_priv *priv;
struct net_device *ndev; struct net_device *ndev;
const u8 *mac_addr; const u8 *mac_addr;
...@@ -1335,10 +1336,14 @@ static int nixge_probe(struct platform_device *pdev) ...@@ -1335,10 +1336,14 @@ static int nixge_probe(struct platform_device *pdev)
priv->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD; priv->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD;
priv->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD; priv->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD;
err = nixge_mdio_setup(priv, pdev->dev.of_node); mn = of_get_child_by_name(pdev->dev.of_node, "mdio");
if (err) { if (mn) {
netdev_err(ndev, "error registering mdio bus"); err = nixge_mdio_setup(priv, mn);
goto free_netdev; 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); priv->phy_mode = of_get_phy_mode(pdev->dev.of_node);
...@@ -1348,23 +1353,33 @@ static int nixge_probe(struct platform_device *pdev) ...@@ -1348,23 +1353,33 @@ static int nixge_probe(struct platform_device *pdev)
goto unregister_mdio; goto unregister_mdio;
} }
priv->phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0); phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
if (!priv->phy_node) { if (!phy_node && of_phy_is_fixed_link(pdev->dev.of_node)) {
netdev_err(ndev, "not find \"phy-handle\" property\n"); err = of_phy_register_fixed_link(pdev->dev.of_node);
err = -EINVAL; if (err < 0) {
goto unregister_mdio; 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); err = register_netdev(priv->ndev);
if (err) { if (err) {
netdev_err(ndev, "register_netdev() error (%i)\n", err); netdev_err(ndev, "register_netdev() error (%i)\n", err);
goto unregister_mdio; goto free_phy;
} }
return 0; 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: unregister_mdio:
mdiobus_unregister(priv->mii_bus); if (priv->mii_bus)
mdiobus_unregister(priv->mii_bus);
free_netdev: free_netdev:
free_netdev(ndev); free_netdev(ndev);
...@@ -1379,7 +1394,12 @@ static int nixge_remove(struct platform_device *pdev) ...@@ -1379,7 +1394,12 @@ static int nixge_remove(struct platform_device *pdev)
unregister_netdev(ndev); 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); free_netdev(ndev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment