From patchwork Sat Feb 2 02:50:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 1035323 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43rz5L4mQqz9sDX for ; Sat, 2 Feb 2019 13:51:50 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727276AbfBBCvo (ORCPT ); Fri, 1 Feb 2019 21:51:44 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:45212 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725828AbfBBCvo (ORCPT ); Fri, 1 Feb 2019 21:51:44 -0500 Received: by mail-oi1-f193.google.com with SMTP id y1so7449994oie.12 for ; Fri, 01 Feb 2019 18:51:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=c1bWMrev5g6V586Ur2U7l6ZK7gaeyNHR6dFOMXgg8r4=; b=A2deiqAR2U1Abgx+l04nXD685a896VJFbNQ+O81S7h1F0WKG3ddowhxL1qSwe2c8X2 haVSZsv77EIYJ1ylT/3akpQenhfx7yfLOynr69liQuY4Tgt0VVjS0h06wVYNyIYUHdox VbVKUl5i5qtQfgmwQxw+3IWW8h4JfhmiEvLywQvsAQeS7HPWVE9Goko2pVDGHI3BgdrG 6c0YShBtuMUR5S1Nr1OTu4mZlE/gWyczGYTGKK8DexD3CPJebtP+iH0Xc0+8Bs4gwaFk A+d34EDds0yfLeHc7oCfw+IKhKy2ot2SpAA4qxWzml/5oNXw/xCvbzIZGkPT5JlIvBi2 jlDg== X-Gm-Message-State: AHQUAuboQ9sddNQ/+TFMQ0EFnYi2iQS7Pek1fbPVOEI/pQOAQ/9kFWD/ 3Q9bN5xdayM+77iJqcOt+d/4ZA== X-Google-Smtp-Source: AHgI3IZKjtUcpxODLANRV0Y3swqPjYp7fi2B/XTup8adHxCG+Zy42yiIsmjol8LHQSm1mcaOuUJFOA== X-Received: by 2002:aca:d78b:: with SMTP id o133mr19274496oig.232.1549075903110; Fri, 01 Feb 2019 18:51:43 -0800 (PST) Received: from localhost ([130.164.62.201]) by smtp.gmail.com with ESMTPSA id a201sm4443062oii.27.2019.02.01.18.51.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Feb 2019 18:51:42 -0800 (PST) From: Moritz Fischer To: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, davem@davemloft.net, alex.williams@ni.com, Moritz Fischer , Andrew Lunn , Rob Herring Subject: [net-next RFC/PATCH] net: nixge: Make mdio child node optional Date: Fri, 1 Feb 2019 18:50:48 -0800 Message-Id: <20190202025048.14772-1-mdf@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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. Signed-off-by: Moritz Fischer Cc: Andrew Lunn Cc: Rob Herring Reviewed-by: Andrew Lunn --- Hi Rob, Andrew, I know generally changing bindings is a no-no. Ultimately I'm working on adding fixed-link support to this driver, during the review of that Andrew suggested to drop the wrong binding if I don't need legacy behavior. In my case I can pretty much guarantee there's no users, even out of tree due to how we ship the software with our devices (overlays & fpga images always go together). I think in the long this change will make the code easier to maintain and allow to easier support the different variants. Thanks, Moritz --- .../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 e55af7f0881a..5a0072b69ce7 100644 --- a/Documentation/devicetree/bindings/net/nixge.txt +++ b/Documentation/devicetree/bindings/net/nixge.txt @@ -10,6 +10,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-2.00"; @@ -25,8 +28,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 1e408d1a9b5f..93d5263cc57e 100644 --- a/drivers/net/ethernet/ni/nixge.c +++ b/drivers/net/ethernet/ni/nixge.c @@ -1230,6 +1230,7 @@ static int nixge_probe(struct platform_device *pdev) struct nixge_priv *priv; struct net_device *ndev; struct resource *dmares; + struct device_node *mn; const u8 *mac_addr; int err; @@ -1286,10 +1287,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); @@ -1315,7 +1320,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); @@ -1330,7 +1336,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);