Commit dd648818 authored by Moritz Fischer's avatar Moritz Fischer Committed by David S. Miller

net: nixge: Make mdio child node optional

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: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarMoritz Fischer <mdf@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5468e82f
...@@ -16,6 +16,9 @@ Required properties: ...@@ -16,6 +16,9 @@ Required properties:
- 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
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 +36,26 @@ Examples (10G generic PHY): ...@@ -33,8 +36,26 @@ 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>;
};
...@@ -1284,6 +1284,7 @@ static int nixge_probe(struct platform_device *pdev) ...@@ -1284,6 +1284,7 @@ static int nixge_probe(struct platform_device *pdev)
{ {
struct nixge_priv *priv; struct nixge_priv *priv;
struct net_device *ndev; struct net_device *ndev;
struct device_node *mn;
const u8 *mac_addr; const u8 *mac_addr;
int err; int err;
...@@ -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);
...@@ -1364,7 +1369,8 @@ static int nixge_probe(struct platform_device *pdev) ...@@ -1364,7 +1369,8 @@ static int nixge_probe(struct platform_device *pdev)
return 0; return 0;
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 +1385,8 @@ static int nixge_remove(struct platform_device *pdev) ...@@ -1379,7 +1385,8 @@ static int nixge_remove(struct platform_device *pdev)
unregister_netdev(ndev); unregister_netdev(ndev);
mdiobus_unregister(priv->mii_bus); 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