From patchwork Mon Dec 7 01:38:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Reid X-Patchwork-Id: 553230 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 16F3B1402DE for ; Mon, 7 Dec 2015 12:39:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754761AbbLGBjd (ORCPT ); Sun, 6 Dec 2015 20:39:33 -0500 Received: from 203-59-230-133.perm.iinet.net.au ([203.59.230.133]:49155 "EHLO preid-centos7.electromag.com.au" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754612AbbLGBjP (ORCPT ); Sun, 6 Dec 2015 20:39:15 -0500 Received: by preid-centos7.electromag.com.au (Postfix, from userid 1000) id 9C61E300B2EAD; Mon, 7 Dec 2015 09:39:12 +0800 (AWST) From: Phil Reid To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, peppe.cavallaro@st.com, davem@davemloft.net, devicetree@vger.kernel.org, netdev@vger.kernel.org Cc: Phil Reid Subject: [PATCH v2 1/5] stmmac: create of compatible mdio bus for stmacc driver Date: Mon, 7 Dec 2015 09:38:39 +0800 Message-Id: <1449452324-53858-2-git-send-email-preid@electromag.com.au> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1449452324-53858-1-git-send-email-preid@electromag.com.au> References: <1449452324-53858-1-git-send-email-preid@electromag.com.au> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The DSA driver needs to be passed a reference to an mdio bus. Typically the mac is configured to use a fixed link but the mdio bus still needs to be registered so that it con configure the switch. This patch follows the same process as the altera tse ethernet driver for creation of the mdio bus. Acked-by: Rob Herring Signed-off-by: Phil Reid --- Documentation/devicetree/bindings/net/stmmac.txt | 10 ++++++- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 32 ++++++++++++++++------ .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 +- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt index f34fc3c..cb6288e 100644 --- a/Documentation/devicetree/bindings/net/stmmac.txt +++ b/Documentation/devicetree/bindings/net/stmmac.txt @@ -47,7 +47,8 @@ Optional properties: - snps,burst_len: The AXI burst lenth value of the AXI BUS MODE register. - tx-fifo-depth: See ethernet.txt file in the same directory - rx-fifo-depth: See ethernet.txt file in the same directory - +- mdio: with compatible = "snps,dwmac-mdio", create and register mdio bus. + Examples: gmac0: ethernet@e0800000 { @@ -65,4 +66,11 @@ Examples: tx-fifo-depth = <16384>; clocks = <&clock>; clock-names = "stmmaceth"; + mdio0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,dwmac-mdio"; + phy1: ethernet-phy@0 { + }; + }; }; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index bba670c..1d972e3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -29,7 +29,7 @@ #include #include #include - +#include #include #include "stmmac.h" @@ -201,6 +201,25 @@ int stmmac_mdio_register(struct net_device *ndev) struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; int addr, found; +#ifdef CONFIG_OF + struct device_node *mdio_node = NULL; + struct device_node *child_node = NULL; + + for_each_child_of_node(priv->device->of_node, child_node) { + if (of_device_is_compatible(child_node, "snps,dwmac-mdio")) { + mdio_node = child_node; + break; + } + } + + if (mdio_node) { + netdev_dbg(ndev, "FOUND MDIO subnode\n"); + } else { + netdev_err(ndev, "NO MDIO subnode\n"); + return 0; + } +#endif + if (!mdio_bus_data) return 0; @@ -231,7 +250,11 @@ int stmmac_mdio_register(struct net_device *ndev) new_bus->irq = irqlist; new_bus->phy_mask = mdio_bus_data->phy_mask; new_bus->parent = priv->device; +#ifdef CONFIG_OF + err = of_mdiobus_register(new_bus, mdio_node); +#else err = mdiobus_register(new_bus); +#endif if (err != 0) { pr_err("%s: Cannot register as MDIO bus\n", new_bus->name); goto bus_register_fail; @@ -284,13 +307,6 @@ int stmmac_mdio_register(struct net_device *ndev) } } - if (!found) { - pr_warn("%s: No PHY found\n", ndev->name); - mdiobus_unregister(new_bus); - mdiobus_free(new_bus); - return -ENODEV; - } - priv->mii = new_bus; return 0; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index d02691b..6863420 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -146,7 +146,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0) dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n"); - if (plat->phy_node || plat->phy_bus_name) + if (plat->phy_bus_name) plat->mdio_bus_data = NULL; else plat->mdio_bus_data =