netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
To: Phil Reid <preid@electromag.com.au>, <robh+dt@kernel.org>,
	<pawel.moll@arm.com>, <mark.rutland@arm.com>,
	<ijc+devicetree@hellion.org.uk>, <galak@codeaurora.org>,
	<davem@davemloft.net>, <vbridger@opensource.altera.com>,
	<devicetree@vger.kernel.org>, <netdev@vger.kernel.org>
Subject: Re: [PATCH v5 1/4] stmmac: create of compatible mdio bus for stmacc driver
Date: Thu, 10 Dec 2015 18:16:34 +0100	[thread overview]
Message-ID: <5669B372.5070207@st.com> (raw)
In-Reply-To: <1449650381-82074-2-git-send-email-preid@electromag.com.au>

Hi

also pls fix this typo

stmmac: create of compatible mdio bus for stmacc driver
                                          ^^^^^^^^
                                           stmmac

On 12/9/2015 9:39 AM, Phil Reid wrote:
> 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 <robh@kernel.org>
> Signed-off-by: Phil Reid <preid@electromag.com.au>
> ---
>   Documentation/devicetree/bindings/net/stmmac.txt   |  8 ++++++
>   drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c  | 31 +++++++++++++++-------
>   .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  2 +-
>   3 files changed, 31 insertions(+), 10 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt
> index f34fc3c..fd5ddf8 100644
> --- a/Documentation/devicetree/bindings/net/stmmac.txt
> +++ b/Documentation/devicetree/bindings/net/stmmac.txt
> @@ -47,6 +47,7 @@ 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:
>
> @@ -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..bb6f75c 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> @@ -29,7 +29,7 @@
>   #include <linux/slab.h>
>   #include <linux/of.h>
>   #include <linux/of_gpio.h>
> -
> +#include <linux/of_mdio.h>
>   #include <asm/io.h>
>
>   #include "stmmac.h"
> @@ -200,10 +200,29 @@ int stmmac_mdio_register(struct net_device *ndev)
>   	struct stmmac_priv *priv = netdev_priv(ndev);
>   	struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
>   	int addr, found;
> +	struct device_node *mdio_node = NULL;
> +	struct device_node *child_node = NULL;
>
>   	if (!mdio_bus_data)
>   		return 0;
>
> +	if (IS_ENABLED(CONFIG_OF)) {
> +		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;
> +		}
> +	}
> +
>   	new_bus = mdiobus_alloc();
>   	if (new_bus == NULL)
>   		return -ENOMEM;
> @@ -231,7 +250,8 @@ 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;
> -	err = mdiobus_register(new_bus);
> +
> +	err = of_mdiobus_register(new_bus, mdio_node);
>   	if (err != 0) {
>   		pr_err("%s: Cannot register as MDIO bus\n", new_bus->name);
>   		goto bus_register_fail;
> @@ -284,13 +304,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;
> -	}

hmm,  this could be necessary on some platforms that wants to
get the phy addr at runtime and in case of failure then
removes the registered bus.

> -
>   	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)

can this breaks some conf case?

> +	if (plat->phy_bus_name)
>   		plat->mdio_bus_data = NULL;
>   	else
>   		plat->mdio_bus_data =
>

peppe

  reply	other threads:[~2015-12-10 17:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09  8:39 [PATCH v5 0/4] stmmac: Fixed Phy & PTP fixes Phil Reid
2015-12-09  8:39 ` [PATCH v5 1/4] stmmac: create of compatible mdio bus for stmacc driver Phil Reid
2015-12-10 17:16   ` Giuseppe CAVALLARO [this message]
2015-12-11  1:44     ` Phil Reid
2015-12-11  9:13       ` Giuseppe CAVALLARO
2015-12-09  8:39 ` [PATCH v5 2/4] stmmac: Correct documentation on stmmac clocks Phil Reid
2015-12-09  8:39 ` [PATCH v5 3/4] stmmac: Fix calculations for ptp counters when clock input = 50Mhz Phil Reid
2015-12-09  8:39 ` [PATCH v5 4/4] stmmac: socfpga: Provide dt node to config ptp clk source Phil Reid
2015-12-10  3:12 ` [PATCH v5 0/4] stmmac: Fixed Phy & PTP fixes David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5669B372.5070207@st.com \
    --to=peppe.cavallaro@st.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=netdev@vger.kernel.org \
    --cc=pawel.moll@arm.com \
    --cc=preid@electromag.com.au \
    --cc=robh+dt@kernel.org \
    --cc=vbridger@opensource.altera.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).