Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Moritz Fischer and committed by
David S. Miller
dd648818 5468e82f

+37 -9
+24 -3
Documentation/devicetree/bindings/net/nixge.txt
··· 16 16 - nvmem-cells: Phandle of nvmem cell containing the MAC address 17 17 - nvmem-cell-names: Should be "address" 18 18 19 + Optional properties: 20 + - mdio subnode to indicate presence of MDIO controller 21 + 19 22 Examples (10G generic PHY): 20 23 nixge0: ethernet@40000000 { 21 24 compatible = "ni,xge-enet-3.00"; ··· 36 33 phy-mode = "xgmii"; 37 34 phy-handle = <&ethernet_phy1>; 38 35 39 - ethernet_phy1: ethernet-phy@4 { 40 - compatible = "ethernet-phy-ieee802.3-c45"; 41 - reg = <4>; 36 + mdio { 37 + ethernet_phy1: ethernet-phy@4 { 38 + compatible = "ethernet-phy-ieee802.3-c45"; 39 + reg = <4>; 40 + }; 42 41 }; 42 + }; 43 + 44 + Examples (10G generic PHY, no MDIO): 45 + nixge0: ethernet@40000000 { 46 + compatible = "ni,xge-enet-2.00"; 47 + reg = <0x40000000 0x6000>; 48 + 49 + nvmem-cells = <&eth1_addr>; 50 + nvmem-cell-names = "address"; 51 + 52 + interrupts = <0 29 IRQ_TYPE_LEVEL_HIGH>, <0 30 IRQ_TYPE_LEVEL_HIGH>; 53 + interrupt-names = "rx", "tx"; 54 + interrupt-parent = <&intc>; 55 + 56 + phy-mode = "xgmii"; 57 + phy-handle = <&ethernet_phy1>; 43 58 };
+13 -6
drivers/net/ethernet/ni/nixge.c
··· 1284 1284 { 1285 1285 struct nixge_priv *priv; 1286 1286 struct net_device *ndev; 1287 + struct device_node *mn; 1287 1288 const u8 *mac_addr; 1288 1289 int err; 1289 1290 ··· 1336 1335 priv->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD; 1337 1336 priv->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD; 1338 1337 1339 - err = nixge_mdio_setup(priv, pdev->dev.of_node); 1340 - if (err) { 1341 - netdev_err(ndev, "error registering mdio bus"); 1342 - goto free_netdev; 1338 + mn = of_get_child_by_name(pdev->dev.of_node, "mdio"); 1339 + if (mn) { 1340 + err = nixge_mdio_setup(priv, mn); 1341 + of_node_put(mn); 1342 + if (err) { 1343 + netdev_err(ndev, "error registering mdio bus"); 1344 + goto free_netdev; 1345 + } 1343 1346 } 1344 1347 1345 1348 priv->phy_mode = of_get_phy_mode(pdev->dev.of_node); ··· 1369 1364 return 0; 1370 1365 1371 1366 unregister_mdio: 1372 - mdiobus_unregister(priv->mii_bus); 1367 + if (priv->mii_bus) 1368 + mdiobus_unregister(priv->mii_bus); 1373 1369 1374 1370 free_netdev: 1375 1371 free_netdev(ndev); ··· 1385 1379 1386 1380 unregister_netdev(ndev); 1387 1381 1388 - mdiobus_unregister(priv->mii_bus); 1382 + if (priv->mii_bus) 1383 + mdiobus_unregister(priv->mii_bus); 1389 1384 1390 1385 free_netdev(ndev); 1391 1386