linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ardelean, Alexandru" <alexandru.Ardelean@analog.com>
To: "andrew@lunn.ch" <andrew@lunn.ch>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"f.fainelli@gmail.com" <f.fainelli@gmail.com>,
	"hkallweit1@gmail.com" <hkallweit1@gmail.com>
Subject: Re: [PATCH v2 2/2] net: phy: adin: implement Energy Detect Powerdown mode via phy-tunable
Date: Thu, 5 Sep 2019 06:32:57 +0000	[thread overview]
Message-ID: <e1739eb3d43ebf854e9eb5c829ffbf59f9dca85c.camel@analog.com> (raw)
In-Reply-To: <20190904200350.GB21264@lunn.ch>

On Wed, 2019-09-04 at 22:03 +0200, Andrew Lunn wrote:
> [External]
> 
> On Wed, Sep 04, 2019 at 07:23:22PM +0300, Alexandru Ardelean wrote:
> > This driver becomes the first user of the kernel's `ETHTOOL_PHY_EDPD`
> > phy-tunable feature.
> > EDPD is also enabled by default on PHY config_init, but can be disabled via
> > the phy-tunable control.
> > 
> > When enabling EDPD, it's also a good idea (for the ADIN PHYs) to enable TX
> > periodic pulses, so that in case the other PHY is also on EDPD mode, there
> > is no lock-up situation where both sides are waiting for the other to
> > transmit.
> > 
> > Via the phy-tunable control, TX pulses can be disabled if specifying 0
> > `tx-interval` via ethtool.
> > 
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> > ---
> >  drivers/net/phy/adin.c | 50 ++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 50 insertions(+)
> > 
> > diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c
> > index 4dec83df048d..742728ab2a5d 100644
> > --- a/drivers/net/phy/adin.c
> > +++ b/drivers/net/phy/adin.c
> > @@ -26,6 +26,11 @@
> >  
> >  #define ADIN1300_RX_ERR_CNT			0x0014
> >  
> > +#define ADIN1300_PHY_CTRL_STATUS2		0x0015
> > +#define   ADIN1300_NRG_PD_EN			BIT(3)
> > +#define   ADIN1300_NRG_PD_TX_EN			BIT(2)
> > +#define   ADIN1300_NRG_PD_STATUS		BIT(1)
> > +
> >  #define ADIN1300_PHY_CTRL2			0x0016
> >  #define   ADIN1300_DOWNSPEED_AN_100_EN		BIT(11)
> >  #define   ADIN1300_DOWNSPEED_AN_10_EN		BIT(10)
> > @@ -328,12 +333,51 @@ static int adin_set_downshift(struct phy_device *phydev, u8 cnt)
> >  			    ADIN1300_DOWNSPEEDS_EN);
> >  }
> >  
> > +static int adin_get_edpd(struct phy_device *phydev, u16 *tx_interval)
> > +{
> > +	int val;
> > +
> > +	val = phy_read(phydev, ADIN1300_PHY_CTRL_STATUS2);
> > +	if (val < 0)
> > +		return val;
> > +
> > +	if (ADIN1300_NRG_PD_EN & val) {
> > +		if (val & ADIN1300_NRG_PD_TX_EN)
> > +			*tx_interval = 1;
> 
> What does 1 mean? 1 pico second, one hour? Anything but zero seconds?
> Does the datasheet specify what it actually does? Maybe you should be
> using ETHTOOL_PHY_EDPD_DFLT_TX_INTERVAL here, to indicate you actually
> have no idea, but it is the default for this PHY?

This PHY currently has a 1 second TX interval.
As specified by the datasheet (page 22 Energy-Detect Powerdown Mode section):
https://www.analog.com/media/en/technical-documentation/data-sheets/ADIN1300.pdf

"The PHY monitors the line for signal energy and sends a link pulse once every second"

Currently there is no control exposed to configure this interval; but there could be some registers (that are not
exposed yet) that could control this.

Micrel's datasheet mentions (page 27 3.16.1ENERGY-DETECT POWER-DOWN MODE section):
http://ww1.microchip.com/downloads/en/devicedoc/00002117f.pdf

"In EDPD Mode, the KSZ9031RNX shuts down all transceiver blocks, except for the transmitter and energy detect cir-cuits. 
Power can be reduced further by extending the time interval between the transmissions of link pulses to check forthe
presence of a link partner."

I did not check for Micrel to see how that interval is controlled.

The reason for doing this TX interval control was mostly based on this mention from Micrel's datasheet, with
consideration that it could work ADIN & other future PHYs.

> 
> > +		else
> > +			*tx_interval = ETHTOOL_PHY_EDPD_NO_TX;
> > +	} else {
> > +		*tx_interval = ETHTOOL_PHY_EDPD_DISABLE;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static int adin_set_edpd(struct phy_device *phydev, u16 tx_interval)
> > +{
> > +	u16 val;
> > +
> > +	if (tx_interval == ETHTOOL_PHY_EDPD_DISABLE)
> > +		return phy_clear_bits(phydev, ADIN1300_PHY_CTRL_STATUS2,
> > +				(ADIN1300_NRG_PD_EN | ADIN1300_NRG_PD_TX_EN));
> > +
> > +	val = ADIN1300_NRG_PD_EN;
> > +	if (tx_interval != ETHTOOL_PHY_EDPD_NO_TX)
> > +		val |= ADIN1300_NRG_PD_TX_EN;
> 
> So you silently accept any interval? That sounds wrong. You really
> should be returning -EINVAL for any value other than, either 1, or
> maybe ETHTOOL_PHY_EDPD_DFLT_TX_INTERVAL, if you change the get
> function.

ack;
will use ETHTOOL_PHY_EDPD_DFLT_TX_INTERVAL, ETHTOOL_PHY_EDPD_NO_TX && 1 as acceptable values here

> 
>       Andrew

      reply	other threads:[~2019-09-05  6:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04 16:23 [PATCH v2 0/2] ethtool: implement Energy Detect Powerdown support via phy-tunable Alexandru Ardelean
2019-09-04 16:23 ` [PATCH v2 1/2] " Alexandru Ardelean
2019-09-04 19:53   ` Andrew Lunn
2019-09-05  6:25     ` Ardelean, Alexandru
2019-09-05 17:23       ` Florian Fainelli
2019-09-04 16:23 ` [PATCH v2 2/2] net: phy: adin: implement Energy Detect Powerdown mode " Alexandru Ardelean
2019-09-04 20:03   ` Andrew Lunn
2019-09-05  6:32     ` Ardelean, Alexandru [this message]

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=e1739eb3d43ebf854e9eb5c829ffbf59f9dca85c.camel@analog.com \
    --to=alexandru.ardelean@analog.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).