netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robherring2@gmail.com>
To: Florian Fainelli <florian@openwrt.org>, netdev@vger.kernel.org
Cc: davem@davemloft.net, grant.likely@linaro.org,
	devicetree@vger.kernel.org, abrodkin@synopsys.com,
	mark.rutland@arm.com, sebastian.hesselbarth@gmail.com,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: [PATCH 5/7] net: of_mdio: parse "max-speed" property to set PHY supported features
Date: Sun, 08 Dec 2013 09:51:34 -0600	[thread overview]
Message-ID: <52A49586.8000201@gmail.com> (raw)
In-Reply-To: <1386283936-26104-6-git-send-email-florian@openwrt.org>

On 12/05/2013 04:52 PM, Florian Fainelli wrote:
> From: Florian Fainelli <f.fainelli@gmail.com>
> 
> The "max-speed" property is defined per the ePAPR specification to
> express the maximum speed a PHY supports. Use that property, if present
> to set the phydev->supported features which properly restricts the PHY
> within the range of defined speeds.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  drivers/of/of_mdio.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
> index 4923ab2..e1e19e5 100644
> --- a/drivers/of/of_mdio.c
> +++ b/drivers/of/of_mdio.c
> @@ -22,12 +22,30 @@
>  MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>");
>  MODULE_LICENSE("GPL");
>  
> +static void of_set_phy_supported(struct phy_device *phydev, u32 max_speed)
> +{
> +	phydev->supported |= PHY_DEFAULT_FEATURES;
> +
> +	switch (max_speed) {
> +	default:
> +		return;
> +
> +	case SPEED_1000:
> +		phydev->supported |= PHY_1000BT_FEATURES;

This assumes the speed is not already set. Do you need to first mask
speeds out?

No need to support 10G PHYs?

A fall-thru note would be helpful here.

> +	case SPEED_100:
> +		phydev->supported |= PHY_100BT_FEATURES;
> +	case SPEED_10:
> +		phydev->supported |= PHY_10BT_FEATURES;
> +	}
> +}
> +
>  static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *child,
>  				   u32 addr)
>  {
>  	struct phy_device *phy;
>  	bool is_c45;
>  	int rc, prev_irq;
> +	u32 max_speed = 0;
>  
>  	is_c45 = of_device_is_compatible(child,
>  					 "ethernet-phy-ieee802.3-c45");
> @@ -58,8 +76,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi
>  		return 1;
>  	}
>  
> +	/* Set phydev->supported based on the "max-speed" property
> +	 * if present */
> +	if (!of_property_read_u32(child, "max-speed", &max_speed))
> +		of_set_phy_supported(phy, max_speed);
> +
>  	dev_dbg(&mdio->dev, "registered phy %s at address %i\n",
> -		 child->name, addr);
> +		child->name, addr);
>  
>  	return 0;
>  }
> 

  parent reply	other threads:[~2013-12-08 15:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05 22:52 [PATCH 0/7] net: of_mdio improvements Florian Fainelli
2013-12-05 22:52 ` [PATCH 1/7] net: of_mdio: factor PHY registration from of_mdiobus_register Florian Fainelli
2013-12-08 16:00   ` Rob Herring
     [not found] ` <1386283936-26104-1-git-send-email-florian-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
2013-12-05 22:52   ` [PATCH 2/7] net: of_mdio: use PHY_MAX_ADDR constant Florian Fainelli
2013-12-11 13:52     ` Grant Likely
2013-12-05 22:52 ` [PATCH 3/7] net: of_mdio: do not overwrite PHY interrupt configuration Florian Fainelli
2013-12-06  0:45   ` Sergei Shtylyov
2013-12-11 13:57   ` Grant Likely
2013-12-05 22:52 ` [PATCH 4/7] net: phy: breakdown PHY_*_FEATURES defines Florian Fainelli
2013-12-05 22:52 ` [PATCH 5/7] net: of_mdio: parse "max-speed" property to set PHY supported features Florian Fainelli
2013-12-06  0:49   ` Sergei Shtylyov
2013-12-05 23:53     ` Florian Fainelli
2013-12-06  0:03       ` Joe Perches
2013-12-06  0:47       ` David Miller
2013-12-08 15:51   ` Rob Herring [this message]
2013-12-11 14:02   ` Grant Likely
2013-12-05 22:52 ` [PATCH 6/7] arc_emac: remove custom "max-speed" parsing code Florian Fainelli
2013-12-05 22:52 ` [PATCH 7/7] Documentation: update Ethernet PHY devices binding with 'max-speed' Florian Fainelli
2013-12-06 19:57 ` [PATCH 0/7] net: of_mdio improvements 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=52A49586.8000201@gmail.com \
    --to=robherring2@gmail.com \
    --cc=abrodkin@synopsys.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=florian@openwrt.org \
    --cc=grant.likely@linaro.org \
    --cc=mark.rutland@arm.com \
    --cc=netdev@vger.kernel.org \
    --cc=sebastian.hesselbarth@gmail.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).