From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH 05/10] net: phy: Support limiting phy speed in the devicetree
Date: Wed, 21 May 2014 14:28:13 +0200 [thread overview]
Message-ID: <537C9BDD.2030300@gmail.com> (raw)
In-Reply-To: <1400674740-6467-6-git-send-email-s.hauer@pengutronix.de>
On 05/21/2014 02:18 PM, Sascha Hauer wrote:
> Even when both the ethernet controller and the phy support certain
> features a board may have additional limitations. Allow specifying
> it in the devicetree.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> drivers/net/phy/mdio_bus.c | 36 +++++++++++++++++++++++++++++++++++-
> include/linux/phy.h | 22 +++++++++++++++-------
> 2 files changed, 50 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index ca01673..3adc944 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -242,6 +242,39 @@ static struct file_operations phydev_ops = {
> .lseek = dev_lseek_default,
> };
>
> +static void of_set_phy_supported(struct phy_device *phydev)
> +{
> + struct device_node *node = phydev->dev.device_node;
> + u32 max_speed;
> +
> + if (!IS_ENABLED(CONFIG_OFDEVICE))
> + return;
> +
> + if (!node)
> + return;
> +
> + if (!of_property_read_u32(node, "max-speed", &max_speed)) {
> + /*
> + * The default values for phydev->supported are provided by the PHY
> + * driver "features" member, we want to reset to sane defaults fist
nit: s/fist/first/
Sebastian
> + * before supporting higher speeds.
> + */
> + phydev->supported &= PHY_DEFAULT_FEATURES;
> +
> + switch (max_speed) {
> + default:
> + return;
> +
> + case SPEED_1000:
> + phydev->supported |= PHY_1000BT_FEATURES;
> + case SPEED_100:
> + phydev->supported |= PHY_100BT_FEATURES;
> + case SPEED_10:
> + phydev->supported |= PHY_10BT_FEATURES;
> + }
> + }
> +}
> +
> static int mdio_bus_probe(struct device_d *_dev)
> {
> struct phy_device *dev = to_phy_device(_dev);
> @@ -275,7 +308,8 @@ static int mdio_bus_probe(struct device_d *_dev)
> * a controller will attach, and may modify one
> * or both of these values */
> dev->supported = drv->features;
> - dev->advertising = drv->features;
> + of_set_phy_supported(dev);
> + dev->advertising = dev->supported;
>
> dev_add_param_int_ro(&dev->dev, "phy_addr", dev->addr, "%d");
> dev_add_param_int_ro(&dev->dev, "phy_id", dev->phy_id, "0x%08x");
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 9567c43..3cdbc6e 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -20,18 +20,26 @@
> #include <linux/ethtool.h>
> #include <linux/mii.h>
>
> -#define PHY_BASIC_FEATURES (SUPPORTED_10baseT_Half | \
> - SUPPORTED_10baseT_Full | \
> - SUPPORTED_100baseT_Half | \
> - SUPPORTED_100baseT_Full | \
> - SUPPORTED_Autoneg | \
> +#define PHY_DEFAULT_FEATURES (SUPPORTED_Autoneg | \
> SUPPORTED_TP | \
> SUPPORTED_MII)
>
> -#define PHY_GBIT_FEATURES (PHY_BASIC_FEATURES | \
> - SUPPORTED_1000baseT_Half | \
> +#define PHY_10BT_FEATURES (SUPPORTED_10baseT_Half | \
> + SUPPORTED_10baseT_Full)
> +
> +#define PHY_100BT_FEATURES (SUPPORTED_100baseT_Half | \
> + SUPPORTED_100baseT_Full)
> +
> +#define PHY_1000BT_FEATURES (SUPPORTED_1000baseT_Half | \
> SUPPORTED_1000baseT_Full)
>
> +#define PHY_BASIC_FEATURES (PHY_10BT_FEATURES | \
> + PHY_100BT_FEATURES | \
> + PHY_DEFAULT_FEATURES)
> +
> +#define PHY_GBIT_FEATURES (PHY_BASIC_FEATURES | \
> + PHY_1000BT_FEATURES)
> +
> /* Interface Mode definitions */
> typedef enum {
> PHY_INTERFACE_MODE_NA,
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-05-21 12:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-21 12:18 [PATCH] devicetree support for ethernet phys Sascha Hauer
2014-05-21 12:18 ` [PATCH 01/10] net: phy: factor out phy_device_attach function Sascha Hauer
2014-05-21 12:18 ` [PATCH 02/10] net: phy: move setting of phy_map to phy_register_device Sascha Hauer
2014-05-21 12:18 ` [PATCH 03/10] net: phy: register phys specified in devicetree Sascha Hauer
2014-05-21 12:18 ` [PATCH 04/10] net: phy: Support finding a phy in the devicetree Sascha Hauer
2014-05-21 12:18 ` [PATCH 05/10] net: phy: Support limiting phy speed " Sascha Hauer
2014-05-21 12:28 ` Sebastian Hesselbarth [this message]
2014-05-21 12:18 ` [PATCH 06/10] net: orion-gbe: use transparent-to-driver of mdio functions Sascha Hauer
2014-05-21 12:29 ` Sebastian Hesselbarth
2014-05-22 20:09 ` Sebastian Hesselbarth
2014-08-02 17:44 ` Ezequiel Garcia
2014-08-04 18:42 ` Sascha Hauer
2014-05-21 12:18 ` [PATCH 07/10] net: phy: remove now unused of_phy_device_connect Sascha Hauer
2014-05-21 12:18 ` [PATCH 08/10] net: phy: genphy: always write MII_CTRL1000 when available Sascha Hauer
2014-05-21 12:18 ` [PATCH 09/10] net: phy: genphy: Make it work with of_set_phy_supported Sascha Hauer
2014-05-21 12:19 ` [PATCH 10/10] net: fec_imx: Add devicetree support for mdio bus Sascha Hauer
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=537C9BDD.2030300@gmail.com \
--to=sebastian.hesselbarth@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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