Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933394AbbGJSji (ORCPT ); Fri, 10 Jul 2015 14:39:38 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:34986 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932641AbbGJSja (ORCPT ); Fri, 10 Jul 2015 14:39:30 -0400 Message-ID: <55A010F9.7030808@gmail.com> Date: Fri, 10 Jul 2015 11:37:45 -0700 From: Florian Fainelli User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Stas Sergeev , netdev CC: Linux kernel , Sebastien Rannou , Arnaud Ebalard , Stas Sergeev , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Grant Likely , "devicetree@vger.kernel.org" Subject: Re: [PATCH 2/3] of_mdio: add new DT property 'autoneg' for fixed-link References: <559FF511.5080102@list.ru> <559FF63E.8020209@list.ru> In-Reply-To: <559FF63E.8020209@list.ru> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5308 Lines: 133 On 10/07/15 09:43, Stas Sergeev wrote: > > Currently for fixed-link the MAC driver decides whether to use the > link status auto-negotiation or not. > Unfortunately the auto-negotiation may not work when expected by > the MAC driver. Sebastien Rannou explains: > << Yes, I confirm that my HW does not generate an in-band status. AFAIK, it's > a PHY that aggregates 4xSGMIIs to 1xQSGMII ; the MAC side of the PHY (with > inband status) is connected to the switch through QSGMII, and in this context > we are on the media side of the PHY. >> > https://lkml.org/lkml/2015/7/10/206 > > This patch introduces the new boolean property 'autoneg' that allows > the user to request the auto-negotiation explicitly. The implementation looks better, but the name might still be slightly controversial. I would go with "use-in-band-status" which is more strictly defined than "autoneg" which could mean anything and everything. What do you think? > > Signed-off-by: Stas Sergeev > > CC: Rob Herring > CC: Pawel Moll > CC: Mark Rutland > CC: Ian Campbell > CC: Kumar Gala > CC: Florian Fainelli > CC: Grant Likely > CC: devicetree@vger.kernel.org > CC: linux-kernel@vger.kernel.org > CC: netdev@vger.kernel.org > --- > .../devicetree/bindings/net/fixed-link.txt | 6 +++++- > drivers/of/of_mdio.c | 23 ++++++++++++++++++++-- > include/linux/of_mdio.h | 5 +++++ > 3 files changed, 31 insertions(+), 3 deletions(-) > > diff --git a/Documentation/devicetree/bindings/net/fixed-link.txt b/Documentation/devicetree/bindings/net/fixed-link.txt > index 82bf7e0..e2959a8 100644 > --- a/Documentation/devicetree/bindings/net/fixed-link.txt > +++ b/Documentation/devicetree/bindings/net/fixed-link.txt > @@ -9,8 +9,12 @@ Such a fixed link situation is described by creating a 'fixed-link' > sub-node of the Ethernet MAC device node, with the following > properties: > > +* 'autoneg' (boolean, optional), to enable the auto-negotiation of link > + state. Auto-negotiation is MII protocol, HW and driver-specific and is > + not supported in many cases, so use it only when you know what you do. > * 'speed' (integer, mandatory), to indicate the link speed. Accepted > - values are 10, 100 and 1000 > + values are 10, 100 and 1000. If the auto-negotiation is enabled, > + 'speed' may not be set. It will then be auto-negotiated, if possible. > * 'full-duplex' (boolean, optional), to indicate that full duplex is > used. When absent, half duplex is assumed. > * 'pause' (boolean, optional), to indicate that pause should be > diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c > index 1bd4305..12b2ede 100644 > --- a/drivers/of/of_mdio.c > +++ b/drivers/of/of_mdio.c > @@ -280,6 +280,22 @@ bool of_phy_is_fixed_link(struct device_node *np) > } > EXPORT_SYMBOL(of_phy_is_fixed_link); > > +bool of_phy_is_autoneg_link(struct device_node *np) > +{ > + struct device_node *dn; > + bool ret; > + > + dn = of_get_child_by_name(np, "fixed-link"); > + if (!dn) > + return false; > + > + ret = of_property_read_bool(dn, "autoneg"); > + > + of_node_put(dn); > + return ret; > +} > +EXPORT_SYMBOL(of_phy_is_autoneg_link); > + > int of_phy_register_fixed_link(struct device_node *np) > { > struct fixed_phy_status status = {}; > @@ -291,10 +307,13 @@ int of_phy_register_fixed_link(struct device_node *np) > /* New binding */ > fixed_link_node = of_get_child_by_name(np, "fixed-link"); > if (fixed_link_node) { > - status.link = 1; > + bool autoneg = of_property_read_bool(fixed_link_node, > + "autoneg"); > + status.link = !autoneg; > status.duplex = of_property_read_bool(fixed_link_node, > "full-duplex"); > - if (of_property_read_u32(fixed_link_node, "speed", &status.speed)) > + if (of_property_read_u32(fixed_link_node, "speed", > + &status.speed) != 0 && !autoneg) > return -EINVAL; > status.pause = of_property_read_bool(fixed_link_node, "pause"); > status.asym_pause = of_property_read_bool(fixed_link_node, > diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h > index d449018..647f348 100644 > --- a/include/linux/of_mdio.h > +++ b/include/linux/of_mdio.h > @@ -65,6 +65,7 @@ static inline struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np) > #if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY) > extern int of_phy_register_fixed_link(struct device_node *np); > extern bool of_phy_is_fixed_link(struct device_node *np); > +extern bool of_phy_is_autoneg_link(struct device_node *np); > #else > static inline int of_phy_register_fixed_link(struct device_node *np) > { > @@ -74,6 +75,10 @@ static inline bool of_phy_is_fixed_link(struct device_node *np) > { > return false; > } > +static inline bool of_phy_is_autoneg_link(struct device_node *np) > +{ > + return false; > +} > #endif > > -- Florian -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/